Xyst test code coverage report
Current view: top level - Base - Writer.hpp (source / functions) Coverage Total Hit
Commit: 1fb74642dd9d7732b67f32dec2f2762e238d3fa7 Lines: 100.0 % 1 1
Test Date: 2025-08-13 22:46:33 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // *****************************************************************************
       2              : /*!
       3              :   \file      src/Base/Writer.hpp
       4              :   \copyright 2012-2015 J. Bakosi,
       5              :              2016-2018 Los Alamos National Security, LLC.,
       6              :              2019-2021 Triad National Security, LLC.,
       7              :              2022-2025 J. Bakosi
       8              :              All rights reserved. See the LICENSE file for details.
       9              :   \brief     Writer base class declaration
      10              :   \details   Writer base class declaration. Writer base serves as a base class
      11              :     for various file writers. It does generic low-level I/O, e.g., opening and
      12              :     closing a file, and associated error handling.
      13              : */
      14              : // *****************************************************************************
      15              : #pragma once
      16              : 
      17              : #include <fstream>
      18              : 
      19              : namespace tk {
      20              : 
      21              : //! Writer base serves as a base class for various file writers. It does generic
      22              : //! low-level I/O, e.g., opening and closing a file, and associated error
      23              : //! handling.
      24              : class Writer {
      25              : 
      26              :   public:
      27              :     //! Constructor: Acquire file handle. Protected: designed to be base only.
      28              :     explicit Writer( const std::string& filename,
      29              :                      std::ios_base::openmode mode = std::ios_base::out );
      30              : 
      31              :     //! Destructor: Release file handle
      32              :     virtual ~Writer() noexcept;
      33              : 
      34              :     //! Unformatted write
      35              :     //! \param[in] data Buffer to write
      36              :     //! \param[in] count Number of characters to write
      37              :     void write( const char* data, std::streamsize count )
      38              :     { m_outFile.write( data, count ); }
      39              : 
      40              :     //! Write access to underlying output file stream
      41          290 :     std::ofstream& stream() { return m_outFile; }
      42              : 
      43              :   protected:
      44              :     const std::string m_filename;          //!< File name
      45              :     mutable std::ofstream m_outFile;       //!< File output stream
      46              : };
      47              : 
      48              : } // tk::
        

Generated by: LCOV version 2.0-1