PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
util::io::Msg Class Reference

Collects a message with stream syntax for use in an exception. More...

#include <io.h>

Collaboration diagram for util::io::Msg:

Public Member Functions

template<typename T >
Msgoperator<< (const T &v)
 Appends a value to the message.
 
Msgoperator<< (std::ostream &(*manip)(std::ostream &))
 Appends a stream manipulator such as std::endl.
 
std::string str () const
 The message built so far.
 
 operator std::string () const
 Implicit conversion so it can be passed straight to an exception.
 

Private Attributes

std::ostringstream d_oss
 Message under construction.
 

Detailed Description

Collects a message with stream syntax for use in an exception.

Validation in the library reports failure by throwing rather than by calling exit(), because exit() terminates the embedding process. Under the Python interface that ends the interpreter with no traceback. The checks already composed their message as std::cerr << a << b. This collects the same sequence into a std::string that an exception can carry.

throw std::invalid_argument(util::io::Msg()
<< "need " << n << " parameters, got "
<< params.size());
Collects a message with stream syntax for use in an exception.
Definition io.h:52

Definition at line 52 of file io.h.

Member Function Documentation

◆ operator std::string()

util::io::Msg::operator std::string ( ) const
inline

Implicit conversion so it can be passed straight to an exception.

Definition at line 70 of file io.h.

70{ return d_oss.str(); }
std::ostringstream d_oss
Message under construction.
Definition io.h:74

References d_oss.

◆ operator<<() [1/2]

template<typename T >
Msg & util::io::Msg::operator<< ( const T &  v)
inline

Appends a value to the message.

Definition at line 55 of file io.h.

55 {
56 d_oss << v;
57 return *this;
58 }

References d_oss.

◆ operator<<() [2/2]

Msg & util::io::Msg::operator<< ( std::ostream &(*)(std::ostream &)  manip)
inline

Appends a stream manipulator such as std::endl.

Definition at line 61 of file io.h.

61 {
62 d_oss << manip;
63 return *this;
64 }

References d_oss.

◆ str()

std::string util::io::Msg::str ( ) const
inline

The message built so far.

Definition at line 67 of file io.h.

67{ return d_oss.str(); }

References d_oss.

Referenced by material::PdState::computeParameters(), anonymous_namespace{materialUtil.cpp}::computeStateMxI(), and geom::createGeomObjectOld().

Here is the caller graph for this function:

Field Documentation

◆ d_oss

std::ostringstream util::io::Msg::d_oss
private

Message under construction.

Definition at line 74 of file io.h.

Referenced by operator std::string(), operator<<(), operator<<(), and str().


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