![]() |
|
A helper class that works as a literal or a variable in StringMapper. More...
#include <StringMapper.h>


Public Member Functions | |
| Stringlet (const std::string &s="", bool isVariable=false) | |
| Default functor. | |
| Stringlet (const std::string &s, const std::string &format) | |
| Stringlet (const Stringlet &s) | |
| Copy constructor. | |
| Stringlet (char c) | |
| bool | isVariable () const |
| void | setLiteral (const std::string &s) |
| Set type to variable or literal. | |
| void | setVariable (const std::string &s) |
| void | setVariable (const std::string &key, const std::string &fmt) |
| const std::string & | getStr () const |
| Return the internal string as is. | |
| const std::string & | getFormat () const |
| Return the internal formatting string. | |
Protected Attributes | |
| bool | isVar |
| std::string | format |
A helper class that works as a literal or a variable in StringMapper.
Stringlet is a std::string that is used either literally or as a variable name referring to an entry in a map (values of which can be of any type).
When a StringMapper parses a given std::string, it splits the std::string to segments containing literals and variables, in turn. The result is stored in a list.
Examples:
Supports also empty format string, for example ${name|}, since perhaps an empty variable value, like ${name|$FORMAT}
|
inline |
Default functor.
| s | - string that should be treated either as a literal or variable (with optional formatting) |
|
inline |
Set type to variable or literal.
Contradictory! Consider x = "| Title | Description |" inline void setVariable(bool isVariable=true) { if (!isVar){ StringTools::split2(*this, *this, format, '|'); isVar = isVariable; } }; inline void setFormat(const std::string &s) { setVariable(...) format.assign(s); isVar = true; }; Assing a value as a literal.
1.9.8