MIRA
Public Member Functions | Public Attributes | List of all members
NumericalIstream Class Reference

Numerical stream adapter that can be assigned to any input stream and allows streaming of numerical values. More...

#include <stream/NumericalStream.h>

Public Member Functions

 NumericalIstream (std::istream &s)
 Constructs a NumericalIstream around the specified existing istream. More...
 
template<typename T >
NumericalIstreamoperator>> (T &val)
 
NumericalIstreamoperator>> (std::istream &(*pf)(std::istream &))
 
NumericalIstreamoperator>> (float &val)
 
NumericalIstreamoperator>> (double &val)
 
NumericalIstreamoperator>> (long double &val)
 

Public Attributes

std::istream & in
 The underlying input stream. More...
 

Detailed Description

Numerical stream adapter that can be assigned to any input stream and allows streaming of numerical values.

In contrast to the default std::istream implementation, this class is able to handle nan and inf values correctly.

This class can be used with different stream "underlays". The underlay provides the actual stream functionality and stores or transmits the data. Currently the binary stream comes in two flavors:

This class can be used like any other std::istream, as shown in the

// reads the file that was written in the NumericalOstream example:
ifstream ifs("myfile.txt");
NumericalIstream is(ifs); // create binary stream and attach to file stream
int a;
is >> a; // a=4
float f, g;
is >> f >> g; // f=1.234f, g=nan
string s;
is >> s; // s="This is a string"
uint32 x
is >> hex >> x; // x = 0x12345F;
See also
NumericalOstream

Constructor & Destructor Documentation

◆ NumericalIstream()

NumericalIstream ( std::istream &  s)
inline

Constructs a NumericalIstream around the specified existing istream.

All input from the NumericalIstream will be relayed to that istream internally. The istream must exist while this NumericalIstream object is existent.

Member Function Documentation

◆ operator>>() [1/5]

NumericalIstream& operator>> ( T &  val)
inline

◆ operator>>() [2/5]

NumericalIstream& operator>> ( std::istream &(*)(std::istream &)  pf)
inline

◆ operator>>() [3/5]

NumericalIstream& operator>> ( float &  val)
inline

◆ operator>>() [4/5]

NumericalIstream& operator>> ( double &  val)
inline

◆ operator>>() [5/5]

NumericalIstream& operator>> ( long double &  val)
inline

Member Data Documentation

◆ in

std::istream& in

The underlying input stream.


The documentation for this class was generated from the following file: