lestes::msg::message_stencil Class Reference

Message stencil base. More...

#include <message_stencil.hh>

Inheritance diagram for lestes::msg::message_stencil:

Inheritance graph
[legend]
List of all members.

Public Member Functions

ulint nparams_get (void) const
 Returns the number of parameters.
ulint kind_get (void) const
 Returns the unique kind identification.
bool equals (const ptr< message_stencil > &other) const
 Tests equality.

Protected Types

typedef message::flags_type flags_type
 Type of message flags.
typedef ::lestes::std::vector<
lstring > 
args_type
 Type of argument list.

Protected Member Functions

 message_stencil (ulint a_nparams, const lstring &a_format, flags_type a_flags)
 Creates the message stencil.
ptr< messagegenerate (const ptr< args_type > &args) const
 Returns a formatted message.
void gc_mark (void)
 Marks the object.

Private Types

typedef ::lestes::std::vector<
lstring > 
texts_type
 Type of storage for message texts.
typedef ::lestes::std::vector<
ulint > 
params_type
 Type of storage for parameters.

Private Member Functions

void parse (const lstring &a_format)
 Parses the format string.
 message_stencil (const message_stencil &)
 Hides copy constructor.
message_stenciloperator= (const message_stencil &)
 Hides assignment operator.

Private Attributes

ulint nparams
 Number of parameters.
ulint kind
 The unique identification of message kind.
flags_type flags
 Message flags.
srp< texts_typetexts
 The parsed texts.
srp< params_typeparams
 The parsed parameters.

Static Private Attributes

static ulint kind_counter = 0
 The internal counter to distinguish instances.

Detailed Description

Message stencil base.

Represents base class parametrised stencil for creating formatted messages. Each instance of stencil represents one unique message family (generating the same kind of messages). Each instance is assigned an unique identification number to help expressing sets of message kinds efficiently, for example via bit vectors. It is however, not assured, that one object will get the same id each time.

The format text recognizes parameter reference in the form D where D is a decimal digit. The parameter numbering starts with 0 and only valid indexes are accepted. The reference to a single parameter can appear zero or more times, in no particular order. To express a single %, %% is used. Any other character after % is not allowed and neither is end of string.

Example: "Value %0 is invalid in %3, %0 is out of range %1 - %2 allowed for %3"

Implementation details: The parsed format text is stored as a sequence of parameter indexes with a special value (equal to the number of parameters) designating use of next part of text, stored in another sequence.


Member Typedef Documentation

typedef message::flags_type lestes::msg::message_stencil::flags_type [protected]

Type of message flags.

typedef ::lestes::std::vector<lstring> lestes::msg::message_stencil::args_type [protected]

Type of argument list.

typedef ::lestes::std::vector<lstring> lestes::msg::message_stencil::texts_type [private]

Type of storage for message texts.

typedef ::lestes::std::vector<ulint> lestes::msg::message_stencil::params_type [private]

Type of storage for parameters.


Constructor & Destructor Documentation

lestes::msg::message_stencil::message_stencil ( ulint  a_nparams,
const lstring &  a_format,
flags_type  a_flags 
) [protected]

Creates the message stencil.

Creates the stencil, initializes with number of expected parameters and values to fill into the message. Assigns a unique id number, starting from zero.

Precondition:
The format string is well-formed.
Parameters:
a_nparams Number of parameters for the stencil.
a_format The format for the message, with % designating indexed parameter slots.
a_flags The flags for the message.

lestes::msg::message_stencil::message_stencil ( const message_stencil  )  [private]

Hides copy constructor.


Member Function Documentation

ulint lestes::msg::message_stencil::nparams_get ( void   )  const

Returns the number of parameters.

Returns the number of parameters for the message.

Returns:
The number of parameters.

ulint lestes::msg::message_stencil::kind_get ( void   )  const

Returns the unique kind identification.

Returns the assigned unique identification number. The number is only for internal use and may vary between compilations.

Returns:
The kind identification number.

bool lestes::msg::message_stencil::equals ( const ptr< message_stencil > &  other  )  const

Tests equality.

Tests equality to other stencil. Each stencil object represents one message kind and is thus unique.

Parameters:
other The stencil to compare to.
Returns:
true If both stencils point to the same object.

ptr< message > lestes::msg::message_stencil::generate ( const ptr< args_type > &  args  )  const [protected]

Returns a formatted message.

Returns message with arguments filled into the parameter slots.

Precondition:
args != NULL

args->size() == nparams_get()

Parameters:
args The arguments for the message.

void lestes::msg::message_stencil::gc_mark ( void   )  [protected, virtual]

Marks the object.

Marks the object for garbage collection.

Reimplemented from lestes::std::mem::keystone.

Reimplemented in lestes::msg::message_stencil0< T >, lestes::msg::message_stencil1< P0 >, lestes::msg::message_stencil2< P0, P1 >, and lestes::msg::message_stencil3< P0, P1, P2 >.

void lestes::msg::message_stencil::parse ( const lstring &  a_format  )  [private]

Parses the format string.

Parses the format text.

Precondition:
The text is well-formed according to the class documentation.
Parameters:
text The text to parse.

message_stencil& lestes::msg::message_stencil::operator= ( const message_stencil  )  [private]

Hides assignment operator.


Member Data Documentation

ulint lestes::msg::message_stencil::nparams [private]

Number of parameters.

ulint lestes::msg::message_stencil::kind [private]

The unique identification of message kind.

flags_type lestes::msg::message_stencil::flags [private]

Message flags.

srp<texts_type> lestes::msg::message_stencil::texts [private]

The parsed texts.

srp<params_type> lestes::msg::message_stencil::params [private]

The parsed parameters.

ulint lestes::msg::message_stencil::kind_counter = 0 [static, private]

The internal counter to distinguish instances.

Internal message stencil instance identification number counter.


The documentation for this class was generated from the following files:
Generated on Mon Feb 12 18:49:40 2007 for lestes by doxygen 1.5.1-20070107