template<typename Enum>
tk::Toggle class

Toggle is the base for an Option, doing generic searches.

Toggle is templated on an enum type (a strongly typed enum), whose values are used as keys in maps of associated option values.

Constructors, destructors, conversion operators

Toggle(std::string&& g, std::map<Enum, std::string>&& n, std::map<std::string, Enum>&& v) protected explicit

Public functions

auto group() const -> const std::string&
Used to access template typename from outside.
auto value(const std::string& keyword) const -> Enum
auto exist(const std::string& keyword) const -> bool
auto name(Enum val) const -> const std::string&

Function documentation

template<typename Enum>
tk::Toggle<Enum>::Toggle(std::string&& g, std::map<Enum, std::string>&& n, std::map<std::string, Enum>&& v) explicit protected

Parameters
in Group name of the option set
in Map associating enum values to option names
in Map associating keyword strings to enum values

Constructor protected: designed to be used only as a base class Note that all arguments are rvalues, thus the objects gutted and this is the only constructor provided.

template<typename Enum>
const std::string& tk::Toggle<Enum>::group() const

Used to access template typename from outside.

Lookup group name

template<typename Enum>
Enum tk::Toggle<Enum>::value(const std::string& keyword) const

Parameters
keyword in Keyword to search for
Returns Strongly-typed enum value associated to keyword if found

Lookup Enum value based on keyword, Enum must exist

template<typename Enum>
bool tk::Toggle<Enum>::exist(const std::string& keyword) const

Parameters
keyword in Keyword to search for
Returns True if keyword if found

Check if keyword exists

template<typename Enum>
const std::string& tk::Toggle<Enum>::name(Enum val) const

Parameters
val in Enum value to search for
Returns Keyword if enum value is found

Lookup option name based on Enum