NEML2 2.0.0
|
Our poor man's implementation of enum reflection. This is a necessary ingredient for bridging runtime string parsed from input files and static enum types.
For developers, this class shall only be used for parsing purposes during the setup phase. Avoid directly working with this class at model evaluation phase at all cost!
#include <EnumSelectionBase.h>
Public Member Functions | |
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. | |
Protected Attributes | |
std::unordered_map< std::string, int > | _candidate_map |
Mapping enum options to int. | |
|
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.
std::string candidates_str | ( | ) | const |
Stringified candidates.
|
protected |
Mapping enum options to int.