as2js: as2js::Message Class Reference

#include <message.h>

Inheritance diagram for as2js::Message:
Collaboration diagram for as2js::Message:
Public Member Functions  Message (message_level_t message_level, err_code_t error_code, Position const &pos)  Create a message object with the specified information. More...
   Message (message_level_t message_level, err_code_t error_code)  Create a message object with the specified information. More...
   Message (Message const &rhs)=delete    ~Message ()  Output the message created with the << operators. More...
  template<typename T > Messageoperator<< (T const &data)   Messageoperator<< (char const *s)  Append an char string. More...
  Messageoperator<< (wchar_t const *s)  Append an wchar_t string. More...
  Messageoperator<< (std::string const &s)  Append an std::string value. More...
  Messageoperator<< (std::wstring const &s)  Append an std::wstring value. More...
  Messageoperator<< (String const &s)  Append a String value. More...
  Messageoperator<< (char const v)  Append a char value. More...
  Messageoperator<< (signed char const v)  Append a signed char value. More...
  Messageoperator<< (unsigned char const v)  Append a unsigned char value. More...
  Messageoperator<< (signed short const v)  Append a signed short value. More...
  Messageoperator<< (unsigned short const v)  Append a unsigned short value. More...
  Messageoperator<< (signed int const v)  Append a signed int value. More...
  Messageoperator<< (unsigned int const v)  Append a unsigned int value. More...
  Messageoperator<< (signed long const v)  Append a signed long value. More...
  Messageoperator<< (unsigned long const v)  Append a unsigned long value. More...
  Messageoperator<< (signed long long const v)  Append a signed long long value. More...
  Messageoperator<< (unsigned long long const v)  Append a unsigned long long value. More...
  Messageoperator<< (Int64 const v)  Append an Int64 value. More...
  Messageoperator<< (float const v)  Append a float value. More...
  Messageoperator<< (double const v)  Append a double value. More...
  Messageoperator<< (Float64 const v)  Append a Float64 value. More...
  Messageoperator<< (bool const v)  Append a Boolean value. More...
  Messageoperator= (Message const &rhs)=delete   Static Public Member Functions static int error_count ()  The number of errors that were found so far. More...
  static void set_message_callback (MessageCallback *callback)  Setup the callback so tools can receive error messages. More...
  static void set_message_level (message_level_t min_level)  Define the maximum level a message can be to be displayed. More...
  static int warning_count ()  The number of warnings that were found so far. More...
  Private Attributes err_code_t f_error_code = err_code_t::AS_ERR_NONE   message_level_t f_message_level = message_level_t::MESSAGE_LEVEL_OFF   Position f_position = Position()   Detailed Description

Definition at line 160 of file message.h.

Constructor & Destructor Documentation
as2js::Message::Message ( message_level_t  message_level, err_code_t  error_code, Position const &  pos  )

This function generates a message object that can be used to generate a message with the << operator and then gets sent to the client using the message callback function on destruction.

The level can be set to any one of the message levels available in the message_level_t enumeration. The special MESSAGE_LEVEL_OFF value can be used to avoid the message altogether (can be handy when you support a varying message level.)

Parameters
[in]message_levelThe level of the message. [in]error_codeAn error code to print in the output message. [in]posThe position to which the message applies.

Definition at line 65 of file message.cpp.

as2js::Message::Message ( message_level_t  message_level, err_code_t  error_code  )

This function is an overload of the default constructor that does not include the position information. This is used whenever we generate an error from outside of the node tree, parser, etc.

Parameters
[in]message_levelThe level of the message. [in]error_codeAn error code to print in the output message.

Definition at line 83 of file message.cpp.

as2js::Message::Message ( Message const &  rhs) delete
as2js::Message::~Message ( )

The destructor of the message object is where things happen. This function prints out the message that was built using the different << operators and the parameters specified in the constructor.

The result is then passed to the message callback. If you did not setup that function, the message is lost.

If the level of the message was set to MESSAGE_LEVEL_OFF (usualy via a command line option) then the message callback does not get called.

Definition at line 104 of file message.cpp.

References f_error_code, f_message_level, f_position, as2js::anonymous_namespace{message.cpp}::g_error_count, as2js::anonymous_namespace{message.cpp}::g_maximum_message_level, as2js::anonymous_namespace{message.cpp}::g_message_callback, as2js::anonymous_namespace{message.cpp}::g_warning_count, as2js::Position::get_filename(), as2js::Position::get_function(), as2js::MESSAGE_LEVEL_ERROR, as2js::MESSAGE_LEVEL_FATAL, as2js::MESSAGE_LEVEL_OFF, as2js::MESSAGE_LEVEL_WARNING, as2js::MessageCallback::output(), as2js::Position::set_filename(), and as2js::Position::set_function().

Member Function Documentation
int as2js::Message::error_count ( ) static

This function returns the number of errors and fatal errors that were processed so far.

Note that this number is a global counter and it cannot be reset.

Returns
The number of errors that were processed so far.

Definition at line 517 of file message.cpp.

References as2js::anonymous_namespace{message.cpp}::g_error_count.

Referenced by as2js::Compiler::compile(), as2js::Optimizer::optimize(), as2js::Compiler::program(), and as2js::Compiler::resolve_call().

template<typename T >
Message& as2js::Message::operator<< ( T const &  data) inline

Definition at line 171 of file message.h.

References as2js::operator<<().

Message & as2js::Message::operator<< ( char const *  s)

This function appends an char string to the message.

Parameters
[in]sA character string.
Returns
A reference to the message.

Definition at line 151 of file message.cpp.

Message & as2js::Message::operator<< ( wchar_t const *  s)

This function appends an wchar_t string to the message.

Parameters
[in]sA wchar_t string.
Returns
A reference to the message.

Definition at line 167 of file message.cpp.

References as2js::String::from_wchar().

Message & as2js::Message::operator<< ( std::string const &  s)

This function appends an std::string value to the message.

Parameters
[in]sAn std::string value.
Returns
A reference to the message.

Definition at line 184 of file message.cpp.

Message & as2js::Message::operator<< ( std::wstring const &  s)

This function appends an std::wstring value to the message.

Parameters
[in]sAn std::wstring value.
Returns
A reference to the message.

Definition at line 199 of file message.cpp.

References as2js::String::from_wchar().

Message & as2js::Message::operator<< ( String const &  s)

This function appends a String value to the message.

Parameters
[in]sA String value.
Returns
A reference to the message.

Definition at line 216 of file message.cpp.

References as2js::String::to_utf8().

Message & as2js::Message::operator<< ( char const  v)

This function appends a character to the message.

Parameters
[in]vA char value.
Returns
A reference to the message.

Definition at line 231 of file message.cpp.

Message & as2js::Message::operator<< ( signed char const  v)

This function appends a signed char value to the message.

Parameters
[in]vA signed char value.
Returns
A reference to the message.

Definition at line 246 of file message.cpp.

Message & as2js::Message::operator<< ( unsigned char const  v)

This function appends a unsigned char value to the message.

Parameters
[in]vA unsigned char value.
Returns
A reference to the message.

Definition at line 261 of file message.cpp.

Message & as2js::Message::operator<< ( signed short const  v)

This function appends a signed short value to the message.

Parameters
[in]vA signed short value.
Returns
A reference to the message.

Definition at line 276 of file message.cpp.

Message & as2js::Message::operator<< ( unsigned short const  v)

This function appends a unsigned short value to the message.

Parameters
[in]vA unsigned short value.
Returns
A reference to the message.

Definition at line 291 of file message.cpp.

Message & as2js::Message::operator<< ( signed int const  v)

This function appends a signed int value to the message.

Parameters
[in]vA signed int value.
Returns
A reference to the message.

Definition at line 306 of file message.cpp.

Message & as2js::Message::operator<< ( unsigned int const  v)

This function appends a unsigned int value to the message.

Parameters
[in]vA unsigned int value.
Returns
A reference to the message.

Definition at line 321 of file message.cpp.

Message & as2js::Message::operator<< ( signed long const  v)

This function appends a signed long value to the message.

Parameters
[in]vA signed long value.
Returns
A reference to the message.

Definition at line 336 of file message.cpp.

Message & as2js::Message::operator<< ( unsigned long const  v)

This function appends a unsigned long value to the message.

Parameters
[in]vA unsigned long value.
Returns
A reference to the message.

Definition at line 351 of file message.cpp.

Message & as2js::Message::operator<< ( signed long long const  v)

This function appends a signed long long value to the message.

Parameters
[in]vA signed long long value.
Returns
A reference to the message.

Definition at line 366 of file message.cpp.

Message & as2js::Message::operator<< ( unsigned long long const  v)

This function appends a unsigned long long value to the message.

Parameters
[in]vA unsigned long long value.
Returns
A reference to the message.

Definition at line 394 of file message.cpp.

Message & as2js::Message::operator<< ( Int64 const  v)

This function appends the value saved in an Int64 value.

Parameters
[in]vAn as2js::Int64 value.

Definition at line 379 of file message.cpp.

References as2js::Int64::get().

Message & as2js::Message::operator<< ( float const  v)

This function appends a float value to the message.

Parameters
[in]vA float value.
Returns
A reference to the message.

Definition at line 409 of file message.cpp.

Message & as2js::Message::operator<< ( double const  v)

This function appends a double value to the message.

Parameters
[in]vA double value.
Returns
A reference to the message.

Definition at line 424 of file message.cpp.

Message & as2js::Message::operator<< ( Float64 const  v)

This function appends the value saved in an Float64 value.

Parameters
[in]vAn as2js::Float64 value.

Definition at line 437 of file message.cpp.

References as2js::Float64::get().

Message & as2js::Message::operator<< ( bool const  v)

This function appends a Boolean value to the message as a 0 or a 1.

Parameters
[in]vA Boolean value.
Returns
A reference to the message.

Definition at line 452 of file message.cpp.

Message& as2js::Message::operator= ( Message const &  rhs) delete
void as2js::Message::set_message_callback ( MessageCallbackcallback) static

This function is used by external processes to setup a callback. The callback receives the message output as generated by the Message class.

See also
configure()

Definition at line 467 of file message.cpp.

References as2js::anonymous_namespace{message.cpp}::g_message_callback.

void as2js::Message::set_message_level ( message_level_t  max_level) static

This function is used to change the maximum level a message can be in order to be displayed. Messages with a larger level are completely ignored.

Note that errors and fatal errors cannot be ignored using this mechanism (i.e. the smallest possible value for max_level is MESSAGE_LEVEL_ERROR.)

Parameters
[in]max_levelThe maximum level a message can have.

Definition at line 485 of file message.cpp.

References as2js::anonymous_namespace{message.cpp}::g_maximum_message_level, and as2js::MESSAGE_LEVEL_ERROR.

int as2js::Message::warning_count ( ) static

This function returns the number of warnings that were processed so far.

Note that this number is a global counter and it cannot be reset.

Returns
The number of warnings that were processed so far.

Definition at line 502 of file message.cpp.

References as2js::anonymous_namespace{message.cpp}::g_warning_count.

Member Data Documentation
err_code_t as2js::Message::f_error_code = err_code_t::AS_ERR_NONE private

Definition at line 208 of file message.h.

Referenced by ~Message().

message_level_t as2js::Message::f_message_level = message_level_t::MESSAGE_LEVEL_OFF private

Definition at line 207 of file message.h.

Referenced by ~Message().

Position as2js::Message::f_position = Position() private

Definition at line 209 of file message.h.

Referenced by ~Message().


The documentation for this class was generated from the following files:
  • /home/snapwebsites/snapcpp/contrib/as2js/include/as2js/message.h
  • /home/snapwebsites/snapcpp/contrib/as2js/lib/message.cpp

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly