4 #include <nlohmann/thirdparty/hedley/hedley.hpp>
10 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
11 #if defined(__clang__)
12 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
13 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
15 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
16 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
17 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
23 #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
24 #define JSON_HAS_CPP_17
25 #define JSON_HAS_CPP_14
26 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
27 #define JSON_HAS_CPP_14
31 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wfloat-equal"
37 #if defined(__clang__)
38 #pragma GCC diagnostic push
39 #pragma GCC diagnostic ignored "-Wdocumentation"
43 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
44 #define JSON_THROW(exception) throw exception
46 #define JSON_CATCH(exception) catch(exception)
47 #define JSON_INTERNAL_CATCH(exception) catch(exception)
50 #define JSON_THROW(exception) std::abort()
51 #define JSON_TRY if(true)
52 #define JSON_CATCH(exception) if(false)
53 #define JSON_INTERNAL_CATCH(exception) if(false)
57 #if defined(JSON_THROW_USER)
59 #define JSON_THROW JSON_THROW_USER
61 #if defined(JSON_TRY_USER)
63 #define JSON_TRY JSON_TRY_USER
65 #if defined(JSON_CATCH_USER)
67 #define JSON_CATCH JSON_CATCH_USER
68 #undef JSON_INTERNAL_CATCH
69 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
71 #if defined(JSON_INTERNAL_CATCH_USER)
72 #undef JSON_INTERNAL_CATCH
73 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
81 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
82 template<typename BasicJsonType> \
83 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
85 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
86 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
87 auto it = std::find_if(std::begin(m), std::end(m), \
88 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
90 return ej_pair.first == e; \
92 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
94 template<typename BasicJsonType> \
95 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
97 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
98 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
99 auto it = std::find_if(std::begin(m), std::end(m), \
100 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
102 return ej_pair.second == j; \
104 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
110 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
111 template<template<typename, typename, typename...> class ObjectType, \
112 template<typename, typename...> class ArrayType, \
113 class StringType, class BooleanType, class NumberIntegerType, \
114 class NumberUnsignedType, class NumberFloatType, \
115 template<typename> class AllocatorType, \
116 template<typename, typename = void> class JSONSerializer>
118 #define NLOHMANN_BASIC_JSON_TPL \
119 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
120 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
121 AllocatorType, JSONSerializer>