-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasic_types.hpp.in
248 lines (194 loc) · 7.73 KB
/
basic_types.hpp.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#ifndef JSON_DESERIALISER_@LIB_ID@_TYPE_BASIC_
#define JSON_DESERIALISER_@LIB_ID@_TYPE_BASIC_
#include "adaptor.@lib@.h"
#include "json_deserialise.hpp"
#include "type_deduction.@lib@.h"
#include <list>
#include <map>
#include <set>
#include <vector>
namespace JsonDeserialise::@LIB_ID@Private {
using Impl = Implementation<@LIB_ID@>;
template <typename T>
using StringConvertor = typename @LIB_ID@::template StringConvertor<T>;
template <typename T>
struct is_string {
static constexpr bool value = StringConvertor<T>::value;
};
template <typename T>
struct is_nullable {
using Type = void;
static constexpr bool value = false;
};
template <typename T>
struct is_nullable<std::optional<T>> {
using Type = T;
static constexpr bool value = true;
};
template <typename T>
struct is_nullable<T*> {
using Type = T;
static constexpr bool value = true;
};
template <>
struct is_nullable<const char*> {
using Type = const char*;
static constexpr bool value = true;
};
template <>
struct is_nullable<char*> {
using Type = char*;
static constexpr bool value = true;
};
template <typename TypeInRef, typename Prototype = typename Deserialisable<TypeInRef>::Type>
using RefWrap = Prototype;
template <typename Any>
struct Deserialisable<Any&> {
using Type = RefWrap<Any>;
};
template <typename Any>
struct Deserialisable<const Any&> {
using Type = RefWrap<Any>;
};
template <typename Any>
struct Deserialisable<std::reference_wrapper<Any>> {
using Type = RefWrap<Any>;
};
template <typename Any>
struct _Deserialisable<Any, false, -1, void, -1, void, -1> {
using Type = _DeserialisableType<Any, false, -1, void, is_nullable<Any>::value,
typename is_nullable<Any>::Type, -1>;
};
template <typename Any>
struct _Deserialisable<Any, false, -1, void, false, void, -1> {
using Type = _DeserialisableType<Any, false, -1, void, false, void, is_string<Any>::value>;
};
template <typename T, typename TypeInNullable>
struct _Deserialisable<T, false, -1, void, true, TypeInNullable, -1> {
using Type = _DeserialisableType<T, false, -1, void, true, TypeInNullable,
is_string<TypeInNullable>::value>;
};
template <typename T, typename TypeInArray>
struct _Deserialisable<T, true, -1, TypeInArray, -1, void, -1> {
using Type = _DeserialisableType<T, true, -1, TypeInArray, is_nullable<TypeInArray>::value,
typename is_nullable<TypeInArray>::Type, -1>;
};
template <typename T, typename TypeInArray>
struct _Deserialisable<T, true, -1, TypeInArray, false, void, -1> {
using Type = _DeserialisableType<T, true, -1, TypeInArray, false, void,
is_string<TypeInArray>::value>;
};
template <typename T, typename TypeInArray, typename TypeInNullable>
struct _Deserialisable<T, true, -1, TypeInArray, true, TypeInNullable, -1> {
using Type = _DeserialisableType<T, true, -1, TypeInArray, true, TypeInNullable,
is_string<TypeInNullable>::value>;
};
// Strings
template <typename StringType>
struct _Deserialisable<StringType, false, -1, void, false, void, true> {
using Type = Impl::String<StringType>;
};
template <typename T, typename StringType>
struct _Deserialisable<T, false, -1, void, true, StringType, true> {
using Type = Impl::NullableString<T, StringType>;
};
template <typename T, typename TypeInNullable>
struct _Deserialisable<T, false, -1, void, true, TypeInNullable, false> {
using Type = Impl::Nullable<T, TypeInNullable>;
};
// Containers
template <typename T, typename StringType>
struct _Deserialisable<T, true, -1, StringType, false, void, true> {
using Type = Impl::StringArray<T, StringType>;
};
template <typename T, typename Nullable, typename StringType>
struct _Deserialisable<T, true, -1, Nullable, true, StringType, true> {
using Type = Impl::NullableStringArray<T, Nullable, StringType>;
};
template <typename ArrayType, typename T>
struct _Deserialisable<ArrayType, true, -1, T, false, void, false> {
using Type = Impl::Array<ArrayType, T>;
};
template <typename ArrayType, typename T, int N>
struct _Deserialisable<ArrayType, true, N, T, -1, void, -1> {
using Type = Impl::LimitedArray<ArrayType, T, N>;
};
template <typename T, typename StringType, int N>
struct _Deserialisable<T, true, N, StringType, false, void, true> {
using Type = Impl::LimitedStringArray<T, StringType, N>;
};
template <typename T, typename Nullable, typename StringType, int N>
struct _Deserialisable<T, true, N, Nullable, true, StringType, true> {
using Type = Impl::LimitedNullableStringArray<T, Nullable, StringType, N>;
};
template <typename TypeInArray, std::size_t N>
struct Deserialisable<TypeInArray[N]>
: public LimitedArrayInfo<TypeInArray[N], TypeInArray, N> {};
template <typename TypeInArray, std::size_t N>
struct Deserialisable<std::array<TypeInArray, N>>
: public LimitedArrayInfo<std::array<TypeInArray, N>, TypeInArray, N> {};
template <typename T, typename Alloc>
struct Deserialisable<std::vector<T, Alloc>> : public ArrayTypeInfo<std::vector<T, Alloc>, T> {
};
template <typename T, typename Alloc>
struct Deserialisable<std::list<T, Alloc>> : public ArrayTypeInfo<std::list<T, Alloc>, T> {};
template <typename T, typename Comp, typename Alloc>
struct Deserialisable<std::set<T, Comp, Alloc>>
: public ArrayTypeInfo<std::set<T, Comp, Alloc>, T> {};
template <typename Key, typename Value, typename Comp, typename Alloc>
struct Deserialisable<std::map<Key, Value, Comp, Alloc>>
: public Impl::MapTypeInfo<std::map<Key, Value, Comp, Alloc>, Key, Value> {};
template <typename First, typename Second>
struct Deserialisable<std::pair<First, Second>> {
using Type = Impl::Pair<std::pair<First, Second>, First, Second>;
};
// Basic Types
template <>
struct Deserialisable<bool> {
using Type = Impl::Boolean;
};
template <>
struct Deserialisable<int32_t> {
using Type = Impl::Integer<true, 4>;
};
template <>
struct Deserialisable<uint32_t> {
using Type = Impl::Integer<false, 4>;
};
template <>
struct Deserialisable<int64_t> {
using Type = Impl::Integer<true, 8>;
};
template <>
struct Deserialisable<uint64_t> {
using Type = Impl::Integer<false, 8>;
};
template <>
struct Deserialisable<double> {
using Type = Impl::Real<double>;
};
template <size_t length>
struct Deserialisable<char[length]> {
using Type = Impl::String<char[length]>;
};
// Reflection Informations
template <typename T>
struct DefinedObject;
template <typename T>
struct DefinedExtension;
template <typename T>
struct DefinedExtensionBase;
template <auto member_ptr>
struct RegisteredJsonKey;
template <auto member_ptr>
struct RegisteredExtension;
template <auto member_ptr>
struct RegisteredExtensionBase;
template <auto member_ptr>
struct RegisteredStyleInfo;
template <auto member_ptr,
typename Inc =
typename ConstexprIncArray<RegisteredStyleInfo<member_ptr>::argc>::Type>
struct RegisteredStyle;
} // namespace JsonDeserialise::@LIB_ID@Private
#endif // JSON_DESERIALISER_@LIB_ID@_TYPE_BASIC_