31 static size_t type_hash() {
return typeid(T).hash_code(); }
35 m_default_value = std::make_shared<T>(value);
65 m_value = std::make_shared<T>(value);
69 T
value() {
return m_value ? *m_value : T(); }
75 std::shared_ptr<T> m_value{
nullptr};
76 std::shared_ptr<T> m_default_value{
nullptr};
92 m_options.push_back(std::make_shared<
typename std::decay<T>::type>(op));
99 add(std::forward<T>(op));
110 virtual bool was_supplied(
const std::string& key) = 0;
111 virtual std::string help() = 0;
113 virtual std::vector<std::shared_ptr<base_option>> get_all_options() = 0;
114 virtual std::shared_ptr<base_option> get_option(
const std::string& key) = 0;
116 virtual void insert(
const std::string& key,
const std::string& value) = 0;
117 virtual void replace(
const std::string& key,
const std::string& value) = 0;
119 template <
typename T>
125 throw std::bad_cast();
132 virtual void check_unregistered() = 0;
140 virtual std::string str() = 0;
141 virtual const char* data() = 0;
142 virtual size_t size() = 0;
145 template <
typename T>
152 template <
typename T>
155 return !(lhs == rhs);
typed_option & default_value(T value)
std::vector< std::shared_ptr< base_option > > m_options
bool default_value_supplied()
bool operator!=(typed_option< T > &lhs, typed_option< T > &rhs)
typed_option< T > & get_typed_option(const std::string &key)
typed_option & value(T value)
typed_option & short_name(const std::string &short_name)
base_option(std::string name, size_t type_hash)
bool operator==(typed_option< T > &lhs, typed_option< T > &rhs)
option_group_definition & add(T &&op)
int add(svm_params ¶ms, svm_example *fec)
option_group_definition & operator()(T &&op)
typed_option< T > make_option(std::string name, T &location)
typed_option(const std::string &name, T &location)
typed_option & help(const std::string &help)
typed_option & keep(bool keep=true)
virtual ~base_option()=default
static size_t type_hash()
option_group_definition(const std::string &name)