#ifndef REFLECTIVE_RAPIDJSON_BINARY_REFLECTOR_BOOST_HANA_H #define REFLECTIVE_RAPIDJSON_BINARY_REFLECTOR_BOOST_HANA_H /*! * \file reflector-boosthana.h * \brief Contains generic functions relying on Boost.Hana which can replace the code which would * otherwise had to be generated. * \remarks * These functions use boost::hana::keys() and boost::hana::at_key() rather than the "plain" * for-loop shown in the introspection examples of the Boost.Hana documentation. The reason is that * the "plain" for-loop involves making copies. This costs performance and - more importantly - prevents * modifying the actual object. */ #include "./reflector.h" #include #include #include #include #include #include namespace ReflectiveRapidJSON { namespace BinaryReflector { template > *> BinaryVersion readCustomType(BinaryDeserializer &deserializer, Type &customType) { boost::hana::for_each( boost::hana::keys(customType), [&deserializer, &customType](auto key) { deserializer.read(boost::hana::at_key(customType, key)); }); return 0; } template > *> void writeCustomType(BinarySerializer &serializer, const Type &customType, BinaryVersion version) { CPP_UTILITIES_UNUSED(version) boost::hana::for_each( boost::hana::keys(customType), [&serializer, &customType](auto key) { serializer.write(boost::hana::at_key(customType, key)); }); } } // namespace BinaryReflector } // namespace ReflectiveRapidJSON #endif // REFLECTIVE_RAPIDJSON_BINARY_REFLECTOR_BOOST_HANA_H