Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Stringlet Class Reference

A helper class that works as a literal or a variable in StringMapper. More...

#include <StringMapper.h>

Inheritance diagram for Stringlet:
Inheritance graph
[legend]
Collaboration diagram for Stringlet:
Collaboration graph
[legend]

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
 

Detailed Description

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}

See also
StringMapper

Constructor & Destructor Documentation

◆ Stringlet()

Stringlet ( const std::string &  s = "",
bool  isVariable = false 
)
inline

Default functor.

Parameters
s- string that should be treated either as a literal or variable (with optional formatting)

Member Function Documentation

◆ setLiteral()

void setLiteral ( const std::string &  s)
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.


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