24 #ifndef ARM_COMPUTE_UTILS_ENUMOPTION 25 #define ARM_COMPUTE_UTILS_ENUMOPTION 56 EnumOption(std::string name, std::set<T> allowed_values, T default_value);
59 std::string
help()
const override;
65 const T &
value()
const;
68 std::set<T> _allowed_values{};
73 :
SimpleOption<T>{ std::move(name) }, _allowed_values{ std::move(allowed_values) }
79 :
SimpleOption<T>{ std::move(name), std::move(default_value) }, _allowed_values{ std::move(allowed_values) }
88 std::stringstream stream{ value };
91 stream >> typed_value;
95 if(_allowed_values.count(typed_value) == 0)
100 this->_value = std::move(typed_value);
101 this->_is_set =
true;
107 catch(
const std::invalid_argument &)
113 template <
typename T>
116 std::stringstream msg;
117 msg <<
"--" + this->
name() +
"={";
119 for(
const auto &value : _allowed_values)
124 msg <<
"} - " << this->_help;
129 template <
typename T>
std::string help() const override
Help message for the option.
bool parse(std::string value) override
Parses the given string.
Copyright (c) 2017-2023 Arm Limited.
std::string name() const
Name of the option.
EnumOption(std::string name, std::set< T > allowed_values)
Construct option with allowed values.
Implementation of a simple option that accepts a value from a fixed set.
const T & value() const
Get the selected value.
Implementation of an option that accepts a single value.