Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends

ts::Errata Class Reference

Class to hold a stack of error messages (the "errata"). More...

#include <Errata.h>

Collaboration diagram for ts::Errata:
Collaboration graph
[legend]

Data Structures

class  const_iterator
 Forward constant iterator for Messages in an Errata. More...
struct  Data
 This is the implementation class for Errata. More...
class  iterator
 Forward iterator for Messages in an Errata. More...
struct  Message
 Storage for a single message. More...
class  Sink
 Base class for erratum sink. More...
struct  SinkFunctionWrapper

Public Types

typedef Errata self
typedef NumericType< unsigned
int, struct MsgIdTag > 
Id
 Self reference type.
typedef NumericType< unsigned
int, struct CodeTag > 
Code
typedef std::deque< MessageContainer
 Storage type for messages.
typedef void(* SinkHandlerFunction )(Errata const &)
 Register a function as a sink.

Public Member Functions

 Errata ()
 Message const iteration.
 Errata (self const &that)
 Copy constructor, very fast.
 Errata (std::string const &text)
 Construct from string.
 Errata (Id id, std::string const &text)
 Construct with id and text.
 Errata (Id id, Code code, std::string const &text)
 Construct with id, code, and text.
 Errata (Message const &msg)
 Construct from a message instance.
 ~Errata ()
 destructor
selfoperator= (const self &that)
 Self assignment.
selfoperator= (Message const &msg)
 Assign message.
selfpush (std::string const &text)
 Push text as a message.
selfpush (Id id, std::string const &text)
 Push text as a message with message id.
selfpush (Id id, Code code, std::string const &text)
 Push text as a message with message id and code.
selfpush (Message const &msg)
 Push a message.
selfpush (self const &err)
 Push a nested status.
Message const & top () const
 Access top message.
selfpull (self &that)
 Move messages from that to this errata.
void pop ()
 Remove last message.
void clear ()
 Remove all messages.
selfdoNotLog ()
 Inhibit logging.
 operator bool () const
 Test status.
bool isOK () const
 Test errata for no failure condition.
size_t size () const
 Number of messages in the errata.
iterator begin ()
 Reference to top item on the stack.
const_iterator begin () const
 Reference to top item on the stack.
iterator end ()
 Reference one past bottom item on the stack.
const_iterator end () const
 Reference one past bottom item on the stack.
std::ostream & write (std::ostream &out, int offset, int indent, int shift, char const *lead) const
 Simple formatted output.
size_t write (char *buffer, size_t n, int offset, int indent, int shift, char const *lead) const
 Simple formatted output to fixed sized buffer.

Static Public Member Functions

static void registerSink (Sink::Handle const &s)
 Register a sink for discarded erratum.
static void registerSink (SinkHandlerFunction f)
 Register a sink function for abandonded erratum.

Static Public Attributes

static std::string const DEFAULT_GLUE
 Default glue value (a newline) for text rendering.

Protected Types

typedef IntrusivePtr< DataImpPtr
 Handle for implementation class instance.

Protected Member Functions

 Errata (ImpPtr const &ptr)
 Construct from implementation pointer.
Datapre_write ()
 Return the implementation instance, allocating and unsharing as needed.
Datainstance ()
 Force and return an implementation instance.

Protected Attributes

ImpPtr m_data
 Implementation instance.

Static Protected Attributes

static Message const NIL_MESSAGE
 Used for returns when no data is present.

Friends

struct Data
class Item
std::ostream & operator<< (std::ostream &, self const &)

Detailed Description

Class to hold a stack of error messages (the "errata").

This is a smart handle class, which wraps the actual data and can therefore be treated a value type with cheap copy semantics. Default construction is very cheap.

Definition at line 87 of file Errata.h.


Member Typedef Documentation

typedef NumericType<unsigned int, struct CodeTag> ts::Errata::Code

Definition at line 105 of file Errata.h.

typedef std::deque<Message> ts::Errata::Container

Storage type for messages.

Definition at line 106 of file Errata.h.

typedef NumericType<unsigned int, struct MsgIdTag> ts::Errata::Id

Self reference type.

Message ID.

Definition at line 97 of file Errata.h.

typedef IntrusivePtr<Data> ts::Errata::ImpPtr [protected]

Handle for implementation class instance.

Definition at line 90 of file Errata.h.

Definition at line 94 of file Errata.h.

typedef void(* ts::Errata::SinkHandlerFunction)(Errata const &)

Register a function as a sink.

Definition at line 294 of file Errata.h.


Constructor & Destructor Documentation

ts::Errata::Errata (  ) 

Message const iteration.

Reverse message iteration. Reverse constant message iteration. Default constructor - empty errata, very fast.

Definition at line 73 of file Errata.cc.

ts::Errata::Errata ( self const &  that  ) 

Copy constructor, very fast.

Parameters:
that Object to copy

Definition at line 76 of file Errata.cc.

ts::Errata::Errata ( std::string const &  text  )  [explicit]

Construct from string.

Message Id and Code are default.

Parameters:
text Finalized message text.

Definition at line 80 of file Errata.cc.

ts::Errata::Errata ( Id  id,
std::string const &  text 
)

Construct with id and text.

Code is default.

Parameters:
id Message id.
text Message text.

Definition at line 84 of file Errata.cc.

ts::Errata::Errata ( Id  id,
Code  code,
std::string const &  text 
) [inline]

Construct with id, code, and text.

Parameters:
id Message text.
code Message code.
text Message text.

Definition at line 836 of file Errata.h.

References push().

ts::Errata::Errata ( Message const &  msg  )  [inline]

Construct from a message instance.

This is equivalent to default constructing an errata and then invoking push with an argument of msg.

Parameters:
msg Message to push

Definition at line 839 of file Errata.h.

References push().

ts::Errata::~Errata (  ) 

destructor

Definition at line 88 of file Errata.cc.

ts::Errata::Errata ( ImpPtr const &  ptr  )  [inline, protected]

Construct from implementation pointer.

Used internally by nested classes.

Definition at line 55 of file Errata.cc.

References NIL_MESSAGE.


Member Function Documentation

Errata::iterator ts::Errata::begin (  ) 

Reference to top item on the stack.

Definition at line 179 of file Errata.cc.

Errata::const_iterator ts::Errata::begin (  )  const

Reference to top item on the stack.

Definition at line 184 of file Errata.cc.

References m_data, and ts::NIL_CONTAINER.

void ts::Errata::clear ( void   ) 

Remove all messages.

Definition at line 162 of file Errata.cc.

Referenced by ts::config::Builder::build(), ts::RvBase::clear(), and ts::Errata::Message::clear().

Errata & ts::Errata::doNotLog (  )  [inline]

Inhibit logging.

Note:
This only affects this as a top level errata. It has no effect on this this being logged as a nested errata.

Definition at line 878 of file Errata.h.

References instance(), and ts::Errata::Data::m_log_on_delete.

Referenced by ts::RvBase::doNotLog(), and ts::Errata::Message::set().

Errata::iterator ts::Errata::end (  ) 

Reference one past bottom item on the stack.

Definition at line 190 of file Errata.cc.

References m_data, and ts::NIL_CONTAINER.

Errata::const_iterator ts::Errata::end (  )  const

Reference one past bottom item on the stack.

Definition at line 195 of file Errata.cc.

References m_data, and ts::NIL_CONTAINER.

Errata::Data * ts::Errata::instance (  )  [protected]

Force and return an implementation instance.

Does not follow copy on write.

Definition at line 109 of file Errata.cc.

Referenced by doNotLog().

bool ts::Errata::isOK (  )  const [inline]

Test errata for no failure condition.

Equivalent to operator bool but easier to invoke.

Returns:
true if no messages or last message has a zero message ID, false otherwise.

Definition at line 849 of file Errata.h.

References m_data, ts::Errata::Message::Success_Test, and top().

Referenced by operator bool().

ts::Errata::operator bool (  )  const [inline]

Test status.

Equivalent to success but more convenient for use in control statements.

Returns:
true if no messages or last message has a zero message ID, false otherwise.

Definition at line 843 of file Errata.h.

References isOK().

Errata & ts::Errata::operator= ( const self that  ) 

Self assignment.

Returns:
A reference to this object.
Parameters:
that Source instance.

Definition at line 121 of file Errata.cc.

References pre_write(), and ts::Errata::Data::push().

Errata & ts::Errata::operator= ( Message const &  msg  ) 

Assign message.

All other messages are discarded.

Returns:
A reference to this object.
Parameters:
msg Source message.

Definition at line 127 of file Errata.cc.

References m_data.

void ts::Errata::pop (  ) 

Remove last message.

Definition at line 154 of file Errata.cc.

Errata::Data * ts::Errata::pre_write (  )  [protected]

Return the implementation instance, allocating and unsharing as needed.

Definition at line 96 of file Errata.cc.

References Data, m_data, and ts::IntrusivePtr< T >::useCount().

Referenced by operator=().

Errata & ts::Errata::pull ( self that  ) 

Move messages from that to this errata.

Messages from that are put on the top of the stack in this and removed from that.

Definition at line 140 of file Errata.cc.

Referenced by ts::config::Builder::literalValue().

Errata & ts::Errata::push ( Id  id,
std::string const &  text 
) [inline]

Push text as a message with message id.

The message is constructed from text and id. It becomes the top message.

Returns:
A reference to this object.

Definition at line 863 of file Errata.h.

References push().

Errata & ts::Errata::push ( Id  id,
Code  code,
std::string const &  text 
) [inline]

Push text as a message with message id and code.

The message is constructed from text and id. It becomes the top message.

Returns:
A reference to this object.

Definition at line 869 of file Errata.h.

References push().

Errata & ts::Errata::push ( Message const &  msg  ) 

Push a message.

msg becomes the top message.

Returns:
A reference to this object.

Definition at line 115 of file Errata.cc.

References ts::IntrusivePtr< T >::get(), and m_data.

Errata & ts::Errata::push ( std::string const &  text  )  [inline]

Push text as a message.

The message is constructed from just the text. It becomes the top message.

Returns:
A reference to this object.

Definition at line 857 of file Errata.h.

Referenced by Errata(), ts::Rv< R >::push(), push(), ts::msg::vlogf(), and ts::msg::vlogf_errno().

self& ts::Errata::push ( self const &  err  ) 

Push a nested status.

err becomes the top item.

Returns:
A reference to this object.
static void ts::Errata::registerSink ( SinkHandlerFunction  f  )  [inline, static]

Register a sink function for abandonded erratum.

Definition at line 306 of file Errata.h.

References registerSink().

void ts::Errata::registerSink ( Sink::Handle const &  s  )  [static]

Register a sink for discarded erratum.

Definition at line 201 of file Errata.cc.

References m_data, and ts::NIL_CONTAINER.

Referenced by registerSink().

size_t ts::Errata::size ( void   )  const [inline]

Number of messages in the errata.

Definition at line 845 of file Errata.h.

References m_data.

Errata::Message const & ts::Errata::top (  )  const [inline]

Access top message.

Returns:
If the errata is empty, a default constructed message otherwise the most recent message.

Definition at line 875 of file Errata.h.

References m_data, and NIL_MESSAGE.

Referenced by isOK().

size_t ts::Errata::write ( char *  buffer,
size_t  n,
int  offset,
int  indent,
int  shift,
char const *  lead 
) const

Simple formatted output to fixed sized buffer.

Returns:
Number of characters written to buffer.
Parameters:
buffer Output buffer.
n Buffer size.
offset Lead white space for every line.
indent Additional indention per line for messages.
shift Additional indent for nested Errata.
lead Leading text for nested Errata.

Definition at line 232 of file Errata.cc.

std::ostream & ts::Errata::write ( std::ostream &  out,
int  offset,
int  indent,
int  shift,
char const *  lead 
) const

Simple formatted output.

Each message is written to a line. All lines are indented with whitespace offset characters. Lines are indented an additional indent. This value is increased by shift for each level of nesting of an Errata. if lead is not NULL the indentation is overwritten by lead if indent is non-zero. It acts as a "continuation" marker for nested Errata.

Parameters:
out Output stream.
offset Lead white space for every line.
indent Additional indention per line for messages.
shift Additional indent for nested Errata.
lead Leading text for nested Errata.

Definition at line 206 of file Errata.cc.


Friends And Related Function Documentation

friend struct Data [friend]

Definition at line 419 of file Errata.h.

Referenced by pre_write().

friend class Item [friend]

Definition at line 420 of file Errata.h.

std::ostream& operator<< ( std::ostream &  ,
self const &   
) [friend]

Field Documentation

std::string const ts::Errata::DEFAULT_GLUE [static]

Default glue value (a newline) for text rendering.

Definition at line 224 of file Errata.h.

Implementation instance.

Definition at line 408 of file Errata.h.

Referenced by begin(), end(), isOK(), operator=(), pre_write(), push(), registerSink(), size(), and top().

Errata::Message const ts::Errata::NIL_MESSAGE [static, protected]

Used for returns when no data is present.

Definition at line 417 of file Errata.h.

Referenced by Errata(), and top().


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