Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JLOGGER::JMessageStream Class Reference

Message streamer. More...

#include <JMessageStream.hh>

Inheritance diagram for JLOGGER::JMessageStream:
JLOGGER::JDebugStream JLOGGER::JErrorStream JLOGGER::JNoticeStream JLOGGER::JStatusStream JLOGGER::JWarningStream

Public Types

typedef std::ostream &(* io_manip) (std::ostream &)
 Type definition of I/O operator. More...
 

Public Member Functions

template<class T >
JMessageStreamoperator<< (const T &value)
 Appends value to internal buffer. More...
 
JMessageStreamoperator<< (io_manip manip)
 Append I/O manipulator. More...
 

Protected Member Functions

 JMessageStream (JMessageLogger &__logger, void(JMessageLogger::*__typeout)(const std::string &))
 Constructor. More...
 
 ~JMessageStream ()
 Report message. More...
 

Protected Attributes

JMessageLoggerlogger
 
void(JMessageLogger::* typeout )(const std::string &)
 

Detailed Description

Message streamer.

This class can be used in the same way as the STL ostream operator.
The actual message is reported on detruction of the object, e.g:

JStreamLogger logger(std::cout);

JDebugStream (logger) << "This is a debug message " << hex << 15;

will produce on the terminal:

"... This is a debug message f"

where ... stands for the message prefix (see class JMessageLogger). The list of available message streamer classes includes:

Definition at line 43 of file JMessageStream.hh.

Member Typedef Documentation

◆ io_manip

typedef std::ostream&(* JLOGGER::JMessageStream::io_manip) (std::ostream &)

Type definition of I/O operator.

Definition at line 65 of file JMessageStream.hh.

Constructor & Destructor Documentation

◆ JMessageStream()

JLOGGER::JMessageStream::JMessageStream ( JMessageLogger __logger,
void(JMessageLogger::*)(const std::string &)  __typeout 
)
inlineprotected

Constructor.

Parameters
__loggermessage logger
__typeoutlogger method

Definition at line 88 of file JMessageStream.hh.

89  :
90  std::ostringstream(),
91  logger (__logger),
92  typeout(__typeout)
93  {}
JMessageLogger & logger
void(JMessageLogger::* typeout)(const std::string &)

◆ ~JMessageStream()

JLOGGER::JMessageStream::~JMessageStream ( )
inlineprotected

Report message.

Definition at line 99 of file JMessageStream.hh.

100  {
101  (logger.*typeout)(this->str());
102  }

Member Function Documentation

◆ operator<<() [1/2]

template<class T >
JMessageStream& JLOGGER::JMessageStream::operator<< ( const T &  value)
inline

Appends value to internal buffer.

Parameters
valuevalue
Returns
this JMessageStream

Definition at line 54 of file JMessageStream.hh.

55  {
56  static_cast<std::ostringstream&>(*this) << value;
57 
58  return *this;
59  }

◆ operator<<() [2/2]

JMessageStream& JLOGGER::JMessageStream::operator<< ( io_manip  manip)
inline

Append I/O manipulator.

Parameters
manipI/O manipulator
Returns
this JMessageStream

Definition at line 74 of file JMessageStream.hh.

75  {
76  static_cast<std::ostringstream&>(*this) << manip;
77 
78  return *this;
79  }

Member Data Documentation

◆ logger

JMessageLogger& JLOGGER::JMessageStream::logger
protected

Definition at line 105 of file JMessageStream.hh.

◆ typeout

void(JMessageLogger::* JLOGGER::JMessageStream::typeout) (const std::string &)
protected

Definition at line 106 of file JMessageStream.hh.


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