Formats variables to output stream.
More...
#include <VariableFormatter.h>
|
|
typedef std::map< std::string, T > | map_t |
| |
|
| virtual bool | handle (const std::string &key, const map_t &variables, std::ostream &ostr) const final |
| | Searches given key in a map, and if found, processes (formats) the value to ostream. Return false, if variable not found.
|
| |
| virtual bool | handle (const std::string &key, const std::string &format, const map_t &variables, std::ostream &ostr) const |
| | Searches given key in a map, and if found, processes (formats) the value to ostream. Return false, if variable not found.
|
| |
| virtual bool | formatVariable (const std::string &key, const T &value, const std::string &format, std::ostream &ostr) const |
| | Given a key, retrieve an associated value from the map and print the value formatted into a stream.
|
| |
|
virtual bool | formatVariable (const std::string &key, const T &value, const std::string &format, std::string &str) const final |
| | Checks if variables have ODIM names (keys), and apply special formatting (currently with time stamps)
|
| |
|
| static bool | formatValue (const T &value, const std::string &format, std::ostream &ostr) |
| | Given a value, print it formatted to stream.
|
| |
template<class T = std::string>
class drain::VariableFormatter< T >
Formats variables to output stream.
This base class supports following formatting:
printf() style formatting, like "%08.2d"
bash substring style formatting, like ":2:3" (take 3 letters, starting from position 2)
- Template Parameters
-
| T | - type of the variables. |
- See also
- StringLet
-
StringMapper
◆ formatValue()
template<class T = std::string>
| static bool formatValue |
( |
const T & |
value, |
|
|
const std::string & |
format, |
|
|
std::ostream & |
ostr |
|
) |
| |
|
inlinestatic |
Given a value, print it formatted to stream.
Formatting options are defined by the first character
Colon ':' selects substring like in bash, with syntax :n[:startpos]. Examples:
- ':3' selects 3 first letters
- ':4:2' selects 4 letters, starting from 2nd character
Percentage '' formats numbers as printf() function in C. Examples, given x = 1.4142135623
- '%05.1f' returns 001.4
- '%04d' returns 0001
◆ formatVariable()
template<class T = std::string>
| virtual bool formatVariable |
( |
const std::string & |
key, |
|
|
const T & |
value, |
|
|
const std::string & |
format, |
|
|
std::ostream & |
ostr |
|
) |
| const |
|
inlinevirtual |
◆ handle() [1/2]
template<class T = std::string>
| virtual bool handle |
( |
const std::string & |
key, |
|
|
const map_t & |
variables, |
|
|
std::ostream & |
ostr |
|
) |
| const |
|
inlinefinalvirtual |
Searches given key in a map, and if found, processes (formats) the value to ostream. Return false, if variable not found.
- Parameters
-
| key | - variable name, optionally followed by '|' and format expression |
- Returns
- false, if variable not found.
Then, further processors may handle the variable tag (remove, change, leave it).
◆ handle() [2/2]
template<class T = std::string>
| virtual bool handle |
( |
const std::string & |
key, |
|
|
const std::string & |
format, |
|
|
const map_t & |
variables, |
|
|
std::ostream & |
ostr |
|
) |
| const |
|
inlinevirtual |
Searches given key in a map, and if found, processes (formats) the value to ostream. Return false, if variable not found.
- Parameters
-
| key | - variable name, optionally followed by '|' and format expression |
| format | - format expression, like f2.5 for floating point numbers. |
- Returns
- false, if variable not found. Then, further processors may handle the variable tag (remove, change, leave it).
The documentation for this class was generated from the following file: