#include <zorba/internal/diagnostic.h>
Public Types | |
typedef params_type::size_type | size_type |
typedef params_type::value_type | value_type |
Public Member Functions | |
template<typename T > | |
parameters & | operator, (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... | |
Definition at line 236 of file internal/diagnostic.h.
typedef params_type::size_type zorba::internal::diagnostic::parameters::size_type |
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.
zorba::internal::diagnostic::parameters::parameters | ( | ) |
Constructs a parameters object.
|
inline |
Adds the string representation of the given object as the next parameter.
T | The object type. |
t | The object. |
*this
. Definition at line 260 of file internal/diagnostic.h.
References zorba::internal::ztd::to_string().
|
inline |
Gets the i'th parameter value.
Parameter numbers start at 1.
i | The parameter to get. |
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:
{
[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.)
s | The string to perform the substitutions on. |
|
static |
A empty instance for convenience.
Definition at line 245 of file internal/diagnostic.h.