The Gaudi Framework  v36r16 (ea80daf8)
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 <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
 

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

203 { return s.doOutput(); }

◆ format()

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

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

Definition at line 119 of file MsgStream.cpp.

119  {
120  const int buffsize = 2048;
121  static char buffer[buffsize];
122  va_list arguments;
123  va_start( arguments, fmt );
124  if ( vsnprintf( buffer, buffsize, fmt, arguments ) >= buffsize )
125  throw GaudiException( "Insufficient buffer size (" + std::to_string( buffsize ) + ") when formatting message",
126  "MsgStream", StatusCode::FAILURE );
127  va_end( arguments );
128  return std::string( buffer );
129 }

◆ operator<<() [1/3]

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

General templated stream operator.

Definition at line 300 of file MsgStream.h.

300  {
301  using namespace GaudiUtils;
302  if ( lhs.isActive() ) try {
303  // this may throw, and we cannot afford it if the stream is used in a catch block
304  lhs.stream() << arg;
305  } catch ( ... ) {}
306  return lhs;
307 }

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

290  {
291  try {
292  // this may throw, and we cannot afford it if the stream is used in a catch block
293  if ( s.isActive() ) s.stream() << arg;
294  } catch ( ... ) {}
295  return s;
296 }

◆ operator<<() [3/3]

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

I/O Manipulator for setfill.

Definition at line 268 of file MsgStream.h.

268  {
269  try {
270  // this may throw, and we cannot afford it if the stream is used in a catch block
271  if ( s.isActive() ) s.stream() << manip;
272  } catch ( ... ) {}
273  return s;
274 }
std::string
STL class.
gaudirun.s
string s
Definition: gaudirun.py:348
GaudiException
Definition: GaudiException.h:31
std::to_string
T to_string(T... args)
fmt
Definition: MessageSvcSink.cpp:25
std::vsnprintf
T vsnprintf(T... args)
va_list
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
GaudiUtils
Definition: GaudiHistoID.h:145
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:121
MsgStream::stream
std::ostringstream & stream()
Access string MsgStream.
Definition: MsgStream.h:104