cprover
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 ()
 
 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 144 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 158 of file message.h.

Constructor & Destructor Documentation

◆ messaget() [1/3]

messaget::messaget ( )
inline

Definition at line 185 of file message.h.

◆ messaget() [2/3]

messaget::messaget ( const messaget other)
inline

Definition at line 191 of file message.h.

◆ messaget() [3/3]

messaget::messaget ( message_handlert _message_handler)
inlineexplicit

Definition at line 204 of file message.h.

◆ ~messaget()

messaget::~messaget ( )
virtual

Definition at line 67 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 324 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 132 of file message.cpp.

◆ debug()

mstreamt& messaget::debug ( ) const
inline

Definition at line 417 of file message.h.

◆ error()

mstreamt& messaget::error ( ) const
inline

Definition at line 387 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 98 of file message.cpp.

◆ get_message_handler()

message_handlert& messaget::get_message_handler ( )
inline

Definition at line 174 of file message.h.

◆ get_mstream()

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

Definition at line 381 of file message.h.

◆ operator=()

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

Definition at line 197 of file message.h.

◆ progress()

mstreamt& messaget::progress ( ) const
inline

Definition at line 412 of file message.h.

◆ result()

mstreamt& messaget::result ( ) const
inline

Definition at line 397 of file message.h.

◆ set_message_handler()

virtual void messaget::set_message_handler ( message_handlert _message_handler)
inlinevirtual

Definition at line 169 of file message.h.

◆ statistics()

mstreamt& messaget::statistics ( ) const
inline

Definition at line 407 of file message.h.

◆ status()

mstreamt& messaget::status ( ) const
inline

Definition at line 402 of file message.h.

◆ warning()

mstreamt& messaget::warning ( ) const
inline

Definition at line 392 of file message.h.

Friends And Related Function Documentation

◆ operator<< [1/2]

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

Definition at line 287 of file message.h.

◆ operator<< [2/2]

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

feed a command into an mstreamt

Definition at line 315 of file message.h.

Member Data Documentation

◆ blue

const messaget::commandt messaget::blue
static

render text with blue foreground color

Definition at line 343 of file message.h.

◆ bold

const messaget::commandt messaget::bold
static

render text with bold font

Definition at line 370 of file message.h.

◆ bright_blue

const messaget::commandt messaget::bright_blue
static

render text with bright blue foreground color

Definition at line 361 of file message.h.

◆ bright_cyan

const messaget::commandt messaget::bright_cyan
static

render text with bright cyan foreground color

Definition at line 367 of file message.h.

◆ bright_green

const messaget::commandt messaget::bright_green
static

render text with bright green foreground color

Definition at line 355 of file message.h.

◆ bright_magenta

const messaget::commandt messaget::bright_magenta
static

render text with bright magenta foreground color

Definition at line 364 of file message.h.

◆ bright_red

const messaget::commandt messaget::bright_red
static

render text with bright red foreground color

Definition at line 352 of file message.h.

◆ bright_yellow

const messaget::commandt messaget::bright_yellow
static

render text with bright yellow foreground color

Definition at line 358 of file message.h.

◆ cyan

const messaget::commandt messaget::cyan
static

render text with cyan foreground color

Definition at line 349 of file message.h.

◆ eom

messaget::eomt messaget::eom
static

Definition at line 285 of file message.h.

◆ faint

const messaget::commandt messaget::faint
static

render text with faint font

Definition at line 373 of file message.h.

◆ green

const messaget::commandt messaget::green
static

render text with green foreground color

Definition at line 337 of file message.h.

◆ italic

const messaget::commandt messaget::italic
static

render italic text

Definition at line 376 of file message.h.

◆ magenta

const messaget::commandt messaget::magenta
static

render text with magenta foreground color

Definition at line 346 of file message.h.

◆ message_handler

message_handlert* messaget::message_handler
protected

Definition at line 427 of file message.h.

◆ mstream

mstreamt messaget::mstream
mutableprotected

Definition at line 428 of file message.h.

◆ red

const messaget::commandt messaget::red
static

render text with red foreground color

Definition at line 334 of file message.h.

◆ reset

const messaget::commandt messaget::reset
static

return to default formatting, as defined by the terminal

Definition at line 331 of file message.h.

◆ underline

const messaget::commandt messaget::underline
static

render underlined text

Definition at line 379 of file message.h.

◆ yellow

const messaget::commandt messaget::yellow
static

render text with yellow foreground color

Definition at line 340 of file message.h.


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