#ifndef DEPTHGUIDE_YAML_UTILITY_HPP #define DEPTHGUIDE_YAML_UTILITY_HPP #include template inline auto yaml_load_number(const YAML::Node &conf, const char *name) { static_assert(std::is_arithmetic_v); assert(conf[name].IsScalar()); return conf[name].as(); } inline auto yaml_load_str(const YAML::Node &conf, const char *name) { assert(conf[name].IsScalar()); return conf[name].as(); } inline auto yaml_load_sub(const YAML::Node &conf, const char *name) { assert(conf[name].IsMap()); return conf[name]; } #define LOAD_NUMBER(type, name) \ yaml_load_number(conf, name) #define LOAD_STR(name) \ yaml_load_str(conf, name) #define LOAD_SUB(name) \ yaml_load_sub(conf, name) #define FROM_YAML_IMPL(type) \ static auto from_yaml(const YAML::Node &conf) { \ auto ret = type(); \ ret.fill_from_yaml(conf); \ return ret; \ } #endif //DEPTHGUIDE_YAML_UTILITY_HPP