OGS
Writer.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <filesystem>
18#include <sstream>
19#include <string>
20
21namespace BaseLib
22{
23namespace IO
24{
30class Writer
31{
32public:
33 Writer();
34 virtual ~Writer() = default;
35
37 std::string writeToString();
38
39protected:
43 virtual bool write() = 0;
44
46 std::ostringstream out;
47};
48
50int writeStringToFile(std::string content,
51 std::filesystem::path const& file_path);
52} // namespace IO
53} // namespace BaseLib
Base class which enables writing an object to string, stringstream or file.
Definition: Writer.h:31
std::ostringstream out
The stream to write to.
Definition: Writer.h:46
virtual bool write()=0
Writes the object to the internal stream. This method must be implemented by a subclass....
std::string writeToString()
Writes the object to a string.
Definition: Writer.cpp:31
virtual ~Writer()=default
int writeStringToFile(std::string content, std::filesystem::path const &file_path)
Definition: Writer.cpp:45