netxsimdg
Loading...
Searching...
No Matches
EnumWrap::EnumWrapper< E > Class Template Reference

#include <EnumWrapper.hpp>

Collaboration diagram for EnumWrap::EnumWrapper< E >:
Collaboration graph

Public Types

typedef std::map< std::string, E > MapType
 

Public Member Functions

operator() (const std::string &key)
 
 operator E () const
 Cast the wrapped enum back to a plain one.
 

Static Public Member Functions

static void setMap (const MapType &inMap)
 

Friends

std::istream & operator>> (std::istream &is, EnumWrapper< E > &e)
 A templated input operator that uses the defined map to set the value of the wrapped enum.
 

Detailed Description

template<typename E>
class EnumWrap::EnumWrapper< E >

A helper class to make configuring enums easier with boost::program_options.

This class provides a templated implementation of the instream operator necessary for enums to be read by boost::program_options. Also provided is a macro which will format the map that is required to go from the string representation in the config file to the values of the enum.

Definition at line 58 of file EnumWrapper.hpp.

Member Typedef Documentation

◆ MapType

template<typename E >
std::map<std::string, E> EnumWrap::EnumWrapper< E >::MapType

Definition at line 60 of file EnumWrapper.hpp.

Member Function Documentation

◆ operator E()

template<typename E >
EnumWrap::EnumWrapper< E >::operator E ( ) const
inline

Cast the wrapped enum back to a plain one.

Definition at line 75 of file EnumWrapper.hpp.

◆ operator()()

template<typename E >
E EnumWrap::EnumWrapper< E >::operator() ( const std::string & key)
inline

Set and return the value of the wrapped enum, based on the passed string and the set map.

Parameters
keya key corresponding to one in the templated map which will set the value of the wrapped enum.

Definition at line 69 of file EnumWrapper.hpp.

◆ setMap()

template<typename E >
static void EnumWrap::EnumWrapper< E >::setMap ( const MapType & inMap)
inlinestatic

Set the mapping between strings and enum types

Parameters
inMapthe mapping to be used.

Definition at line 82 of file EnumWrapper.hpp.

Friends And Related Symbol Documentation

◆ operator>>

template<typename E >
std::istream & operator>> ( std::istream & is,
EnumWrapper< E > & e )
friend

A templated input operator that uses the defined map to set the value of the wrapped enum.

Definition at line 101 of file EnumWrapper.hpp.


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