Template Class TextStream
Defined in File text_stream.hpp
Inheritance Relationships
Base Types
public ecl::interfaces::InputTextStream< Device, is_source< Device >::value >
(Template Class InputTextStream)public ecl::interfaces::OutputTextStream< Device, is_sink< Device >::value >
(Template Class OutputTextStream)
Class Documentation
-
template<typename Device>
class TextStream : public ecl::interfaces::InputTextStream<Device, is_source<Device>::value>, public ecl::interfaces::OutputTextStream<Device, is_sink<Device>::value> A text streaming interface.
This connects to an underlying device and enables text streaming to and from the device. The device type (determined by input and output device concept checks) determines the type of interface that is brought into the textstream instance, either input, output or both.
Usage:
Instantiating
To open the underlying device,
TextStream<OFile> ofstream; ofstream.device().open("dudes.txt",New);
Streaming
Usage follows very similar to the standard c++ streams.
ofstream << "dudes " << 32.36; ofstream.flush();
Formatting
These streams are usable with the format classes in ecl_formatters.
Format<double> format; format.width(5); format.precision(2); double d = 1.0/3.0; ostream << format(d); // This will send 0.33 to the stream. ostream.flush();
Error Checking
Output streams can generate errors that are not so easily checked compared with handling devices directly. To check for failure, ecl streams use a mechanism similar to that of the standard cout stream.
ostream << 32.1; if ( ostream.fail() ) { std::cout << ostream.errorMessage() << std::endl; }
You can also use the errorStatus() method to retrieve the exact error flag (enumeration).
See also
interfaces::InputTextStream<Device,true>, interfaces::OutputTextStream<Device,true>, interfaces::BaseTextStream.
Public Functions
-
inline virtual ~TextStream()
-
inline virtual ~TextStream()