12SOIL::Enum::Enum(std::string value, std::vector<std::string> choices): _selected(value), _choices(choices)
33 for (
int i = 0; i < static_cast<int>(_choices.size()); i++)
35 if (_selected == _choices.at(i))
40 throw std::logic_error(
"Value of ENUM not in choices!");
45 for (
int i = 0; i < static_cast<int>(_choices.size()); i++)
47 if (value == _choices.at(i))
52 throw std::logic_error(
"Value of ENUM not in choices!");
57 if (value <
static_cast<int>(_choices.size()))
59 _selected = _choices.at(value);
63 throw std::logic_error(
"Index not in ENUM choices!");
void set(int value)
Set selected item (index)
std::string selected(void) const
Get selected value.
int index() const
Get index of selected element.
std::vector< std::string > choices(void)
Get Choices.