Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ers::HumanStream Class Reference

Single line, human readable format stream. More...

#include <HumanStream.h>

Inheritance diagram for ers::HumanStream:

ers::Stream ers::Stream List of all members.

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 Issuereceive ()
 Receives an issue from the stream.
virtual Issuereceive ()
 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

Detailed Description

Single line, human readable format 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.

Author:
Matthias Wiesmann
Version:
1.0


Constructor & Destructor Documentation

ers::HumanStream::HumanStream  ) 
 

00047 : ers::Stream() {} // HumanStream

ers::HumanStream::HumanStream const HumanStream other  ) 
 

00048 : ers::Stream(other) {} 

ers::HumanStream::~HumanStream  ) 
 

00049 {} 

ers::HumanStream::HumanStream  ) 
 

ers::HumanStream::HumanStream const HumanStream other  ) 
 

ers::HumanStream::~HumanStream  ) 
 


Member Function Documentation

void ers::HumanStream::clear  ) 
 

void ers::HumanStream::clear  ) 
 

Clears the content of the stream

00061                            {
00062     m_out_stream.str(""); 
00063 } // clear

ers::Stream::operator std::string  )  const [inherited]
 

ers::Stream::operator std::string  )  const [inherited]
 

00035                                     {
00036     std::ostringstream stream ; 
00037     print_to(stream); 
00038     return stream.str(); 
00039 } // to string 

virtual void ers::HumanStream::print_to std::ostream stream  )  const [virtual]
 

Reimplemented from ers::Stream.

void ers::HumanStream::print_to std::ostream stream  )  const [virtual]
 

Reimplemented from ers::Stream.

00065                                                       {
00066     stream << ers::HumanStream::KEY << ':' ; 
00067 } // print_to

virtual Issue* ers::Stream::receive  )  [virtual, inherited]
 

Receives an issue from the stream.

Reimplemented in ers::FIFOStream, and ers::FIFOStream.

ers::Issue * ers::Stream::receive  )  [virtual, inherited]
 

Receives an issue from the stream.

Reads an isssue on the stream

Returns:
the issue that has been read
Note:
This implementation always returns a null pointer

Reimplemented in ers::FIFOStream, and ers::FIFOStream.

00055                              {
00056     return 0 ; 
00057 } // receive

virtual void ers::HumanStream::send const Issue ptr  )  [virtual]
 

Sends an issue into the stream.

Sends the issue to the stream.

Parameters:
i the issue to send
Note:
This implementation silently discards the Issue

Reimplemented from ers::Stream.

void ers::HumanStream::send const Issue issue_ptr  )  [virtual]
 

Sends an issue into the stream.

Sends the issue to the stream.

Parameters:
i the issue to send
Note:
This implementation silently discards the Issue

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

std::string ers::HumanStream::to_string  ) 
 

std::string ers::HumanStream::to_string const Issue issue  )  throw () [static]
 

std::string ers::HumanStream::to_string  ) 
 

Returns:
the content of the stream as a string
00054                                     { 
00055      return m_out_stream.str(); 
00056 } // to_string

std::string ers::HumanStream::to_string const Issue issue_ptr  )  throw () [static]
 

Dumps the content of an issue into a string This class is used internally by the Issue class to produce then description field.

Parameters:
issue_ptr the Issue to serialise
Returns:
string description
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


Member Data Documentation

const char* const ers::HumanStream::KEY [static]
 

const char *const ers::HumanStream::KEY = "human" [static]
 

std::ostringstream ers::HumanStream::m_out_stream [protected]
 

const char* const ers::Stream::NULL_STREAM_KEY [static, inherited]
 

Key for discard stream

const char *const ers::Stream::NULL_STREAM_KEY = "null" [static, inherited]
 

Key for discard stream


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:19:38 2011 for BOSS6.5.5 by  doxygen 1.3.9.1