cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches

A simple exception handler. More...

#include <CepGen/Utils/Message.h>

+ Inheritance diagram for LoggedMessage:
+ Collaboration diagram for LoggedMessage:

Public Types

enum class  MessageType {
  undefined = -1 , debug , verbatim , info ,
  warning
}
 Enumeration of message type. More...
 

Public Member Functions

 LoggedMessage (const char *mod, const char *from="", MessageType type=MessageType::undefined, const char *file="", short lineno=0) noexcept
 Generic constructor.
 
 LoggedMessage (const LoggedMessage &) noexcept
 Copy constructor.
 
virtual ~LoggedMessage () noexcept override
 Default destructor.
 
template<typename T >
const LoggedMessagelog (T &&lam) noexcept
 Lambda function handler.
 
std::string message () const
 Human-readable message.
 
const std::string & from () const
 Origin of the exception.
 
const std::string & file () const
 File where the exception occured.
 
short lineNumber () const
 Line number where the exception occured.
 
const MessageTypetype () const
 Message type.
 
void dump (std::ostream *os=nullptr) const noexcept override
 Human-readable dump of the message.
 
std::ostream & stream ()
 Output stream object.
 

Static Public Member Functions

static std::string now ()
 Human-readable date/time.
 

Protected Attributes

std::ostringstream message_
 Message to throw.
 
std::string from_
 Origin of the exception.
 
std::string file_
 File.
 
short line_num_
 Line number.
 

Friends

std::ostream & operator<< (std::ostream &, const MessageType &)
 Printout operator for message type.
 
template<typename T >
const LoggedMessageoperator<< (const LoggedMessage &exc, const T &var) noexcept
 Generic templated message feeder operator.
 
const LoggedMessageoperator<< (const LoggedMessage &, const bool &) noexcept
 Specialised feeder operator for booleans.
 
const LoggedMessageoperator<< (const LoggedMessage &, const std::wstring &) noexcept
 Specialised feeder operator for wide strings.
 
template<typename T , typename U >
const LoggedMessageoperator<< (const LoggedMessage &exc, const std::pair< T, U > &pair_var) noexcept
 Generic templated pair-variables feeder operator.
 
template<typename T >
const LoggedMessageoperator<< (const LoggedMessage &exc, const std::set< T > &set_var) noexcept
 Generic templated vector-variables feeder operator.
 
template<typename T >
const LoggedMessageoperator<< (const LoggedMessage &exc, const std::vector< T > &vec_var) noexcept
 Generic templated vector-variables feeder operator.
 
template<typename T , std::size_t N>
const LoggedMessageoperator<< (const LoggedMessage &exc, const std::array< T, N > &vec_var) noexcept
 Generic templated vector-variables feeder operator.
 
template<typename T , typename U >
const LoggedMessageoperator<< (const LoggedMessage &exc, const std::map< T, U > &map_var) noexcept
 Generic templated mapping-variables feeder operator.
 
template<typename T , typename U >
const LoggedMessageoperator<< (const LoggedMessage &exc, const std::unordered_map< T, U > &map_var) noexcept
 Generic templated mapping-variables feeder operator.
 
const LoggedMessageoperator<< (const LoggedMessage &exc, std::ios_base &(*f)(std::ios_base &)) noexcept
 Pipe modifier operator.
 

Detailed Description

Date
24 Mar 2015

Definition at line 44 of file Message.h.

Member Enumeration Documentation

◆ MessageType

enum class MessageType
strong
Enumerator
undefined 

Irregular message.

debug 

Debugging information to be enabled.

verbatim 

Raw information.

info 

Prettified information.

warning 

Casual non-stopping warning.

Definition at line 47 of file Message.h.

Constructor & Destructor Documentation

◆ LoggedMessage() [1/2]

LoggedMessage ( const char *  mod,
const char *  from = "",
MessageType  type = MessageType::undefined,
const char *  file = "",
short  lineno = 0 
)
explicitnoexcept
Parameters
[in]modexception classifier
[in]frommethod invoking the exception
[in]typeexception type
[in]filefile where this occured
[in]linenoLine number where exception occured

Definition at line 25 of file Message.cpp.

◆ LoggedMessage() [2/2]

LoggedMessage ( const LoggedMessage rhs)
noexcept

Definition at line 29 of file Message.cpp.

◆ ~LoggedMessage()

~LoggedMessage ( )
overridevirtualnoexcept

Definition at line 37 of file Message.cpp.

Member Function Documentation

◆ dump()

void dump ( std::ostream *  os = nullptr) const
overridevirtualnoexcept

Implements Message.

Definition at line 55 of file Message.cpp.

◆ file()

const std::string & file ( ) const

Definition at line 163 of file Message.h.

◆ from()

const std::string & from ( ) const

Definition at line 161 of file Message.h.

◆ lineNumber()

short lineNumber ( ) const

Definition at line 165 of file Message.h.

◆ log()

template<typename T >
const LoggedMessage & log ( T &&  lam)
noexcept

Definition at line 152 of file Message.h.

◆ message()

std::string message ( ) const

Definition at line 158 of file Message.h.

◆ now()

std::string now ( )
staticinherited

Definition at line 23 of file Message.cpp.

◆ stream()

std::ostream & stream ( )

Definition at line 171 of file Message.h.

◆ type()

const MessageType & type ( ) const

Definition at line 167 of file Message.h.

Friends And Related Symbol Documentation

◆ operator<< [1/11]

const LoggedMessage & operator<< ( const LoggedMessage exc,
const bool &  var 
)
friend

Definition at line 42 of file Message.cpp.

◆ operator<< [2/11]

const LoggedMessage & operator<< ( const LoggedMessage exc,
const std::wstring &  var 
)
friend

Definition at line 49 of file Message.cpp.

◆ operator<< [3/11]

template<typename T , std::size_t N>
const LoggedMessage & operator<< ( const LoggedMessage exc,
const std::array< T, N > &  vec_var 
)
friend

Definition at line 113 of file Message.h.

◆ operator<< [4/11]

template<typename T , typename U >
const LoggedMessage & operator<< ( const LoggedMessage exc,
const std::map< T, U > &  map_var 
)
friend

Definition at line 123 of file Message.h.

◆ operator<< [5/11]

template<typename T , typename U >
const LoggedMessage & operator<< ( const LoggedMessage exc,
const std::pair< T, U > &  pair_var 
)
friend

Definition at line 88 of file Message.h.

◆ operator<< [6/11]

template<typename T >
const LoggedMessage & operator<< ( const LoggedMessage exc,
const std::set< T > &  set_var 
)
friend

Definition at line 93 of file Message.h.

◆ operator<< [7/11]

template<typename T , typename U >
const LoggedMessage & operator<< ( const LoggedMessage exc,
const std::unordered_map< T, U > &  map_var 
)
friend

Definition at line 133 of file Message.h.

◆ operator<< [8/11]

template<typename T >
const LoggedMessage & operator<< ( const LoggedMessage exc,
const std::vector< T > &  vec_var 
)
friend

Definition at line 103 of file Message.h.

◆ operator<< [9/11]

template<typename T >
const LoggedMessage & operator<< ( const LoggedMessage exc,
const T &  var 
)
friend

Definition at line 77 of file Message.h.

◆ operator<< [10/11]

const LoggedMessage & operator<< ( const LoggedMessage exc,
std::ios_base &(*)(std::ios_base &)  f 
)
friend

Definition at line 143 of file Message.h.

◆ operator<< [11/11]

std::ostream & operator<< ( std::ostream &  os,
const MessageType type 
)
friend

Definition at line 97 of file Message.cpp.

Member Data Documentation

◆ file_

std::string file_
protected

Definition at line 176 of file Message.h.

◆ from_

std::string from_
protected

Definition at line 175 of file Message.h.

◆ line_num_

short line_num_
protected

Definition at line 177 of file Message.h.

◆ message_

std::ostringstream message_
protected

Definition at line 174 of file Message.h.