Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (01b473db)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MsgStream.h File Reference
#include <GaudiKernel/IMessageSvc.h>
#include <GaudiKernel/SerializeSTL.h>
#include <iomanip>
#include <sstream>
#include <string>
Include dependency graph for MsgStream.h:

Go to the source code of this file.

Classes

class  MsgStream
 

Namespaces

 MSG
 Print levels enumeration.
 

Functions

MsgStreamendmsg (MsgStream &s)
 MsgStream Modifier: endmsg. Calls the output method of the MsgStream. More...
 
GAUDI_API std::string format (const char *,...)
 MsgStream format utility "a la sprintf(...)". More...
 
template<class _Tm >
MsgStreamoperator<< (MsgStream &s, const std::smanip< _Tm > &manip)
 I/O Manipulator for setfill. More...
 
MsgStreamMSG::dec (MsgStream &log)
 
MsgStreamMSG::hex (MsgStream &log)
 
MsgStreamoperator<< (MsgStream &s, const char *arg)
 Specialization to avoid the generation of implementations for char[]. More...
 
template<typename T >
MsgStreamoperator<< (MsgStream &lhs, const T &arg)
 General templated stream operator. More...
 

Function Documentation

◆ endmsg()

MsgStream& endmsg ( MsgStream s)
inline

MsgStream Modifier: endmsg. Calls the output method of the MsgStream.

Definition at line 198 of file MsgStream.h.

198 { return s.doOutput(); }

◆ format()

GAUDI_API std::string format ( const char *  ,
  ... 
)

MsgStream format utility "a la sprintf(...)".

Definition at line 93 of file MsgStream.cpp.

93  {
94  const int buffsize = 2048;
95  static char buffer[buffsize];
96  va_list arguments;
97  va_start( arguments, fmt );
98  if ( vsnprintf( buffer, buffsize, fmt, arguments ) >= buffsize ) {
99  va_end( arguments );
100  throw GaudiException( "Insufficient buffer size (" + std::to_string( buffsize ) + ") when formatting message",
101  "MsgStream", StatusCode::FAILURE );
102  }
103  va_end( arguments );
104  return std::string( buffer );
105 }

◆ operator<<() [1/3]

template<typename T >
MsgStream& operator<< ( MsgStream lhs,
const T &  arg 
)

General templated stream operator.

Definition at line 276 of file MsgStream.h.

276  {
277  using namespace GaudiUtils;
278  if ( lhs.isActive() ) try {
279  // this may throw, and we cannot afford it if the stream is used in a catch block
280  lhs.stream() << arg;
281  } catch ( ... ) {}
282  return lhs;
283 }

◆ operator<<() [2/3]

MsgStream& operator<< ( MsgStream s,
const char *  arg 
)
inline

Specialization to avoid the generation of implementations for char[].

See also
{bug #87340}

Definition at line 266 of file MsgStream.h.

266  {
267  try {
268  // this may throw, and we cannot afford it if the stream is used in a catch block
269  if ( s.isActive() ) s.stream() << arg;
270  } catch ( ... ) {}
271  return s;
272 }

◆ operator<<() [3/3]

template<class _Tm >
MsgStream& operator<< ( MsgStream s,
const std::smanip< _Tm > &  manip 
)
inline

I/O Manipulator for setfill.

Definition at line 244 of file MsgStream.h.

244  {
245  try {
246  // this may throw, and we cannot afford it if the stream is used in a catch block
247  if ( s.isActive() ) s.stream() << manip;
248  } catch ( ... ) {}
249  return s;
250 }
gaudirun.s
string s
Definition: gaudirun.py:346
GaudiException
Definition: GaudiException.h:29
fmt
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
GaudiUtils
Definition: Allocator.h:62
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:116
MsgStream::stream
std::ostringstream & stream()
Access string MsgStream.
Definition: MsgStream.h:99