tk::Writer class

Writer base serves as a base class for various file writers. It does generic low-level I/O, e.g., opening and closing a file, and associated error handling.

Derived classes

class GmshMeshWriter
class PDFWriter
PDFWriter : Writer.
class TxtStatWriter
TxtStatWriter : tk::Writer.

Constructors, destructors, conversion operators

Writer(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) explicit
Constructor: Acquire file handle. Protected: designed to be base only.
~Writer() virtual noexcept
Destructor: Release file handle.

Public functions

void write(const char* data, std::streamsize count)
auto stream() -> std::ofstream&
Write access to underlying output file stream.

Protected variables

const std::string m_filename
File name.
std::ofstream m_outFile
File output stream.

Function documentation

tk::Writer::Writer(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) explicit

Constructor: Acquire file handle. Protected: designed to be base only.

Parameters
filename in Name of file to open for writing
mode in Open mode, see http://en.cppreference.com/w/cpp/io/ios_base/openmode

tk::Writer::~Writer() virtual noexcept

Destructor: Release file handle.

Exception safety: no-throw guarantee: never throws exceptions. Error handling, while done by throwing and catching exceptions, results in warnings to terminal. We use C-style printf, since that will not throw exceptions.

void tk::Writer::write(const char* data, std::streamsize count)

Parameters
data in Buffer to write
count in Number of characters to write

Unformatted write