Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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.
 

Public Member Functions

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

Protected Member Functions

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

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

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::* __typeout )(const std::string &) )
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 {}
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: