Reflection for RapidJSON 0.0.16
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
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
24namespace ReflectiveRapidJSON {
25namespace BinaryReflector {
26
27template <typename Type, Traits::EnableIf<IsCustomType<Type>> *>
28BinaryVersion readCustomType(BinaryDeserializer &deserializer, Type &customType, BinaryVersion version)
29{
30 boost::hana::for_each(boost::hana::keys(customType), [&](auto key) { deserializer.read(boost::hana::at_key(customType, key), version); });
31 return 0;
32}
33
34template <typename Type, Traits::EnableIf<IsCustomType<Type>> *>
35void writeCustomType(BinarySerializer &serializer, const Type &customType, BinaryVersion version)
36{
37 boost::hana::for_each(boost::hana::keys(customType), [&](auto key) { serializer.write(boost::hana::at_key(customType, key), version); });
38}
39
40} // namespace BinaryReflector
41} // namespace ReflectiveRapidJSON
42
43#endif // REFLECTIVE_RAPIDJSON_BINARY_REFLECTOR_BOOST_HANA_H
Contains BinaryReader and BinaryWriter supporting binary (de)serialization of primitive and custom ty...
The BinaryDeserializer class can read various data types, including custom ones, from an std::istream...
Definition reflector.h:73
The BinarySerializer class can write various data types, including custom ones, to an std::ostream.
Definition reflector.h:100
BinaryVersion readCustomType(BinaryDeserializer &deserializer, Type &customType, BinaryVersion version=0)
Reads customType via deserializer.
void writeCustomType(BinarySerializer &serializer, const Type &customType, BinaryVersion version=0)
Writes customType via serializer.
std::uint64_t BinaryVersion
Definition reflector.h:38