coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
parameter_substitution::format Struct Reference

struct parameter_substitution::format encapsulates a parameter substitution format. More...

#include <parameter_substitution.h>

Public Member Functions

 format (symbol &sym)
 Construct a parameter substitution format for a given symbol.
 
std::string const & str () const
 Get a reference to the format string.
 
std::string legible () const
 Get a string legibly representing the format.
 

Static Public Member Functions

static std::string legible (std::string const &pb)
 Get a string legibly representing a string with embedded specifiers.
 

Private Member Functions

void build_format (symbol &sym)
 Build a format with appropriate specifiers inserted at all parameter positions. More...
 
void do_stringify_adjustments (size_t nparams)
 After building the first-cut format, make any necessary adjustments for the presence of '#'-operators. More...
 
void do_token_paste_adjustments ()
 After building the first-cut format, make any necessary adjustments for the presence of '##'-operators. More...
 
ptrdiff_t adjust_for_stringify_op (size_t pos, size_t nparams)
 Adjust the format for a '#'-operator. More...
 
ptrdiff_t adjust_for_token_paste_op (size_t pos)
 Adjust the format for a '##'-operator. More...
 

Private Attributes

std::string _fmt
 The format string.
 
std::vector< size_t > _stringify_offs
 Vector of offsets of #-operators.
 
std::vector< size_t > _token_paste_offs
 Vector of offset of ##-operators.
 

Detailed Description

struct parameter_substitution::format encapsulates a parameter substitution format.

Such a format is a string with embedded specifiers that encodes the substitution of arguments for parameters into the format.

Definition at line 257 of file parameter_substitution.h.

Member Function Documentation

ptrdiff_t parameter_substitution::format::adjust_for_stringify_op ( size_t  pos,
size_t  nparams 
)
private

Adjust the format for a '#'-operator.

If nparams > 0 and the operand is a format specifier then the operator and operand are replaced with the corresponding <substitute_quoted_arg_specifier>

Parameters
posThe offset to the '#'-operator.
nparamsThe number of parameters of the symbol requiring the format
Returns
The signed difference in the length of the format that results from the adjustment.
Exceptions
error_stringify_non_paramif nparams1 > 0 and an operand of # is not a parameter.
ptrdiff_t parameter_substitution::format::adjust_for_token_paste_op ( size_t  pos)
private

Adjust the format for a '##'-operator.

If the either operand is a format specifier then it is replaced with the corresponding <substitute_arg_specifier>

The operator and flanking whitespace are deleted.

Parameters
posThe offset to the '##'-operator.
Returns
The signed difference in the length of the format that results from the adjustment.
Exceptions
error_misplaced_token_pasteif the operator has no left operand or no right operand.
error_bad_token_pasteif pasting the operands will not form a token
void parameter_substitution::format::build_format ( symbol sym)
private

Build a format with appropriate specifiers inserted at all parameter positions.

Parameters
symThe symbol for which the format is built.
void parameter_substitution::format::do_stringify_adjustments ( size_t  nparams)
private

After building the first-cut format, make any necessary adjustments for the presence of '#'-operators.

Occurrences of #<whitespace><subsititute_expanded_arg_specifier> are replaced by the corresponding <subsititute_quoted_arg_specifier>

Parameters
nparamsThe number of parameters of the symbol requiring the format.
Exceptions
error_stringify_non_paramif nparams1 > 0 and an operand of # is not a parameter.
void parameter_substitution::format::do_token_paste_adjustments ( )
private

After building the first-cut format, make any necessary adjustments for the presence of '##'-operators.

Consecutive occurrences of '##' are collapsed to one.

If an operand is <subsititute_expanded_arg_specifier> that operand is replaced with the corresponding <substitute_arg_specifier>

Remaining occurrences of '##' and flanking whitespace are deleted.

Exceptions
error_misplaced_token_pasteif an '##'-operator has no left operand or no right operand.
error_bad_token_pasteif pasting the operands of ## will not form a token

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