![]() |
|


Public Types | |
| enum | handleMissing { REMOVE_MISSING_VARIABLE , KEEP_MISSING_VARIABLE } |
Public Member Functions | |
| StringMapper (const std::string &format="", const std::string &validChars="[a-zA-Z0-9_]+", bool formatting=true) | |
| Default constructor. | |
| StringMapper (const RegExp ®exp, bool formatting=true) | |
| Initialize with the given RegExp // REMOVE! | |
| StringMapper (const StringMapper &mapper) | |
| Copy constructor copies the parsed string and the regExp. | |
| StringMapper & | setValidChars (const std::string &chars) |
| StringMapper & | enableFormatting (bool formatting) |
| Enable variable formatting, followed by pipe '|'. | |
| StringMapper & | parse (const std::string &s, bool convertEscaped=false) |
| Converts a std::string containing variables like in "Hello, ${NAME}!" to a list of StringLet's. | |
| bool | isLiteral () const |
| Return true, if all the elements are literal. | |
| std::ostream & | toStream (std::ostream &ostr) const |
| Output a concatenated chain of stringlets: literals as such and variables surrounded with "${" and "}". | |
| template<class T > | |
| std::ostream & | toStream (std::ostream &ostr, const std::map< std::string, T > &variables, int replace=REMOVE_MISSING_VARIABLE, const VariableFormatter< T > &formatter=VariableFormatter< T >()) const |
| Expands the variables in the last. | |
| template<class T > | |
| std::string | toStr (const std::map< std::string, T > &m, int replaceChar=REMOVE_MISSING_VARIABLE, const VariableFormatter< T > &formatter=VariableFormatter< T >()) const |
| Expands the variables in the last parsed std::string to a std::string. | |
| template<class T > | |
| void | expand (const std::map< std::string, T > &m, const VariableFormatter< T > &formatter=VariableFormatter< T >(), bool clear=false) |
| Expands the variables in StringMapper, turning expanded variables to constants. | |
| template<class T > | |
| std::ostream & | debug (std::ostream &ostr, const std::map< std::string, T > &m) const |
| Dumps the list of StringLet's. | |
Public Attributes | |
| IosFormat | iosFormat |
Protected Member Functions | |
| void | updateRegExp () |
| StringMapper & | parse (const std::string &s, RegExp &r) |
Protected Attributes | |
| std::string | validChars |
| bool | formatting |
| RegExp | regExp |
|
inline |
Default constructor.
| format | - string containing variables like ${name} |
| validChars | - allowed characters in variable names, ie inside braces. |
| formatting | - support postprocessing of variable value (number rounding, string operations) |
|
inline |
Enable variable formatting, followed by pipe '|'.
The formatting depends on the implementation. In this base class, VariableFormatter<T> is applied.
|
inline |
Expands the variables in StringMapper, turning expanded variables to constants.
| StringMapper & parse | ( | const std::string & | s, |
| bool | convertEscaped = false |
||
| ) |
Converts a std::string containing variables like in "Hello, ${NAME}!" to a list of StringLet's.
The Stringlet list is internal.
| s | - string containing variables like in "Hello, ${NAME}!" |
| convertEscaped | - convert backslash+letter segments to actual chars (\t, \n) first |
|
inline |
Expands the variables in the last parsed std::string to a std::string.
| m | - map containing variable values |
| replaceChar |
|
inline |
Output a concatenated chain of stringlets: literals as such and variables surrounded with "${" and "}".
Prints the mapper in its current state, ie. some variables may have been expanded to literals.
| ostr | - output stream |
|
inline |
Expands the variables in the last.
| ostr | - output stream |
| variables | - map containing variable values |
| replace | - if given, replace undefined variables with this char, or empty (if 0), else (-1) leave variable entry |
1.9.8