13#include <system_error>
27 "' cannot be indexed in '" +
37 std::string(s.full_key) +
"'");
44void set_param(std::string_view &
v, ParamString s);
50 requires((std::floating_point<T> || std::integral<T>) && !std::is_enum_v<T>)
53#ifdef ALPAQA_WITH_QUAD_PRECISION
64template <
class Rep,
class Period>
65void set_param(std::chrono::duration<Rep, Period> &t, ParamString s);
69template <
class T,
class T_actual,
class A>
78 template <
class T_actual,
class A>
88 std::map<std::string_view, param_setter_fun_t<T>>;
101 return std::string{};
104 return a +
"'" + std::string(b.first) +
"', ";
107 "'" + std::string(
penult->first) +
"'";
113 requires requires { dict_to_struct_table<T>::table; }
117 auto it = m.find(key);
121 "' in '" + std::string(s.
full_key) +
124 it->second.set(t, s);
128#define PARAMS_TABLE(type_, ...) \
130 struct dict_to_struct_table<type_> { \
131 using type = type_; \
132 inline static const dict_to_struct_table_t<type> table{__VA_ARGS__}; \
137#define PARAMS_MEMBER(name) \
138 { #name, &type::name }
std::string demangled_typename(const std::type_info &t)
Get the pretty name of the given type as a string.
auto param_setter(A T_actual::*attr)
Return a function that applies set_param to the given attribute of a value of type T.
void set_param(bool &b, ParamString s)
void unsupported_type(T &, ParamString s)
Throw a meaningful error to indicate that parameters of type T are not supported or implemented.
std::string_view key
The subkey to resolve next.
void assert_key_empty(ParamString s)
Throw a meaningful error when s.key is not empty, to indicate that the given type T is not of struct ...
std::string_view full_key
Full key string, used for diagnostics.
auto split_key(std::string_view full, char tok='.')
Split the string full on the first occurrence of tok.
std::map< std::string_view, param_setter_fun_t< T > > dict_to_struct_table_t
Dictionary that maps struct attribute names to type-erased functions that set those attributes.
auto possible_keys()
Return a string enumerating the possible attribute names for the struct type T.
Represents a parameter value encoded as a string in the format abc.def.key=value.
Specialize this type to define the attribute name to attribute setters dictionaries for a struct type...
EigenConfigd DefaultConfig
Double-precision double configuration.
Custom parameter parsing exception.
Function wrapper to set attributes of a struct, type-erasing the type of the attribute.
param_setter_fun_t(A T_actual::*attr)
std::function< void(T &, ParamString)> set
void operator()(T &t, ParamString s) const