Class to hold a stack of error messages (the "errata"). More...
#include <Errata.h>
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< Message > | Container |
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 | |
self & | operator= (const self &that) |
Self assignment. | |
self & | operator= (Message const &msg) |
Assign message. | |
self & | push (std::string const &text) |
Push text as a message. | |
self & | push (Id id, std::string const &text) |
Push text as a message with message id. | |
self & | push (Id id, Code code, std::string const &text) |
Push text as a message with message id and code. | |
self & | push (Message const &msg) |
Push a message. | |
self & | push (self const &err) |
Push a nested status. | |
Message const & | top () const |
Access top message. | |
self & | pull (self &that) |
Move messages from that to this errata. | |
void | pop () |
Remove last message. | |
void | clear () |
Remove all messages. | |
self & | doNotLog () |
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< Data > | ImpPtr |
Handle for implementation class instance. | |
Protected Member Functions | |
Errata (ImpPtr const &ptr) | |
Construct from implementation pointer. | |
Data * | pre_write () |
Return the implementation instance, allocating and unsharing as needed. | |
Data * | instance () |
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 &) |
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.
typedef NumericType<unsigned int, struct CodeTag> ts::Errata::Code |
typedef std::deque<Message> ts::Errata::Container |
typedef NumericType<unsigned int, struct MsgIdTag> ts::Errata::Id |
typedef IntrusivePtr<Data> ts::Errata::ImpPtr [protected] |
typedef Errata ts::Errata::self |
typedef void(* ts::Errata::SinkHandlerFunction)(Errata const &) |
ts::Errata::Errata | ( | ) |
ts::Errata::Errata | ( | self const & | that | ) |
ts::Errata::Errata | ( | std::string const & | text | ) | [explicit] |
ts::Errata::Errata | ( | Id | id, | |
std::string const & | text | |||
) |
ts::Errata::Errata | ( | Message const & | msg | ) | [inline] |
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.
Errata::iterator ts::Errata::begin | ( | ) |
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.
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.
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] |
Self assignment.
that | Source instance. |
Definition at line 121 of file Errata.cc.
References pre_write(), and ts::Errata::Data::push().
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=().
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().
Push a message.
msg becomes the top message.
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.
Definition at line 857 of file Errata.h.
Referenced by Errata(), ts::Rv< R >::push(), push(), ts::msg::vlogf(), and ts::msg::vlogf_errno().
Push a nested status.
err becomes the top item.
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] |
Errata::Message const & ts::Errata::top | ( | ) | const [inline] |
Access top 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.
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
.
friend struct Data [friend] |
Definition at line 419 of file Errata.h.
Referenced by pre_write().
std::ostream& operator<< | ( | std::ostream & | , | |
self const & | ||||
) | [friend] |
std::string const ts::Errata::DEFAULT_GLUE [static] |
ImpPtr ts::Errata::m_data [protected] |
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] |