Maps names to constants. More...
#include <keyvalue/key/map/FlagMap.h>
Public Types | |
typedef OutputType | OutputType_ |
Public Member Functions | |
OutputType | map (const value::Variant &variant) const |
Performs the mapping. | |
virtual OutputType | get (const string &name) const =0 |
Performs the mapping from string to OutputType. | |
Private Member Functions | |
virtual string | getName () const =0 |
Gets Key's name. |
Maps names to constants.
A string
is mapped to a flag (normally an enum
). Consider, for instance, key::Device which specifies a logger::Logger type to be build. Users provide a string
either "Console", "File" or "Standard". However, inside keyvalue, devices are designated by key::Device::Flag. An error occurs when a string
cannot be mapped to a valid output.
Traits derived class
es which uses this map must implement a method to perform the mapping. This method has the following signature
OutputType get(const string& name) const;
OutputType | : (template parameter) Output type. |
OutputType_ | : Same as OutputType. |
OutputType map | ( | const value::Variant & | variant | ) | const |
Performs the mapping.
This method converts the input from value::Variant to string
and calls get().
variant | : A value::Variant containing the input string to be mapped. |
virtual OutputType get | ( | const string & | name | ) | const [pure virtual] |
Performs the mapping from string
to OutputType.
Must be implemented by derived real keys.
name | : The string to be mapped. |