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#include <string_view>
21
22namespace BaseLib
23{
24namespace IO
25{
31class Writer
32{
33public:
34 Writer();
35 virtual ~Writer() = default;
36
38 std::string writeToString();
39
40protected:
44 virtual bool write() = 0;
45
47 std::ostringstream out;
48};
49
51int writeStringToFile(std::string_view content,
52 std::filesystem::path const& file_path);
53} // namespace IO
54} // namespace BaseLib
Base class which enables writing an object to string, stringstream or file.
Definition Writer.h:32
std::ostringstream out
The stream to write to.
Definition Writer.h:47
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_view content, std::filesystem::path const &file_path)
Definition Writer.cpp:45