The Gaudi Framework  v32r2 (46d42edc)
MsgStream.h File Reference
#include "GaudiKernel/IMessageSvc.h"
#include "GaudiKernel/SerializeSTL.h"
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
Include dependency graph for MsgStream.h:

Go to the source code of this file.

Classes

class  MsgStream
 Definition of the MsgStream class used to transmit messages. More...
 

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 192 of file MsgStream.h.

192 { return s.doOutput(); }
string s
Definition: gaudirun.py:318

◆ format()

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

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

Definition at line 109 of file MsgStream.cpp.

109  {
110  const int buffsize = 2048;
111  static char buffer[buffsize];
112  va_list arguments;
113  va_start( arguments, fmt );
114  if ( vsnprintf( buffer, buffsize, fmt, arguments ) >= buffsize )
115  throw GaudiException( "Insufficient buffer size (" + std::to_string( buffsize ) + ") when formatting message",
116  "MsgStream", StatusCode::FAILURE );
117  va_end( arguments );
118  return std::string( buffer );
119 }
Define general base for Gaudi exception.
T to_string(T... args)
STL class.
T vsnprintf(T... args)
constexpr static const auto FAILURE
Definition: StatusCode.h:86

◆ operator<<() [1/3]

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

I/O Manipulator for setfill.

Definition at line 257 of file MsgStream.h.

257  {
258  try {
259  // this may throw, and we cannot afford it if the stream is used in a catch block
260  if ( s.isActive() ) s.stream() << manip;
261  } catch ( ... ) {}
262  return s;
263 }
string s
Definition: gaudirun.py:318

◆ 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 279 of file MsgStream.h.

279  {
280  try {
281  // this may throw, and we cannot afford it if the stream is used in a catch block
282  if ( s.isActive() ) s.stream() << arg;
283  } catch ( ... ) {}
284  return s;
285 }
string s
Definition: gaudirun.py:318

◆ operator<<() [3/3]

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

General templated stream operator.

Definition at line 289 of file MsgStream.h.

289  {
290  using namespace GaudiUtils;
291  if ( lhs.isActive() ) try {
292  // this may throw, and we cannot afford it if the stream is used in a catch block
293  lhs.stream() << arg;
294  } catch ( ... ) {}
295  return lhs;
296 }
std::ostringstream & stream()
Access string MsgStream.
Definition: MsgStream.h:94
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:111
Forward declarations for the functions in SerializeSTL.h.
Definition: GaudiHistoID.h:136