OGS
Writer.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <filesystem>
7#include <sstream>
8#include <string>
9#include <string_view>
10
11namespace BaseLib
12{
13namespace IO
14{
20class Writer
21{
22public:
23 Writer();
24 virtual ~Writer() = default;
25
27 std::string writeToString();
28
29protected:
33 virtual bool write() = 0;
34
36 std::ostringstream out;
37};
38
40int writeStringToFile(std::string_view content,
41 std::filesystem::path const& file_path);
42} // namespace IO
43} // namespace BaseLib
std::ostringstream out
The stream to write to.
Definition Writer.h:36
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:20
virtual ~Writer()=default
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
Definition Writer.cpp:34