Implementation of class Message.  
More...
#include <keyvalue/sys/message/MessageImpl.h>

| Public Member Functions | |
| MessageImpl () | |
| MessageImpl (unsigned int level) | |
| const string & | getPrefix () const | 
| Gets prefix associated this type of Message. | |
| logger::Colour | getColour () const | 
| Gets the colour associated this type of Message. | |
| unsigned int | getLevel () const | 
| Gets Message's level. | |
| string | getString () const | 
| Gets Message's text. | |
| template<typename DataType > | |
| Message & | operator& (const DataType &data) | 
| Appends data to the end of message. | |
| Static Protected Attributes | |
| static const Traits_ | traits_ [] | 
| Private Member Functions | |
| Message & | operator= (const MessageImpl &orig) | 
Implementation of class Message. 
This template class provides default implementations for Message methods and extends its interface.
In this template class, parameter unsigned int id serves to distinguish specialisations. Clients, rather than directly instantiate this template by providing id, will use provided typedefs for the following types of Messages:
| id | : ( templateparameter) Used to distinguish different specializations. | 
| MessageImpl | ( | ) |  [inline] | 
| const string& getPrefix | ( | ) | const  [virtual] | 
| logger::Colour getColour | ( | ) | const  [virtual] | 
| unsigned int getLevel | ( | ) | const  [inherited] | 
Gets Message's level.
| string getString | ( | ) | const  [inherited] | 
Gets Message's text.
| Message & operator& | ( | const DataType & | data | ) |  [inherited] | 
Appends data to the end of message.
This template method makes use of std::ostream::operator<<() to append data to this Message. Hence, the type of data DataType must be such that std::ostream::operator<<(ostream&, const DataType&) is well defined.
A typical use of this method is
Info info(1); // Info is derived from Message size_t i; vector<double> x; // ... info & "x[" & i & "] = " & x[i];
Warning: For some reason, one cannot append std::endl to Message, despite the fact that a standard ostream can accept it!
Remark: It would be more natural using operator<< rather than operator&. However, the main use of operator& is related to exceptions (see exception::ExceptionImpl documentation). Indeed, there exist ExceptionImpl::operator&() which just redirects its call to this operator& here. In the past, KeyValue exceptions were derived from boost::exception which defines operator<< for other purposes. Therefore, operator& was preferred rather than operator<< to avoid conflict with boost. Be aware that, in the near future, if it is proven convenient, one might change operator& to operator<< again.
| DataType | : ( templateparameter) Type of data; | |
| data | : the data to be appended. | 
 1.7.1
 1.7.1