17 #ifndef AWALI_DYN_OPTIONS_OPTION_HH
18 #define AWALI_DYN_OPTIONS_OPTION_HH
20 #include <unordered_map>
62 return (
"any string");
79 std::string option_name;
82 bool default_set_by_user =
false;
86 option_name(other.option_name),
87 acceptor(other.acceptor),
88 default_value(other.default_set_by_user?other.def:def),
89 default_set_by_user(other.was_user_set)
92 template<
typename X,
typename P>
94 throw std::runtime_error(
"Wrong value type for option "+option_name
100 template<
typename X=T,
typename P>
105 template<
typename X=T,
typename P>
108 awali::internal::make_enum<X>(
value),
109 internal::option_value_pair_t(
id, default_value)
111 if (
value ==
"default")
112 return {
id, default_value};
113 return {
id, awali::internal::make_enum<X>(
value)};
117 internal::option_value_pair_t make(
const T&
value, priority::FOUR<P>) {
127 :
id(internal::
next_id++), option_name(std::move(name)), acceptor(acc),
132 return acceptor(
value);
138 throw std::runtime_error(
"Using option without argument is only possible if they expect boolean values.");
160 return option_t(*
this, new_default_value);
167 default_value = new_default_value;
168 default_set_by_user =
true;
172 return default_value;
value_t of_string(std::string const &str)
Create of value of the type expected by this option_t, from string str.
Definition: option.hh:186
const size_t id
Definition: option.hh:76
option_t(std::string name, T def, acceptor_t< T > acc=acceptor_t< T >())
Definition: option.hh:126
value_t get_default_value()
Definition: option.hh:171
T value_t
Definition: option.hh:75
internal::option_value_pair_t operator=(const X &value)
Definition: option.hh:178
void set_default_value(value_t new_default_value)
Definition: option.hh:166
bool acceptable(T value)
Definition: option.hh:131
option_t< value_t > with_default_value(value_t new_default_value)
Creates a phony option_t that overrides system default value (but not user defined default,...
Definition: option.hh:159
size_t next_id
Global variable that assign a unique identifier to each instance of option<T> independentely of type ...
std::string demangle(const char *name)
Definition: demangle.hxx:48
static constexpr TOP< void > value
Definition: priority.hh:93
static constexpr ONE< void > one
Definition: priority.hh:76
Definition: priority.hh:52
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
Definition: synchronizing_word.hh:266
Main namespace of Awali.
Definition: ato.hh:22
std::string acceptable_values()
Definition: option.hh:50
virtual bool is_valid(bool const &)
Definition: option.hh:47
virtual ~acceptor_t()=default
virtual ~acceptor_t()=default
virtual std::string acceptable_values()
Definition: option.hh:61
virtual bool is_valid(std::string const &)
Definition: option.hh:58
virtual bool is_valid(T const &)
Definition: option.hh:36
virtual std::string acceptable_values()
Definition: option.hh:39
virtual ~acceptor_t()=default