NEML2 2.0.0
|
Selection of an enum value from a list of candidates. More...
Selection of an enum value from a list of candidates.
#include <EnumSelection.h>
Public Member Functions | |
EnumSelection ()=default | |
EnumSelection (const std::vector< std::string > &candidates, const std::string &selection) | |
Create an enum selection from a list of candidates and a default selection. | |
EnumSelection (const std::vector< std::string > &candidates, const std::vector< int > &values, const std::string &selection) | |
Create an enum selection from a list of candidates, a list of values, and a default selection. | |
void | select (const std::string &selection) |
Select a new value. | |
bool | operator== (const EnumSelection &other) const |
Test for equality. | |
bool | operator!= (const EnumSelection &other) const |
Test for inequality. | |
bool | operator== (const std::string &other) const |
Test for selection equality. | |
bool | operator!= (const std::string &other) const |
Test for selection inequality. | |
operator std::string () const | |
Poor man's reflection implementation. | |
operator int () const | |
Implicit conversion to int to let it behave more like a enum. | |
template<typename T > | |
T | as () const |
Statically cast the enum value to a C++ enum class. | |
Public Member Functions inherited from EnumSelectionBase | |
EnumSelectionBase ()=default | |
EnumSelectionBase (const std::vector< std::string > &candidates) | |
Create an enum selection from a list of candidates. | |
EnumSelectionBase (const std::vector< std::string > &candidates, const std::vector< int > &values) | |
Create an enum selection from a list of candidates and their corresponding values. | |
const std::unordered_map< std::string, int > & | candidates () const |
Candidates. | |
std::string | candidates_str () const |
Stringified candidates. | |
Additional Inherited Members | |
Protected Attributes inherited from EnumSelectionBase | |
std::unordered_map< std::string, int > | _candidate_map |
Mapping enum options to int. | |
|
default |
EnumSelection | ( | const std::vector< std::string > & | candidates, |
const std::string & | selection ) |
Create an enum selection from a list of candidates and a default selection.
EnumSelection | ( | const std::vector< std::string > & | candidates, |
const std::vector< int > & | values, | ||
const std::string & | selection ) |
Create an enum selection from a list of candidates, a list of values, and a default selection.
|
inline |
Statically cast the enum value to a C++ enum class.
|
inline |
Poor man's reflection implementation.
bool operator!= | ( | const EnumSelection & | other | ) | const |
Test for inequality.
bool operator== | ( | const EnumSelection & | other | ) | const |
Test for equality.