Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
VariableFormatter< T > Class Template Reference

Formats variables to output stream. More...

#include <VariableFormatter.h>

Inheritance diagram for VariableFormatter< T >:
Inheritance graph
[legend]
Collaboration diagram for VariableFormatter< T >:
Collaboration graph
[legend]

Public Types

typedef std::map< std::string, T > map_t
 

Public Member Functions

virtual bool handle (const std::string &key, 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. More...
 
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. More...
 

Static Public Member Functions

static bool formatValue (const T &value, const std::string &format, std::ostream &ostr)
 Given a value, print it formatted to stream.
 

Public Attributes

IosFormat iosFormat
 

Detailed Description

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

Member Function Documentation

◆ formatVariable()

virtual bool formatVariable ( const std::string &  key,
const T &  value,
const std::string &  format,
std::ostream &  ostr 
) const
inlinevirtual

Given a key, retrieve an associated value from the map and print the value formatted into a stream.

Default implementation discards key.

Returns
false if value not found in the map, else print it formatted in a stream.

Reimplemented in VariableFormatterODIM< T >.

◆ handle()

virtual bool handle ( const std::string &  key,
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.

Return 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: