|
|
@@ -1,7 +1,7 @@ |
|
|
|
/* |
|
|
|
__ _____ _____ _____ |
|
|
|
__| | __| | | | JSON for Modern C++ |
|
|
|
| | |__ | | | | | | version 3.7.0 |
|
|
|
| | |__ | | | | | | version 3.7.1 |
|
|
|
|_____|_____|_____|_|___| https://github.com/nlohmann/json |
|
|
|
|
|
|
|
Licensed under the MIT License <http://opensource.org/licenses/MIT>. |
|
|
@@ -32,7 +32,7 @@ SOFTWARE. |
|
|
|
|
|
|
|
#define NLOHMANN_JSON_VERSION_MAJOR 3 |
|
|
|
#define NLOHMANN_JSON_VERSION_MINOR 7 |
|
|
|
#define NLOHMANN_JSON_VERSION_PATCH 0 |
|
|
|
#define NLOHMANN_JSON_VERSION_PATCH 1 |
|
|
|
|
|
|
|
#include <algorithm> // all_of, find, for_each |
|
|
|
#include <cassert> // assert |
|
|
@@ -122,11 +122,11 @@ struct position_t |
|
|
|
* SPDX-License-Identifier: CC0-1.0 |
|
|
|
*/ |
|
|
|
|
|
|
|
#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 9) |
|
|
|
#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 11) |
|
|
|
#if defined(JSON_HEDLEY_VERSION) |
|
|
|
#undef JSON_HEDLEY_VERSION |
|
|
|
#endif |
|
|
|
#define JSON_HEDLEY_VERSION 9 |
|
|
|
#define JSON_HEDLEY_VERSION 11 |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_STRINGIFY_EX) |
|
|
|
#undef JSON_HEDLEY_STRINGIFY_EX |
|
|
@@ -493,12 +493,29 @@ struct position_t |
|
|
|
#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) |
|
|
|
#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE |
|
|
|
#endif |
|
|
|
#if defined(__has_cpp_attribute) && defined(__cplusplus) |
|
|
|
#if \ |
|
|
|
defined(__has_cpp_attribute) && \ |
|
|
|
defined(__cplusplus) && \ |
|
|
|
(!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) |
|
|
|
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) |
|
|
|
#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS |
|
|
|
#endif |
|
|
|
#if !defined(__cplusplus) || !defined(__has_cpp_attribute) |
|
|
|
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) |
|
|
|
#elif \ |
|
|
|
!defined(JSON_HEDLEY_PGI_VERSION) && \ |
|
|
|
(!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ |
|
|
|
(!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) |
|
|
|
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) |
|
|
|
#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE |
|
|
|
#endif |
|
|
@@ -652,6 +669,21 @@ struct position_t |
|
|
|
#define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
|
|
|
#endif |
|
|
|
|
|
|
|
/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for |
|
|
|
HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ |
|
|
|
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ |
|
|
|
#endif |
|
|
|
#if defined(__cplusplus) && JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") |
|
|
|
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ |
|
|
|
JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
|
|
|
_Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ |
|
|
|
xpr \ |
|
|
|
JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
#else |
|
|
|
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x |
|
|
|
#endif |
|
|
|
|
|
|
|
#if \ |
|
|
|
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ |
|
|
|
defined(__clang__) || \ |
|
|
@@ -752,6 +784,27 @@ struct position_t |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES |
|
|
|
#endif |
|
|
|
#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") |
|
|
|
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") |
|
|
|
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") |
|
|
|
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) |
|
|
|
#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") |
|
|
|
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") |
|
|
|
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL |
|
|
|
#endif |
|
|
@@ -772,8 +825,8 @@ struct position_t |
|
|
|
#undef JSON_HEDLEY_DEPRECATED_FOR |
|
|
|
#endif |
|
|
|
#if defined(__cplusplus) && (__cplusplus >= 201402L) |
|
|
|
#define JSON_HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] |
|
|
|
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] |
|
|
|
#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) |
|
|
|
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) |
|
|
|
#elif \ |
|
|
|
JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ |
|
|
|
JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ |
|
|
@@ -798,7 +851,7 @@ struct position_t |
|
|
|
#elif \ |
|
|
|
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ |
|
|
|
JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) |
|
|
|
#define JSON_HEDLEY_DEPRECATED(since) _declspec(deprecated) |
|
|
|
#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) |
|
|
|
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) |
|
|
|
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
|
|
|
#define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") |
|
|
@@ -824,7 +877,7 @@ struct position_t |
|
|
|
#undef JSON_HEDLEY_WARN_UNUSED_RESULT |
|
|
|
#endif |
|
|
|
#if defined(__cplusplus) && (__cplusplus >= 201703L) |
|
|
|
#define JSON_HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] |
|
|
|
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) |
|
|
|
#elif \ |
|
|
|
JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ |
|
|
|
JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ |
|
|
@@ -863,7 +916,7 @@ struct position_t |
|
|
|
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
|
|
|
#define JSON_HEDLEY_NO_RETURN _Noreturn |
|
|
|
#elif defined(__cplusplus) && (__cplusplus >= 201103L) |
|
|
|
#define JSON_HEDLEY_NO_RETURN [[noreturn]] |
|
|
|
#define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) |
|
|
|
#elif \ |
|
|
|
JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ |
|
|
|
JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ |
|
|
@@ -873,6 +926,8 @@ struct position_t |
|
|
|
JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ |
|
|
|
(JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) |
|
|
|
#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) |
|
|
|
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
|
|
|
#define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") |
|
|
|
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) |
|
|
|
#define JSON_HEDLEY_NO_RETURN __declspec(noreturn) |
|
|
|
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) |
|
|
@@ -885,6 +940,15 @@ struct position_t |
|
|
|
#define JSON_HEDLEY_NO_RETURN |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_NO_ESCAPE) |
|
|
|
#undef JSON_HEDLEY_NO_ESCAPE |
|
|
|
#endif |
|
|
|
#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) |
|
|
|
#define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_NO_ESCAPE |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_UNREACHABLE) |
|
|
|
#undef JSON_HEDLEY_UNREACHABLE |
|
|
|
#endif |
|
|
@@ -941,11 +1005,14 @@ struct position_t |
|
|
|
#define JSON_HEDLEY_ASSUME(expr) ((void) (expr)) |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
JSON_HEDLEY_DIAGNOSTIC_PUSH |
|
|
|
#if \ |
|
|
|
JSON_HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ |
|
|
|
JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) |
|
|
|
#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") |
|
|
|
#pragma clang diagnostic ignored "-Wpedantic" |
|
|
|
#endif |
|
|
|
#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) |
|
|
|
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" |
|
|
|
#endif |
|
|
|
#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) |
|
|
|
#if defined(__clang__) |
|
|
|
#pragma clang diagnostic ignored "-Wvariadic-macros" |
|
|
|
#elif defined(JSON_HEDLEY_GCC_VERSION) |
|
|
@@ -993,7 +1060,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
#endif |
|
|
|
#if defined(__cplusplus) |
|
|
|
#if __cplusplus >= 201103L |
|
|
|
#define JSON_HEDLEY_CONSTEXPR constexpr |
|
|
|
#define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#if !defined(JSON_HEDLEY_CONSTEXPR) |
|
|
@@ -1073,6 +1140,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ |
|
|
|
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) |
|
|
|
#define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) |
|
|
|
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
|
|
|
#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") |
|
|
|
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) |
|
|
|
#define JSON_HEDLEY_MALLOC __declspec(restrict) |
|
|
|
#else |
|
|
@@ -1093,6 +1162,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
|
|
|
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) |
|
|
|
#define JSON_HEDLEY_PURE __attribute__((__pure__)) |
|
|
|
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
|
|
|
#define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") |
|
|
|
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) |
|
|
|
#define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") |
|
|
|
#else |
|
|
@@ -1113,6 +1184,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
|
|
|
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) |
|
|
|
#define JSON_HEDLEY_CONST __attribute__((__const__)) |
|
|
|
#elif \ |
|
|
|
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
|
|
|
#define JSON_HEDLEY_CONST _Pragma("no_side_effect") |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_CONST JSON_HEDLEY_PURE |
|
|
|
#endif |
|
|
@@ -1263,28 +1337,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
#if defined(JSON_HEDLEY_FALL_THROUGH) |
|
|
|
#undef JSON_HEDLEY_FALL_THROUGH |
|
|
|
#endif |
|
|
|
#if \ |
|
|
|
defined(__cplusplus) && \ |
|
|
|
(!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ |
|
|
|
!defined(JSON_HEDLEY_PGI_VERSION) |
|
|
|
#if \ |
|
|
|
(__cplusplus >= 201703L) || \ |
|
|
|
((__cplusplus >= 201103L) && JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH [[fallthrough]] |
|
|
|
#elif (__cplusplus >= 201103L) && JSON_HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH [[clang::fallthrough]] |
|
|
|
#elif (__cplusplus >= 201103L) && JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH [[gnu::fallthrough]] |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#if !defined(JSON_HEDLEY_FALL_THROUGH) |
|
|
|
#if JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION) |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) |
|
|
|
#elif defined(__fallthrough) /* SAL */ |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH __fallthrough |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH |
|
|
|
#endif |
|
|
|
#if JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION) |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) |
|
|
|
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) |
|
|
|
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) |
|
|
|
#elif defined(__fallthrough) /* SAL */ |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH __fallthrough |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_FALL_THROUGH |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_RETURNS_NON_NULL) |
|
|
@@ -1320,12 +1382,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) |
|
|
|
#undef JSON_HEDLEY_REQUIRE_CONSTEXPR |
|
|
|
#endif |
|
|
|
/* Note the double-underscore. For internal use only; no API |
|
|
|
* guarantees! */ |
|
|
|
#if defined(JSON_HEDLEY__IS_CONSTEXPR) |
|
|
|
#undef JSON_HEDLEY__IS_CONSTEXPR |
|
|
|
/* JSON_HEDLEY_IS_CONSTEXPR_ is for |
|
|
|
HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ |
|
|
|
#if defined(JSON_HEDLEY_IS_CONSTEXPR_) |
|
|
|
#undef JSON_HEDLEY_IS_CONSTEXPR_ |
|
|
|
#endif |
|
|
|
|
|
|
|
#if \ |
|
|
|
JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ |
|
|
|
JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ |
|
|
@@ -1334,7 +1395,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
|
|
|
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ |
|
|
|
JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ |
|
|
|
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ |
|
|
|
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ |
|
|
|
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) |
|
|
|
#define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) |
|
|
|
#endif |
|
|
@@ -1348,10 +1409,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ |
|
|
|
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) |
|
|
|
#if defined(__INTPTR_TYPE__) |
|
|
|
#define JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) |
|
|
|
#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) |
|
|
|
#else |
|
|
|
#include <stdint.h> |
|
|
|
#define JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) |
|
|
|
#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) |
|
|
|
#endif |
|
|
|
# elif \ |
|
|
|
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ |
|
|
@@ -1361,10 +1422,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ |
|
|
|
JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) |
|
|
|
#if defined(__INTPTR_TYPE__) |
|
|
|
#define JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) |
|
|
|
#define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) |
|
|
|
#else |
|
|
|
#include <stdint.h> |
|
|
|
#define JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) |
|
|
|
#define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) |
|
|
|
#endif |
|
|
|
# elif \ |
|
|
|
defined(JSON_HEDLEY_GCC_VERSION) || \ |
|
|
@@ -1372,7 +1433,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
defined(JSON_HEDLEY_TINYC_VERSION) || \ |
|
|
|
defined(JSON_HEDLEY_TI_VERSION) || \ |
|
|
|
defined(__clang__) |
|
|
|
# define JSON_HEDLEY__IS_CONSTEXPR(expr) ( \ |
|
|
|
# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ |
|
|
|
sizeof(void) != \ |
|
|
|
sizeof(*( \ |
|
|
|
1 ? \ |
|
|
@@ -1383,11 +1444,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
) |
|
|
|
# endif |
|
|
|
#endif |
|
|
|
#if defined(JSON_HEDLEY__IS_CONSTEXPR) |
|
|
|
#if defined(JSON_HEDLEY_IS_CONSTEXPR_) |
|
|
|
#if !defined(JSON_HEDLEY_IS_CONSTANT) |
|
|
|
#define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY__IS_CONSTEXPR(expr) |
|
|
|
#define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) |
|
|
|
#endif |
|
|
|
#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) |
|
|
|
#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) |
|
|
|
#else |
|
|
|
#if !defined(JSON_HEDLEY_IS_CONSTANT) |
|
|
|
#define JSON_HEDLEY_IS_CONSTANT(expr) (0) |
|
|
@@ -1427,12 +1488,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
) |
|
|
|
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) |
|
|
|
#elif \ |
|
|
|
(defined(__cplusplus) && (__cplusplus >= 201703L)) || \ |
|
|
|
(defined(__cplusplus) && (__cplusplus >= 201103L)) || \ |
|
|
|
JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ |
|
|
|
(defined(__cplusplus) && JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) |
|
|
|
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) |
|
|
|
#elif defined(__cplusplus) && (__cplusplus >= 201103L) |
|
|
|
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) |
|
|
|
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) |
|
|
|
#else |
|
|
|
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) |
|
|
|
#endif |
|
|
@@ -1483,6 +1542,23 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
#define JSON_HEDLEY_CPP_CAST(T, expr) (expr) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_NULL) |
|
|
|
#undef JSON_HEDLEY_NULL |
|
|
|
#endif |
|
|
|
#if defined(__cplusplus) |
|
|
|
#if __cplusplus >= 201103L |
|
|
|
#define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) |
|
|
|
#elif defined(NULL) |
|
|
|
#define JSON_HEDLEY_NULL NULL |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) |
|
|
|
#endif |
|
|
|
#elif defined(NULL) |
|
|
|
#define JSON_HEDLEY_NULL NULL |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_NULL ((void*) 0) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_MESSAGE) |
|
|
|
#undef JSON_HEDLEY_MESSAGE |
|
|
|
#endif |
|
|
@@ -1525,28 +1601,33 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_REQUIRE) |
|
|
|
#undef JSON_HEDLEY_REQUIRE |
|
|
|
#endif |
|
|
|
#if defined(JSON_HEDLEY_REQUIRE_MSG) |
|
|
|
#undef JSON_HEDLEY_REQUIRE_MSG |
|
|
|
#endif |
|
|
|
#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) |
|
|
|
# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") |
|
|
|
# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ |
|
|
|
# define JSON_HEDLEY_REQUIRE(expr) \ |
|
|
|
JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
|
|
|
_Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ |
|
|
|
__attribute__((diagnose_if(!(expr), #expr, "error"))) \ |
|
|
|
JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ |
|
|
|
JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
|
|
|
_Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ |
|
|
|
__attribute__((__diagnose_if__(!(expr), msg, "error"))) \ |
|
|
|
__attribute__((diagnose_if(!(expr), msg, "error"))) \ |
|
|
|
JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
# else |
|
|
|
# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) |
|
|
|
# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) |
|
|
|
# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) |
|
|
|
# endif |
|
|
|
#else |
|
|
|
# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) |
|
|
|
# define JSON_HEDLEY_REQUIRE(expr) |
|
|
|
# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_REQUIRE) |
|
|
|
#undef JSON_HEDLEY_REQUIRE |
|
|
|
#endif |
|
|
|
#define JSON_HEDLEY_REQUIRE(expr) JSON_HEDLEY_REQUIRE_MSG(expr, #expr) |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_FLAGS) |
|
|
|
#undef JSON_HEDLEY_FLAGS |
|
|
|
#endif |
|
|
@@ -1568,6 +1649,15 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_EMPTY_BASES) |
|
|
|
#undef JSON_HEDLEY_EMPTY_BASES |
|
|
|
#endif |
|
|
|
#if JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0) |
|
|
|
#define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) |
|
|
|
#else |
|
|
|
#define JSON_HEDLEY_EMPTY_BASES |
|
|
|
#endif |
|
|
|
|
|
|
|
/* Remaining macros are deprecated. */ |
|
|
|
|
|
|
|
#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) |
|
|
@@ -1692,30 +1782,30 @@ JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
@def NLOHMANN_JSON_SERIALIZE_ENUM |
|
|
|
@since version 3.4.0 |
|
|
|
*/ |
|
|
|
#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ |
|
|
|
template<typename BasicJsonType> \ |
|
|
|
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ |
|
|
|
{ \ |
|
|
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ |
|
|
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ |
|
|
|
auto it = std::find_if(std::begin(m), std::end(m), \ |
|
|
|
[e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ |
|
|
|
{ \ |
|
|
|
return ej_pair.first == e; \ |
|
|
|
}); \ |
|
|
|
j = ((it != std::end(m)) ? it : std::begin(m))->second; \ |
|
|
|
} \ |
|
|
|
template<typename BasicJsonType> \ |
|
|
|
inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ |
|
|
|
{ \ |
|
|
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ |
|
|
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ |
|
|
|
auto it = std::find_if(std::begin(m), std::end(m), \ |
|
|
|
[j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ |
|
|
|
{ \ |
|
|
|
return ej_pair.second == j; \ |
|
|
|
}); \ |
|
|
|
e = ((it != std::end(m)) ? it : std::begin(m))->first; \ |
|
|
|
#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ |
|
|
|
template<typename BasicJsonType> \ |
|
|
|
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ |
|
|
|
{ \ |
|
|
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ |
|
|
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ |
|
|
|
auto it = std::find_if(std::begin(m), std::end(m), \ |
|
|
|
[e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ |
|
|
|
{ \ |
|
|
|
return ej_pair.first == e; \ |
|
|
|
}); \ |
|
|
|
j = ((it != std::end(m)) ? it : std::begin(m))->second; \ |
|
|
|
} \ |
|
|
|
template<typename BasicJsonType> \ |
|
|
|
inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ |
|
|
|
{ \ |
|
|
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ |
|
|
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ |
|
|
|
auto it = std::find_if(std::begin(m), std::end(m), \ |
|
|
|
[&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ |
|
|
|
{ \ |
|
|
|
return ej_pair.second == j; \ |
|
|
|
}); \ |
|
|
|
e = ((it != std::end(m)) ? it : std::begin(m))->first; \ |
|
|
|
} |
|
|
|
|
|
|
|
// Ugly macros to avoid uglier copy-paste when specializing basic_json. They |
|
|
@@ -2704,6 +2794,19 @@ struct is_compatible_type_impl < |
|
|
|
template <typename BasicJsonType, typename CompatibleType> |
|
|
|
struct is_compatible_type |
|
|
|
: is_compatible_type_impl<BasicJsonType, CompatibleType> {}; |
|
|
|
|
|
|
|
// https://en.cppreference.com/w/cpp/types/conjunction |
|
|
|
template<class...> struct conjunction : std::true_type { }; |
|
|
|
template<class B1> struct conjunction<B1> : B1 { }; |
|
|
|
template<class B1, class... Bn> |
|
|
|
struct conjunction<B1, Bn...> |
|
|
|
: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {}; |
|
|
|
|
|
|
|
template <typename T1, typename T2> |
|
|
|
struct is_constructible_tuple : std::false_type {}; |
|
|
|
|
|
|
|
template <typename T1, typename... Args> |
|
|
|
struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<std::is_constructible<T1, Args>...> {}; |
|
|
|
} // namespace detail |
|
|
|
} // namespace nlohmann |
|
|
|
|
|
|
@@ -2922,7 +3025,7 @@ void from_json(const BasicJsonType& j, std::valarray<T>& l) |
|
|
|
JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); |
|
|
|
} |
|
|
|
l.resize(j.size()); |
|
|
|
std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l)); |
|
|
|
std::copy(j.begin(), j.end(), std::begin(l)); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename BasicJsonType, typename T, std::size_t N> |
|
|
@@ -3186,6 +3289,11 @@ namespace nlohmann |
|
|
|
{ |
|
|
|
namespace detail |
|
|
|
{ |
|
|
|
template<typename string_type> |
|
|
|
void int_to_string( string_type& target, std::size_t value ) |
|
|
|
{ |
|
|
|
target = std::to_string(value); |
|
|
|
} |
|
|
|
template <typename IteratorType> class iteration_proxy_value |
|
|
|
{ |
|
|
|
public: |
|
|
@@ -3194,6 +3302,7 @@ template <typename IteratorType> class iteration_proxy_value |
|
|
|
using pointer = value_type * ; |
|
|
|
using reference = value_type & ; |
|
|
|
using iterator_category = std::input_iterator_tag; |
|
|
|
using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type; |
|
|
|
|
|
|
|
private: |
|
|
|
/// the iterator |
|
|
@@ -3203,9 +3312,9 @@ template <typename IteratorType> class iteration_proxy_value |
|
|
|
/// last stringified array index |
|
|
|
mutable std::size_t array_index_last = 0; |
|
|
|
/// a string representation of the array index |
|
|
|
mutable std::string array_index_str = "0"; |
|
|
|
mutable string_type array_index_str = "0"; |
|
|
|
/// an empty string (to return a reference for primitive values) |
|
|
|
const std::string empty_str = ""; |
|
|
|
const string_type empty_str = ""; |
|
|
|
|
|
|
|
public: |
|
|
|
explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {} |
|
|
@@ -3238,7 +3347,7 @@ template <typename IteratorType> class iteration_proxy_value |
|
|
|
} |
|
|
|
|
|
|
|
/// return key of the iterator |
|
|
|
const std::string& key() const |
|
|
|
const string_type& key() const |
|
|
|
{ |
|
|
|
assert(anchor.m_object != nullptr); |
|
|
|
|
|
|
@@ -3249,7 +3358,7 @@ template <typename IteratorType> class iteration_proxy_value |
|
|
|
{ |
|
|
|
if (array_index != array_index_last) |
|
|
|
{ |
|
|
|
array_index_str = std::to_string(array_index); |
|
|
|
int_to_string( array_index_str, array_index ); |
|
|
|
array_index_last = array_index; |
|
|
|
} |
|
|
|
return array_index_str; |
|
|
@@ -3489,7 +3598,10 @@ struct external_constructor<value_t::array> |
|
|
|
j.m_type = value_t::array; |
|
|
|
j.m_value = value_t::array; |
|
|
|
j.m_value.array->resize(arr.size()); |
|
|
|
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); |
|
|
|
if (arr.size() > 0) |
|
|
|
{ |
|
|
|
std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); |
|
|
|
} |
|
|
|
j.assert_invariant(); |
|
|
|
} |
|
|
|
}; |
|
|
@@ -3634,8 +3746,8 @@ void to_json(BasicJsonType& j, const T(&arr)[N]) |
|
|
|
external_constructor<value_t::array>::construct(j, arr); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename BasicJsonType, typename... Args> |
|
|
|
void to_json(BasicJsonType& j, const std::pair<Args...>& p) |
|
|
|
template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 > |
|
|
|
void to_json(BasicJsonType& j, const std::pair<T1, T2>& p) |
|
|
|
{ |
|
|
|
j = { p.first, p.second }; |
|
|
|
} |
|
|
@@ -3654,10 +3766,10 @@ void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> |
|
|
|
j = { std::get<Idx>(t)... }; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename BasicJsonType, typename... Args> |
|
|
|
void to_json(BasicJsonType& j, const std::tuple<Args...>& t) |
|
|
|
template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int > = 0> |
|
|
|
void to_json(BasicJsonType& j, const T& t) |
|
|
|
{ |
|
|
|
to_json_tuple_impl(j, t, index_sequence_for<Args...> {}); |
|
|
|
to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value> {}); |
|
|
|
} |
|
|
|
|
|
|
|
struct to_json_fn |
|
|
@@ -3882,9 +3994,8 @@ class input_stream_adapter : public input_adapter_protocol |
|
|
|
class input_buffer_adapter : public input_adapter_protocol |
|
|
|
{ |
|
|
|
public: |
|
|
|
JSON_HEDLEY_NON_NULL(2) |
|
|
|
input_buffer_adapter(const char* b, const std::size_t l) noexcept |
|
|
|
: cursor(b), limit(b + l) |
|
|
|
: cursor(b), limit(b == nullptr ? nullptr : (b + l)) |
|
|
|
{} |
|
|
|
|
|
|
|
// delete because of pointer members |
|
|
@@ -3898,6 +4009,7 @@ class input_buffer_adapter : public input_adapter_protocol |
|
|
|
{ |
|
|
|
if (JSON_HEDLEY_LIKELY(cursor < limit)) |
|
|
|
{ |
|
|
|
assert(cursor != nullptr and limit != nullptr); |
|
|
|
return std::char_traits<char>::to_int_type(*(cursor++)); |
|
|
|
} |
|
|
|
|
|
|
@@ -5675,7 +5787,7 @@ class binary_reader |
|
|
|
const int exp = (half >> 10u) & 0x1Fu; |
|
|
|
const unsigned int mant = half & 0x3FFu; |
|
|
|
assert(0 <= exp and exp <= 32); |
|
|
|
assert(0 <= mant and mant <= 1024); |
|
|
|
assert(mant <= 1024); |
|
|
|
switch (exp) |
|
|
|
{ |
|
|
|
case 0: |
|
|
@@ -6957,7 +7069,7 @@ class binary_reader |
|
|
|
/*! |
|
|
|
@param[in] format the current format |
|
|
|
@param[in] detail a detailed error message |
|
|
|
@param[in] context further contect information |
|
|
|
@param[in] context further context information |
|
|
|
@return a message string to use in the parse_error exceptions |
|
|
|
*/ |
|
|
|
std::string exception_message(const input_format_t format, |
|
|
@@ -9315,8 +9427,8 @@ class iter_impl |
|
|
|
/*! |
|
|
|
@brief const copy constructor |
|
|
|
@param[in] other const iterator to copy from |
|
|
|
@note This copy constuctor had to be defined explicitely to circumvent a bug |
|
|
|
occuring on msvc v19.0 compiler (VS 2015) debug build. For more |
|
|
|
@note This copy constructor had to be defined explicitly to circumvent a bug |
|
|
|
occurring on msvc v19.0 compiler (VS 2015) debug build. For more |
|
|
|
information refer to: https://github.com/nlohmann/json/issues/1608 |
|
|
|
*/ |
|
|
|
iter_impl(const iter_impl<const BasicJsonType>& other) noexcept |
|
|
@@ -10088,7 +10200,7 @@ class json_pointer |
|
|
|
/*! |
|
|
|
@brief append an array index at the end of this JSON pointer |
|
|
|
|
|
|
|
@param[in] array_index array index ot append |
|
|
|
@param[in] array_index array index to append |
|
|
|
@return JSON pointer with @a array_index appended |
|
|
|
|
|
|
|
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} |
|
|
@@ -10229,7 +10341,7 @@ class json_pointer |
|
|
|
|
|
|
|
@since version 3.6.0 |
|
|
|
*/ |
|
|
|
const std::string& back() |
|
|
|
const std::string& back() const |
|
|
|
{ |
|
|
|
if (JSON_HEDLEY_UNLIKELY(empty())) |
|
|
|
{ |
|
|
@@ -12041,13 +12153,12 @@ class binary_writer |
|
|
|
*/ |
|
|
|
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value) |
|
|
|
{ |
|
|
|
std::size_t embedded_document_size = 0ul; |
|
|
|
std::size_t array_index = 0ul; |
|
|
|
|
|
|
|
for (const auto& el : value) |
|
|
|
const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), 0ul, [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) |
|
|
|
{ |
|
|
|
embedded_document_size += calc_bson_element_size(std::to_string(array_index++), el); |
|
|
|
} |
|
|
|
return result + calc_bson_element_size(std::to_string(array_index++), el); |
|
|
|
}); |
|
|
|
|
|
|
|
return sizeof(std::int32_t) + embedded_document_size + 1ul; |
|
|
|
} |
|
|
@@ -12868,7 +12979,7 @@ inline cached_power get_cached_power_for_binary_exponent(int e) |
|
|
|
// ==> 2^(q - 1 + alpha) <= c * 2^(e + q) |
|
|
|
// ==> 2^(alpha - e - 1) <= c |
|
|
|
// |
|
|
|
// If c were an exakt power of ten, i.e. c = 10^k, one may determine k as |
|
|
|
// If c were an exact power of ten, i.e. c = 10^k, one may determine k as |
|
|
|
// |
|
|
|
// k = ceil( log_10( 2^(alpha - e - 1) ) ) |
|
|
|
// = ceil( (alpha - e - 1) * log_10(2) ) |
|
|
@@ -14264,7 +14375,7 @@ class serializer |
|
|
|
if (is_negative) |
|
|
|
{ |
|
|
|
*buffer_ptr = '-'; |
|
|
|
abs_value = static_cast<number_unsigned_t>(std::abs(static_cast<std::intmax_t>(x))); |
|
|
|
abs_value = remove_sign(x); |
|
|
|
|
|
|
|
// account one more byte for the minus sign |
|
|
|
n_chars = 1 + count_digits(abs_value); |
|
|
@@ -14445,6 +14556,32 @@ class serializer |
|
|
|
return state; |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* Overload to make the compiler happy while it is instantiating |
|
|
|
* dump_integer for number_unsigned_t. |
|
|
|
* Must never be called. |
|
|
|
*/ |
|
|
|
number_unsigned_t remove_sign(number_unsigned_t x) |
|
|
|
{ |
|
|
|
assert(false); // LCOV_EXCL_LINE |
|
|
|
return x; // LCOV_EXCL_LINE |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* Helper function for dump_integer |
|
|
|
* |
|
|
|
* This function takes a negative signed integer and returns its absolute |
|
|
|
* value as unsigned integer. The plus/minus shuffling is necessary as we can |
|
|
|
* not directly remove the sign of an arbitrary signed integer as the |
|
|
|
* absolute values of INT_MIN and INT_MAX are usually not the same. See |
|
|
|
* #1708 for details. |
|
|
|
*/ |
|
|
|
inline number_unsigned_t remove_sign(number_integer_t x) noexcept |
|
|
|
{ |
|
|
|
assert(x < 0 and x < (std::numeric_limits<number_integer_t>::max)()); |
|
|
|
return static_cast<number_unsigned_t>(-(x + 1)) + 1; |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
/// the output of the serializer |
|
|
|
output_adapter_t<char> o = nullptr; |
|
|
@@ -15359,7 +15496,7 @@ class basic_json |
|
|
|
object = nullptr; // silence warning, see #821 |
|
|
|
if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) |
|
|
|
{ |
|
|
|
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.7.0")); // LCOV_EXCL_LINE |
|
|
|
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.7.1")); // LCOV_EXCL_LINE |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
@@ -17039,11 +17176,11 @@ class basic_json |
|
|
|
detail::has_non_default_from_json<basic_json_t, ValueType>::value, |
|
|
|
int> = 0> |
|
|
|
ValueType get() const noexcept(noexcept( |
|
|
|
JSONSerializer<ValueTypeCV>::from_json(std::declval<const basic_json_t&>()))) |
|
|
|
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>()))) |
|
|
|
{ |
|
|
|
static_assert(not std::is_reference<ValueTypeCV>::value, |
|
|
|
"get() cannot be used with reference types, you might want to use get_ref()"); |
|
|
|
return JSONSerializer<ValueTypeCV>::from_json(*this); |
|
|
|
return JSONSerializer<ValueType>::from_json(*this); |
|
|
|
} |
|
|
|
|
|
|
|
/*! |
|
|
@@ -18416,7 +18553,7 @@ class basic_json |
|
|
|
@since version 3.6.0 |
|
|
|
*/ |
|
|
|
template<typename KeyT, typename std::enable_if< |
|
|
|
not std::is_same<KeyT, json_pointer>::value, int>::type = 0> |
|
|
|
not std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int>::type = 0> |
|
|
|
bool contains(KeyT && key) const |
|
|
|
{ |
|
|
|
return is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end(); |
|
|
@@ -18425,7 +18562,7 @@ class basic_json |
|
|
|
/*! |
|
|
|
@brief check the existence of an element in a JSON object given a JSON pointer |
|
|
|
|
|
|
|
Check wehther the given JSON pointer @a ptr can be resolved in the current |
|
|
|
Check whether the given JSON pointer @a ptr can be resolved in the current |
|
|
|
JSON value. |
|
|
|
|
|
|
|
@note This method can be executed on any JSON value type. |
|
|
@@ -22468,7 +22605,7 @@ struct hash<nlohmann::json> |
|
|
|
/// @note: do not remove the space after '<', |
|
|
|
/// see https://github.com/nlohmann/json/pull/679 |
|
|
|
template<> |
|
|
|
struct less< ::nlohmann::detail::value_t> |
|
|
|
struct less<::nlohmann::detail::value_t> |
|
|
|
{ |
|
|
|
/*! |
|
|
|
@brief compare two value_t enum values |
|
|
@@ -22563,6 +22700,7 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std |
|
|
|
#undef JSON_HEDLEY_ARRAY_PARAM |
|
|
|
#undef JSON_HEDLEY_ASSUME |
|
|
|
#undef JSON_HEDLEY_BEGIN_C_DECLS |
|
|
|
#undef JSON_HEDLEY_C_DECL |
|
|
|
#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE |
|
|
|
#undef JSON_HEDLEY_CLANG_HAS_BUILTIN |
|
|
|
#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE |
|
|
@@ -22575,21 +22713,23 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std |
|
|
|
#undef JSON_HEDLEY_CONCAT |
|
|
|
#undef JSON_HEDLEY_CONCAT_EX |
|
|
|
#undef JSON_HEDLEY_CONST |
|
|
|
#undef JSON_HEDLEY_CONSTEXPR |
|
|
|
#undef JSON_HEDLEY_CONST_CAST |
|
|
|
#undef JSON_HEDLEY_CONSTEXPR |
|
|
|
#undef JSON_HEDLEY_CPP_CAST |
|
|
|
#undef JSON_HEDLEY_CRAY_VERSION |
|
|
|
#undef JSON_HEDLEY_CRAY_VERSION_CHECK |
|
|
|
#undef JSON_HEDLEY_C_DECL |
|
|
|
#undef JSON_HEDLEY_DEPRECATED |
|
|
|
#undef JSON_HEDLEY_DEPRECATED_FOR |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_POP |
|
|
|
#undef JSON_HEDLEY_DIAGNOSTIC_PUSH |
|
|
|
#undef JSON_HEDLEY_DMC_VERSION |
|
|
|
#undef JSON_HEDLEY_DMC_VERSION_CHECK |
|
|
|
#undef JSON_HEDLEY_EMPTY_BASES |
|
|
|
#undef JSON_HEDLEY_EMSCRIPTEN_VERSION |
|
|
|
#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK |
|
|
|
#undef JSON_HEDLEY_END_C_DECLS |
|
|
@@ -22618,6 +22758,7 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std |
|
|
|
#undef JSON_HEDLEY_HAS_ATTRIBUTE |
|
|
|
#undef JSON_HEDLEY_HAS_BUILTIN |
|
|
|
#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE |
|
|
|
#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS |
|
|
|
#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE |
|
|
|
#undef JSON_HEDLEY_HAS_EXTENSION |
|
|
|
#undef JSON_HEDLEY_HAS_FEATURE |
|
|
@@ -22631,15 +22772,18 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std |
|
|
|
#undef JSON_HEDLEY_INTEL_VERSION |
|
|
|
#undef JSON_HEDLEY_INTEL_VERSION_CHECK |
|
|
|
#undef JSON_HEDLEY_IS_CONSTANT |
|
|
|
#undef JSON_HEDLEY_IS_CONSTEXPR_ |
|
|
|
#undef JSON_HEDLEY_LIKELY |
|
|
|
#undef JSON_HEDLEY_MALLOC |
|
|
|
#undef JSON_HEDLEY_MESSAGE |
|
|
|
#undef JSON_HEDLEY_MSVC_VERSION |
|
|
|
#undef JSON_HEDLEY_MSVC_VERSION_CHECK |
|
|
|
#undef JSON_HEDLEY_NEVER_INLINE |
|
|
|
#undef JSON_HEDLEY_NO_ESCAPE |
|
|
|
#undef JSON_HEDLEY_NON_NULL |
|
|
|
#undef JSON_HEDLEY_NO_RETURN |
|
|
|
#undef JSON_HEDLEY_NO_THROW |
|
|
|
#undef JSON_HEDLEY_NULL |
|
|
|
#undef JSON_HEDLEY_PELLES_VERSION |
|
|
|
#undef JSON_HEDLEY_PELLES_VERSION_CHECK |
|
|
|
#undef JSON_HEDLEY_PGI_VERSION |