A text streaming interface. More...
#include <text_stream.hpp>
Public Member Functions | |
virtual | ~TextStream () |
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).
Definition at line 93 of file text_stream.hpp.
virtual ecl::TextStream< Device >::~TextStream | ( | ) | [inline, virtual] |
Definition at line 96 of file text_stream.hpp.