Public Types | Public Member Functions | Static Public Attributes | List of all members
zorba::internal::diagnostic::parameters Class Reference

#include <zorba/internal/diagnostic.h>

Collaboration diagram for zorba::internal::diagnostic::parameters:
Collaboration graph
[legend]

Public Types

typedef params_type::size_type size_type
 
typedef params_type::value_type value_type
 

Public Member Functions

template<typename T >
parametersoperator, (T const &t)
 Adds the string representation of the given object as the next parameter. More...
 
value_type const & operator[] (size_type i) const
 Gets the i'th parameter value. More...
 
 parameters ()
 Constructs a parameters object. More...
 
void substitute (value_type *s) const
 Substitutes substrings of the given string. More...
 

Static Public Attributes

static parameters const empty
 A empty instance for convenience. More...
 

Detailed Description

Definition at line 236 of file internal/diagnostic.h.

Member Typedef Documentation

Definition at line 240 of file internal/diagnostic.h.

typedef params_type::value_type zorba::internal::diagnostic::parameters::value_type

Definition at line 239 of file internal/diagnostic.h.

Constructor & Destructor Documentation

zorba::internal::diagnostic::parameters::parameters ( )

Constructs a parameters object.

Member Function Documentation

template<typename T >
parameters& zorba::internal::diagnostic::parameters::operator, ( T const &  t)
inline

Adds the string representation of the given object as the next parameter.

Template Parameters
TThe object type.
Parameters
tThe object.
Returns
Returns *this.

Definition at line 260 of file internal/diagnostic.h.

References zorba::internal::ztd::to_string().

value_type const& zorba::internal::diagnostic::parameters::operator[] ( size_type  i) const
inline

Gets the i'th parameter value.

Parameter numbers start at 1.

Parameters
iThe parameter to get.
Returns
Returns said parameter value.

Definition at line 272 of file internal/diagnostic.h.

void zorba::internal::diagnostic::parameters::substitute ( value_type s) const

Substitutes substrings of the given string.

Substitutions are in three forms:

  • $i
  • ${[chars]i[chars]}
  • $i?then[:else]

where i is a digit in the range [1,9] and refers to the value of the ith parameter, chars may be any characters except [1-9}], and then and else are of one of the two forms:

  • j
  • {[chars j chars k chars ...]}

where j is likewise a digit in the range [1,9] and refers to the value of the jth parameter.

The first substitution form replaces $i with the value of the ith parameter.

The second form replaces everything from the $ to the } with the contents of the {} where i is replaced with the value of the ith parameter. However, if the value is empty, then everything from the $ to the } is instead erased.

For example, ${"1": } will substitute the value of the 1st parameter quoted followed by a : and a space if non-empty; if empty, then everything from the $ to the } will instead be erased.

The third form tests the value of the ith parameter: if non-empty, then the then portion is substituted; if empty, then the else portion is. Both the then and else portions can be either a digit in the range [1,9] or chars enclosed by {}. The {} here can contain multiple parameter indicies. If at least one is non-empty, then the substitution for the portion will be done; if all are empty, then everything for the portion will be erased.

The \ character can be used to escape the meaning of the $, [1-9], ?, :, and } characters and instead treat them as ordinary characters.

Substitution is performed by making at most 9 passes over the string, one pass per parameter starting at 1. Substitutions may themselves have further substitutions, but, due to the way that substitution is performed, should only refer to parameters having higher digits. (Digits less than or equal to the current one will not be substituted.)

Parameters
sThe string to perform the substitutions on.

Member Data Documentation

parameters const zorba::internal::diagnostic::parameters::empty
static

A empty instance for convenience.

Definition at line 245 of file internal/diagnostic.h.


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