1 #ifndef REFLECTIVE_RAPIDJSON_TRAITS
2 #define REFLECTIVE_RAPIDJSON_TRAITS
4 #include <c++utilities/misc/traits.h>
9 #include <unordered_map>
10 #include <unordered_set>
15 namespace Traits = ::CppUtilities::Traits;
25 template <
typename T>
struct TreatAsSet :
public Traits::Bool<false> {
31 #define REFLECTIVE_RAPIDJSON_TREAT_AS_MAP_OR_HASH(T) \
32 template <> struct TreatAsMapOrHash<T> : public Traits::Bool<true> { \
34 #define REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_MAP_OR_HASH(T) \
35 template <> struct TreatAsMultiMapOrHash<T> : public Traits::Bool<true> { \
37 #define REFLECTIVE_RAPIDJSON_TREAT_AS_SET(T) \
38 template <> struct TreatAsSet<T> : public Traits::Bool<true> { \
40 #define REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_SET(T) \
41 template <> struct TreatAsMultiSet<T> : public Traits::Bool<true> { \
45 template <
typename Type>
47 = Traits::Any<Traits::IsSpecializationOf<Type, std::map>, Traits::IsSpecializationOf<Type, std::unordered_map>,
TreatAsMapOrHash<Type>>;
48 template <
typename Type>
49 using IsMultiMapOrHash = Traits::Any<Traits::IsSpecializationOf<Type, std::multimap>, Traits::IsSpecializationOf<Type, std::unordered_multimap>,
51 template <
typename Type>
52 using IsSet = Traits::Any<Traits::IsSpecializationOf<Type, std::set>, Traits::IsSpecializationOf<Type, std::unordered_set>,
TreatAsSet<Type>>;
53 template <
typename Type>
55 = Traits::Any<Traits::IsSpecializationOf<Type, std::multiset>, Traits::IsSpecializationOf<Type, std::unordered_multiset>,
TreatAsMultiSet<Type>>;
56 template <
typename Type>
58 Traits::All<Traits::IsIteratable<Type>, Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>,
59 Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string_view>>, Traits::Not<IsMapOrHash<Type>>, Traits::Not<IsMultiMapOrHash<Type>>>,
61 template <
typename Type>
62 using IsArray = Traits::All<Traits::IsIteratable<Type>, Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>,
63 Traits::Not<IsMapOrHash<Type>>, Traits::Not<IsMultiMapOrHash<Type>>, Traits::Not<IsSet<Type>>, Traits::Not<IsMultiSet<Type>>>;
64 template <
typename Type>
65 using IsIteratableExceptString = Traits::All<Traits::IsIteratable<Type>, Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>,
66 Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>>;
67 template <
typename Type>
using IsVariant = Traits::All<Traits::IsSpecializationOf<Type, std::variant>>;
71 #endif // REFLECTIVE_RAPIDJSON_TRAITS