#include <HumanStream.h>
Inheritance diagram for ers::HumanStream:
Public Member Functions | |
void | clear () |
void | clear () |
HumanStream (const HumanStream &other) | |
HumanStream () | |
HumanStream (const HumanStream &other) | |
HumanStream () | |
operator std::string () const | |
operator std::string () const | |
virtual void | print_to (std::ostream &stream) const |
virtual void | print_to (std::ostream &stream) const |
virtual Issue * | receive () |
Receives an issue from the stream. | |
virtual Issue * | receive () |
Receives an issue from the stream. | |
virtual void | send (const Issue *ptr) |
Sends an issue into the stream. | |
virtual void | send (const Issue *ptr) |
Sends an issue into the stream. | |
std::string | to_string () |
std::string | to_string () |
~HumanStream () | |
~HumanStream () | |
Static Public Member Functions | |
std::string | to_string (const Issue *issue) throw () |
std::string | to_string (const Issue *issue) throw () |
Static Public Attributes | |
const char *const | KEY |
const char *const | KEY = "human" |
const char *const | NULL_STREAM_KEY |
const char *const | NULL_STREAM_KEY = "null" |
Protected Attributes | |
std::ostringstream | m_out_stream |
This class streams an issue into an human readable string. It is uses by the issue class to display itself. This stream can be specified for other uses, but the user is then responsible for reading data from the stream and clearing it.
|
00047 : ers::Stream() {} // HumanStream
|
|
00048 : ers::Stream(other) {}
|
|
00049 {}
|
|
|
|
|
|
|
|
|
|
Clears the content of the stream 00061 { 00062 m_out_stream.str(""); 00063 } // clear
|
|
|
|
00035 { 00036 std::ostringstream stream ; 00037 print_to(stream); 00038 return stream.str(); 00039 } // to string
|
|
Reimplemented from ers::Stream. |
|
Reimplemented from ers::Stream. 00065 { 00066 stream << ers::HumanStream::KEY << ':' ; 00067 } // print_to
|
|
Receives an issue from the stream.
Reimplemented in ers::FIFOStream, and ers::FIFOStream. |
|
Receives an issue from the stream. Reads an isssue on the stream
Reimplemented in ers::FIFOStream, and ers::FIFOStream. 00055 { 00056 return 0 ; 00057 } // receive
|
|
Sends an issue into the stream. Sends the issue to the stream.
Reimplemented from ers::Stream. |
|
Sends an issue into the stream. Sends the issue to the stream.
Reimplemented from ers::Stream. 00069 { 00070 ERS_PRE_CHECK_PTR(issue_ptr); 00071 if (m_out_stream) { 00072 try { 00073 const string_map_type *table = issue_ptr->get_value_table(); 00074 const std::string message_str = issue_ptr->get_value(Issue::MESSAGE_KEY) ; 00075 const std::string severity_str = issue_ptr->get_value(Issue::SEVERITY_KEY) ; 00076 m_out_stream << "issue: " << message_str << "(" << severity_str << ")[" ; 00077 bool first = true ; 00078 for(string_map_type::const_iterator pos = table->begin();pos!=table->end();++pos) { 00079 const std::string &key = pos->first ; 00080 const std::string &value = pos->second ; 00081 if (first) { 00082 first = false ; 00083 } else { 00084 m_out_stream << ", " ; 00085 } // first or not 00086 m_out_stream << key << "=\"" << value << '\"'; 00087 } // for 00088 m_out_stream << "]" ; 00089 } catch (std::ios_base::failure &ex) { 00090 throw ers::Issue(ERS_HERE,ers::error,&ex); 00091 } // catch generic I/O errors 00092 } // if m_out_stream 00093 } // send
|
|
|
|
|
|
00054 { 00055 return m_out_stream.str(); 00056 } // to_string
|
|
Dumps the content of an issue into a string This class is used internally by the Issue class to produce then description field.
00035 { 00036 try { 00037 HumanStream ers_stream ; 00038 ers_stream.send(issue_ptr) ; 00039 std::string str = ers_stream.to_string(); 00040 return str ; 00041 } catch (std::exception &ex) { 00042 std::string msg = "error while building message " + std::string(ex.what()) ; 00043 return msg; 00044 } // 00045 } // to_string
|
|
|
|
|
|
|
|
Key for discard stream |
|
Key for discard stream |