CBMC
messaget Class Reference

Class that provides messages with a built-in verbosity 'level'. More...

#include <message.h>

+ Inheritance diagram for messaget:
+ Collaboration diagram for messaget:

Classes

class  commandt
 
class  eomt
 
class  mstreamt
 

Public Types

enum  message_levelt {
  M_ERROR =1 , M_WARNING =2 , M_RESULT =4 , M_STATUS =6 ,
  M_STATISTICS =8 , M_PROGRESS =9 , M_DEBUG =10
}
 

Public Member Functions

virtual void set_message_handler (message_handlert &_message_handler)
 
message_handlertget_message_handler ()
 
 messaget (const messaget &other)
 
messagetoperator= (const messaget &other)
 
 messaget (message_handlert &_message_handler)
 
virtual ~messaget ()
 
mstreamtget_mstream (unsigned message_level) const
 
mstreamterror () const
 
mstreamtwarning () const
 
mstreamtresult () const
 
mstreamtstatus () const
 
mstreamtstatistics () const
 
mstreamtprogress () const
 
mstreamtdebug () const
 
void conditional_output (mstreamt &mstream, const std::function< void(mstreamt &)> &output_generator) const
 Generate output to message_stream using output_generator if the configured verbosity is at least as high as that of message_stream. More...
 

Static Public Member Functions

static unsigned eval_verbosity (const std::string &user_input, const message_levelt default_verbosity, message_handlert &dest)
 Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest. More...
 
static commandt command (unsigned c)
 Create an ECMA-48 SGR (Select Graphic Rendition) command. More...
 

Static Public Attributes

static eomt eom
 
static const commandt reset
 return to default formatting, as defined by the terminal More...
 
static const commandt red
 render text with red foreground color More...
 
static const commandt green
 render text with green foreground color More...
 
static const commandt yellow
 render text with yellow foreground color More...
 
static const commandt blue
 render text with blue foreground color More...
 
static const commandt magenta
 render text with magenta foreground color More...
 
static const commandt cyan
 render text with cyan foreground color More...
 
static const commandt bright_red
 render text with bright red foreground color More...
 
static const commandt bright_green
 render text with bright green foreground color More...
 
static const commandt bright_yellow
 render text with bright yellow foreground color More...
 
static const commandt bright_blue
 render text with bright blue foreground color More...
 
static const commandt bright_magenta
 render text with bright magenta foreground color More...
 
static const commandt bright_cyan
 render text with bright cyan foreground color More...
 
static const commandt bold
 render text with bold font More...
 
static const commandt faint
 render text with faint font More...
 
static const commandt italic
 render italic text More...
 
static const commandt underline
 render underlined text More...
 

Protected Attributes

message_handlertmessage_handler
 
mstreamt mstream
 

Friends

mstreamtoperator<< (mstreamt &m, eomt)
 
mstreamtoperator<< (mstreamt &m, const commandt &c)
 feed a command into an mstreamt More...
 

Detailed Description

Class that provides messages with a built-in verbosity 'level'.

These messages are then processed by a subclass of message_handlert - which filters out all messages above a set verbosity level. By default the verbosity filtering level is set to the maximum level (10) - all messages printed (level 10 messages are debug information). Common practice is to inherit from the messaget class, to provide local infrastructure for messaging, by calling one of the utility methods, e.g. debug(), warning() etc. - which return a reference to a new instance of mstreamt set with the appropriate level. Individual messages are stored in mstreamt - an ostringstream subtype. eomt is used to flush the internal string of mstreamt. A static member eom, of eomt type is provided.

Definition at line 153 of file message.h.

Member Enumeration Documentation

◆ message_levelt

Enumerator
M_ERROR 
M_WARNING 
M_RESULT 
M_STATUS 
M_STATISTICS 
M_PROGRESS 
M_DEBUG 

Definition at line 167 of file message.h.

Constructor & Destructor Documentation

◆ messaget() [1/2]

messaget::messaget ( const messaget other)
inline

Definition at line 193 of file message.h.

◆ messaget() [2/2]

messaget::messaget ( message_handlert _message_handler)
inlineexplicit

Definition at line 206 of file message.h.

◆ ~messaget()

messaget::~messaget ( )
virtual

Definition at line 74 of file message.cpp.

Member Function Documentation

◆ command()

static commandt messaget::command ( unsigned  c)
inlinestatic

Create an ECMA-48 SGR (Select Graphic Rendition) command.

Definition at line 328 of file message.h.

◆ conditional_output()

void messaget::conditional_output ( mstreamt message_stream,
const std::function< void(mstreamt &)> &  output_generator 
) const

Generate output to message_stream using output_generator if the configured verbosity is at least as high as that of message_stream.

Use whenever generating output involves additional computational effort that should only be spent when such output will actually be displayed.

Parameters
message_streamOutput message stream
output_generatorFunction generating output

Definition at line 139 of file message.cpp.

◆ debug()

mstreamt& messaget::debug ( ) const
inline

Definition at line 421 of file message.h.

◆ error()

mstreamt& messaget::error ( ) const
inline

Definition at line 391 of file message.h.

◆ eval_verbosity()

unsigned messaget::eval_verbosity ( const std::string &  user_input,
const message_levelt  default_verbosity,
message_handlert dest 
)
static

Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest.

Parameters
user_inputInput string; if empty, the default verbosity is used.
default_verbosityVerbosity to use if no value is provided.
destmessage handler the verbosity of which is to be set.
Returns
Computed verbosity

Definition at line 105 of file message.cpp.

◆ get_message_handler()

message_handlert& messaget::get_message_handler ( )
inline

Definition at line 183 of file message.h.

◆ get_mstream()

mstreamt& messaget::get_mstream ( unsigned  message_level) const
inline

Definition at line 385 of file message.h.

◆ operator=()

messaget& messaget::operator= ( const messaget other)
inline

Definition at line 199 of file message.h.

◆ progress()

mstreamt& messaget::progress ( ) const
inline

Definition at line 416 of file message.h.

◆ result()

mstreamt& messaget::result ( ) const
inline

Definition at line 401 of file message.h.

◆ set_message_handler()

virtual void messaget::set_message_handler ( message_handlert _message_handler)
inlinevirtual

Definition at line 178 of file message.h.

◆ statistics()

mstreamt& messaget::statistics ( ) const
inline

Definition at line 411 of file message.h.

◆ status()

mstreamt& messaget::status ( ) const
inline

Definition at line 406 of file message.h.

◆ warning()

mstreamt& messaget::warning ( ) const
inline

Definition at line 396 of file message.h.

Friends And Related Function Documentation

◆ operator<< [1/2]

mstreamt& operator<< ( mstreamt m,
const commandt c 
)
friend

feed a command into an mstreamt

Definition at line 319 of file message.h.

◆ operator<< [2/2]

mstreamt& operator<< ( mstreamt m,
eomt   
)
friend

Definition at line 291 of file message.h.

Member Data Documentation

◆ blue

const messaget::commandt messaget::blue
static

render text with blue foreground color

Definition at line 347 of file message.h.

◆ bold

const messaget::commandt messaget::bold
static

render text with bold font

Definition at line 374 of file message.h.

◆ bright_blue

const messaget::commandt messaget::bright_blue
static

render text with bright blue foreground color

Definition at line 365 of file message.h.

◆ bright_cyan

const messaget::commandt messaget::bright_cyan
static

render text with bright cyan foreground color

Definition at line 371 of file message.h.

◆ bright_green

const messaget::commandt messaget::bright_green
static

render text with bright green foreground color

Definition at line 359 of file message.h.

◆ bright_magenta

const messaget::commandt messaget::bright_magenta
static

render text with bright magenta foreground color

Definition at line 368 of file message.h.

◆ bright_red

const messaget::commandt messaget::bright_red
static

render text with bright red foreground color

Definition at line 356 of file message.h.

◆ bright_yellow

const messaget::commandt messaget::bright_yellow
static

render text with bright yellow foreground color

Definition at line 362 of file message.h.

◆ cyan

const messaget::commandt messaget::cyan
static

render text with cyan foreground color

Definition at line 353 of file message.h.

◆ eom

messaget::eomt messaget::eom
static

Definition at line 289 of file message.h.

◆ faint

const messaget::commandt messaget::faint
static

render text with faint font

Definition at line 377 of file message.h.

◆ green

const messaget::commandt messaget::green
static

render text with green foreground color

Definition at line 341 of file message.h.

◆ italic

const messaget::commandt messaget::italic
static

render italic text

Definition at line 380 of file message.h.

◆ magenta

const messaget::commandt messaget::magenta
static

render text with magenta foreground color

Definition at line 350 of file message.h.

◆ message_handler

message_handlert* messaget::message_handler
protected

Definition at line 431 of file message.h.

◆ mstream

mstreamt messaget::mstream
mutableprotected

Definition at line 432 of file message.h.

◆ red

const messaget::commandt messaget::red
static

render text with red foreground color

Definition at line 338 of file message.h.

◆ reset

const messaget::commandt messaget::reset
static

return to default formatting, as defined by the terminal

Definition at line 335 of file message.h.

◆ underline

const messaget::commandt messaget::underline
static

render underlined text

Definition at line 383 of file message.h.

◆ yellow

const messaget::commandt messaget::yellow
static

render text with yellow foreground color

Definition at line 344 of file message.h.


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