#ifndef TOML11_REFLECT_HPP #define TOML11_REFLECT_HPP #include // boost-ext/reflect #include namespace toml { namespace refl { template T from(const basic_value& v) { T x; reflect::for_each([&v, &x](auto I) { using member_type = std::remove_cvref_t(x))>; const auto key = std::string(reflect::member_name(x)); reflect::get(x) = toml::find(v, key); }, x); return x; } template basic_value into(const T& x) { basic_value v(toml::table{}); reflect::for_each([&v, &x](auto I) { using member_type = std::remove_cvref_t(x))>; const auto key = std::string(reflect::member_name(x)); v[key] = reflect::get(x); }, x); return v; } } // refl } // toml #define TOML11_REFLECT(X) \ namespace toml { \ template<> \ struct into \ { \ template \ static toml::basic_value into_toml(const X& x) \ { \ return refl::into(x); \ } \ }; \ template<> \ struct from \ { \ template \ static X from_toml(const toml::basic_value& v) \ { \ return refl::from(v); \ } \ }; \ } /* toml */ #endif // TOML11_REFLECT_HPP