#ifndef REFLECTIVE_RAPIDJSON_REFLECTABLE_H #define REFLECTIVE_RAPIDJSON_REFLECTABLE_H #include "./reflect.h" #include #include namespace ReflectiveRapidJSON { template struct Reflectable { // RapidJSON-level API void push(RAPIDJSON_NAMESPACE::Value &container); void push(RAPIDJSON_NAMESPACE::Value &container, const char *name); // high-level API RAPIDJSON_NAMESPACE::StringBuffer toJson() const; static Type fromJson(const char *json, std::size_t jsonSize); static Type fromJson(const char *json); static Type fromJson(const std::string &json); }; template void Reflectable::push(RAPIDJSON_NAMESPACE::Value &container) { return Reflector::push(*this, container); } template void Reflectable::push(RAPIDJSON_NAMESPACE::Value &container, const char *name) { return Reflector::push(*this, name, container); } template RAPIDJSON_NAMESPACE::StringBuffer Reflectable::toJson() const { return Reflector::toJson(static_cast(*this)); } template Type Reflectable::fromJson(const char *json, std::size_t jsonSize) { return Reflector::fromJson(json, jsonSize); } template Type Reflectable::fromJson(const char *json) { return Reflector::fromJson(json, std::strlen(json)); } template Type Reflectable::fromJson(const std::string &json) { return Reflector::fromJson(json.data(), json.size()); } } // namespace ReflectiveRapidJSON #endif // REFLECTIVE_RAPIDJSON_REFLECTABLE_H