-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmacros.h.in
87 lines (81 loc) · 6.67 KB
/
macros.h.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
#ifndef JSON_DESERIALISER_@LIB_ID@PrivateMACROS
#define JSON_DESERIALISER_@LIB_ID@PrivateMACROS
#include "macros.hpp"
#define @lib@_declare_object(object_type, ...) \
namespace JsonDeserialise::@LIB_ID@Private { \
declare_object_body(object_type, declare_object_process(object_type, __VA_ARGS__)); \
}
#define @lib@_declare_object_with_base_class(object_type, base_type, ...) \
namespace JsonDeserialise::@LIB_ID@Private { \
declare_object_with_base_class_body(object_type, base_type, \
declare_object_process(object_type, __VA_ARGS__)); \
}
#define @lib@_declare_class_with_json_constructor_and_serialiser(object_type) \
namespace JsonDeserialise::@LIB_ID@Private { \
template <> \
struct Deserialisable<object_type> { \
using Type = Impl::SelfDeserialisableObject<object_type>; \
}; \
}
#define @lib@_declare_as_trivial(type_name, as) \
namespace JsonDeserialise::@LIB_ID@Private { \
template <> \
struct Deserialisable<type_name> { \
using Type = Impl::AsTrivial<type_name, as>; \
}; \
}
#define @lib@_declare_enum_as(type_name, as) @lib@_declare_as_trivial(type_name, as)
#define @lib@_declare_enum(type_name) \
namespace JsonDeserialise::@LIB_ID@Private { \
template <> \
struct Deserialisable<type_name> { \
using AsType = typename Impl::Integer<true, sizeof(type_name)>::Target; \
using Type = Impl::AsTrivial<type_name, AsType>; \
}; \
}
#define @lib@_declare_named_extension(name, target_type, convertor, deconvertor) \
namespace JsonDeserialise::@LIB_ID@Private::Extension { \
namespace ExtensionBase { \
using name = decltype(Impl::Extension(convertor, deconvertor, *(target_type*)nullptr)); \
} \
struct name : public ExtensionBase::name { \
using Base = ExtensionBase::name; \
template <typename... Args> \
name(Args&&... args) : Base(convertor, deconvertor, std::forward<Args>(args)...) {} \
}; \
}
#define @lib@_declare_default_extension(target_type, convertor, deconvertor) \
namespace JsonDeserialise::@LIB_ID@Private { \
template <> \
struct DefinedExtensionBase<target_type> { \
using Type = decltype(Impl::Extension(convertor, deconvertor, *(target_type*)nullptr)); \
}; \
template <> \
struct DefinedExtension<target_type> : public DefinedExtensionBase<target_type>::Type { \
using Base = typename DefinedExtensionBase<target_type>::Type; \
template <typename... Args> \
DefinedExtension(Args&&... args) \
: Base(convertor, deconvertor, std::forward<Args>(args)...) {} \
}; \
template <> \
struct Deserialisable<target_type> { \
using Type = DefinedExtension<target_type>; \
}; \
}
#cmakedefine JSON_DESERIALISER_DEFAULT_MODE
#ifdef JSON_DESERIALISER_DEFAULT_MODE
#define declare_object(object_type, ...) @lib@_declare_object(object_type, __VA_ARGS__)
#define declare_class_with_json_constructor_and_serialiser(object_type) \
@lib@_declare_class_with_json_constructor_and_serialiser(object_type)
#define declare_object_with_base_class(object_type, base_type, ...) \
@lib@_declare_object_with_base_class(object_type, base_type, __VA_ARGS__)
#define declare_as_trivial(type_name, as) @lib@_declare_as_trivial(type_name, as)
#define declare_enum(type_name) @lib@_declare_enum(type_name)
#define declare_enum_as(type_name, as) @lib@_declare_enum_as(type_name, as)
#define declare_default_extension(target_type, convertor, deconvertor) \
@lib@_declare_default_extension(target_type, convertor, deconvertor)
#define declare_named_extension(name, target_type, convertor, deconvertor) \
@lib@_declare_named_extension(name, target_type, convertor, deconvertor)
#endif // JSON_DESERIALISER_DEFAULT_MODE
#undef JSON_DESERIALISER_DEFAULT_MODE
#endif // JSON_DESERIALISER_@LIB_ID@PrivateMACROS