24 #ifndef ARM_COMPUTE_UTILS_ENUMLISTOPTION 25 #define ARM_COMPUTE_UTILS_ENUMLISTOPTION 29 #include <initializer_list> 58 EnumListOption(std::string name, std::set<T> allowed_values, std::initializer_list<T> &&default_values);
61 std::string
help()
const override;
67 const std::vector<T> &
value()
const;
70 std::vector<T> _values{};
71 std::set<T> _allowed_values{};
82 :
Option{ std::move(name),
false,
true }, _values{ std::forward<std::initializer_list<T>>(default_values) },
_allowed_values{ std::move(allowed_values) }
93 std::stringstream stream{ value };
96 while(!std::getline(stream, item,
',').fail())
100 std::stringstream item_stream(item);
103 item_stream >> typed_value;
105 if(!item_stream.fail())
113 _values.emplace_back(typed_value);
116 _is_set = _is_set && !item_stream.fail();
118 catch(
const std::invalid_argument &)
127 template <
typename T>
130 std::stringstream msg;
131 msg <<
"--" +
name() +
"={";
138 msg <<
"}[,{...}[,...]] - " << _help;
143 template <
typename T>
std::string help() const override
Help message for the option.
Abstract base class for a command line option.
Implementation of an option that accepts any number of values from a fixed set.
const std::vector< T > & value() const
Get the values of the option.
bool parse(std::string value) override
Parses the given string.
Copyright (c) 2017-2021 Arm Limited.
std::string name() const
Name of the option.
EnumListOption(std::string name, std::set< T > allowed_values)
Construct option with allowed values.