zorba::internal::diagnostic::parameters

#include <zorba/internal/diagnostic.h>

Private Types

std::vector< std::string >

params_type

Public Types

params_type::size_type

size_type

params_type::value_type

value_type

Public Static Attributes

parameters const

empty

A empty instance for convenience.

Private Attributes

params_type

params_

Public Functions

parameters &

operator,(T const &t)

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

value_type const &

operator[](size_type i) const

Gets the i'th parameter value.

parameters()

Constructs a parameters object.

void

substitute(value_type *s) const

Substitutes substrings of the given string.

Private Functions

void

add_param(value_type const &)

value_type

lookup_param(size_type i) const

bool

then_else(bool, value_type const &, value_type::size_type *, value_type *) const

size_type

to_index(value_type::value_type) const

Private Types

params_type

std::vector< std::string > params_type

Public Types

size_type

params_type::size_type size_type

value_type

params_type::value_type value_type

Public Static Attributes

empty

parameters const empty

A empty instance for convenience.

Private Attributes

params_

params_type params_

Public Functions

operator,

parameters & operator,(T const &t)

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

Parameters

T The object type.

Parameters

t The object.

Returns

Returns *this.

operator[]

value_type const & operator[](size_type i) const

Gets the i'th parameter value.

Parameter numbers start at 1.

Parameters

i The parameter to get.

Returns

Returns said parameter value.

parameters

 parameters()

Constructs a parameters object.

substitute

void 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

s The string to perform the substitutions on.

Private Functions

add_param

void add_param(value_type const &)

lookup_param

value_type lookup_param(size_type i) const

then_else

bool then_else(bool, value_type const &, value_type::size_type *, value_type *) const

to_index

size_type to_index(value_type::value_type) const