Reflection for RapidJSON 0.0.17
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
morestructs.h
Go to the documentation of this file.
1#ifndef REFLECTIVE_RAPIDJSON_TESTS_MORE_STRUCTS_H
2#define REFLECTIVE_RAPIDJSON_TESTS_MORE_STRUCTS_H
3
4#define REFLECTIVE_RAPIDJSON_SHORT_MACROS
5
6#include "../../lib/binary/serializable.h"
7#include "../../lib/json/serializable.h"
8#include "../../lib/versioning.h"
9
10using namespace std;
11using namespace ReflectiveRapidJSON;
12
22struct IncludedStruct : public JsonSerializable<IncludedStruct>, public BinarySerializable<IncludedStruct> {
23 int someInt = 0;
24};
25
30struct ConstStruct : public JsonSerializable<ConstStruct>, public BinarySerializable<IncludedStruct> {
31 int modifiableInt = 23;
32 const int constInt = 42;
33};
34
38struct PointerTarget : public BinarySerializable<PointerTarget> {
40 : n(0xAAAAAAAA)
41 , dummy1(0x1111111111111111)
42 , dummy2(0x1111111111111111)
43 , dummy3(0x1111111111111111)
44 {
45 }
46
47 PointerTarget(uint32_t n)
48 : n(n)
49 , dummy1(0x1111111111111111)
50 , dummy2(0x1111111111111111)
51 , dummy3(0x1111111111111111)
52 {
53 }
54
55 uint32_t n;
56 uint64_t dummy1;
57 uint64_t dummy2;
58 uint64_t dummy3;
59};
60
64struct PointerStruct : public BinarySerializable<PointerStruct> {
65 std::shared_ptr<PointerTarget> s1;
66 std::unique_ptr<PointerTarget> u2;
67 std::unique_ptr<PointerTarget> u3;
68 std::shared_ptr<PointerTarget> s2;
69 std::unique_ptr<PointerTarget> u1;
70 std::shared_ptr<PointerTarget> s3;
71};
72
76namespace SomeNamespace {
77
81// clang-format off
82struct VersionedStruct : public BinarySerializable<VersionedStruct, 3> {
83 std::uint32_t a, b;
84
85until_version(2):
86 std::uint32_t c, d;
87
88as_of_version(3):
89 std::uint32_t e, f;
90
91as_of_version(4):
92 std::uint32_t g;
93};
94// clang-format on
95
96} // namespace SomeNamespace
97
98#endif // REFLECTIVE_RAPIDJSON_TESTS_MORE_STRUCTS_H
All of this is supposed to work if classes are within a namespace so let's use a namespace here.
Definition morestructs.h:76
The ConstStruct struct is used to test handling of const members.
Definition morestructs.h:30
const int constInt
Definition morestructs.h:32
int modifiableInt
Definition morestructs.h:31
The IncludedStruct struct is used to test whether only code for directly included structs is generate...
Definition morestructs.h:22
The PointerStruct struct is used to test the behavior of the binary (de)serialization with smart poin...
Definition morestructs.h:64
std::shared_ptr< PointerTarget > s2
Definition morestructs.h:68
std::unique_ptr< PointerTarget > u3
Definition morestructs.h:67
std::unique_ptr< PointerTarget > u2
Definition morestructs.h:66
std::shared_ptr< PointerTarget > s3
Definition morestructs.h:70
std::shared_ptr< PointerTarget > s1
Definition morestructs.h:65
std::unique_ptr< PointerTarget > u1
Definition morestructs.h:69
uint64_t dummy2
Definition morestructs.h:57
uint64_t dummy3
Definition morestructs.h:58
uint64_t dummy1
Definition morestructs.h:56
PointerTarget(uint32_t n)
Definition morestructs.h:47
The PointerStruct struct is used to test the behavior of the binary (de)serialization with smart poin...
Definition morestructs.h:82