TDictMap< T > Class Template Reference

A mapper from emums to string values. - usefull for names flags. More...

#include <mia/core/dictmap.hh>

Inheritance diagram for TDictMap< T >:
[legend]

Data Structures

struct  Table
 

Public Types

typedef std::map< T, std::pair< std::string, std::string > > THelpMap
 

Public Member Functions

const char * get_help (T value) const
 
THelpMap::const_iterator get_help_begin () const
 
THelpMap::const_iterator get_help_end () const
 
const char * get_name (T value) const
 
const std::set< std::string > get_name_set () const
 
get_value (const char *name) const
 
 TDictMap (const Table *table, bool last_is_default=false)
 

Detailed Description

template<typename T>
class TDictMap< T >

A mapper from emums to string values. - usefull for names flags.

Todo:
extend it to also contain help strings for each flag.

Definition at line 45 of file dictmap.hh.

Member Typedef Documentation

◆ THelpMap

template<typename T>
typedef std::map<T, std::pair<std::string, std::string> > TDictMap< T >::THelpMap

This map is used to reference the help strings

Definition at line 50 of file dictmap.hh.

Constructor & Destructor Documentation

◆ TDictMap()

template<typename T >
TDictMap< T >::TDictMap ( const Table table,
bool  last_is_default = false 
)

Create the map by providing an initialisation map

Parameters
tablethe initialisation table, needs to be terminated by a {NULL, some_value} pair.
last_is_defaulttrue if the value provided with the NULL name is the default return value if unknown names are given. If false, an unknown name in get_value() will throw std::invalid_argument exception.

Definition at line 131 of file dictmap.hh.

Member Function Documentation

◆ get_help()

template<typename T>
const char * TDictMap< T >::get_help ( value) const
Parameters
value
Returns
corresponding flag
Remarks
throws std::invalid_argument if the value is unknown

Definition at line 178 of file dictmap.hh.

◆ get_help_begin()

template<typename T >
TDictMap< T >::THelpMap::const_iterator TDictMap< T >::get_help_begin ( ) const
Returns
start of help map

Definition at line 195 of file dictmap.hh.

◆ get_help_end()

template<typename T >
TDictMap< T >::THelpMap::const_iterator TDictMap< T >::get_help_end ( ) const
Returns
end of help map

Definition at line 201 of file dictmap.hh.

◆ get_name()

template<typename T>
const char * TDictMap< T >::get_name ( value) const
Parameters
value
Returns
corresponding flag
Remarks
throws std::invalid_argument if the value is unknown

Definition at line 164 of file dictmap.hh.

◆ get_name_set()

template<typename T >
const std::set< std::string > TDictMap< T >::get_name_set ( ) const
Returns
a set of all available names

Definition at line 187 of file dictmap.hh.

◆ get_value()

template<typename T >
T TDictMap< T >::get_value ( const char *  name) const
Parameters
name
Returns
corresponding flag
Remarks
throws std::invalid_argument if the name is unknown

Definition at line 150 of file dictmap.hh.


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