PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::ErrorStream Class Reference

#include <Puma/ErrorStream.h>

+ Inheritance diagram for Puma::ErrorStream:

Description

An error stream is a special ErrorSink that prints out an error message as soon as it is complete.

It also stores the maximum error severity. The error stream can be reset to its initial state.

Public Member Functions

 ErrorStream (std::ostream &out=std::cerr)
 Constructor. More...
 
virtual ~ErrorStream ()
 Destructor. More...
 
ErrorStreamoperator<< (const char *str)
 Add given string to current error message. More...
 
ErrorStreamoperator<< (long value)
 Add given long integer value to current error message. More...
 
ErrorStreamoperator<< (unsigned value)
 Add given unsigned integer value to current error message. More...
 
ErrorStreamoperator<< (int value)
 Add given signed integer value to current error message. More...
 
ErrorStreamoperator<< (short value)
 Add given short integer value to current error message. More...
 
ErrorStreamoperator<< (char c)
 Add given character to current error message. More...
 
ErrorStreamoperator<< (double value)
 Add given floating point value to current error message. More...
 
ErrorStreamoperator<< (const ErrorSeverity &sev)
 Change the severity of the current error message. More...
 
ErrorStreamoperator<< (Location location)
 Set the location the error occurred. More...
 
ErrorStreamoperator<< (const Printable &obj)
 Add the serialized value of the given object to the current error message. More...
 
ErrorStreamoperator<< (void(*fct)(ErrorSink &))
 Apply the given stream manipulator. More...
 
void endMessage ()
 Finish the current error message. More...
 
void reset ()
 Reset the error stream to its initial state. More...
 
bool silent ()
 Turn to silent mode. More...
 
bool loud ()
 Turn to loud mode. More...
 
ErrorSeverity severity () const
 Get the current error severity. More...
 
void severity (ErrorSeverity &sev)
 Set a new severity for all following messages. More...
 
- Public Member Functions inherited from Puma::ErrorSink
virtual ~ErrorSink ()
 Destructor. More...
 
virtual ErrorSinkoperator<< (const char *str)=0
 Add given string to current error message. More...
 
virtual ErrorSinkoperator<< (long value)=0
 Add given long integer value to current error message. More...
 
virtual ErrorSinkoperator<< (unsigned value)=0
 Add given unsigned integer value to current error message. More...
 
virtual ErrorSinkoperator<< (int value)=0
 Add given signed integer value to current error message. More...
 
virtual ErrorSinkoperator<< (short value)=0
 Add given short integer value to current error message. More...
 
virtual ErrorSinkoperator<< (char c)=0
 Add given character to current error message. More...
 
virtual ErrorSinkoperator<< (double value)=0
 Add given floating point value to current error message. More...
 
virtual ErrorSinkoperator<< (const ErrorSeverity &severity)=0
 Change the severity of the current error message. More...
 
virtual ErrorSinkoperator<< (Location location)=0
 Set the location the error occurred. More...
 
virtual ErrorSinkoperator<< (const Printable &obj)=0
 Add the serialized value of the given object to the current error message. More...
 
virtual ErrorSinkoperator<< (void(*fct)(ErrorSink &))=0
 Apply the given stream manipulator. More...
 
virtual void endMessage ()=0
 Finish the current error message. More...
 

Constructor & Destructor Documentation

◆ ErrorStream()

Puma::ErrorStream::ErrorStream ( std::ostream &  out = std::cerr)
inline

Constructor.

Parameters
outThe output stream to use. Defaults to std::cerr.

◆ ~ErrorStream()

virtual Puma::ErrorStream::~ErrorStream ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ endMessage()

void Puma::ErrorStream::endMessage ( )
virtual

Finish the current error message.

Implements Puma::ErrorSink.

◆ loud()

bool Puma::ErrorStream::loud ( )

Turn to loud mode.

In loud mode messages are printed on the output stream. This is the default mode.

Returns
True if the previous mode was loud already.

◆ operator<<() [1/11]

ErrorStream & Puma::ErrorStream::operator<< ( char  c)
virtual

Add given character to current error message.

Parameters
cThe character to add.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [2/11]

ErrorStream & Puma::ErrorStream::operator<< ( const char *  str)
virtual

Add given string to current error message.

Parameters
strThe string to add.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [3/11]

ErrorStream & Puma::ErrorStream::operator<< ( const ErrorSeverity sev)
virtual

Change the severity of the current error message.

Parameters
sevThe new severity.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [4/11]

ErrorStream & Puma::ErrorStream::operator<< ( const Printable obj)
virtual

Add the serialized value of the given object to the current error message.

Parameters
objThe object to serialize.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [5/11]

ErrorStream & Puma::ErrorStream::operator<< ( double  value)
virtual

Add given floating point value to current error message.

Parameters
valueThe value to add.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [6/11]

ErrorStream & Puma::ErrorStream::operator<< ( int  value)
virtual

Add given signed integer value to current error message.

Parameters
valueThe value to add.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [7/11]

ErrorStream & Puma::ErrorStream::operator<< ( Location  location)
virtual

Set the location the error occurred.

Parameters
locationThe error location.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [8/11]

ErrorStream & Puma::ErrorStream::operator<< ( long  value)
virtual

Add given long integer value to current error message.

Parameters
valueThe value to add.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [9/11]

ErrorStream & Puma::ErrorStream::operator<< ( short  value)
virtual

Add given short integer value to current error message.

Parameters
valueThe value to add.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [10/11]

ErrorStream & Puma::ErrorStream::operator<< ( unsigned  value)
virtual

Add given unsigned integer value to current error message.

Parameters
valueThe value to add.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ operator<<() [11/11]

ErrorStream & Puma::ErrorStream::operator<< ( void(*)(ErrorSink &)  fct)
virtual

Apply the given stream manipulator.

Parameters
fctThe stream manipulator function.
Returns
A reference to this error stream.

Implements Puma::ErrorSink.

◆ reset()

void Puma::ErrorStream::reset ( )

Reset the error stream to its initial state.

◆ severity() [1/2]

ErrorSeverity Puma::ErrorStream::severity ( ) const
inline

Get the current error severity.

Returns
The error severity.

◆ severity() [2/2]

void Puma::ErrorStream::severity ( ErrorSeverity sev)
inline

Set a new severity for all following messages.

Parameters
sevThe new severity.

◆ silent()

bool Puma::ErrorStream::silent ( )

Turn to silent mode.

In silent mode no message is printed on the output stream.

Returns
True if the previous mode was silent already.