#pragma once #include #include #include #include #include namespace renderive::web { template struct Observer_Pfr_Adapter { using Type = adminive::Boost_Pfr_Reflection_Adapter; }; namespace detail { template nlohmann::json observer_value_json(const T& value); template nlohmann::json observer_object_json( const T& value, std::index_sequence) { nlohmann::json result = nlohmann::json::object(); ((result[std::string(Adapter::template name())] = observer_value_json(Adapter::template get(value))), ...); return result; } template nlohmann::json observer_value_json(const T& value) { using Value = std::remove_cvref_t; if constexpr (std::same_as) { return value; } else if constexpr (std::same_as || std::is_arithmetic_v) { return value; } else if constexpr (std::is_enum_v) { return static_cast>(value); } else if constexpr (std::is_aggregate_v) { using Adapter = typename Observer_Pfr_Adapter::Type; return observer_object_json( value, std::make_index_sequence{}); } else { return nullptr; } } } // namespace detail template nlohmann::json observer_json(const Observer& observer) { return detail::observer_value_json(observer); } } // namespace renderive::web