Reflection for RapidJSON  0.0.15
Reflection for serializing/deserializing with RapidJSON
reflector-boosthana.h
Go to the documentation of this file.
1 #ifndef REFLECTIVE_RAPIDJSON_BINARY_REFLECTOR_BOOST_HANA_H
2 #define REFLECTIVE_RAPIDJSON_BINARY_REFLECTOR_BOOST_HANA_H
3 
15 #include "./reflector.h"
16 
17 #include <boost/hana/adapt_struct.hpp>
18 #include <boost/hana/at_key.hpp>
19 #include <boost/hana/define_struct.hpp>
20 #include <boost/hana/for_each.hpp>
21 #include <boost/hana/intersection.hpp>
22 #include <boost/hana/keys.hpp>
23 
24 namespace ReflectiveRapidJSON {
25 namespace BinaryReflector {
26 
27 template <typename Type, Traits::EnableIf<IsCustomType<Type>> *> void readCustomType(BinaryDeserializer &deserializer, Type &customType)
28 {
29  boost::hana::for_each(
30  boost::hana::keys(customType), [&deserializer, &customType](auto key) { deserializer.read(boost::hana::at_key(customType, key)); });
31 }
32 
33 template <typename Type, Traits::EnableIf<IsCustomType<Type>> *> void writeCustomType(BinarySerializer &serializer, const Type &customType)
34 {
35  boost::hana::for_each(
36  boost::hana::keys(customType), [&serializer, &customType](auto key) { serializer.write(boost::hana::at_key(customType, key)); });
37 }
38 
39 } // namespace BinaryReflector
40 } // namespace ReflectiveRapidJSON
41 
42 #endif // REFLECTIVE_RAPIDJSON_BINARY_REFLECTOR_BOOST_HANA_H
reflector.h
Contains BinaryReader and BinaryWriter supporting binary (de)serialization of primitive and custom ty...
ReflectiveRapidJSON::BinaryReflector::BinarySerializer
Definition: reflector.h:80
ReflectiveRapidJSON::BinaryReflector::BinarySerializer::write
void write(const Type &pair)
Definition: reflector.h:220
ReflectiveRapidJSON::BinaryReflector::BinaryDeserializer::read
void read(Type &pair)
Definition: reflector.h:104
ReflectiveRapidJSON
Definition: traits.h:13
ReflectiveRapidJSON::BinaryReflector::BinaryDeserializer
Definition: reflector.h:56
ReflectiveRapidJSON::BinaryReflector::writeCustomType
void writeCustomType(BinarySerializer &serializer, const Type &customType)
Definition: reflector-boosthana.h:33
ReflectiveRapidJSON::BinaryReflector::readCustomType
void readCustomType(BinaryDeserializer &deserializer, Type &customType)
Definition: reflector-boosthana.h:27