Public Member Functions | List of all members
ecl::TextStream< Device > Class Template Reference

A text streaming interface. More...

#include <text_stream.hpp>

Inheritance diagram for ecl::TextStream< Device >:
Inheritance graph
[legend]

Public Member Functions

virtual ~TextStream ()
 

Detailed Description

template<typename Device>
class ecl::TextStream< Device >

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.

Definition at line 100 of file text_stream.hpp.

Constructor & Destructor Documentation

◆ ~TextStream()

template<typename Device >
virtual ecl::TextStream< Device >::~TextStream ( )
inlinevirtual

Definition at line 111 of file text_stream.hpp.


The documentation for this class was generated from the following file:
ecl::New
New
ecl::endl
EndOfLine endl
Definition: manipulators.cpp:30
d
void d()


ecl_streams
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:48