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

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

#include <stream/NumericalStream.h>

Public Member Functions

 NumericalOstream (std::ostream &s)
 Constructs a NumericalOstream around the specified existing std::ostream. More...
 
template<typename T >
NumericalOstreamoperator<< (const T &val)
 
NumericalOstreamoperator<< (std::ostream &(*pf)(std::ostream &))
 
NumericalOstreamoperator<< (float val)
 
NumericalOstreamoperator<< (double val)
 
NumericalOstreamoperator<< (long double val)
 

Public Attributes

std::ostream & out
 The underlying output stream. More...
 

Detailed Description

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

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

This class can be used like any other std::ostream, as shown in the following Example:

ofstream ofs("myfile.txt");
NumericalOstream os(ofs); // create numerical stream and attach it to the file stream
int a = 4;
os << a << std::endl;
os << 1.234f << std::numeric_limits<float>::quiet_NaN() << std::endl;
os << "This is a string" << std::endl;
uint32 x = 0x12345F;
os << std::hex << x; // write x in hexadecimal format
See also
NumericalIstream

Constructor & Destructor Documentation

◆ NumericalOstream()

NumericalOstream ( std::ostream &  s)
inline

Constructs a NumericalOstream around the specified existing std::ostream.

All outputs written to the NumericalOstream will be relayed to that std::ostream internally. The std::ostream must exist while this NumericalOstream object is existent.

Member Function Documentation

◆ operator<<() [1/5]

NumericalOstream& operator<< ( const T &  val)
inline

◆ operator<<() [2/5]

NumericalOstream& operator<< ( std::ostream &(*)(std::ostream &)  pf)
inline

◆ operator<<() [3/5]

NumericalOstream& operator<< ( float  val)
inline

◆ operator<<() [4/5]

NumericalOstream& operator<< ( double  val)
inline

◆ operator<<() [5/5]

NumericalOstream& operator<< ( long double  val)
inline

Member Data Documentation

◆ out

std::ostream& out

The underlying output stream.


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