1#ifndef XPED_TOML_HELPERS_HPP_
2#define XPED_TOML_HELPERS_HPP_
16template <typename T, typename = typename std::enable_if_t<boost::describe::has_describe_enumerators<T>::value>>
20 bool success = boost::describe::enum_from_string(std::string(t.as_string()).c_str(), out);
21 if(not success) {
throw std::invalid_argument(
"Bad conversion from toml input to enum."); }
27 std::map<std::string, Param> params;
28 for(
const auto& [k, v] : t.as_table()) {
30 params[k] =
Param{.
value =
static_cast<double>(v.as_floating())};
31 }
else if(v.is_array()) {
32 if(v.at(0).is_floating()) {
33 params[k] =
Param{.
value = toml::get<std::vector<double>>(v)};
34 }
else if(v.at(0).is_array()) {
35 params[k] =
Param{.
value = toml::get<std::vector<std::vector<double>>>(v)};
38 throw std::invalid_argument(
"Bad model parameters.");
Definition: FusionTree.hpp:15
T enum_from_toml(const toml::value &t)
Definition: TomlHelpers.hpp:17
std::map< std::string, Param > params_from_toml(const toml::value &t)
Definition: TomlHelpers.hpp:25
std::any value
Definition: Param.hpp:10