Selection of an enum value from a list of choices.
More...
Selection of an enum value from a list of choices.
- See also
- neml2::EnumSelectionBase
#include <EnumSelection.h>
|
| | EnumSelection ()=default |
| |
| | EnumSelection (const std::vector< std::string > &choices, const std::string &selection) |
| | Create an enum selection from a list of choices and a default selection.
|
| |
| | EnumSelection (const std::vector< std::string > &choices, const std::vector< int > &values, const std::string &selection) |
| | Create an enum selection from a list of choices, 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.
|
| |
| const std::string & | selection () const |
| | Poor man's reflection implementation.
|
| |
| int | value () 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.
|
| |
| | EnumSelectionBase ()=default |
| |
| | EnumSelectionBase (const std::vector< std::string > &choices) |
| | Create an enum selection from a list of choices.
|
| |
| | EnumSelectionBase (const std::vector< std::string > &choices, const std::vector< int > &values) |
| | Create an enum selection from a list of choices and their corresponding values.
|
| |
| const std::unordered_map< std::string, int > & | choices () const |
| | Choices.
|
| |
| std::string | join (const std::string &separator=", ") const |
| | Join the choices into a single string with the given separator.
|
| |
|
| std::unordered_map< std::string, int > | _choice_map |
| | Mapping enum options to int.
|
| |
◆ EnumSelection() [1/3]
◆ EnumSelection() [2/3]
| EnumSelection |
( |
const std::vector< std::string > & | choices, |
|
|
const std::string & | selection ) |
Create an enum selection from a list of choices and a default selection.
◆ EnumSelection() [3/3]
| EnumSelection |
( |
const std::vector< std::string > & | choices, |
|
|
const std::vector< int > & | values, |
|
|
const std::string & | selection ) |
Create an enum selection from a list of choices, a list of values, and a default selection.
◆ as()
Statically cast the enum value to a C++ enum class.
◆ operator!=() [1/2]
◆ operator!=() [2/2]
| bool operator!= |
( |
const std::string & | other | ) |
const |
Test for selection inequality.
◆ operator==() [1/2]
◆ operator==() [2/2]
| bool operator== |
( |
const std::string & | other | ) |
const |
Test for selection equality.
◆ select()
| void select |
( |
const std::string & | selection | ) |
|
◆ selection()
| const std::string & selection |
( |
| ) |
const |
|
inline |
Poor man's reflection implementation.
◆ value()
Implicit conversion to int to let it behave more like a enum.