#include <genesis/utils/io/base_output_target.hpp>
Inherited by FileOutputTarget, GzipBlockOutputTarget, GzipOutputTarget, StreamOutputTarget, and StringOutputTarget.
Abstract base class for writing data to an output target.
The class is an interface that allows writing to different targets, and adds a layer of abstraction around using simple std::ostream
functionality. In particular, we want to add some checks, naming of the streams, etc. Internally however, the derived classes of this base class use std::ostream
, and make it accessible.
- See also
- FileOutputTarget, GzipOutputTarget, StreamOutputTarget, StringOutputTarget for our derived output target classes.
-
to_file(), to_gzip_block_file(), to_stream(), to_string() for helper functions to create these classes, to add some syntactic sugar and make it easy to use.
Definition at line 59 of file base_output_target.hpp.
◆ BaseOutputTarget() [1/3]
◆ BaseOutputTarget() [2/3]
◆ BaseOutputTarget() [3/3]
◆ ~BaseOutputTarget()
◆ flush()
Flush output stream buffer.
Internally, the different output target derived classes use some variant of std::ostream
to do the writing. Hence, the target might need flushing in cases where we want to synchronize it while writing, before closing the stream.
Definition at line 117 of file base_output_target.hpp.
◆ operator<<()
Output stream operator template that simply forwards to the underlying ostream() object.
This is the main function used to write output. This way, nothing has to be changed in code that wants to write some output, comared to standard write-to-stream functions. The only change necessary is the initial setup of the output object: Instead of an std::ostream, one has to initialize this class. From then on, usage is identical.
Alternatively, the ostream() function can be used to obtain the underlying stream that is internally used to write the data. Also, see flush() to synchronize the writing with the actual target of the stream.
Definition at line 95 of file base_output_target.hpp.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ ostream()
std::ostream& ostream |
( |
| ) |
|
|
inline |
◆ target_name()
std::string target_name |
( |
| ) |
const |
|
inline |
Get a name of the output target. This is intended for user output.
This will for example return something like "output file (/path/to/file.txt)", so that users know what type of output stream it is, and where it streams to.
Definition at line 128 of file base_output_target.hpp.
◆ target_string()
std::string target_string |
( |
| ) |
const |
|
inline |
Get a string representing the output target.
This is intended for the writer classes, which for example might want to examine the output file name. Hence, this function is meant to return just the file path (for a file target).
Definition at line 140 of file base_output_target.hpp.
The documentation for this class was generated from the following file: