Discontinuous Galerkin Library
#include "dg/algorithm.h"
dg::Message Class Reference

small class holding a stringstream More...

Public Member Functions

 Message ()
 construct an empty message More...
 
 Message (const char *file, const int line)
 Initiate message with the file and line it comes from. More...
 
 Message (std::string m)
 Construct message with string. More...
 
 ~Message ()
 
template<class T >
Messageoperator<< (const T &value)
 add values to the message stream More...
 
std::string str () const
 return the message contained in the stream as a string More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Message &m)
 

Detailed Description

small class holding a stringstream

try{ throw Error(Message(_ping_)<<"This is error number "<<number);}
catch( Error& m) {std::cerr << m.what();}
Message()
construct an empty message
Definition: exceptions.h:36
#define _ping_
Definition: exceptions.h:12

Constructor & Destructor Documentation

◆ Message() [1/3]

dg::Message::Message ( )
inline

construct an empty message

◆ Message() [2/3]

dg::Message::Message ( const char *  file,
const int  line 
)
inline

Initiate message with the file and line it comes from.

Parameters
fileThe file in which the exception is thrown (contained in the predefined Macro __FILE__ )
lineThe line in which the exception is thrown (contained in the predefined Macro __LINE__ )
Note
The Macro _ping_ expands to __FILE__, __LINE__ _

◆ Message() [3/3]

dg::Message::Message ( std::string  m)
inline

Construct message with string.

Parameters
mputs m into stream

◆ ~Message()

dg::Message::~Message ( )
inline

Member Function Documentation

◆ operator<<()

template<class T >
Message & dg::Message::operator<< ( const T &  value)
inline

add values to the message stream

Note
you can't use std::endl or std::flush in here

◆ str()

std::string dg::Message::str ( ) const
inline

return the message contained in the stream as a string

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Message m 
)
friend

put the sringstream string into the ostream

Note
same as os<<m.str();

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