OGS
Writer.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <filesystem.h>
18 #include <string>
19 #include <sstream>
20 
21 namespace BaseLib
22 {
23 namespace IO
24 {
30 class Writer
31 {
32 public:
33  Writer();
34  virtual ~Writer() = default;
35 
37  std::string writeToString();
38 
39 protected:
43  virtual bool write() = 0;
44 
46  std::ostringstream out;
47 };
48 
50 int 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