OGS
BaseLib::IO::Writer Class Referenceabstract

Detailed Description

Base class which enables writing an object to string, stringstream or file.

When subclassing you only need to implement void write() in which you have to write to out.

Definition at line 31 of file Writer.h.

#include <Writer.h>

Inheritance diagram for BaseLib::IO::Writer:
[legend]

Public Member Functions

 Writer ()
 
virtual ~Writer ()=default
 
std::string writeToString ()
 Writes the object to a string.
 

Protected Member Functions

virtual bool write ()=0
 Writes the object to the internal stream. This method must be implemented by a subclass. The implementation should return true on success, else false.
 

Protected Attributes

std::ostringstream out
 The stream to write to.
 

Constructor & Destructor Documentation

◆ Writer()

BaseLib::IO::Writer::Writer ( )

Definition at line 26 of file Writer.cpp.

27{
28 out.precision(std::numeric_limits<double>::digits10);
29}
std::ostringstream out
The stream to write to.
Definition Writer.h:47

References out.

◆ ~Writer()

virtual BaseLib::IO::Writer::~Writer ( )
virtualdefault

Member Function Documentation

◆ write()

virtual bool BaseLib::IO::Writer::write ( )
protectedpure virtual

Writes the object to the internal stream. This method must be implemented by a subclass. The implementation should return true on success, else false.

Implemented in FileIO::CsvInterface, FileIO::GMSH::GMSHInterface, FileIO::XmlPrjInterface, GeoLib::IO::BoostXmlGmlInterface, GeoLib::IO::XmlGmlInterface, GeoLib::IO::XmlStnInterface, and MeshLib::IO::Legacy::MeshIO.

Referenced by writeToString().

◆ writeToString()

std::string BaseLib::IO::Writer::writeToString ( )

Writes the object to a string.

Definition at line 31 of file Writer.cpp.

32{
33 // Empty stream and clear error states.
34 out.str("");
35 out.clear();
36
37 if (this->write())
38 {
39 return out.str();
40 }
41
42 return std::string("");
43}
virtual bool write()=0
Writes the object to the internal stream. This method must be implemented by a subclass....

References out, and write().

Referenced by SaveMeshDialog::accept(), MainWindow::callGMSH(), consolidateGeometry(), OGSFileConverter::convertGLI2GML(), convertPoints(), OGSFileConverter::convertVTU2MSH(), FileIO::createSurface(), generateMesh(), main(), MainWindow::save(), FileIO::XmlPrjInterface::write(), FileIO::SwmmInterface::writeCsvForObject(), FileIO::SwmmInterface::writeCsvForTimestep(), MainWindow::writeGeometryToFile(), FileIO::writeGeometryToFile(), writeGeoOutput(), MeshLib::IO::writeMeshToFile(), MainWindow::writeStationListToFile(), and FileIO::XmlPrjInterface::writeToFile().

Member Data Documentation

◆ out


The documentation for this class was generated from the following files: