20#ifndef INCLUDE_NLOHMANN_JSON_HPP_
21#define INCLUDE_NLOHMANN_JSON_HPP_
26#include <initializer_list>
62#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
63 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
64 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
65 #warning "Already included a different version of the library!"
70#define NLOHMANN_JSON_VERSION_MAJOR 3
71#define NLOHMANN_JSON_VERSION_MINOR 12
72#define NLOHMANN_JSON_VERSION_PATCH 0
74#ifndef JSON_DIAGNOSTICS
75 #define JSON_DIAGNOSTICS 0
78#ifndef JSON_DIAGNOSTIC_POSITIONS
79 #define JSON_DIAGNOSTIC_POSITIONS 0
82#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
83 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
87 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
89 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
92#if JSON_DIAGNOSTIC_POSITIONS
93 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
95 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
98#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
99 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
101 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
104#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
105 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
109#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
110#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
111 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
113#define NLOHMANN_JSON_ABI_TAGS \
114 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
115 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
116 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
117 NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
120#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
121 _v ## major ## _ ## minor ## _ ## patch
122#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
123 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
125#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
126#define NLOHMANN_JSON_NAMESPACE_VERSION
128#define NLOHMANN_JSON_NAMESPACE_VERSION \
129 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
130 NLOHMANN_JSON_VERSION_MINOR, \
131 NLOHMANN_JSON_VERSION_PATCH)
135#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
136#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
137 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
139#ifndef NLOHMANN_JSON_NAMESPACE
140#define NLOHMANN_JSON_NAMESPACE \
141 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
142 NLOHMANN_JSON_ABI_TAGS, \
143 NLOHMANN_JSON_NAMESPACE_VERSION)
146#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
147#define NLOHMANN_JSON_NAMESPACE_BEGIN \
150 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
151 NLOHMANN_JSON_ABI_TAGS, \
152 NLOHMANN_JSON_NAMESPACE_VERSION) \
156#ifndef NLOHMANN_JSON_NAMESPACE_END
157#define NLOHMANN_JSON_NAMESPACE_END \
175#include <forward_list>
180#include <type_traits>
181#include <unordered_map>
244#include <type_traits>
289template<
class Default,
291 template<
class...>
class Op,
299template<
class Default,
template<
class...>
class Op,
class... Args>
306template<
template<
class...>
class Op,
class... Args>
309template<
template<
class...>
class Op,
class... Args>
312template<
template<
class...>
class Op,
class... Args>
315template<
class Default,
template<
class...>
class Op,
class... Args>
318template<
class Default,
template<
class...>
class Op,
class... Args>
321template<
class Expected,
template<
class...>
class Op,
class... Args>
324template<
class To,
template<
class...>
class Op,
class... Args>
326 std::is_convertible<
detected_t<Op, Args...>, To>;
347#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
348#if defined(JSON_HEDLEY_VERSION)
349 #undef JSON_HEDLEY_VERSION
351#define JSON_HEDLEY_VERSION 15
353#if defined(JSON_HEDLEY_STRINGIFY_EX)
354 #undef JSON_HEDLEY_STRINGIFY_EX
356#define JSON_HEDLEY_STRINGIFY_EX(x) #x
358#if defined(JSON_HEDLEY_STRINGIFY)
359 #undef JSON_HEDLEY_STRINGIFY
361#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
363#if defined(JSON_HEDLEY_CONCAT_EX)
364 #undef JSON_HEDLEY_CONCAT_EX
366#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
368#if defined(JSON_HEDLEY_CONCAT)
369 #undef JSON_HEDLEY_CONCAT
371#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
373#if defined(JSON_HEDLEY_CONCAT3_EX)
374 #undef JSON_HEDLEY_CONCAT3_EX
376#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
378#if defined(JSON_HEDLEY_CONCAT3)
379 #undef JSON_HEDLEY_CONCAT3
381#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
383#if defined(JSON_HEDLEY_VERSION_ENCODE)
384 #undef JSON_HEDLEY_VERSION_ENCODE
386#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
388#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
389 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
391#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
393#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
394 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
396#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
398#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
399 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
401#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
403#if defined(JSON_HEDLEY_GNUC_VERSION)
404 #undef JSON_HEDLEY_GNUC_VERSION
406#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
407 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
408#elif defined(__GNUC__)
409 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
412#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
413 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
415#if defined(JSON_HEDLEY_GNUC_VERSION)
416 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
418 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
421#if defined(JSON_HEDLEY_MSVC_VERSION)
422 #undef JSON_HEDLEY_MSVC_VERSION
424#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
425 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
426#elif defined(_MSC_FULL_VER) && !defined(__ICL)
427 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
428#elif defined(_MSC_VER) && !defined(__ICL)
429 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
432#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
433 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
435#if !defined(JSON_HEDLEY_MSVC_VERSION)
436 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
437#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
438 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
439#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
440 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
442 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
445#if defined(JSON_HEDLEY_INTEL_VERSION)
446 #undef JSON_HEDLEY_INTEL_VERSION
448#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
449 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
450#elif defined(__INTEL_COMPILER) && !defined(__ICL)
451 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
454#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
455 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
457#if defined(JSON_HEDLEY_INTEL_VERSION)
458 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
460 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
463#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
464 #undef JSON_HEDLEY_INTEL_CL_VERSION
466#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
467 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
470#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
471 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
473#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
474 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
476 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
479#if defined(JSON_HEDLEY_PGI_VERSION)
480 #undef JSON_HEDLEY_PGI_VERSION
482#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
483 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
486#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
487 #undef JSON_HEDLEY_PGI_VERSION_CHECK
489#if defined(JSON_HEDLEY_PGI_VERSION)
490 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
492 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
495#if defined(JSON_HEDLEY_SUNPRO_VERSION)
496 #undef JSON_HEDLEY_SUNPRO_VERSION
498#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
499 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
500#elif defined(__SUNPRO_C)
501 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
502#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
503 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
504#elif defined(__SUNPRO_CC)
505 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
508#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
509 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
511#if defined(JSON_HEDLEY_SUNPRO_VERSION)
512 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
514 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
517#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
518 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
520#if defined(__EMSCRIPTEN__)
521 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
524#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
525 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
527#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
528 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
530 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
533#if defined(JSON_HEDLEY_ARM_VERSION)
534 #undef JSON_HEDLEY_ARM_VERSION
536#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
537 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
538#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
539 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
542#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
543 #undef JSON_HEDLEY_ARM_VERSION_CHECK
545#if defined(JSON_HEDLEY_ARM_VERSION)
546 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
548 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
551#if defined(JSON_HEDLEY_IBM_VERSION)
552 #undef JSON_HEDLEY_IBM_VERSION
554#if defined(__ibmxl__)
555 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
556#elif defined(__xlC__) && defined(__xlC_ver__)
557 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
558#elif defined(__xlC__)
559 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
562#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
563 #undef JSON_HEDLEY_IBM_VERSION_CHECK
565#if defined(JSON_HEDLEY_IBM_VERSION)
566 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
568 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
571#if defined(JSON_HEDLEY_TI_VERSION)
572 #undef JSON_HEDLEY_TI_VERSION
575 defined(__TI_COMPILER_VERSION__) && \
577 defined(__TMS470__) || defined(__TI_ARM__) || \
578 defined(__MSP430__) || \
579 defined(__TMS320C2000__) \
581#if (__TI_COMPILER_VERSION__ >= 16000000)
582 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
586#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
587 #undef JSON_HEDLEY_TI_VERSION_CHECK
589#if defined(JSON_HEDLEY_TI_VERSION)
590 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
592 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
595#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
596 #undef JSON_HEDLEY_TI_CL2000_VERSION
598#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
599 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
602#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
603 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
605#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
606 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
608 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
611#if defined(JSON_HEDLEY_TI_CL430_VERSION)
612 #undef JSON_HEDLEY_TI_CL430_VERSION
614#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
615 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
618#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
619 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
621#if defined(JSON_HEDLEY_TI_CL430_VERSION)
622 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
624 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
627#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
628 #undef JSON_HEDLEY_TI_ARMCL_VERSION
630#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
631 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
634#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
635 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
637#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
638 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
640 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
643#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
644 #undef JSON_HEDLEY_TI_CL6X_VERSION
646#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
647 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
650#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
651 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
653#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
654 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
656 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
659#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
660 #undef JSON_HEDLEY_TI_CL7X_VERSION
662#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
663 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
666#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
667 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
669#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
670 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
672 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
675#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
676 #undef JSON_HEDLEY_TI_CLPRU_VERSION
678#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
679 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
682#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
683 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
685#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
686 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
688 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
691#if defined(JSON_HEDLEY_CRAY_VERSION)
692 #undef JSON_HEDLEY_CRAY_VERSION
695 #if defined(_RELEASE_PATCHLEVEL)
696 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
698 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
702#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
703 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
705#if defined(JSON_HEDLEY_CRAY_VERSION)
706 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
708 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
711#if defined(JSON_HEDLEY_IAR_VERSION)
712 #undef JSON_HEDLEY_IAR_VERSION
714#if defined(__IAR_SYSTEMS_ICC__)
716 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
718 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
722#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
723 #undef JSON_HEDLEY_IAR_VERSION_CHECK
725#if defined(JSON_HEDLEY_IAR_VERSION)
726 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
728 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
731#if defined(JSON_HEDLEY_TINYC_VERSION)
732 #undef JSON_HEDLEY_TINYC_VERSION
734#if defined(__TINYC__)
735 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
738#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
739 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
741#if defined(JSON_HEDLEY_TINYC_VERSION)
742 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
744 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
747#if defined(JSON_HEDLEY_DMC_VERSION)
748 #undef JSON_HEDLEY_DMC_VERSION
751 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
754#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
755 #undef JSON_HEDLEY_DMC_VERSION_CHECK
757#if defined(JSON_HEDLEY_DMC_VERSION)
758 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
760 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
763#if defined(JSON_HEDLEY_COMPCERT_VERSION)
764 #undef JSON_HEDLEY_COMPCERT_VERSION
766#if defined(__COMPCERT_VERSION__)
767 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
770#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
771 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
773#if defined(JSON_HEDLEY_COMPCERT_VERSION)
774 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
776 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
779#if defined(JSON_HEDLEY_PELLES_VERSION)
780 #undef JSON_HEDLEY_PELLES_VERSION
783 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
786#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
787 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
789#if defined(JSON_HEDLEY_PELLES_VERSION)
790 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
792 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
795#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
796 #undef JSON_HEDLEY_MCST_LCC_VERSION
798#if defined(__LCC__) && defined(__LCC_MINOR__)
799 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
802#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
803 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
805#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
806 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
808 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
811#if defined(JSON_HEDLEY_GCC_VERSION)
812 #undef JSON_HEDLEY_GCC_VERSION
815 defined(JSON_HEDLEY_GNUC_VERSION) && \
816 !defined(__clang__) && \
817 !defined(JSON_HEDLEY_INTEL_VERSION) && \
818 !defined(JSON_HEDLEY_PGI_VERSION) && \
819 !defined(JSON_HEDLEY_ARM_VERSION) && \
820 !defined(JSON_HEDLEY_CRAY_VERSION) && \
821 !defined(JSON_HEDLEY_TI_VERSION) && \
822 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
823 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
824 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
825 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
826 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
827 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
828 !defined(__COMPCERT__) && \
829 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
830 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
833#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
834 #undef JSON_HEDLEY_GCC_VERSION_CHECK
836#if defined(JSON_HEDLEY_GCC_VERSION)
837 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
839 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
842#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
843 #undef JSON_HEDLEY_HAS_ATTRIBUTE
846 defined(__has_attribute) && \
848 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
850# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
852# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
855#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
856 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
858#if defined(__has_attribute)
859 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
861 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
864#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
865 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
867#if defined(__has_attribute)
868 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
870 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
873#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
874 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
877 defined(__has_cpp_attribute) && \
878 defined(__cplusplus) && \
879 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
882 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
885#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
886 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
888#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
889 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
891 !defined(JSON_HEDLEY_PGI_VERSION) && \
892 !defined(JSON_HEDLEY_IAR_VERSION) && \
893 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
894 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
895 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
897 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
900#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
901 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
903#if defined(__has_cpp_attribute) && defined(__cplusplus)
904 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
906 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
909#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
910 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
912#if defined(__has_cpp_attribute) && defined(__cplusplus)
913 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
915 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
918#if defined(JSON_HEDLEY_HAS_BUILTIN)
919 #undef JSON_HEDLEY_HAS_BUILTIN
921#if defined(__has_builtin)
922 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
924 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
927#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
928 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
930#if defined(__has_builtin)
931 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
933 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
936#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
937 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
939#if defined(__has_builtin)
940 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
942 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
945#if defined(JSON_HEDLEY_HAS_FEATURE)
946 #undef JSON_HEDLEY_HAS_FEATURE
948#if defined(__has_feature)
949 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
951 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
954#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
955 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
957#if defined(__has_feature)
958 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
960 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
963#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
964 #undef JSON_HEDLEY_GCC_HAS_FEATURE
966#if defined(__has_feature)
967 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
969 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
972#if defined(JSON_HEDLEY_HAS_EXTENSION)
973 #undef JSON_HEDLEY_HAS_EXTENSION
975#if defined(__has_extension)
976 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
978 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
981#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
982 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
984#if defined(__has_extension)
985 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
987 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
990#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
991 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
993#if defined(__has_extension)
994 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
996 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
999#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
1000 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1002#if defined(__has_declspec_attribute)
1003 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1005 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1008#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1009 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1011#if defined(__has_declspec_attribute)
1012 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1014 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1017#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1018 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1020#if defined(__has_declspec_attribute)
1021 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1023 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1026#if defined(JSON_HEDLEY_HAS_WARNING)
1027 #undef JSON_HEDLEY_HAS_WARNING
1029#if defined(__has_warning)
1030 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1032 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1035#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1036 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1038#if defined(__has_warning)
1039 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1041 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1044#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1045 #undef JSON_HEDLEY_GCC_HAS_WARNING
1047#if defined(__has_warning)
1048 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1050 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1054 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1055 defined(__clang__) || \
1056 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1057 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1058 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1059 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1060 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1061 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1062 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1063 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1064 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1065 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1066 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1067 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1068 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1069 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1070 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1071 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1072 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1073#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1074 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1076 #define JSON_HEDLEY_PRAGMA(value)
1079#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1080 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1082#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1083 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1085#if defined(__clang__)
1086 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1087 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1088#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1089 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1090 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1091#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1092 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1093 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1095 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1096 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1097 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1098 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1099#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1100 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1101 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1103 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1104 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1105 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1106 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1107 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1108 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1109 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1110 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1111#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1112 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1113 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1115 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1116 #define JSON_HEDLEY_DIAGNOSTIC_POP
1121#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1122 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1124#if defined(__cplusplus)
1125# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1126# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1127# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1128# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1129 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1130 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1131 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1132 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1134 JSON_HEDLEY_DIAGNOSTIC_POP
1136# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1137 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1138 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1139 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1141 JSON_HEDLEY_DIAGNOSTIC_POP
1144# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1145 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1146 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1148 JSON_HEDLEY_DIAGNOSTIC_POP
1152#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1153 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1156#if defined(JSON_HEDLEY_CONST_CAST)
1157 #undef JSON_HEDLEY_CONST_CAST
1159#if defined(__cplusplus)
1160# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1162 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1163 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1164 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1165# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1166 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1167 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1169 JSON_HEDLEY_DIAGNOSTIC_POP \
1172# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1175#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1176 #undef JSON_HEDLEY_REINTERPRET_CAST
1178#if defined(__cplusplus)
1179 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1181 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1184#if defined(JSON_HEDLEY_STATIC_CAST)
1185 #undef JSON_HEDLEY_STATIC_CAST
1187#if defined(__cplusplus)
1188 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1190 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1193#if defined(JSON_HEDLEY_CPP_CAST)
1194 #undef JSON_HEDLEY_CPP_CAST
1196#if defined(__cplusplus)
1197# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1198# define JSON_HEDLEY_CPP_CAST(T, expr) \
1199 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1200 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1202 JSON_HEDLEY_DIAGNOSTIC_POP
1203# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1204# define JSON_HEDLEY_CPP_CAST(T, expr) \
1205 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1206 _Pragma("diag_suppress=Pe137") \
1207 JSON_HEDLEY_DIAGNOSTIC_POP
1209# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1212# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1215#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1216 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1218#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1219 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1220#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1221 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1222#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1223 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1224#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1225 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1226#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1227 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1228#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1229 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1230#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1232#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1233 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1235 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1236 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1237 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1238 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1239 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1240 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1241 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1242 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1243 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1244 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1245 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1246 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1247#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1248 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1249#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1251#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1253#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1256 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1259#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1260 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1262#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1263 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1264#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1265 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1266#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1267 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1268#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1269 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1270#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1271 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1272#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1273 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1275 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1276 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1277 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1278 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1280#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1282#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1284#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1287 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1290#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1291 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1293#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1295#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1297#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1298 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1299#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1301#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1303#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1305#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1307#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1308 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1310 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1311 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1312 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1314#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1316#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1319 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1322#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1323 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1325#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1327#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1329#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1332 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1335#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1336 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1338#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1339 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1340#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1341 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1342#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1343 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1344#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1345 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1347 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1350#if defined(JSON_HEDLEY_DEPRECATED)
1351 #undef JSON_HEDLEY_DEPRECATED
1353#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1354 #undef JSON_HEDLEY_DEPRECATED_FOR
1357 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1358 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1359 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1360 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1362 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1363 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1364 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1365 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1366 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1367 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1368 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1369 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1370 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1371 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1372 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1373 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1374 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1375 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1376#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1377 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1378 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1380 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1381 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1382 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1383 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1384 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1385 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1386 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1387 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1388 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1389 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1390 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1391 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1392 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1393 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1394 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1395 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1396 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1397 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1399 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1400 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1401 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1402 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1403 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1404#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1405 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1406 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1408 #define JSON_HEDLEY_DEPRECATED(since)
1409 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1412#if defined(JSON_HEDLEY_UNAVAILABLE)
1413 #undef JSON_HEDLEY_UNAVAILABLE
1416 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1417 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1418 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1419 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1420 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1422 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1425#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1426 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1428#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1429 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1432 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1433 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1434 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1435 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1436 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1437 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1438 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1439 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1440 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1441 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1442 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1443 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1444 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1445 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1446 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1447 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1448 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1449 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1451#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1452 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1454#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1455 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1456 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1457#elif defined(_Check_return_)
1458 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1459 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1461 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1462 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1465#if defined(JSON_HEDLEY_SENTINEL)
1466 #undef JSON_HEDLEY_SENTINEL
1469 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1470 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1471 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1472 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1473 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1474 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1476 #define JSON_HEDLEY_SENTINEL(position)
1479#if defined(JSON_HEDLEY_NO_RETURN)
1480 #undef JSON_HEDLEY_NO_RETURN
1482#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1483 #define JSON_HEDLEY_NO_RETURN __noreturn
1485 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1486 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1487 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1488#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1489 #define JSON_HEDLEY_NO_RETURN _Noreturn
1490#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1491 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1493 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1494 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1495 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1496 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1497 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1498 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1499 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1500 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1501 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1502 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1503 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1504 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1505 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1506 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1507 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1508 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1509 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1510 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1511#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1512 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1514 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1515 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1516 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1517#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1518 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1519#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1520 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1521#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1522 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1524 #define JSON_HEDLEY_NO_RETURN
1527#if defined(JSON_HEDLEY_NO_ESCAPE)
1528 #undef JSON_HEDLEY_NO_ESCAPE
1530#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1531 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1533 #define JSON_HEDLEY_NO_ESCAPE
1536#if defined(JSON_HEDLEY_UNREACHABLE)
1537 #undef JSON_HEDLEY_UNREACHABLE
1539#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1540 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1542#if defined(JSON_HEDLEY_ASSUME)
1543 #undef JSON_HEDLEY_ASSUME
1546 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1547 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1548 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1549 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1550#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1551 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1553 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1554 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1555 #if defined(__cplusplus)
1556 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1558 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1562 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1563 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1564 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1565 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1566 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1567 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1568 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1569 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1570#elif defined(JSON_HEDLEY_ASSUME)
1571 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1573#if !defined(JSON_HEDLEY_ASSUME)
1574 #if defined(JSON_HEDLEY_UNREACHABLE)
1575 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1577 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1580#if defined(JSON_HEDLEY_UNREACHABLE)
1582 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1583 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1584 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1586 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1589 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1591#if !defined(JSON_HEDLEY_UNREACHABLE)
1592 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1596#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1597 #pragma clang diagnostic ignored "-Wpedantic"
1599#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1600 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1602#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1603 #if defined(__clang__)
1604 #pragma clang diagnostic ignored "-Wvariadic-macros"
1605 #elif defined(JSON_HEDLEY_GCC_VERSION)
1606 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1609#if defined(JSON_HEDLEY_NON_NULL)
1610 #undef JSON_HEDLEY_NON_NULL
1613 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1614 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1615 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1616 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1617 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1619 #define JSON_HEDLEY_NON_NULL(...)
1623#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1624 #undef JSON_HEDLEY_PRINTF_FORMAT
1626#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1627 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1628#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1629 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1631 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1632 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1633 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1634 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1635 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1636 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1637 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1638 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1639 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1640 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1641 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1642 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1643 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1644 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1645 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1646 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1647 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1648 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1649#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1650 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1652 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1655#if defined(JSON_HEDLEY_CONSTEXPR)
1656 #undef JSON_HEDLEY_CONSTEXPR
1658#if defined(__cplusplus)
1659 #if __cplusplus >= 201103L
1660 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1663#if !defined(JSON_HEDLEY_CONSTEXPR)
1664 #define JSON_HEDLEY_CONSTEXPR
1667#if defined(JSON_HEDLEY_PREDICT)
1668 #undef JSON_HEDLEY_PREDICT
1670#if defined(JSON_HEDLEY_LIKELY)
1671 #undef JSON_HEDLEY_LIKELY
1673#if defined(JSON_HEDLEY_UNLIKELY)
1674 #undef JSON_HEDLEY_UNLIKELY
1676#if defined(JSON_HEDLEY_UNPREDICTABLE)
1677 #undef JSON_HEDLEY_UNPREDICTABLE
1679#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1680 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1683 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1684 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1685 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1686# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1687# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1688# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1689# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1690# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1692 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1693 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1694 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1695 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1696 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1697 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1698 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1699 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1700 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1701 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1702 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1703 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1704 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1705 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1706 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1707 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1708# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1709 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1710# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1712 double hedley_probability_ = (probability); \
1713 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1715# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1717 double hedley_probability_ = (probability); \
1718 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1720# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1721# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1723# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1724# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1725# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1726# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1727# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1729#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1730 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1733#if defined(JSON_HEDLEY_MALLOC)
1734 #undef JSON_HEDLEY_MALLOC
1737 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1738 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1739 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1740 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1741 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1742 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1743 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1744 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1745 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1746 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1747 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1748 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1749 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1750 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1751 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1752 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1753 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1754 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1755 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1756#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1757 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1759 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1760 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1761 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1763 #define JSON_HEDLEY_MALLOC
1766#if defined(JSON_HEDLEY_PURE)
1767 #undef JSON_HEDLEY_PURE
1770 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1771 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1772 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1773 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1774 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1775 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1776 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1777 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1778 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1779 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1780 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1781 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1782 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1783 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1784 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1785 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1786 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1787 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1788 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1789# define JSON_HEDLEY_PURE __attribute__((__pure__))
1790#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1791# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1792#elif defined(__cplusplus) && \
1794 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1795 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1796 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1798# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1800# define JSON_HEDLEY_PURE
1803#if defined(JSON_HEDLEY_CONST)
1804 #undef JSON_HEDLEY_CONST
1807 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1808 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1809 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1810 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1811 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1812 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1813 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1814 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1815 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1816 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1817 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1818 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1819 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1820 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1821 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1822 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1823 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1824 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1825 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1826 #define JSON_HEDLEY_CONST __attribute__((__const__))
1828 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1829 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1831 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1834#if defined(JSON_HEDLEY_RESTRICT)
1835 #undef JSON_HEDLEY_RESTRICT
1837#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1838 #define JSON_HEDLEY_RESTRICT restrict
1840 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1841 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1842 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1843 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1844 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1845 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1846 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1847 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1848 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1849 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1850 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1851 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1852 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1853 defined(__clang__) || \
1854 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1855 #define JSON_HEDLEY_RESTRICT __restrict
1856#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1857 #define JSON_HEDLEY_RESTRICT _Restrict
1859 #define JSON_HEDLEY_RESTRICT
1862#if defined(JSON_HEDLEY_INLINE)
1863 #undef JSON_HEDLEY_INLINE
1866 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1867 (defined(__cplusplus) && (__cplusplus >= 199711L))
1868 #define JSON_HEDLEY_INLINE inline
1870 defined(JSON_HEDLEY_GCC_VERSION) || \
1871 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1872 #define JSON_HEDLEY_INLINE __inline__
1874 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1875 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1876 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1877 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1878 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1879 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1880 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1881 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1882 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1883 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1884 #define JSON_HEDLEY_INLINE __inline
1886 #define JSON_HEDLEY_INLINE
1889#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1890 #undef JSON_HEDLEY_ALWAYS_INLINE
1893 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1894 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1895 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1896 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1897 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1898 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1899 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1900 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1901 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1902 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1903 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1904 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1905 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1906 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1907 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1908 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1909 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1910 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1911 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1912# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1914 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1915 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1916# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1917#elif defined(__cplusplus) && \
1919 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1920 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1921 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1922 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1923 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1924 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1926# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1927#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1928# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1930# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1933#if defined(JSON_HEDLEY_NEVER_INLINE)
1934 #undef JSON_HEDLEY_NEVER_INLINE
1937 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1938 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1939 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1940 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1941 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1942 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1943 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1944 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1945 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1946 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1947 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1948 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1949 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1950 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1951 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1952 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1953 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1954 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1955 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1956 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1958 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1959 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1960 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1961#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1962 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1963#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1964 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1965#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1966 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1967#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1968 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1969#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1970 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1972 #define JSON_HEDLEY_NEVER_INLINE
1975#if defined(JSON_HEDLEY_PRIVATE)
1976 #undef JSON_HEDLEY_PRIVATE
1978#if defined(JSON_HEDLEY_PUBLIC)
1979 #undef JSON_HEDLEY_PUBLIC
1981#if defined(JSON_HEDLEY_IMPORT)
1982 #undef JSON_HEDLEY_IMPORT
1984#if defined(_WIN32) || defined(__CYGWIN__)
1985# define JSON_HEDLEY_PRIVATE
1986# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1987# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1990 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1991 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1992 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1993 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1994 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1995 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1997 defined(__TI_EABI__) && \
1999 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
2000 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2003 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2004# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2005# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2007# define JSON_HEDLEY_PRIVATE
2008# define JSON_HEDLEY_PUBLIC
2010# define JSON_HEDLEY_IMPORT extern
2013#if defined(JSON_HEDLEY_NO_THROW)
2014 #undef JSON_HEDLEY_NO_THROW
2017 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2018 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2019 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2020 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2021 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2023 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2024 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2025 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2026 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2028 #define JSON_HEDLEY_NO_THROW
2031#if defined(JSON_HEDLEY_FALL_THROUGH)
2032 #undef JSON_HEDLEY_FALL_THROUGH
2035 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2036 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2037 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2038 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2039#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2040 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2041#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2042 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2043#elif defined(__fallthrough)
2044 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2046 #define JSON_HEDLEY_FALL_THROUGH
2049#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2050 #undef JSON_HEDLEY_RETURNS_NON_NULL
2053 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2054 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2055 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2056 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2057#elif defined(_Ret_notnull_)
2058 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2060 #define JSON_HEDLEY_RETURNS_NON_NULL
2063#if defined(JSON_HEDLEY_ARRAY_PARAM)
2064 #undef JSON_HEDLEY_ARRAY_PARAM
2067 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2068 !defined(__STDC_NO_VLA__) && \
2069 !defined(__cplusplus) && \
2070 !defined(JSON_HEDLEY_PGI_VERSION) && \
2071 !defined(JSON_HEDLEY_TINYC_VERSION)
2072 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2074 #define JSON_HEDLEY_ARRAY_PARAM(name)
2077#if defined(JSON_HEDLEY_IS_CONSTANT)
2078 #undef JSON_HEDLEY_IS_CONSTANT
2080#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2081 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2085#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2086 #undef JSON_HEDLEY_IS_CONSTEXPR_
2089 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2090 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2091 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2092 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2093 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2094 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2095 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2096 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2097 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2098 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2099 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2101#if !defined(__cplusplus)
2103 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2104 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2105 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2106 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2107 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2108 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2109 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2110#if defined(__INTPTR_TYPE__)
2111 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2114 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2118 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2119 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2120 !defined(JSON_HEDLEY_PGI_VERSION) && \
2121 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2122 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2123 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2124 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2125 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2126 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2127#if defined(__INTPTR_TYPE__)
2128 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2131 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2134 defined(JSON_HEDLEY_GCC_VERSION) || \
2135 defined(JSON_HEDLEY_INTEL_VERSION) || \
2136 defined(JSON_HEDLEY_TINYC_VERSION) || \
2137 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2138 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2139 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2140 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2141 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2142 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2144# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2148 ((void*) ((expr) * 0L) ) : \
2149((struct { char v[sizeof(void) * 2]; } *) 1) \
2155#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2156 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2157 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2159 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2161 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2162 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2164 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2167#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2168 #undef JSON_HEDLEY_BEGIN_C_DECLS
2170#if defined(JSON_HEDLEY_END_C_DECLS)
2171 #undef JSON_HEDLEY_END_C_DECLS
2173#if defined(JSON_HEDLEY_C_DECL)
2174 #undef JSON_HEDLEY_C_DECL
2176#if defined(__cplusplus)
2177 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2178 #define JSON_HEDLEY_END_C_DECLS }
2179 #define JSON_HEDLEY_C_DECL extern "C"
2181 #define JSON_HEDLEY_BEGIN_C_DECLS
2182 #define JSON_HEDLEY_END_C_DECLS
2183 #define JSON_HEDLEY_C_DECL
2186#if defined(JSON_HEDLEY_STATIC_ASSERT)
2187 #undef JSON_HEDLEY_STATIC_ASSERT
2190 !defined(__cplusplus) && ( \
2191 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2192 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2193 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2194 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2195 defined(_Static_assert) \
2197# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2199 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2200 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2201 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2202# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2204# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2207#if defined(JSON_HEDLEY_NULL)
2208 #undef JSON_HEDLEY_NULL
2210#if defined(__cplusplus)
2211 #if __cplusplus >= 201103L
2212 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2214 #define JSON_HEDLEY_NULL NULL
2216 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2219 #define JSON_HEDLEY_NULL NULL
2221 #define JSON_HEDLEY_NULL ((void*) 0)
2224#if defined(JSON_HEDLEY_MESSAGE)
2225 #undef JSON_HEDLEY_MESSAGE
2227#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2228# define JSON_HEDLEY_MESSAGE(msg) \
2229 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2230 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2231 JSON_HEDLEY_PRAGMA(message msg) \
2232 JSON_HEDLEY_DIAGNOSTIC_POP
2234 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2235 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2236# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2237#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2238# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2239#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2240# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2241#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2242# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2244# define JSON_HEDLEY_MESSAGE(msg)
2247#if defined(JSON_HEDLEY_WARNING)
2248 #undef JSON_HEDLEY_WARNING
2250#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2251# define JSON_HEDLEY_WARNING(msg) \
2252 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2253 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2254 JSON_HEDLEY_PRAGMA(clang warning msg) \
2255 JSON_HEDLEY_DIAGNOSTIC_POP
2257 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2258 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2259 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2260# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2262 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2263 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2264# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2266# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2269#if defined(JSON_HEDLEY_REQUIRE)
2270 #undef JSON_HEDLEY_REQUIRE
2272#if defined(JSON_HEDLEY_REQUIRE_MSG)
2273 #undef JSON_HEDLEY_REQUIRE_MSG
2275#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2276# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2277# define JSON_HEDLEY_REQUIRE(expr) \
2278 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2279 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2280 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2281 JSON_HEDLEY_DIAGNOSTIC_POP
2282# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2283 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2284 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2285 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2286 JSON_HEDLEY_DIAGNOSTIC_POP
2288# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2289# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2292# define JSON_HEDLEY_REQUIRE(expr)
2293# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2296#if defined(JSON_HEDLEY_FLAGS)
2297 #undef JSON_HEDLEY_FLAGS
2299#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2300 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2302 #define JSON_HEDLEY_FLAGS
2305#if defined(JSON_HEDLEY_FLAGS_CAST)
2306 #undef JSON_HEDLEY_FLAGS_CAST
2308#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2309# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2310 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2311 _Pragma("warning(disable:188)") \
2313 JSON_HEDLEY_DIAGNOSTIC_POP \
2316# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2319#if defined(JSON_HEDLEY_EMPTY_BASES)
2320 #undef JSON_HEDLEY_EMPTY_BASES
2323 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2324 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2325 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2327 #define JSON_HEDLEY_EMPTY_BASES
2332#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2333 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2335#if defined(__clang__)
2336 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2338 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2341#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2342 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2344#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2346#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2347 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2349#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2351#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2352 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2354#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2356#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2357 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2359#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2361#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2362 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2364#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2366#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2367 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2369#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2371#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2372 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2374#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2386#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2387 #if defined(__clang__)
2388 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2389 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2391 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2392 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2393 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2400#if !defined(JSON_HAS_CPP_26) && !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2401 #if (defined(__cplusplus) && __cplusplus > 202302L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202302L)
2402 #define JSON_HAS_CPP_26
2403 #define JSON_HAS_CPP_23
2404 #define JSON_HAS_CPP_20
2405 #define JSON_HAS_CPP_17
2406 #define JSON_HAS_CPP_14
2407 #elif (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
2408 #define JSON_HAS_CPP_23
2409 #define JSON_HAS_CPP_20
2410 #define JSON_HAS_CPP_17
2411 #define JSON_HAS_CPP_14
2412 #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
2413 #define JSON_HAS_CPP_20
2414 #define JSON_HAS_CPP_17
2415 #define JSON_HAS_CPP_14
2416 #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2417 #define JSON_HAS_CPP_17
2418 #define JSON_HAS_CPP_14
2419 #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2420 #define JSON_HAS_CPP_14
2423 #define JSON_HAS_CPP_11
2427 #if __has_include(<version>)
2432#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2433 #ifdef JSON_HAS_CPP_17
2434 #if defined(__cpp_lib_filesystem)
2435 #define JSON_HAS_FILESYSTEM 1
2436 #elif defined(__cpp_lib_experimental_filesystem)
2437 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2438 #elif !defined(__has_include)
2439 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2440 #elif __has_include(<filesystem>)
2441 #define JSON_HAS_FILESYSTEM 1
2442 #elif __has_include(<experimental/filesystem>)
2443 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2447 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2448 #undef JSON_HAS_FILESYSTEM
2449 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2453 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2454 #undef JSON_HAS_FILESYSTEM
2455 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2459 #if defined(__clang_major__) && __clang_major__ < 7
2460 #undef JSON_HAS_FILESYSTEM
2461 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2465 #if defined(_MSC_VER) && _MSC_VER < 1914
2466 #undef JSON_HAS_FILESYSTEM
2467 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2471 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2472 #undef JSON_HAS_FILESYSTEM
2473 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2477 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2478 #undef JSON_HAS_FILESYSTEM
2479 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2484#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2485 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2488#ifndef JSON_HAS_FILESYSTEM
2489 #define JSON_HAS_FILESYSTEM 0
2492#ifndef JSON_HAS_THREE_WAY_COMPARISON
2493 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2494 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2495 #define JSON_HAS_THREE_WAY_COMPARISON 1
2497 #define JSON_HAS_THREE_WAY_COMPARISON 0
2501#ifndef JSON_HAS_RANGES
2503 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2504 #define JSON_HAS_RANGES 0
2505 #elif defined(__cpp_lib_ranges)
2506 #define JSON_HAS_RANGES 1
2508 #define JSON_HAS_RANGES 0
2512#ifndef JSON_HAS_STATIC_RTTI
2513 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2514 #define JSON_HAS_STATIC_RTTI 1
2516 #define JSON_HAS_STATIC_RTTI 0
2520#ifdef JSON_HAS_CPP_17
2521 #define JSON_INLINE_VARIABLE inline
2523 #define JSON_INLINE_VARIABLE
2526#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2527 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2529 #define JSON_NO_UNIQUE_ADDRESS
2533#if defined(__clang__)
2534 #pragma clang diagnostic push
2535 #pragma clang diagnostic ignored "-Wdocumentation"
2536 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2540#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2541 #define JSON_THROW(exception) throw exception
2542 #define JSON_TRY try
2543 #define JSON_CATCH(exception) catch(exception)
2544 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2547 #define JSON_THROW(exception) std::abort()
2548 #define JSON_TRY if(true)
2549 #define JSON_CATCH(exception) if(false)
2550 #define JSON_INTERNAL_CATCH(exception) if(false)
2554#if defined(JSON_THROW_USER)
2556 #define JSON_THROW JSON_THROW_USER
2558#if defined(JSON_TRY_USER)
2560 #define JSON_TRY JSON_TRY_USER
2562#if defined(JSON_CATCH_USER)
2564 #define JSON_CATCH JSON_CATCH_USER
2565 #undef JSON_INTERNAL_CATCH
2566 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2568#if defined(JSON_INTERNAL_CATCH_USER)
2569 #undef JSON_INTERNAL_CATCH
2570 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2574#if !defined(JSON_ASSERT)
2576 #define JSON_ASSERT(x) assert(x)
2580#if defined(JSON_TESTS_PRIVATE)
2581 #define JSON_PRIVATE_UNLESS_TESTED public
2583 #define JSON_PRIVATE_UNLESS_TESTED private
2591#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2592 template<typename BasicJsonType> \
2593 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2596 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2598 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2599 auto it = std::find_if(std::begin(m), std::end(m), \
2600 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2602 return ej_pair.first == e; \
2604 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2606 template<typename BasicJsonType> \
2607 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2610 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2612 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2613 auto it = std::find_if(std::begin(m), std::end(m), \
2614 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2616 return ej_pair.second == j; \
2618 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2624#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2625 template<template<typename, typename, typename...> class ObjectType, \
2626 template<typename, typename...> class ArrayType, \
2627 class StringType, class BooleanType, class NumberIntegerType, \
2628 class NumberUnsignedType, class NumberFloatType, \
2629 template<typename> class AllocatorType, \
2630 template<typename, typename = void> class JSONSerializer, \
2632 class CustomBaseClass>
2634#define NLOHMANN_BASIC_JSON_TPL \
2635 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2636 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2637 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2641#define NLOHMANN_JSON_EXPAND( x ) x
2642#define NLOHMANN_JSON_GET_MACRO(_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, NAME,...) NAME
2643#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2644 NLOHMANN_JSON_PASTE64, \
2645 NLOHMANN_JSON_PASTE63, \
2646 NLOHMANN_JSON_PASTE62, \
2647 NLOHMANN_JSON_PASTE61, \
2648 NLOHMANN_JSON_PASTE60, \
2649 NLOHMANN_JSON_PASTE59, \
2650 NLOHMANN_JSON_PASTE58, \
2651 NLOHMANN_JSON_PASTE57, \
2652 NLOHMANN_JSON_PASTE56, \
2653 NLOHMANN_JSON_PASTE55, \
2654 NLOHMANN_JSON_PASTE54, \
2655 NLOHMANN_JSON_PASTE53, \
2656 NLOHMANN_JSON_PASTE52, \
2657 NLOHMANN_JSON_PASTE51, \
2658 NLOHMANN_JSON_PASTE50, \
2659 NLOHMANN_JSON_PASTE49, \
2660 NLOHMANN_JSON_PASTE48, \
2661 NLOHMANN_JSON_PASTE47, \
2662 NLOHMANN_JSON_PASTE46, \
2663 NLOHMANN_JSON_PASTE45, \
2664 NLOHMANN_JSON_PASTE44, \
2665 NLOHMANN_JSON_PASTE43, \
2666 NLOHMANN_JSON_PASTE42, \
2667 NLOHMANN_JSON_PASTE41, \
2668 NLOHMANN_JSON_PASTE40, \
2669 NLOHMANN_JSON_PASTE39, \
2670 NLOHMANN_JSON_PASTE38, \
2671 NLOHMANN_JSON_PASTE37, \
2672 NLOHMANN_JSON_PASTE36, \
2673 NLOHMANN_JSON_PASTE35, \
2674 NLOHMANN_JSON_PASTE34, \
2675 NLOHMANN_JSON_PASTE33, \
2676 NLOHMANN_JSON_PASTE32, \
2677 NLOHMANN_JSON_PASTE31, \
2678 NLOHMANN_JSON_PASTE30, \
2679 NLOHMANN_JSON_PASTE29, \
2680 NLOHMANN_JSON_PASTE28, \
2681 NLOHMANN_JSON_PASTE27, \
2682 NLOHMANN_JSON_PASTE26, \
2683 NLOHMANN_JSON_PASTE25, \
2684 NLOHMANN_JSON_PASTE24, \
2685 NLOHMANN_JSON_PASTE23, \
2686 NLOHMANN_JSON_PASTE22, \
2687 NLOHMANN_JSON_PASTE21, \
2688 NLOHMANN_JSON_PASTE20, \
2689 NLOHMANN_JSON_PASTE19, \
2690 NLOHMANN_JSON_PASTE18, \
2691 NLOHMANN_JSON_PASTE17, \
2692 NLOHMANN_JSON_PASTE16, \
2693 NLOHMANN_JSON_PASTE15, \
2694 NLOHMANN_JSON_PASTE14, \
2695 NLOHMANN_JSON_PASTE13, \
2696 NLOHMANN_JSON_PASTE12, \
2697 NLOHMANN_JSON_PASTE11, \
2698 NLOHMANN_JSON_PASTE10, \
2699 NLOHMANN_JSON_PASTE9, \
2700 NLOHMANN_JSON_PASTE8, \
2701 NLOHMANN_JSON_PASTE7, \
2702 NLOHMANN_JSON_PASTE6, \
2703 NLOHMANN_JSON_PASTE5, \
2704 NLOHMANN_JSON_PASTE4, \
2705 NLOHMANN_JSON_PASTE3, \
2706 NLOHMANN_JSON_PASTE2, \
2707 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2708#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2709#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2710#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2711#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2712#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2713#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2714#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2715#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2716#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2717#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2718#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2719#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2720#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2721#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2722#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2723#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2724#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2725#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2726#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2727#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2728#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2729#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2730#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2731#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2732#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2733#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2734#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2735#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2736#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2737#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2738#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2739#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2740#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2741#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2742#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2743#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2744#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2745#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2746#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2747#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2748#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2749#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2750#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2751#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2752#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2753#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2754#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2755#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2756#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2757#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2758#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2759#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2760#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2761#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2762#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2763#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2764#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2765#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2766#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2767#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2768#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2769#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2770#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2772#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2773#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2774#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
2782#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2783 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2784 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2785 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2786 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2794#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2795 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2796 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2797 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2798 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2806#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2807 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2808 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2816#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2817 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2818 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2819 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2820 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2828#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2829 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2830 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2831 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2832 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2840#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2841 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2842 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2850#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2851 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2852 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2853 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2854 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2862#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2863 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2864 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2865 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2866 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2874#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2875 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2876 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2884#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2885 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2886 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2887 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2888 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2896#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2897 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2898 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2899 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2900 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2908#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2909 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2910 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2918#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2919 namespace detail { \
2920 using std::std_name; \
2922 template<typename... T> \
2923 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2926 namespace detail2 { \
2927 struct std_name##_tag \
2931 template<typename... T> \
2932 std_name##_tag std_name(T&&...); \
2934 template<typename... T> \
2935 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2937 template<typename... T> \
2938 struct would_call_std_##std_name \
2940 static constexpr auto const value = ::nlohmann::detail:: \
2941 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2945 template<typename... T> \
2946 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2950#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2951 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2954#if JSON_USE_IMPLICIT_CONVERSIONS
2955 #define JSON_EXPLICIT
2957 #define JSON_EXPLICIT explicit
2960#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2961 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2964#ifndef JSON_USE_GLOBAL_UDLS
2965 #define JSON_USE_GLOBAL_UDLS 1
2968#if JSON_HAS_THREE_WAY_COMPARISON
3031#if JSON_HAS_THREE_WAY_COMPARISON
3032 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
3037 static constexpr std::array<std::uint8_t, 9> order = {{
3044 const auto l_index =
static_cast<std::size_t
>(lhs);
3045 const auto r_index =
static_cast<std::size_t
>(rhs);
3046#if JSON_HAS_THREE_WAY_COMPARISON
3047 if (l_index < order.size() && r_index < order.size())
3049 return order[l_index] <=> order[r_index];
3051 return std::partial_ordering::unordered;
3053 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3061#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
3064 return std::is_lt(lhs <=> rhs);
3102template<
typename StringType>
3104 const StringType& t)
3107 for (
auto pos = s.find(f);
3108 pos != StringType::npos;
3109 s.replace(pos, f.size(), t),
3110 pos = s.find(f, pos + t.size()))
3121template<
typename StringType>
3136template<
typename StringType>
3177 constexpr operator size_t()
const
3202#include <type_traits>
3213using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3215#ifdef JSON_HAS_CPP_14
3218using std::enable_if_t;
3219using std::index_sequence;
3220using std::make_index_sequence;
3221using std::index_sequence_for;
3226template<
bool B,
typename T =
void>
3253template <
typename T, T... Ints>
3257 static constexpr std::size_t
size() noexcept
3259 return sizeof...(Ints);
3268template <
size_t... Ints>
3271namespace utility_internal
3274template <
typename Seq,
size_t SeqSize,
size_t Rem>
3278template <
typename T, T... Ints,
size_t SeqSize>
3284template <
typename T, T... Ints,
size_t SeqSize>
3292template <
typename T,
size_t N>
3299template <
typename T>
3314template <
typename T, T N>
3330template <
typename... Ts>
3348#ifndef JSON_HAS_CPP_17
3349 template<
typename T>
3353template<
typename T,
typename... Args>
3354constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3356 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3376#include <type_traits>
3378#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3405template<
typename It,
typename =
void>
3408template<
typename It>
3412 typename It::reference, typename It::iterator_category >>
3423template<
typename T,
typename =
void>
3502#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3503 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3528 template<
typename T =
void,
typename SFINAE =
void>
3533 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3535 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3536 class StringType = std::string,
class BooleanType = bool,
3537 class NumberIntegerType = std::int64_t,
3538 class NumberUnsignedType = std::uint64_t,
3539 class NumberFloatType =
double,
3540 template<
typename U>
class AllocatorType = std::allocator,
3541 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3543 class BinaryType = std::vector<std::uint8_t>,
3544 class CustomBaseClass =
void>
3549 template<
typename RefStringType>
3560 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3605template<
typename BasicJsonContext>
3607 std::integral_constant < bool,
3608 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3609 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3650template<
typename T,
typename... Args>
3653template<
typename T,
typename... Args>
3656template<
typename T,
typename U>
3660template<
typename BasicJsonType,
typename T,
typename =
void>
3667template <
typename BasicJsonType,
typename T>
3673template<
typename BasicJsonType,
typename T>
3676 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3680 const BasicJsonType&, T&>
::value;
3685template<
typename BasicJsonType,
typename T,
typename =
void>
3688template<
typename BasicJsonType,
typename T>
3691 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3700template<
typename BasicJsonType,
typename T,
typename =
void>
3703template<
typename BasicJsonType,
typename T>
3706 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3717struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3720template<
typename BasicJsonType>
3725 using type =
typename std::conditional < has_key_compare<object_t>::value,
3729template<
typename BasicJsonType>
3761 return static_cast<int_type>(std::char_traits<char>::eof());
3785 return static_cast<int_type>(std::char_traits<char>::eof());
3789#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3791struct char_traits<
std::byte> : std::char_traits<char>
3793 using char_type = std::byte;
3794 using int_type = uint64_t;
3796 static int_type to_int_type(char_type c)
noexcept
3798 return static_cast<int_type
>(std::to_integer<unsigned char>(c));
3801 static char_type to_char_type(int_type i)
noexcept
3803 return std::byte(
static_cast<unsigned char>(i));
3806 static constexpr int_type eof() noexcept
3808 return static_cast<int_type
>(std::char_traits<char>::eof());
3820template<
class B,
class... Bn>
3822: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3825template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3830template <
typename T>
3833template <
typename T1,
typename T2>
3835 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3837template <
typename T1,
typename T2>
3839 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3841template <
typename... Ts>
3843 :
conjunction<is_default_constructible<Ts>...> {};
3845template <
typename... Ts>
3847 :
conjunction<is_default_constructible<Ts>...> {};
3849template <
typename T,
typename... Args>
3852template <
typename T1,
typename T2>
3855template <
typename T1,
typename T2>
3858template <
typename... Ts>
3861template <
typename... Ts>
3864template<
typename T,
typename =
void>
3886 using t_ref =
typename std::add_lvalue_reference<T>::type;
3898 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3911template<
typename T,
typename =
void>
3917template<
typename BasicJsonType,
typename CompatibleObjectType,
3921template<
typename BasicJsonType,
typename CompatibleObjectType>
3923 BasicJsonType, CompatibleObjectType,
3932 typename CompatibleObjectType::key_type>
::value &&
3934 typename CompatibleObjectType::mapped_type>
::value;
3937template<
typename BasicJsonType,
typename CompatibleObjectType>
3941template<
typename BasicJsonType,
typename ConstructibleObjectType,
3945template<
typename BasicJsonType,
typename ConstructibleObjectType>
3947 BasicJsonType, ConstructibleObjectType,
3955 (std::is_move_assignable<ConstructibleObjectType>::value ||
3956 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3958 typename object_t::key_type>
::value &&
3960 typename object_t::mapped_type,
3961 typename ConstructibleObjectType::mapped_type >
::value)) ||
3963 typename ConstructibleObjectType::mapped_type>
::value ||
3966 typename ConstructibleObjectType::mapped_type >
::value);
3969template<
typename BasicJsonType,
typename ConstructibleObjectType>
3972 ConstructibleObjectType> {};
3974template<
typename BasicJsonType,
typename CompatibleStringType>
3981template<
typename BasicJsonType,
typename ConstructibleStringType>
3985#ifdef __INTEL_COMPILER
3986 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3998template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
4001template<
typename BasicJsonType,
typename CompatibleArrayType>
4003 BasicJsonType, CompatibleArrayType,
4009 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
4016template<
typename BasicJsonType,
typename CompatibleArrayType>
4020template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
4023template<
typename BasicJsonType,
typename ConstructibleArrayType>
4025 BasicJsonType, ConstructibleArrayType,
4027 typename BasicJsonType::value_type>
::value >>
4028 : std::true_type {};
4030template<
typename BasicJsonType,
typename ConstructibleArrayType>
4032 BasicJsonType, ConstructibleArrayType,
4034 typename BasicJsonType::value_type>
::value&&
4037(std::is_move_assignable<ConstructibleArrayType>::value ||
4038 std::is_copy_assignable<ConstructibleArrayType>::value)&&
4044!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
4046detected_t<range_value_t, ConstructibleArrayType >>
::value >>
4052 typename BasicJsonType::array_t::value_type>
::value ||
4060template<
typename BasicJsonType,
typename ConstructibleArrayType>
4064template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
4068template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4070 RealIntegerType, CompatibleNumberIntegerType,
4072 std::is_integral<CompatibleNumberIntegerType>
::value&&
4073 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
4081 CompatibleNumberIntegerType>
::value &&
4082 CompatibleLimits::is_integer &&
4083 RealLimits::is_signed == CompatibleLimits::is_signed;
4086template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4089 CompatibleNumberIntegerType> {};
4091template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
4094template<
typename BasicJsonType,
typename CompatibleType>
4096 BasicJsonType, CompatibleType,
4103template<
typename BasicJsonType,
typename CompatibleType>
4107template<
typename T1,
typename T2>
4110template<
typename T1,
typename... Args>
4113template<
typename BasicJsonType,
typename T>
4116template<
typename BasicJsonType>
4119template<
typename BasicJsonType>
4124template<
template <
typename...>
class Primary,
typename T>
4127template<
template <
typename...>
class Primary,
typename... Args>
4134template<
typename Compare,
typename A,
typename B,
typename =
void>
4137template<
typename Compare,
typename A,
typename B>
4139decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4140decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4141>> : std::true_type {};
4148template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4152 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4154 && (!RequireTransparentComparator
4155 || is_detected <detect_is_transparent, Comparator>::value)
4158 std::false_type >::type;
4166template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4170 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4171 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4174 std::false_type >::type;
4176template<
typename ObjectType,
typename KeyType>
4180template<
typename BasicJsonType,
typename KeyType>
4184 typename BasicJsonType::object_t, KeyType >
::value,
4186 std::false_type >::type;
4190template <
typename T>
4200 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4203 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
4207template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4210 return static_cast<T
>(
value);
4213template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4219template<
typename... Types>
4222template<
typename... Types>
4225template<
typename... Types>
4229template<
typename... Types>
4233template<
typename OfType,
typename T>
4235 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4238template<
typename OfType,
typename T,
4239 bool OfTypeSigned = std::is_signed<OfType>::value,
4240 bool TSigned = std::is_signed<T>::value>
4243template<
typename OfType,
typename T>
4248 using CommonType =
typename std::common_type<OfType, T>::type;
4249 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4253template<
typename OfType,
typename T>
4258 using CommonType =
typename std::common_type<OfType, T>::type;
4259 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4263template<
typename OfType,
typename T>
4268 using CommonType =
typename std::common_type<OfType, T>::type;
4269 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4273template<
typename OfType,
typename T>
4278 using CommonType =
typename std::common_type<OfType, T>::type;
4279 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4280 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4284template<
typename OfType,
typename T,
4285 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4289template<
typename OfType,
typename T>
4298template<
typename OfType,
typename T>
4307template<
typename OfType,
typename T>
4326 using TUnExt =
typename std::remove_extent<T>::type;
4327 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4328 using TUnPtr =
typename std::remove_pointer<T>::type;
4329 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4331 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4332 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4397template<
typename... Args>
4398inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4400template<
typename StringType,
typename... Args>
4401inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4403template<
typename... Args>
4409template<
typename... Args>
4416template<
typename StringType,
typename... Args>
4422template<
typename OutStringType>
4426template<
typename StringType,
typename Arg>
4429template<
typename StringType,
typename Arg>
4432template<
typename StringType,
typename Arg>
4435template<
typename StringType,
typename Arg>
4438template<
typename StringType,
typename Arg>
4439using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4441template<
typename StringType,
typename Arg>
4444template<
typename StringType,
typename Arg>
4445using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().
data(), std::declval<const Arg&>().size()));
4447template<
typename StringType,
typename Arg>
4450template <
typename OutStringType,
typename Arg,
typename... Args,
4451 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4453inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4455template <
typename OutStringType,
typename Arg,
typename... Args,
4456 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4459inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4461template <
typename OutStringType,
typename Arg,
typename... Args,
4462 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4466inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4468template<
typename OutStringType,
typename Arg,
typename... Args,
4470inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4472 out.append(std::forward<Arg>(arg));
4476template <
typename OutStringType,
typename Arg,
typename... Args,
4477 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4478 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4479inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4481 out += std::forward<Arg>(arg);
4485template <
typename OutStringType,
typename Arg,
typename... Args,
4486 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4487 && !detect_string_can_append_op<OutStringType, Arg>::value
4488 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4489inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4491 out.append(arg.begin(), arg.end());
4495template <
typename OutStringType,
typename Arg,
typename... Args,
4496 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4497 && !detect_string_can_append_op<OutStringType, Arg>::value
4498 && !detect_string_can_append_iter<OutStringType, Arg>::value
4499 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4500inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4502 out.append(arg.data(), arg.size());
4506template<
typename OutStringType = std::string,
typename... Args>
4526#if defined(__clang__)
4527 #pragma clang diagnostic push
4528 #pragma clang diagnostic ignored "-Wweak-vtables"
4545 const char*
what() const noexcept
override
4555 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
4557 static std::string
name(
const std::string& ename,
int id_)
4559 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4567 template<
typename BasicJsonType>
4571 std::vector<std::string> tokens;
4572 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4574 switch (current->m_parent->type())
4578 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4580 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4582 tokens.emplace_back(std::to_string(i));
4591 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4593 if (&element.second == current)
4595 tokens.emplace_back(element.first.c_str());
4620 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4621 [](
const std::string & a,
const std::string & b)
4623 return concat(a,
'/', detail::escape(b));
4634 std::runtime_error
m;
4635#if JSON_DIAGNOSTIC_POSITIONS
4636 template<
typename BasicJsonType>
4639 if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
4641 return concat(
"(bytes ", std::to_string(leaf_element->start_pos()),
"-", std::to_string(leaf_element->end_pos()),
") ");
4646 template<
typename BasicJsonType>
4649 static_cast<void>(leaf_element);
4669 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4677 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4678 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4681 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4683 return {id_, byte_, w.c_str()};
4713 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4717 return {id_, w.c_str()};
4731 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4735 return {id_, w.c_str()};
4748 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4752 return {id_, w.c_str()};
4765 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4769 return {id_, w.c_str()};
4780#if defined(__clang__)
4781 #pragma clang diagnostic pop
4826#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4827#include <experimental/filesystem>
4831namespace std_fs = std::experimental::filesystem;
4834#elif JSON_HAS_FILESYSTEM
4835#include <filesystem>
4839namespace std_fs = std::filesystem;
4852#ifdef JSON_HAS_CPP_17
4856#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4857 #include <string_view>
4864template<
typename BasicJsonType>
4865inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4874#ifdef JSON_HAS_CPP_17
4875template<
typename BasicJsonType,
typename T>
4876void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4884 opt.emplace(j.template get<T>());
4890template <
typename BasicJsonType,
typename ArithmeticType,
4891 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4892 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4896 switch (
static_cast<value_t>(j))
4900 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4905 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4910 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4926template<
typename BasicJsonType>
4927inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4933 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4936template<
typename BasicJsonType>
4937inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4943 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4947 typename BasicJsonType,
typename StringType,
4949 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4950 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4951 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4952 && !is_json_ref<StringType>::value,
int > = 0 >
4960 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4963template<
typename BasicJsonType>
4964inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4969template<
typename BasicJsonType>
4970inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4975template<
typename BasicJsonType>
4976inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4981#if !JSON_DISABLE_ENUM_SERIALIZATION
4982template<
typename BasicJsonType,
typename EnumType,
4983 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4986 typename std::underlying_type<EnumType>::type val;
4988 e =
static_cast<EnumType
>(val);
4993template<
typename BasicJsonType,
typename T,
typename Allocator,
4994 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4995inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
5002 std::transform(j.rbegin(), j.rend(),
5003 std::front_inserter(l), [](
const BasicJsonType & i)
5005 return i.template get<T>();
5010template<
typename BasicJsonType,
typename T,
5011 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
5012inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
5019 std::transform(j.begin(), j.end(), std::begin(l),
5020 [](
const BasicJsonType & elem)
5022 return elem.template get<T>();
5026template<
typename BasicJsonType,
typename T, std::
size_t N>
5028->
decltype(j.template get<T>(), void())
5030 for (std::size_t i = 0; i < N; ++i)
5032 arr[i] = j.at(i).template get<T>();
5036template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2>
5038->
decltype(j.template get<T>(), void())
5040 for (std::size_t i1 = 0; i1 < N1; ++i1)
5042 for (std::size_t i2 = 0; i2 < N2; ++i2)
5044 arr[i1][i2] = j.at(i1).at(i2).template get<T>();
5049template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3>
5051->
decltype(j.template get<T>(), void())
5053 for (std::size_t i1 = 0; i1 < N1; ++i1)
5055 for (std::size_t i2 = 0; i2 < N2; ++i2)
5057 for (std::size_t i3 = 0; i3 < N3; ++i3)
5059 arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template get<T>();
5065template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3, std::
size_t N4>
5066auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3][N4])
5067->
decltype(j.template get<T>(), void())
5069 for (std::size_t i1 = 0; i1 < N1; ++i1)
5071 for (std::size_t i2 = 0; i2 < N2; ++i2)
5073 for (std::size_t i3 = 0; i3 < N3; ++i3)
5075 for (std::size_t i4 = 0; i4 < N4; ++i4)
5077 arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template get<T>();
5084template<
typename BasicJsonType>
5087 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
5090template<
typename BasicJsonType,
typename T, std::
size_t N>
5093->
decltype(j.template get<T>(), void())
5095 for (std::size_t i = 0; i < N; ++i)
5097 arr[i] = j.at(i).template get<T>();
5101template<
typename BasicJsonType,
typename ConstructibleArrayType,
5103 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5107 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
5108 j.template get<typename ConstructibleArrayType::value_type>(),
5113 ConstructibleArrayType ret;
5114 ret.reserve(j.size());
5115 std::transform(j.begin(), j.end(),
5116 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
5120 return i.template get<typename ConstructibleArrayType::value_type>();
5122 arr = std::move(ret);
5125template<
typename BasicJsonType,
typename ConstructibleArrayType,
5127 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5134 ConstructibleArrayType ret;
5136 j.begin(), j.end(), std::inserter(ret, end(ret)),
5137 [](
const BasicJsonType & i)
5141 return i.template get<typename ConstructibleArrayType::value_type>();
5143 arr = std::move(ret);
5146template <
typename BasicJsonType,
typename ConstructibleArrayType,
5148 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
5149 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
5151 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
5152 !is_basic_json<ConstructibleArrayType>::value,
5154auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
5156j.template get<typename ConstructibleArrayType::value_type>(),
5167template <
typename BasicJsonType,
typename T, std::size_t... Idx >
5171 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
5174template <
typename BasicJsonType,
typename T, std::
size_t N >
5186template<
typename BasicJsonType>
5187inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
5194 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5197template<
typename BasicJsonType,
typename ConstructibleObjectType,
5198 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5199inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5206 ConstructibleObjectType ret;
5207 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5208 using value_type =
typename ConstructibleObjectType::value_type;
5210 inner_object->begin(), inner_object->end(),
5211 std::inserter(ret, ret.begin()),
5212 [](
typename BasicJsonType::object_t::value_type
const & p)
5214 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5216 obj = std::move(ret);
5223template <
typename BasicJsonType,
typename ArithmeticType,
5225 std::is_arithmetic<ArithmeticType>::value&&
5226 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5227 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5228 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5229 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5231inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5233 switch (
static_cast<value_t>(j))
5237 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5242 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5247 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5252 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5267template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5270 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5273template<
typename BasicJsonType>
5279template <
typename BasicJsonType,
class A1,
class A2 >
5282 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
5283 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
5286template<
typename BasicJsonType,
typename A1,
typename A2>
5292template<
typename BasicJsonType,
typename... Args>
5298template<
typename BasicJsonType,
typename... Args>
5304template<
typename BasicJsonType,
typename TupleRelated>
5313 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5316template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5318 typename BasicJsonType::string_t, Key >
::value >>
5319inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5326 for (
const auto& p : j)
5332 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5336template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5338 typename BasicJsonType::string_t, Key >
::value >>
5339inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5346 for (
const auto& p : j)
5352 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5356#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5357template<
typename BasicJsonType>
5358inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5364 const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5368#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
5369 p = std_fs::path(std::u8string_view(
reinterpret_cast<const char8_t*
>(s.data()), s.size()));
5371 p = std_fs::u8path(s);
5378 template<
typename BasicJsonType,
typename T>
5380 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5381 ->
decltype(
from_json(j, std::forward<T>(val)))
5383 return from_json(j, std::forward<T>(val));
5389#ifndef JSON_HAS_CPP_17
5398#ifndef JSON_HAS_CPP_17
5417#ifdef JSON_HAS_CPP_17
5426#include <type_traits>
5476template<
typename StringType>
5480 using std::to_string;
5484template<
typename StringType>
5510 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5527 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5537 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5540 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5584 switch (
anchor.m_object->type())
5616 typename IteratorType::reference
value()
const
5658template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5659auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5666template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5667auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5682#if defined(__clang__)
5684 #pragma clang diagnostic push
5685 #pragma clang diagnostic ignored "-Wmismatched-tags"
5687template<
typename IteratorType>
5688class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5689 :
public std::integral_constant<std::size_t, 2> {};
5691template<std::
size_t N,
typename IteratorType>
5692class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5696 get<N>(std::declval <
5697 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5699#if defined(__clang__)
5700 #pragma clang diagnostic pop
5706 template <
typename IteratorType>
5707 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5739 template<
typename BasicJsonType>
5740 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5742 j.m_data.m_value.destroy(j.m_data.m_type);
5744 j.m_data.m_value = b;
5745 j.assert_invariant();
5752 template<
typename BasicJsonType>
5753 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5755 j.m_data.m_value.destroy(j.m_data.m_type);
5757 j.m_data.m_value = s;
5758 j.assert_invariant();
5761 template<
typename BasicJsonType>
5762 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5764 j.m_data.m_value.destroy(j.m_data.m_type);
5766 j.m_data.m_value = std::move(s);
5767 j.assert_invariant();
5770 template <
typename BasicJsonType,
typename CompatibleStringType,
5771 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5773 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5775 j.m_data.m_value.destroy(j.m_data.m_type);
5777 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5778 j.assert_invariant();
5785 template<
typename BasicJsonType>
5786 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5788 j.m_data.m_value.destroy(j.m_data.m_type);
5790 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5791 j.assert_invariant();
5794 template<
typename BasicJsonType>
5795 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5797 j.m_data.m_value.destroy(j.m_data.m_type);
5799 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5800 j.assert_invariant();
5807 template<
typename BasicJsonType>
5808 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5810 j.m_data.m_value.destroy(j.m_data.m_type);
5812 j.m_data.m_value = val;
5813 j.assert_invariant();
5820 template<
typename BasicJsonType>
5821 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5823 j.m_data.m_value.destroy(j.m_data.m_type);
5825 j.m_data.m_value = val;
5826 j.assert_invariant();
5833 template<
typename BasicJsonType>
5834 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5836 j.m_data.m_value.destroy(j.m_data.m_type);
5838 j.m_data.m_value = val;
5839 j.assert_invariant();
5846 template<
typename BasicJsonType>
5847 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5849 j.m_data.m_value.destroy(j.m_data.m_type);
5851 j.m_data.m_value = arr;
5853 j.assert_invariant();
5856 template<
typename BasicJsonType>
5857 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5859 j.m_data.m_value.destroy(j.m_data.m_type);
5861 j.m_data.m_value = std::move(arr);
5863 j.assert_invariant();
5866 template <
typename BasicJsonType,
typename CompatibleArrayType,
5867 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5869 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5874 j.m_data.m_value.destroy(j.m_data.m_type);
5876 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5878 j.assert_invariant();
5881 template<
typename BasicJsonType>
5882 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5884 j.m_data.m_value.destroy(j.m_data.m_type);
5887 j.m_data.m_value.array->reserve(arr.size());
5888 for (
const bool x : arr)
5890 j.m_data.m_value.array->push_back(x);
5891 j.set_parent(j.m_data.m_value.array->back());
5893 j.assert_invariant();
5896 template<
typename BasicJsonType,
typename T,
5898 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5900 j.m_data.m_value.destroy(j.m_data.m_type);
5903 j.m_data.m_value.array->resize(arr.size());
5906 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5909 j.assert_invariant();
5916 template<
typename BasicJsonType>
5917 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5919 j.m_data.m_value.destroy(j.m_data.m_type);
5921 j.m_data.m_value = obj;
5923 j.assert_invariant();
5926 template<
typename BasicJsonType>
5927 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5929 j.m_data.m_value.destroy(j.m_data.m_type);
5931 j.m_data.m_value = std::move(obj);
5933 j.assert_invariant();
5936 template <
typename BasicJsonType,
typename CompatibleObjectType,
5937 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5938 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5943 j.m_data.m_value.destroy(j.m_data.m_type);
5945 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5947 j.assert_invariant();
5955#ifdef JSON_HAS_CPP_17
5956template<
typename BasicJsonType,
typename T,
5957 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
5958void to_json(BasicJsonType& j,
const std::optional<T>& opt)
noexcept
5960 if (opt.has_value())
5971template<
typename BasicJsonType,
typename T,
5972 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5973inline void to_json(BasicJsonType& j, T b)
noexcept
5978template <
typename BasicJsonType,
typename BoolRef,
5980 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5981 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5982 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5984 typename BasicJsonType::boolean_t >
::value))
5985 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5986inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5991template<
typename BasicJsonType,
typename CompatibleString,
5992 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5993inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5998template<
typename BasicJsonType>
5999inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
6004template<
typename BasicJsonType,
typename FloatType,
6005 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
6006inline void to_json(BasicJsonType& j, FloatType val)
noexcept
6011template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
6012 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
6013inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
6018template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
6019 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
6020inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
6025#if !JSON_DISABLE_ENUM_SERIALIZATION
6026template<
typename BasicJsonType,
typename EnumType,
6027 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
6028inline void to_json(BasicJsonType& j, EnumType e)
noexcept
6030 using underlying_type =
typename std::underlying_type<EnumType>::type;
6036template<
typename BasicJsonType>
6037inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
6042template <
typename BasicJsonType,
typename CompatibleArrayType,
6043 enable_if_t < is_compatible_array_type<BasicJsonType,
6045 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
6047 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
6048 !is_basic_json<CompatibleArrayType>::value,
6050inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
6055template<
typename BasicJsonType>
6056inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
6061template<
typename BasicJsonType,
typename T,
6062 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
6063inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
6068template<
typename BasicJsonType>
6069inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
6074template <
typename BasicJsonType,
typename CompatibleObjectType,
6075 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
6076inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
6081template<
typename BasicJsonType>
6082inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6088 typename BasicJsonType,
typename T, std::size_t N,
6089 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
6092inline void to_json(BasicJsonType& j,
const T(&arr)[N])
6097template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
6098inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
6100 j = { p.first, p.second };
6104template<
typename BasicJsonType,
typename T,
6105 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
6108 j = { {b.key(), b.value()} };
6111template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
6114 j = { std::get<Idx>(t)... };
6117template<
typename BasicJsonType,
typename Tuple>
6120 using array_t =
typename BasicJsonType::array_t;
6124template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
6125inline void to_json(BasicJsonType& j,
const T& t)
6130#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
6131#if defined(__cpp_lib_char8_t)
6132template<
typename BasicJsonType,
typename Tr,
typename Allocator>
6133inline void to_json(BasicJsonType& j,
const std::basic_string<char8_t, Tr, Allocator>& s)
6135 using OtherAllocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<char>;
6136 j = std::basic_string<char, std::char_traits<char>, OtherAllocator>(s.begin(), s.end(), s.get_allocator());
6140template<
typename BasicJsonType>
6141inline void to_json(BasicJsonType& j,
const std_fs::path& p)
6151 template<
typename BasicJsonType,
typename T>
6152 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
6153 ->
decltype(
to_json(j, std::forward<T>(val)), void())
6155 return to_json(j, std::forward<T>(val));
6160#ifndef JSON_HAS_CPP_17
6169#ifndef JSON_HAS_CPP_17
6181template<
typename ValueType,
typename>
6186 template<
typename BasicJsonType,
typename TargetType = ValueType>
6187 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
6188 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
6189 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
6191 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
6196 template<
typename BasicJsonType,
typename TargetType = ValueType>
6206 template<
typename BasicJsonType,
typename TargetType = ValueType>
6207 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
6208 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
6209 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
6211 ::nlohmann::to_json(j, std::forward<TargetType>(val));
6239template<
typename BinaryType>
6283 return !(rhs == *
this);
6342#include <functional>
6354inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6356 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6371template<
typename BasicJsonType>
6372std::size_t
hash(
const BasicJsonType& j)
6374 using string_t =
typename BasicJsonType::string_t;
6375 using number_integer_t =
typename BasicJsonType::number_integer_t;
6376 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6377 using number_float_t =
typename BasicJsonType::number_float_t;
6379 const auto type =
static_cast<std::size_t
>(j.type());
6382 case BasicJsonType::value_t::null:
6383 case BasicJsonType::value_t::discarded:
6388 case BasicJsonType::value_t::object:
6390 auto seed =
combine(type, j.size());
6391 for (
const auto& element : j.items())
6393 const auto h = std::hash<string_t> {}(element.key());
6400 case BasicJsonType::value_t::array:
6402 auto seed =
combine(type, j.size());
6403 for (
const auto& element : j)
6410 case BasicJsonType::value_t::string:
6412 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6416 case BasicJsonType::value_t::boolean:
6418 const auto h = std::hash<bool> {}(j.template get<bool>());
6422 case BasicJsonType::value_t::number_integer:
6424 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6428 case BasicJsonType::value_t::number_unsigned:
6430 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6434 case BasicJsonType::value_t::number_float:
6436 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6440 case BasicJsonType::value_t::binary:
6442 auto seed =
combine(type, j.get_binary().size());
6443 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6445 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6446 for (
const auto byte : j.get_binary())
6448 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6485#ifdef __cpp_lib_byteswap
6510#include <type_traits>
6564 return std::fgetc(
m_file);
6571 return fread(dest, 1,
sizeof(T) * count,
m_file);
6599 is->clear(
is->rdstate() & std::ios::eofbit);
6604 :
is(&i),
sb(i.rdbuf())
6613 :
is(rhs.is),
sb(rhs.sb)
6624 auto res =
sb->sbumpc();
6628 is->clear(
is->rdstate() | std::ios::eofbit);
6636 auto res =
static_cast<std::size_t
>(
sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(count *
sizeof(T))));
6639 is->clear(
is->rdstate() | std::ios::eofbit);
6646 std::istream*
is =
nullptr;
6647 std::streambuf*
sb =
nullptr;
6653template<
typename IteratorType>
6657 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6679 auto* ptr =
reinterpret_cast<char*
>(dest);
6680 for (std::size_t read_index = 0; read_index < count *
sizeof(T); ++read_index)
6684 ptr[read_index] =
static_cast<char>(*current);
6692 return count *
sizeof(T);
6699 template<
typename BaseInputAdapter,
size_t T>
6708template<
typename BaseInputAdapter,
size_t T>
6711template<
typename BaseInputAdapter>
6716 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6717 size_t& utf8_bytes_index,
6718 size_t& utf8_bytes_filled)
6720 utf8_bytes_index = 0;
6724 utf8_bytes[0] = std::char_traits<char>::eof();
6725 utf8_bytes_filled = 1;
6730 const auto wc = input.get_character();
6735 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6736 utf8_bytes_filled = 1;
6738 else if (wc <= 0x7FF)
6740 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6741 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6742 utf8_bytes_filled = 2;
6744 else if (wc <= 0xFFFF)
6746 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6747 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6748 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6749 utf8_bytes_filled = 3;
6751 else if (wc <= 0x10FFFF)
6753 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6754 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6755 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6756 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6757 utf8_bytes_filled = 4;
6762 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6763 utf8_bytes_filled = 1;
6769template<
typename BaseInputAdapter>
6774 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6775 size_t& utf8_bytes_index,
6776 size_t& utf8_bytes_filled)
6778 utf8_bytes_index = 0;
6782 utf8_bytes[0] = std::char_traits<char>::eof();
6783 utf8_bytes_filled = 1;
6788 const auto wc = input.get_character();
6793 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6794 utf8_bytes_filled = 1;
6796 else if (wc <= 0x7FF)
6798 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6799 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6800 utf8_bytes_filled = 2;
6802 else if (0xD800 > wc || wc >= 0xE000)
6804 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6805 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6806 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6807 utf8_bytes_filled = 3;
6813 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6814 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6815 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6816 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6817 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6818 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6819 utf8_bytes_filled = 4;
6823 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6824 utf8_bytes_filled = 1;
6832template<
typename BaseInputAdapter,
typename W
ideCharType>
6846 fill_buffer<sizeof(WideCharType)>();
6875 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
6883template<
typename IteratorType,
typename Enable =
void>
6887 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6906template<
typename IteratorType>
6910 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6921template<
typename IteratorType>
6925 return factory_type::create(
first, last);
6932namespace container_input_adapter_factory_impl
6938template<
typename ContainerType,
typename Enable =
void>
6941template<
typename ContainerType>
6943 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6955template<
typename ContainerType>
6968 if (file ==
nullptr)
6970 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
6989template <
typename CharT,
6990 typename std::enable_if <
6991 std::is_pointer<CharT>::value&&
6992 !std::is_array<CharT>::value&&
6993 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6994 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
7000 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
7002 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
7003 const auto* ptr =
reinterpret_cast<const char*
>(b);
7007template<
typename T, std::
size_t N>
7019 template <
typename CharT,
7020 typename std::enable_if <
7021 std::is_pointer<CharT>::value&&
7022 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
7023 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
7026 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
7028 template<
class IteratorType,
7029 typename std::enable_if<
7030 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
7037 return std::move(ia);
7060#include <type_traits>
7082#include <initializer_list>
7104template<
typename BasicJsonType>
7138 return "<uninitialized>";
7140 return "true literal";
7142 return "false literal";
7144 return "null literal";
7146 return "string literal";
7150 return "number literal";
7164 return "<parse error>";
7166 return "end of input";
7168 return "'[', '{', or a literal";
7171 return "unknown token";
7181template<
typename BasicJsonType,
typename InputAdapterType>
7194 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7195 :
ia(
std::move(adapter))
7216 const auto* loc = localeconv();
7218 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7246 const auto factors = { 12u, 8u, 4u, 0u };
7247 for (
const auto factor : factors)
7253 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
7257 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
7261 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
7269 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7290 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7293 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7342 return token_type::parse_error;
7348 return token_type::value_string;
7393 int codepoint = codepoint1;
7397 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7398 return token_type::parse_error;
7402 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7411 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7412 return token_type::parse_error;
7419 codepoint =
static_cast<int>(
7421 (
static_cast<unsigned int>(codepoint1) << 10u)
7423 +
static_cast<unsigned int>(codepoint2)
7431 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7432 return token_type::parse_error;
7437 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7438 return token_type::parse_error;
7445 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7446 return token_type::parse_error;
7451 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7454 if (codepoint < 0x80)
7459 else if (codepoint <= 0x7FF)
7462 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7463 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7465 else if (codepoint <= 0xFFFF)
7468 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7469 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7470 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7475 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7476 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7477 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7478 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7486 error_message =
"invalid string: forbidden character after backslash";
7487 return token_type::parse_error;
7496 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7497 return token_type::parse_error;
7502 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7503 return token_type::parse_error;
7508 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7509 return token_type::parse_error;
7514 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7515 return token_type::parse_error;
7520 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7521 return token_type::parse_error;
7526 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7527 return token_type::parse_error;
7532 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7533 return token_type::parse_error;
7538 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7539 return token_type::parse_error;
7544 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7545 return token_type::parse_error;
7550 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7551 return token_type::parse_error;
7556 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7557 return token_type::parse_error;
7562 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7563 return token_type::parse_error;
7568 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7569 return token_type::parse_error;
7574 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7575 return token_type::parse_error;
7580 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7581 return token_type::parse_error;
7586 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7587 return token_type::parse_error;
7592 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7593 return token_type::parse_error;
7598 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7599 return token_type::parse_error;
7604 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7605 return token_type::parse_error;
7610 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7611 return token_type::parse_error;
7616 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7617 return token_type::parse_error;
7622 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7623 return token_type::parse_error;
7628 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7629 return token_type::parse_error;
7634 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7635 return token_type::parse_error;
7640 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7641 return token_type::parse_error;
7646 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7647 return token_type::parse_error;
7652 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7653 return token_type::parse_error;
7658 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7659 return token_type::parse_error;
7664 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7665 return token_type::parse_error;
7670 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7671 return token_type::parse_error;
7676 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7677 return token_type::parse_error;
7682 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7683 return token_type::parse_error;
7820 return token_type::parse_error;
7830 return token_type::parse_error;
7854 return token_type::parse_error;
7864 return token_type::parse_error;
7874 return token_type::parse_error;
7886 return token_type::parse_error;
7896 return token_type::parse_error;
7905 return token_type::parse_error;
7976 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7983 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7985 f = std::strtof(str, endptr);
7989 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7991 f = std::strtod(str, endptr);
7995 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7997 f = std::strtold(str, endptr);
8047 token_type number_type = token_type::value_unsigned;
8055 goto scan_number_minus;
8061 goto scan_number_zero;
8075 goto scan_number_any1;
8085 number_type = token_type::value_integer;
8091 goto scan_number_zero;
8105 goto scan_number_any1;
8111 return token_type::parse_error;
8123 goto scan_number_decimal1;
8130 goto scan_number_exponent;
8134 goto scan_number_done;
8153 goto scan_number_any1;
8160 goto scan_number_decimal1;
8167 goto scan_number_exponent;
8171 goto scan_number_done;
8174scan_number_decimal1:
8176 number_type = token_type::value_float;
8191 goto scan_number_decimal2;
8197 return token_type::parse_error;
8201scan_number_decimal2:
8217 goto scan_number_decimal2;
8224 goto scan_number_exponent;
8228 goto scan_number_done;
8231scan_number_exponent:
8233 number_type = token_type::value_float;
8240 goto scan_number_sign;
8255 goto scan_number_any2;
8261 "invalid number; expected '+', '-', or digit after exponent";
8262 return token_type::parse_error;
8282 goto scan_number_any2;
8287 error_message =
"invalid number; expected digit after exponent sign";
8288 return token_type::parse_error;
8308 goto scan_number_any2;
8312 goto scan_number_done;
8320 char* endptr =
nullptr;
8324 if (number_type == token_type::value_unsigned)
8326 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
8331 if (errno != ERANGE)
8336 return token_type::value_unsigned;
8340 else if (number_type == token_type::value_integer)
8342 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
8347 if (errno != ERANGE)
8352 return token_type::value_integer;
8364 return token_type::value_float;
8377 for (std::size_t i = 1; i < length; ++i)
8382 return token_type::parse_error;
8477 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8533 if (
static_cast<unsigned char>(c) <=
'\x1F')
8536 std::array<char, 9> cs{{}};
8537 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8538 result += cs.data();
8543 result.push_back(
static_cast<std::string::value_type
>(c));
8570 return get() == 0xBB &&
get() == 0xBF;
8593 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8594 return token_type::parse_error;
8605 return token_type::parse_error;
8616 return token_type::begin_array;
8618 return token_type::end_array;
8620 return token_type::begin_object;
8622 return token_type::end_object;
8624 return token_type::name_separator;
8626 return token_type::value_separator;
8632 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8637 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8642 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8667 return token_type::end_of_input;
8672 return token_type::parse_error;
8729template<
typename BasicJsonType>
8833 const std::string& last_token,
8848 return (std::numeric_limits<std::size_t>::max)();
8864template<
typename BasicJsonType,
typename InputAdapterType>
8881 : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
8893 handle_value(
nullptr);
8929 handle_value(std::move(val));
8935 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
8937#if JSON_DIAGNOSTIC_POSITIONS
8944 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8950 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
8962 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
8971#if JSON_DIAGNOSTIC_POSITIONS
8975 ref_stack.back()->end_position = m_lexer_ref->get_position();
8979 ref_stack.back()->set_parents();
8980 ref_stack.pop_back();
8986 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
8988#if JSON_DIAGNOSTIC_POSITIONS
8993 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8999 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
9010#if JSON_DIAGNOSTIC_POSITIONS
9014 ref_stack.back()->end_position = m_lexer_ref->get_position();
9018 ref_stack.back()->set_parents();
9019 ref_stack.pop_back();
9023 template<
class Exception>
9025 const Exception& ex)
9028 static_cast<void>(ex);
9029 if (allow_exceptions)
9043#if JSON_DIAGNOSTIC_POSITIONS
9044 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9051 v.end_position = m_lexer_ref->get_position();
9055 case value_t::boolean:
9058 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9065 v.start_position = v.end_position - 4;
9069 case value_t::string:
9072 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9081 case value_t::discarded:
9083 v.end_position = std::string::npos;
9084 v.start_position = v.end_position;
9088 case value_t::binary:
9089 case value_t::number_integer:
9090 case value_t::number_unsigned:
9091 case value_t::number_float:
9093 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9096 case value_t::object:
9097 case value_t::array:
9117 template<
typename Value>
9121 if (ref_stack.empty())
9123 root = BasicJsonType(std::forward<Value>(v));
9125#if JSON_DIAGNOSTIC_POSITIONS
9126 handle_diagnostic_positions_for_json_value(root);
9132 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9134 if (ref_stack.back()->is_array())
9136 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
9138#if JSON_DIAGNOSTIC_POSITIONS
9139 handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
9142 return &(ref_stack.back()->m_data.m_value.array->back());
9147 *object_element = BasicJsonType(std::forward<Value>(v));
9149#if JSON_DIAGNOSTIC_POSITIONS
9150 handle_diagnostic_positions_for_json_value(*object_element);
9153 return object_element;
9159 std::vector<BasicJsonType*> ref_stack {};
9161 BasicJsonType* object_element =
nullptr;
9163 bool errored =
false;
9165 const bool allow_exceptions =
true;
9170template<
typename BasicJsonType,
typename InputAdapterType>
9185 const bool allow_exceptions_ =
true,
9187 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9189 keep_stack.push_back(
true);
9201 handle_value(
nullptr);
9237 handle_value(std::move(val));
9244 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
9245 keep_stack.push_back(keep);
9247 auto val = handle_value(BasicJsonType::value_t::object,
true);
9248 ref_stack.push_back(val.second);
9250 if (ref_stack.back())
9253#if JSON_DIAGNOSTIC_POSITIONS
9260 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9267 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
9275 BasicJsonType k = BasicJsonType(val);
9278 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
9279 key_keep_stack.push_back(keep);
9282 if (keep && ref_stack.back())
9284 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
9292 if (ref_stack.back())
9294 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
9299#if JSON_DIAGNOSTIC_POSITIONS
9301 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9307#if JSON_DIAGNOSTIC_POSITIONS
9311 ref_stack.back()->end_position = m_lexer_ref->get_position();
9315 ref_stack.back()->set_parents();
9321 ref_stack.pop_back();
9322 keep_stack.pop_back();
9324 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
9327 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
9329 if (it->is_discarded())
9331 ref_stack.back()->erase(it);
9342 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
9343 keep_stack.push_back(keep);
9345 auto val = handle_value(BasicJsonType::value_t::array,
true);
9346 ref_stack.push_back(val.second);
9348 if (ref_stack.back())
9351#if JSON_DIAGNOSTIC_POSITIONS
9358 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9365 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
9376 if (ref_stack.back())
9378 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
9382#if JSON_DIAGNOSTIC_POSITIONS
9386 ref_stack.back()->end_position = m_lexer_ref->get_position();
9390 ref_stack.back()->set_parents();
9397#if JSON_DIAGNOSTIC_POSITIONS
9399 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9406 ref_stack.pop_back();
9407 keep_stack.pop_back();
9410 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
9412 ref_stack.back()->m_data.m_value.array->pop_back();
9418 template<
class Exception>
9420 const Exception& ex)
9423 static_cast<void>(ex);
9424 if (allow_exceptions)
9438#if JSON_DIAGNOSTIC_POSITIONS
9439 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9446 v.end_position = m_lexer_ref->get_position();
9450 case value_t::boolean:
9453 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9460 v.start_position = v.end_position - 4;
9464 case value_t::string:
9467 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9471 case value_t::discarded:
9473 v.end_position = std::string::npos;
9474 v.start_position = v.end_position;
9478 case value_t::binary:
9479 case value_t::number_integer:
9480 case value_t::number_unsigned:
9481 case value_t::number_float:
9483 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9487 case value_t::object:
9488 case value_t::array:
9517 template<
typename Value>
9518 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
9524 if (!keep_stack.back())
9526 return {
false,
nullptr};
9530 auto value = BasicJsonType(std::forward<Value>(v));
9532#if JSON_DIAGNOSTIC_POSITIONS
9533 handle_diagnostic_positions_for_json_value(value);
9537 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
9542 return {
false,
nullptr};
9545 if (ref_stack.empty())
9547 root = std::move(value);
9548 return {
true, & root};
9553 if (!ref_stack.back())
9555 return {
false,
nullptr};
9559 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9562 if (ref_stack.back()->is_array())
9564 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
9565 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
9572 const bool store_element = key_keep_stack.back();
9573 key_keep_stack.pop_back();
9577 return {
false,
nullptr};
9581 *object_element = std::move(value);
9582 return {
true, object_element};
9588 std::vector<BasicJsonType*> ref_stack {};
9590 std::vector<bool> keep_stack {};
9592 std::vector<bool> key_keep_stack {};
9594 BasicJsonType* object_element =
nullptr;
9596 bool errored =
false;
9600 const bool allow_exceptions =
true;
9602 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
9607template<
typename BasicJsonType>
9721 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9723template<
typename T,
typename Integer>
9725 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9727template<
typename T,
typename Un
signed>
9729 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9731template<
typename T,
typename Float,
typename String>
9733 std::declval<Float>(), std::declval<const String&>()));
9735template<
typename T,
typename String>
9737 decltype(std::declval<T&>().string(std::declval<String&>()));
9739template<
typename T,
typename Binary>
9741 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9745 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9747template<
typename T,
typename String>
9749 decltype(std::declval<T&>().key(std::declval<String&>()));
9756 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9761template<
typename T,
typename Exception>
9763 std::declval<std::size_t>(), std::declval<const std::string&>(),
9764 std::declval<const Exception&>()));
9766template<
typename SAX,
typename BasicJsonType>
9771 "BasicJsonType must be of type basic_json<...>");
9781 static constexpr bool value =
9797template<
typename SAX,
typename BasicJsonType>
9802 "BasicJsonType must be of type basic_json<...>");
9813 "Missing/invalid function: bool null()");
9815 "Missing/invalid function: bool boolean(bool)");
9817 "Missing/invalid function: bool boolean(bool)");
9821 "Missing/invalid function: bool number_integer(number_integer_t)");
9825 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9828 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9831 "Missing/invalid function: bool string(string_t&)");
9834 "Missing/invalid function: bool binary(binary_t&)");
9836 "Missing/invalid function: bool start_object(std::size_t)");
9838 "Missing/invalid function: bool key(string_t&)");
9840 "Missing/invalid function: bool end_object()");
9842 "Missing/invalid function: bool start_array(std::size_t)");
9844 "Missing/invalid function: bool end_array()");
9847 "Missing/invalid function: bool parse_error(std::size_t, const "
9848 "std::string&, const exception&)");
9882 return *
reinterpret_cast<char*
>(&num) == 1;
9892template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
9910 explicit binary_reader(InputAdapterType&& adapter,
const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format)
9933 const
bool strict = true,
9937 bool result =
false;
9941 case input_format_t::bson:
9942 result = parse_bson_internal();
9945 case input_format_t::cbor:
9946 result = parse_cbor_internal(
true, tag_handler);
9949 case input_format_t::msgpack:
9950 result = parse_msgpack_internal();
9953 case input_format_t::ubjson:
9954 case input_format_t::bjdata:
9955 result = parse_ubjson_internal();
9958 case input_format_t::json:
9966 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9977 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
9978 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9996 std::int32_t document_size{};
9997 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10009 return sax->end_object();
10021 auto out = std::back_inserter(result);
10029 if (current == 0x00)
10033 *out++ =
static_cast<typename string_t::value_type
>(current);
10048 template<
typename NumberType>
10053 auto last_token = get_token_string();
10054 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10055 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
10070 template<
typename NumberType>
10075 auto last_token = get_token_string();
10076 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10077 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
10081 std::uint8_t subtype{};
10082 get_number<std::uint8_t>(input_format_t::bson, subtype);
10083 result.set_subtype(subtype);
10085 return get_binary(input_format_t::bson, len, result);
10099 const std::size_t element_type_parse_position)
10101 switch (element_type)
10106 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10111 std::int32_t len{};
10113 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
10118 return parse_bson_internal();
10123 return parse_bson_array();
10128 std::int32_t len{};
10130 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
10135 return sax->boolean(
get() != 0);
10140 return sax->null();
10145 std::int32_t value{};
10146 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10151 std::int64_t value{};
10152 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10157 std::uint64_t value{};
10158 return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
10163 std::array<char, 3> cr{{}};
10164 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
10165 const std::string cr_str{cr.data()};
10166 return sax->parse_error(element_type_parse_position, cr_str,
10167 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
10188 while (
auto element_type =
get())
10195 const std::size_t element_type_parse_position = chars_read;
10201 if (!is_array && !sax->key(
key))
10206 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
10224 std::int32_t document_size{};
10225 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10237 return sax->end_array();
10255 switch (get_char ?
get() : current)
10259 return unexpect_eof(input_format_t::cbor,
"value");
10290 std::uint8_t number{};
10291 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10296 std::uint16_t number{};
10297 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10302 std::uint32_t number{};
10303 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10308 std::uint64_t number{};
10309 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10337 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
10341 std::uint8_t number{};
10342 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
10347 std::uint16_t number{};
10348 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
10353 std::uint32_t number{};
10354 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
10359 std::uint64_t number{};
10360 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1)
10396 return get_cbor_binary(b) && sax->binary(b);
10431 return get_cbor_string(s) && sax->string(s);
10459 return get_cbor_array(
10460 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10464 std::uint8_t len{};
10465 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10470 std::uint16_t len{};
10471 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10476 std::uint32_t len{};
10477 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10482 std::uint64_t len{};
10483 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10514 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10518 std::uint8_t len{};
10519 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10524 std::uint16_t len{};
10525 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10530 std::uint32_t len{};
10531 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10536 std::uint64_t len{};
10537 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10563 switch (tag_handler)
10565 case cbor_tag_handler_t::error:
10567 auto last_token = get_token_string();
10568 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10569 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10572 case cbor_tag_handler_t::ignore:
10579 std::uint8_t subtype_to_ignore{};
10580 get_number(input_format_t::cbor, subtype_to_ignore);
10585 std::uint16_t subtype_to_ignore{};
10586 get_number(input_format_t::cbor, subtype_to_ignore);
10591 std::uint32_t subtype_to_ignore{};
10592 get_number(input_format_t::cbor, subtype_to_ignore);
10597 std::uint64_t subtype_to_ignore{};
10598 get_number(input_format_t::cbor, subtype_to_ignore);
10604 return parse_cbor_internal(
true, tag_handler);
10607 case cbor_tag_handler_t::store:
10615 std::uint8_t subtype{};
10616 get_number(input_format_t::cbor, subtype);
10617 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10622 std::uint16_t subtype{};
10623 get_number(input_format_t::cbor, subtype);
10624 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10629 std::uint32_t subtype{};
10630 get_number(input_format_t::cbor, subtype);
10631 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10636 std::uint64_t subtype{};
10637 get_number(input_format_t::cbor, subtype);
10638 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10642 return parse_cbor_internal(
true, tag_handler);
10645 return get_cbor_binary(b) && sax->binary(b);
10655 return sax->boolean(
false);
10658 return sax->boolean(
true);
10661 return sax->null();
10665 const auto byte1_raw =
get();
10670 const auto byte2_raw =
get();
10676 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10677 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10687 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10688 const double val = [&half]
10690 const int exp = (half >> 10u) & 0x1Fu;
10691 const unsigned int mant = half & 0x3FFu;
10697 return std::ldexp(mant, -24);
10700 ? std::numeric_limits<double>::infinity()
10701 : std::numeric_limits<double>::quiet_NaN();
10703 return std::ldexp(mant + 1024, exp - 25);
10706 return sax->number_float((half & 0x8000u) != 0
10714 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10720 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10725 auto last_token = get_token_string();
10726 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10727 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10778 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10783 std::uint8_t len{};
10784 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10789 std::uint16_t len{};
10790 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10795 std::uint32_t len{};
10796 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10801 std::uint64_t len{};
10802 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10807 while (
get() != 0xFF)
10810 if (!get_cbor_string(chunk))
10814 result.append(chunk);
10821 auto last_token = get_token_string();
10822 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10823 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10874 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10879 std::uint8_t len{};
10880 return get_number(input_format_t::cbor, len) &&
10881 get_binary(input_format_t::cbor, len, result);
10886 std::uint16_t len{};
10887 return get_number(input_format_t::cbor, len) &&
10888 get_binary(input_format_t::cbor, len, result);
10893 std::uint32_t len{};
10894 return get_number(input_format_t::cbor, len) &&
10895 get_binary(input_format_t::cbor, len, result);
10900 std::uint64_t len{};
10901 return get_number(input_format_t::cbor, len) &&
10902 get_binary(input_format_t::cbor, len, result);
10907 while (
get() != 0xFF)
10910 if (!get_cbor_binary(chunk))
10914 result.insert(result.end(), chunk.begin(), chunk.end());
10921 auto last_token = get_token_string();
10922 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10923 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10944 for (std::size_t i = 0; i < len; ++i)
10954 while (
get() != 0xFF)
10963 return sax->end_array();
10985 for (std::size_t i = 0; i < len; ++i)
11002 while (
get() != 0xFF)
11018 return sax->end_object();
11034 return unexpect_eof(input_format_t::msgpack,
"value");
11184 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11203 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11243 return get_msgpack_string(s) && sax->string(s);
11247 return sax->null();
11250 return sax->boolean(
false);
11253 return sax->boolean(
true);
11268 return get_msgpack_binary(b) && sax->binary(b);
11274 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11280 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11285 std::uint8_t number{};
11286 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11291 std::uint16_t number{};
11292 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11297 std::uint32_t number{};
11298 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11303 std::uint64_t number{};
11304 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11309 std::int8_t number{};
11310 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11315 std::int16_t number{};
11316 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11321 std::int32_t number{};
11322 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11327 std::int64_t number{};
11328 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11333 std::uint16_t len{};
11334 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
11339 std::uint32_t len{};
11340 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
11345 std::uint16_t len{};
11346 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
11351 std::uint32_t len{};
11352 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
11388 return sax->number_integer(
static_cast<std::int8_t
>(current));
11392 auto last_token = get_token_string();
11393 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11394 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
11452 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
11457 std::uint8_t len{};
11458 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11463 std::uint16_t len{};
11464 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11469 std::uint32_t len{};
11470 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11475 auto last_token = get_token_string();
11476 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11477 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
11495 auto assign_and_return_true = [&result](std::int8_t subtype)
11497 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
11505 std::uint8_t len{};
11506 return get_number(input_format_t::msgpack, len) &&
11507 get_binary(input_format_t::msgpack, len, result);
11512 std::uint16_t len{};
11513 return get_number(input_format_t::msgpack, len) &&
11514 get_binary(input_format_t::msgpack, len, result);
11519 std::uint32_t len{};
11520 return get_number(input_format_t::msgpack, len) &&
11521 get_binary(input_format_t::msgpack, len, result);
11526 std::uint8_t len{};
11527 std::int8_t subtype{};
11528 return get_number(input_format_t::msgpack, len) &&
11529 get_number(input_format_t::msgpack, subtype) &&
11530 get_binary(input_format_t::msgpack, len, result) &&
11531 assign_and_return_true(subtype);
11536 std::uint16_t len{};
11537 std::int8_t subtype{};
11538 return get_number(input_format_t::msgpack, len) &&
11539 get_number(input_format_t::msgpack, subtype) &&
11540 get_binary(input_format_t::msgpack, len, result) &&
11541 assign_and_return_true(subtype);
11546 std::uint32_t len{};
11547 std::int8_t subtype{};
11548 return get_number(input_format_t::msgpack, len) &&
11549 get_number(input_format_t::msgpack, subtype) &&
11550 get_binary(input_format_t::msgpack, len, result) &&
11551 assign_and_return_true(subtype);
11556 std::int8_t subtype{};
11557 return get_number(input_format_t::msgpack, subtype) &&
11558 get_binary(input_format_t::msgpack, 1, result) &&
11559 assign_and_return_true(subtype);
11564 std::int8_t subtype{};
11565 return get_number(input_format_t::msgpack, subtype) &&
11566 get_binary(input_format_t::msgpack, 2, result) &&
11567 assign_and_return_true(subtype);
11572 std::int8_t subtype{};
11573 return get_number(input_format_t::msgpack, subtype) &&
11574 get_binary(input_format_t::msgpack, 4, result) &&
11575 assign_and_return_true(subtype);
11580 std::int8_t subtype{};
11581 return get_number(input_format_t::msgpack, subtype) &&
11582 get_binary(input_format_t::msgpack, 8, result) &&
11583 assign_and_return_true(subtype);
11588 std::int8_t subtype{};
11589 return get_number(input_format_t::msgpack, subtype) &&
11590 get_binary(input_format_t::msgpack, 16, result) &&
11591 assign_and_return_true(subtype);
11610 for (std::size_t i = 0; i < len; ++i)
11618 return sax->end_array();
11633 for (std::size_t i = 0; i < len; ++i)
11648 return sax->end_object();
11664 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11697 std::uint8_t len{};
11698 return get_number(input_format, len) && get_string(input_format, len, result);
11704 return get_number(input_format, len) && get_string(input_format, len, result);
11709 std::int16_t len{};
11710 return get_number(input_format, len) && get_string(input_format, len, result);
11715 std::int32_t len{};
11716 return get_number(input_format, len) && get_string(input_format, len, result);
11721 std::int64_t len{};
11722 return get_number(input_format, len) && get_string(input_format, len, result);
11727 if (input_format != input_format_t::bjdata)
11731 std::uint16_t len{};
11732 return get_number(input_format, len) && get_string(input_format, len, result);
11737 if (input_format != input_format_t::bjdata)
11741 std::uint32_t len{};
11742 return get_number(input_format, len) && get_string(input_format, len, result);
11747 if (input_format != input_format_t::bjdata)
11751 std::uint64_t len{};
11752 return get_number(input_format, len) && get_string(input_format, len, result);
11758 auto last_token = get_token_string();
11759 std::string message;
11761 if (input_format != input_format_t::bjdata)
11763 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11767 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11769 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11778 std::pair<std::size_t, char_int_type> size_and_type;
11780 bool no_ndarray =
true;
11787 if (size_and_type.first != npos)
11789 if (size_and_type.second != 0)
11791 if (size_and_type.second !=
'N')
11793 for (std::size_t i = 0; i < size_and_type.first; ++i)
11799 dim.push_back(dimlen);
11805 for (std::size_t i = 0; i < size_and_type.first; ++i)
11811 dim.push_back(dimlen);
11817 while (current !=
']')
11823 dim.push_back(dimlen);
11845 prefix = get_ignore_noop();
11852 std::uint8_t number{};
11857 result =
static_cast<std::size_t
>(number);
11863 std::int8_t number{};
11870 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11871 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11873 result =
static_cast<std::size_t
>(number);
11879 std::int16_t number{};
11886 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11887 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11889 result =
static_cast<std::size_t
>(number);
11895 std::int32_t number{};
11902 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11903 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11905 result =
static_cast<std::size_t
>(number);
11911 std::int64_t number{};
11918 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11919 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11921 if (!value_in_range_of<std::size_t>(number))
11923 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11924 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11926 result =
static_cast<std::size_t
>(number);
11932 if (input_format != input_format_t::bjdata)
11936 std::uint16_t number{};
11941 result =
static_cast<std::size_t
>(number);
11947 if (input_format != input_format_t::bjdata)
11951 std::uint32_t number{};
11956 result = conditional_static_cast<std::size_t>(number);
11962 if (input_format != input_format_t::bjdata)
11966 std::uint64_t number{};
11971 if (!value_in_range_of<std::size_t>(number))
11973 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11974 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11976 result = detail::conditional_static_cast<std::size_t>(number);
11982 if (input_format != input_format_t::bjdata)
11988 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11990 std::vector<size_t> dim;
11995 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11997 result = dim.at(dim.size() - 1);
12024 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
12028 if (result == 0 || result == npos)
12030 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
12038 return sax->end_array();
12047 auto last_token = get_token_string();
12048 std::string message;
12050 if (input_format != input_format_t::bjdata)
12052 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
12056 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
12058 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
12074 result.first = npos;
12076 bool is_ndarray =
false;
12080 if (current ==
'$')
12082 result.second =
get();
12083 if (input_format == input_format_t::bjdata
12084 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
12086 auto last_token = get_token_string();
12087 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12088 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
12103 auto last_token = get_token_string();
12104 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12105 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
12108 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12109 if (input_format == input_format_t::bjdata && is_ndarray)
12111 if (inside_ndarray)
12113 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12114 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
12116 result.second |= (1 << 8);
12121 if (current ==
'#')
12123 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12124 if (input_format == input_format_t::bjdata && is_ndarray)
12126 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12127 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
12144 return unexpect_eof(input_format,
"value");
12147 return sax->boolean(
true);
12149 return sax->boolean(
false);
12152 return sax->null();
12156 if (input_format != input_format_t::bjdata)
12160 std::uint8_t number{};
12161 return get_number(input_format, number) && sax->number_unsigned(number);
12166 std::uint8_t number{};
12167 return get_number(input_format, number) && sax->number_unsigned(number);
12172 std::int8_t number{};
12173 return get_number(input_format, number) && sax->number_integer(number);
12178 std::int16_t number{};
12179 return get_number(input_format, number) && sax->number_integer(number);
12184 std::int32_t number{};
12185 return get_number(input_format, number) && sax->number_integer(number);
12190 std::int64_t number{};
12191 return get_number(input_format, number) && sax->number_integer(number);
12196 if (input_format != input_format_t::bjdata)
12200 std::uint16_t number{};
12201 return get_number(input_format, number) && sax->number_unsigned(number);
12206 if (input_format != input_format_t::bjdata)
12210 std::uint32_t number{};
12211 return get_number(input_format, number) && sax->number_unsigned(number);
12216 if (input_format != input_format_t::bjdata)
12220 std::uint64_t number{};
12221 return get_number(input_format, number) && sax->number_unsigned(number);
12226 if (input_format != input_format_t::bjdata)
12230 const auto byte1_raw =
get();
12235 const auto byte2_raw =
get();
12241 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
12242 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
12252 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
12253 const double val = [&half]
12255 const int exp = (half >> 10u) & 0x1Fu;
12256 const unsigned int mant = half & 0x3FFu;
12262 return std::ldexp(mant, -24);
12265 ? std::numeric_limits<double>::infinity()
12266 : std::numeric_limits<double>::quiet_NaN();
12268 return std::ldexp(mant + 1024, exp - 25);
12271 return sax->number_float((half & 0x8000u) != 0
12279 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
12285 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
12290 return get_ubjson_high_precision_number();
12302 auto last_token = get_token_string();
12303 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
12304 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
12306 string_t s(1,
static_cast<typename string_t::value_type
>(current));
12307 return sax->string(s);
12313 return get_ubjson_string(s) && sax->string(s);
12317 return get_ubjson_array();
12320 return get_ubjson_object();
12325 auto last_token = get_token_string();
12326 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
12334 std::pair<std::size_t, char_int_type> size_and_type;
12343 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12345 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
12346 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type & p,
char_int_type t)
12348 return p.first < t;
12353 auto last_token = get_token_string();
12354 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12355 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
12364 if (size_and_type.second ==
'C' || size_and_type.second ==
'B')
12366 size_and_type.second =
'U';
12369 key =
"_ArrayData_";
12375 for (std::size_t i = 0; i < size_and_type.first; ++i)
12383 return (sax->end_array() && sax->end_object());
12387 if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second ==
'B')
12390 return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
12393 if (size_and_type.first != npos)
12400 if (size_and_type.second != 0)
12402 if (size_and_type.second !=
'N')
12404 for (std::size_t i = 0; i < size_and_type.first; ++i)
12415 for (std::size_t i = 0; i < size_and_type.first; ++i)
12431 while (current !=
']')
12441 return sax->end_array();
12449 std::pair<std::size_t, char_int_type> size_and_type;
12456 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12458 auto last_token = get_token_string();
12459 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12460 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
12464 if (size_and_type.first != npos)
12471 if (size_and_type.second != 0)
12473 for (std::size_t i = 0; i < size_and_type.first; ++i)
12488 for (std::size_t i = 0; i < size_and_type.first; ++i)
12509 while (current !=
'}')
12524 return sax->end_object();
12533 std::size_t size{};
12534 bool no_ndarray =
true;
12535 auto res = get_ubjson_size_value(size, no_ndarray);
12542 std::vector<char> number_vector;
12543 for (std::size_t i = 0; i < size; ++i)
12550 number_vector.push_back(
static_cast<char>(current));
12556 const auto result_number = number_lexer.scan();
12557 const auto number_string = number_lexer.get_token_string();
12558 const auto result_remainder = number_lexer.scan();
12564 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12565 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12568 switch (result_number)
12570 case token_type::value_integer:
12571 return sax->number_integer(number_lexer.get_number_integer());
12572 case token_type::value_unsigned:
12573 return sax->number_unsigned(number_lexer.get_number_unsigned());
12574 case token_type::value_float:
12575 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12576 case token_type::uninitialized:
12577 case token_type::literal_true:
12578 case token_type::literal_false:
12579 case token_type::literal_null:
12580 case token_type::value_string:
12581 case token_type::begin_array:
12582 case token_type::begin_object:
12583 case token_type::end_array:
12584 case token_type::end_object:
12585 case token_type::name_separator:
12586 case token_type::value_separator:
12587 case token_type::parse_error:
12588 case token_type::end_of_input:
12589 case token_type::literal_or_value:
12591 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12592 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12612 return current = ia.get_character();
12626 auto new_chars_read = ia.get_elements(&dest);
12627 chars_read += new_chars_read;
12632 sax->parse_error(chars_read,
"<end of file>", parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12647 while (current ==
'N');
12652 template<
class NumberType>
12655 constexpr std::size_t sz =
sizeof(number);
12656#ifdef __cpp_lib_byteswap
12657 if constexpr (sz == 1)
12661 else if constexpr(std::is_integral_v<NumberType>)
12663 number = std::byteswap(number);
12669 auto* ptr =
reinterpret_cast<std::uint8_t*
>(&number);
12670 for (std::size_t i = 0; i < sz / 2; ++i)
12674#ifdef __cpp_lib_byteswap
12694 template<
typename NumberType,
bool InputIsLittleEndian = false>
12703 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
12724 template<
typename NumberType>
12726 const NumberType len,
12729 bool success =
true;
12730 for (NumberType i = 0; i < len; i++)
12738 result.push_back(
static_cast<typename string_t::value_type
>(current));
12757 template<
typename NumberType>
12759 const NumberType len,
12762 bool success =
true;
12763 for (NumberType i = 0; i < len; i++)
12771 result.push_back(
static_cast<typename binary_t::value_type
>(current));
12786 return sax->parse_error(chars_read,
"<end of file>",
12787 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12797 std::array<char, 3> cr{{}};
12798 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12799 return std::string{cr.data()};
12809 const std::string&
detail,
12810 const std::string& context)
const
12812 std::string error_msg =
"syntax error while parsing ";
12816 case input_format_t::cbor:
12817 error_msg +=
"CBOR";
12820 case input_format_t::msgpack:
12821 error_msg +=
"MessagePack";
12824 case input_format_t::ubjson:
12825 error_msg +=
"UBJSON";
12828 case input_format_t::bson:
12829 error_msg +=
"BSON";
12832 case input_format_t::bjdata:
12833 error_msg +=
"BJData";
12836 case input_format_t::json:
12854 std::size_t chars_read = 0;
12866#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12867 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12869#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12870 make_array<bjd_type>( \
12871 bjd_type{'B', "byte"}, \
12872 bjd_type{'C', "char"}, \
12873 bjd_type{'D', "double"}, \
12874 bjd_type{'I', "int16"}, \
12875 bjd_type{'L', "int64"}, \
12876 bjd_type{'M', "uint64"}, \
12877 bjd_type{'U', "uint8"}, \
12878 bjd_type{'d', "single"}, \
12879 bjd_type{'i', "int8"}, \
12880 bjd_type{'l', "int32"}, \
12881 bjd_type{'m', "uint32"}, \
12882 bjd_type{'u', "uint16"})
12895#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12896#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12899#ifndef JSON_HAS_CPP_17
12900 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12924#include <functional>
12969template<
typename BasicJsonType>
12971 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12978template<
typename BasicJsonType,
typename InputAdapterType>
12992 const bool allow_exceptions_ =
true,
12993 const bool ignore_comments =
false,
12994 const bool ignore_trailing_commas_ =
false)
12995 : callback(
std::move(cb))
12996 , m_lexer(
std::move(adapter), ignore_comments)
12997 , allow_exceptions(allow_exceptions_)
12998 , ignore_trailing_commas(ignore_trailing_commas_)
13014 void parse(
const bool strict, BasicJsonType& result)
13019 sax_parse_internal(&sdp);
13022 if (
strict && (get_token() != token_type::end_of_input))
13025 m_lexer.get_token_string(),
13026 parse_error::create(101, m_lexer.get_position(),
13027 exception_message(token_type::end_of_input,
"value"),
nullptr));
13033 result = value_t::discarded;
13039 if (result.is_discarded())
13047 sax_parse_internal(&sdp);
13050 if (
strict && (get_token() != token_type::end_of_input))
13053 m_lexer.get_token_string(),
13054 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13060 result = value_t::discarded;
13065 result.assert_invariant();
13077 return sax_parse(&sax_acceptor,
strict);
13080 template<
typename SAX>
13082 bool sax_parse(SAX* sax, const
bool strict = true)
13085 const bool result = sax_parse_internal(sax);
13088 if (result &&
strict && (get_token() != token_type::end_of_input))
13090 return sax->parse_error(m_lexer.get_position(),
13091 m_lexer.get_token_string(),
13092 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13099 template<
typename SAX>
13101 bool sax_parse_internal(SAX* sax)
13105 std::vector<bool> states;
13107 bool skip_to_state_evaluation =
false;
13111 if (!skip_to_state_evaluation)
13114 switch (last_token)
13116 case token_type::begin_object:
13124 if (get_token() == token_type::end_object)
13136 return sax->parse_error(m_lexer.get_position(),
13137 m_lexer.get_token_string(),
13138 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13148 return sax->parse_error(m_lexer.get_position(),
13149 m_lexer.get_token_string(),
13150 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13154 states.push_back(
false);
13161 case token_type::begin_array:
13169 if (get_token() == token_type::end_array)
13179 states.push_back(
true);
13185 case token_type::value_float:
13187 const auto res = m_lexer.get_number_float();
13191 return sax->parse_error(m_lexer.get_position(),
13192 m_lexer.get_token_string(),
13193 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
13204 case token_type::literal_false:
13213 case token_type::literal_null:
13222 case token_type::literal_true:
13231 case token_type::value_integer:
13240 case token_type::value_string:
13249 case token_type::value_unsigned:
13258 case token_type::parse_error:
13261 return sax->parse_error(m_lexer.get_position(),
13262 m_lexer.get_token_string(),
13263 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
13265 case token_type::end_of_input:
13269 return sax->parse_error(m_lexer.get_position(),
13270 m_lexer.get_token_string(),
13271 parse_error::create(101, m_lexer.get_position(),
13272 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
13275 return sax->parse_error(m_lexer.get_position(),
13276 m_lexer.get_token_string(),
13277 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13279 case token_type::uninitialized:
13280 case token_type::end_array:
13281 case token_type::end_object:
13282 case token_type::name_separator:
13283 case token_type::value_separator:
13284 case token_type::literal_or_value:
13287 return sax->parse_error(m_lexer.get_position(),
13288 m_lexer.get_token_string(),
13289 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13295 skip_to_state_evaluation =
false;
13299 if (states.empty())
13309 if (get_token() == token_type::value_separator)
13315 if (!(ignore_trailing_commas && last_token == token_type::end_array))
13335 skip_to_state_evaluation =
true;
13339 return sax->parse_error(m_lexer.get_position(),
13340 m_lexer.get_token_string(),
13341 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
13348 if (get_token() == token_type::value_separator)
13353 if (!(ignore_trailing_commas && last_token == token_type::end_object))
13358 return sax->parse_error(m_lexer.get_position(),
13359 m_lexer.get_token_string(),
13360 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13371 return sax->parse_error(m_lexer.get_position(),
13372 m_lexer.get_token_string(),
13373 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13396 skip_to_state_evaluation =
true;
13400 return sax->parse_error(m_lexer.get_position(),
13401 m_lexer.get_token_string(),
13402 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
13409 return last_token = m_lexer.scan();
13414 std::string error_msg =
"syntax error ";
13416 if (!context.empty())
13418 error_msg +=
concat(
"while parsing ", context,
' ');
13423 if (last_token == token_type::parse_error)
13425 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
13426 m_lexer.get_token_string(),
'\'');
13430 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
13433 if (expected != token_type::uninitialized)
13435 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
13449 const bool allow_exceptions =
true;
13451 const bool ignore_trailing_commas =
false;
13520 m_it = begin_value;
13532 return m_it == begin_value;
13538 return m_it == end_value;
13543 return lhs.m_it == rhs.m_it;
13548 return lhs.m_it < rhs.m_it;
13553 auto result = *
this;
13560 return lhs.m_it - rhs.m_it;
13571 auto result = *
this;
13584 auto result = *
this;
13619 typename BasicJsonType::object_t::iterator object_iterator {};
13621 typename BasicJsonType::array_t::iterator array_iterator {};
13641#include <type_traits>
13663template<
typename IteratorType>
class iteration_proxy;
13664template<
typename IteratorType>
class iteration_proxy_value;
13682template<
typename BasicJsonType>
13697 "iter_impl only accepts (const) basic_json");
13699 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13700 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value,
13701 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13716 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13717 typename BasicJsonType::const_pointer,
13718 typename BasicJsonType::pointer>::type;
13721 typename std::conditional<std::is_const<BasicJsonType>::value,
13722 typename BasicJsonType::const_reference,
13723 typename BasicJsonType::reference>::type;
13740 switch (m_object->m_data.m_type)
13742 case value_t::object:
13744 m_it.object_iterator =
typename object_t::iterator();
13748 case value_t::array:
13750 m_it.array_iterator =
typename array_t::iterator();
13754 case value_t::null:
13755 case value_t::string:
13756 case value_t::boolean:
13757 case value_t::number_integer:
13758 case value_t::number_unsigned:
13759 case value_t::number_float:
13760 case value_t::binary:
13761 case value_t::discarded:
13787 : m_object(other.m_object), m_it(other.m_it)
13798 if (&other !=
this)
13800 m_object = other.m_object;
13812 : m_object(other.m_object), m_it(other.m_it)
13823 m_object = other.m_object;
13833 void set_begin() noexcept
13837 switch (m_object->m_data.m_type)
13839 case value_t::object:
13841 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13845 case value_t::array:
13847 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13851 case value_t::null:
13854 m_it.primitive_iterator.set_end();
13858 case value_t::string:
13859 case value_t::boolean:
13860 case value_t::number_integer:
13861 case value_t::number_unsigned:
13862 case value_t::number_float:
13863 case value_t::binary:
13864 case value_t::discarded:
13867 m_it.primitive_iterator.set_begin();
13881 switch (m_object->m_data.m_type)
13883 case value_t::object:
13885 m_it.object_iterator = m_object->m_data.m_value.object->end();
13889 case value_t::array:
13891 m_it.array_iterator = m_object->m_data.m_value.array->end();
13895 case value_t::null:
13896 case value_t::string:
13897 case value_t::boolean:
13898 case value_t::number_integer:
13899 case value_t::number_unsigned:
13900 case value_t::number_float:
13901 case value_t::binary:
13902 case value_t::discarded:
13905 m_it.primitive_iterator.set_end();
13920 switch (m_object->m_data.m_type)
13922 case value_t::object:
13924 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13925 return m_it.object_iterator->second;
13928 case value_t::array:
13930 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13931 return *m_it.array_iterator;
13934 case value_t::null:
13935 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13937 case value_t::string:
13938 case value_t::boolean:
13939 case value_t::number_integer:
13940 case value_t::number_unsigned:
13941 case value_t::number_float:
13942 case value_t::binary:
13943 case value_t::discarded:
13951 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13964 switch (m_object->m_data.m_type)
13966 case value_t::object:
13968 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13969 return &(m_it.object_iterator->second);
13972 case value_t::array:
13974 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13975 return &*m_it.array_iterator;
13978 case value_t::null:
13979 case value_t::string:
13980 case value_t::boolean:
13981 case value_t::number_integer:
13982 case value_t::number_unsigned:
13983 case value_t::number_float:
13984 case value_t::binary:
13985 case value_t::discarded:
13993 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14004 auto result = *
this;
14017 switch (m_object->m_data.m_type)
14019 case value_t::object:
14021 std::advance(m_it.object_iterator, 1);
14025 case value_t::array:
14027 std::advance(m_it.array_iterator, 1);
14031 case value_t::null:
14032 case value_t::string:
14033 case value_t::boolean:
14034 case value_t::number_integer:
14035 case value_t::number_unsigned:
14036 case value_t::number_float:
14037 case value_t::binary:
14038 case value_t::discarded:
14041 ++m_it.primitive_iterator;
14055 auto result = *
this;
14068 switch (m_object->m_data.m_type)
14070 case value_t::object:
14072 std::advance(m_it.object_iterator, -1);
14076 case value_t::array:
14078 std::advance(m_it.array_iterator, -1);
14082 case value_t::null:
14083 case value_t::string:
14084 case value_t::boolean:
14085 case value_t::number_integer:
14086 case value_t::number_unsigned:
14087 case value_t::number_float:
14088 case value_t::binary:
14089 case value_t::discarded:
14092 --m_it.primitive_iterator;
14104 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
14110 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14114 if (m_object ==
nullptr)
14119 switch (m_object->m_data.m_type)
14121 case value_t::object:
14122 return (m_it.object_iterator == other.m_it.object_iterator);
14124 case value_t::array:
14125 return (m_it.array_iterator == other.m_it.array_iterator);
14127 case value_t::null:
14128 case value_t::string:
14129 case value_t::boolean:
14130 case value_t::number_integer:
14131 case value_t::number_unsigned:
14132 case value_t::number_float:
14133 case value_t::binary:
14134 case value_t::discarded:
14136 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
14144 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
14159 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14163 if (m_object ==
nullptr)
14169 switch (m_object->m_data.m_type)
14171 case value_t::object:
14172 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
14174 case value_t::array:
14177 case value_t::null:
14178 case value_t::string:
14179 case value_t::boolean:
14180 case value_t::number_integer:
14181 case value_t::number_unsigned:
14182 case value_t::number_float:
14183 case value_t::binary:
14184 case value_t::discarded:
14196 return !other.operator < (*this);
14205 return !operator<=(other);
14225 switch (m_object->m_data.m_type)
14227 case value_t::object:
14228 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14230 case value_t::array:
14232 std::advance(m_it.array_iterator, i);
14236 case value_t::null:
14237 case value_t::string:
14238 case value_t::boolean:
14239 case value_t::number_integer:
14240 case value_t::number_unsigned:
14241 case value_t::number_float:
14242 case value_t::binary:
14243 case value_t::discarded:
14246 m_it.primitive_iterator += i;
14260 return operator+=(-i);
14269 auto result = *
this;
14291 auto result = *
this;
14304 switch (m_object->m_data.m_type)
14306 case value_t::object:
14307 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14309 case value_t::array:
14312 case value_t::null:
14313 case value_t::string:
14314 case value_t::boolean:
14315 case value_t::number_integer:
14316 case value_t::number_unsigned:
14317 case value_t::number_float:
14318 case value_t::binary:
14319 case value_t::discarded:
14333 switch (m_object->m_data.m_type)
14335 case value_t::object:
14336 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
14338 case value_t::array:
14339 return *std::next(m_it.array_iterator, n);
14341 case value_t::null:
14342 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14344 case value_t::string:
14345 case value_t::boolean:
14346 case value_t::number_integer:
14347 case value_t::number_unsigned:
14348 case value_t::number_float:
14349 case value_t::binary:
14350 case value_t::discarded:
14358 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14367 const typename object_t::key_type&
key()
const
14373 return m_it.object_iterator->first;
14376 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
14385 return operator*();
14444template<
typename Base>
14512 return *(this->operator+(n));
14516 auto key() const -> decltype(
std::declval<Base>().key())
14518 auto it = --this->base();
14525 auto it = --this->base();
14526 return it.operator * ();
14546#include <type_traits>
14569 std::is_same<T, void>::value,
14588#include <algorithm>
14616template<
typename RefStringType>
14626 template<
typename T>
14645 : reference_tokens(split(s))
14652 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14656 return detail::concat(a,
'/', detail::escape(b));
14682 reference_tokens.insert(reference_tokens.end(),
14692 push_back(std::move(token));
14700 return *
this /= std::to_string(array_idx);
14748 reference_tokens.pop_back();
14760 return reference_tokens.back();
14767 reference_tokens.push_back(token);
14774 reference_tokens.push_back(std::move(token));
14781 return reference_tokens.empty();
14795 template<
typename BasicJsonType>
14798 using size_type =
typename BasicJsonType::size_type;
14812 const char* p = s.c_str();
14813 char* p_end =
nullptr;
14815 const unsigned long long res = std::strtoull(p, &p_end, 10);
14825 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14830 return static_cast<size_type
>(res);
14855 template<
typename BasicJsonType>
14862 for (
const auto& reference_token : reference_tokens)
14864 switch (result->type())
14868 if (reference_token ==
"0")
14871 result = &result->operator[](0);
14876 result = &result->operator[](reference_token);
14884 result = &result->operator[](reference_token);
14891 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14935 template<
typename BasicJsonType>
14938 for (
const auto& reference_token : reference_tokens)
14941 if (ptr->is_null())
14945 std::all_of(reference_token.begin(), reference_token.end(),
14946 [](
const unsigned char x)
14948 return std::isdigit(x);
14952 *ptr = (nums || reference_token ==
"-")
14957 switch (ptr->type())
14962 ptr = &ptr->operator[](reference_token);
14968 if (reference_token ==
"-")
14971 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14976 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15003 template<
typename BasicJsonType>
15006 for (
const auto& reference_token : reference_tokens)
15008 switch (ptr->type())
15013 ptr = &ptr->at(reference_token);
15023 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15024 ") is out of range"), ptr));
15028 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15061 template<
typename BasicJsonType>
15064 for (
const auto& reference_token : reference_tokens)
15066 switch (ptr->type())
15071 ptr = &ptr->operator[](reference_token);
15084 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15110 template<
typename BasicJsonType>
15113 for (
const auto& reference_token : reference_tokens)
15115 switch (ptr->type())
15120 ptr = &ptr->at(reference_token);
15130 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15131 ") is out of range"), ptr));
15135 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15159 template<
typename BasicJsonType>
15162 for (
const auto& reference_token : reference_tokens)
15164 switch (ptr->type())
15168 if (!ptr->contains(reference_token))
15174 ptr = &ptr->operator[](reference_token);
15185 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
15197 for (std::size_t i = 1; i < reference_token.size(); i++)
15207 const auto idx = array_index<BasicJsonType>(reference_token);
15208 if (idx >= ptr->size())
15214 ptr = &ptr->operator[](idx);
15250 std::vector<string_t> result;
15253 if (reference_string.empty())
15269 std::size_t slash = reference_string.find_first_of(
'/', 1),
15276 start = (slash == string_t::npos) ? 0 : slash + 1,
15278 slash = reference_string.find_first_of(
'/', start))
15282 auto reference_token = reference_string.substr(start, slash - start);
15285 for (std::size_t pos = reference_token.find_first_of(
'~');
15286 pos != string_t::npos;
15287 pos = reference_token.find_first_of(
'~', pos + 1))
15293 (reference_token[pos + 1] !=
'0' &&
15294 reference_token[pos + 1] !=
'1')))
15302 result.push_back(reference_token);
15316 template<
typename BasicJsonType>
15318 const BasicJsonType& value,
15319 BasicJsonType& result)
15321 switch (value.type())
15325 if (value.m_data.m_value.array->empty())
15328 result[reference_string] =
nullptr;
15333 for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
15335 flatten(detail::concat<string_t>(reference_string,
'/', std::to_string(i)),
15336 value.m_data.m_value.array->operator[](i), result);
15344 if (value.m_data.m_value.object->empty())
15347 result[reference_string] =
nullptr;
15352 for (
const auto& element : *value.m_data.m_value.object)
15354 flatten(detail::concat<string_t>(reference_string,
'/',
detail::escape(element.first)), element.second, result);
15371 result[reference_string] = value;
15387 template<
typename BasicJsonType>
15388 static BasicJsonType
15396 BasicJsonType result;
15399 for (
const auto& element : *value.m_data.m_value.object)
15432#if JSON_HAS_THREE_WAY_COMPARISON
15435 template<
typename RefStringTypeRhs>
15450 template<
typename RefStringTypeRhs>
15453 return reference_tokens <=> rhs.reference_tokens;
15458 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15465 template<
typename RefStringTypeLhs,
typename StringType>
15468 const StringType& rhs);
15472 template<
typename RefStringTypeRhs,
typename StringType>
15474 friend bool operator==(
const StringType& lhs,
15479 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15486 template<
typename RefStringTypeLhs,
typename StringType>
15489 const StringType& rhs);
15493 template<
typename RefStringTypeRhs,
typename StringType>
15495 friend bool operator!=(
const StringType& lhs,
15499 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15510#if !JSON_HAS_THREE_WAY_COMPARISON
15512template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15516 return lhs.reference_tokens == rhs.reference_tokens;
15519template<
typename RefStringTypeLhs,
15523 const StringType& rhs)
15528template<
typename RefStringTypeRhs,
15531inline
bool operator==(const StringType& lhs,
15537template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15541 return !(lhs == rhs);
15544template<
typename RefStringTypeLhs,
15548 const StringType& rhs)
15550 return !(lhs == rhs);
15553template<
typename RefStringTypeRhs,
15556inline
bool operator!=(const StringType& lhs,
15559 return !(lhs == rhs);
15562template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15583#include <initializer_list>
15595template<
typename BasicJsonType>
15602 : owned_value(
std::move(value))
15606 : value_ref(&value)
15610 : owned_value(init)
15615 enable_if_t<std::is_constructible<value_type, Args...>::value,
int> = 0 >
15617 : owned_value(
std::forward<Args>(args)...)
15629 if (value_ref ==
nullptr)
15631 return std::move(owned_value);
15638 return value_ref ? *value_ref : owned_value;
15677#include <algorithm>
15703#include <algorithm>
15737template<typename CharType>
15741template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15755 void write_characters(const CharType* s,
std::
size_t length)
override
15757 v.insert(v.end(), s, s + length);
15761 std::vector<CharType, AllocatorType>&
v;
15766template<
typename CharType>
15780 void write_characters(const CharType* s,
std::
size_t length)
override
15782 stream.write(s,
static_cast<std::streamsize
>(length));
15791template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15805 void write_characters(const CharType* s,
std::
size_t length)
override
15807 str.append(s, length);
15814template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15818 template<
typename AllocatorType = std::allocator<CharType>>
15863template<
typename BasicJsonType,
typename CharType>
15889 case value_t::object:
15891 write_bson_object(*j.m_data.m_value.object);
15895 case value_t::null:
15896 case value_t::array:
15897 case value_t::string:
15898 case value_t::boolean:
15899 case value_t::number_integer:
15900 case value_t::number_unsigned:
15901 case value_t::number_float:
15902 case value_t::binary:
15903 case value_t::discarded:
15906 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15918 case value_t::null:
15920 oa->write_character(to_char_type(0xF6));
15924 case value_t::boolean:
15926 oa->write_character(j.m_data.m_value.boolean
15927 ? to_char_type(0xF5)
15928 : to_char_type(0xF4));
15932 case value_t::number_integer:
15934 if (j.m_data.m_value.number_integer >= 0)
15939 if (j.m_data.m_value.number_integer <= 0x17)
15941 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15943 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15945 oa->write_character(to_char_type(0x18));
15946 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15948 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15950 oa->write_character(to_char_type(0x19));
15951 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15953 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15955 oa->write_character(to_char_type(0x1A));
15956 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15960 oa->write_character(to_char_type(0x1B));
15961 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15968 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15969 if (j.m_data.m_value.number_integer >= -24)
15971 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15973 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15975 oa->write_character(to_char_type(0x38));
15976 write_number(
static_cast<std::uint8_t
>(positive_number));
15978 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15980 oa->write_character(to_char_type(0x39));
15981 write_number(
static_cast<std::uint16_t
>(positive_number));
15983 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15985 oa->write_character(to_char_type(0x3A));
15986 write_number(
static_cast<std::uint32_t
>(positive_number));
15990 oa->write_character(to_char_type(0x3B));
15991 write_number(
static_cast<std::uint64_t
>(positive_number));
15997 case value_t::number_unsigned:
15999 if (j.m_data.m_value.number_unsigned <= 0x17)
16001 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16003 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16005 oa->write_character(to_char_type(0x18));
16006 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16008 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16010 oa->write_character(to_char_type(0x19));
16011 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
16013 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16015 oa->write_character(to_char_type(0x1A));
16016 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
16020 oa->write_character(to_char_type(0x1B));
16021 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
16026 case value_t::number_float:
16028 if (std::isnan(j.m_data.m_value.number_float))
16031 oa->write_character(to_char_type(0xF9));
16032 oa->write_character(to_char_type(0x7E));
16033 oa->write_character(to_char_type(0x00));
16035 else if (std::isinf(j.m_data.m_value.number_float))
16038 oa->write_character(to_char_type(0xf9));
16039 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
16040 oa->write_character(to_char_type(0x00));
16049 case value_t::string:
16052 const auto N = j.m_data.m_value.string->size();
16055 write_number(
static_cast<std::uint8_t
>(0x60 + N));
16057 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16059 oa->write_character(to_char_type(0x78));
16060 write_number(
static_cast<std::uint8_t
>(N));
16062 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16064 oa->write_character(to_char_type(0x79));
16065 write_number(
static_cast<std::uint16_t
>(N));
16067 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16069 oa->write_character(to_char_type(0x7A));
16070 write_number(
static_cast<std::uint32_t
>(N));
16073 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16075 oa->write_character(to_char_type(0x7B));
16076 write_number(
static_cast<std::uint64_t
>(N));
16081 oa->write_characters(
16082 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16083 j.m_data.m_value.string->size());
16087 case value_t::array:
16090 const auto N = j.m_data.m_value.array->size();
16093 write_number(
static_cast<std::uint8_t
>(0x80 + N));
16095 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16097 oa->write_character(to_char_type(0x98));
16098 write_number(
static_cast<std::uint8_t
>(N));
16100 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16102 oa->write_character(to_char_type(0x99));
16103 write_number(
static_cast<std::uint16_t
>(N));
16105 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16107 oa->write_character(to_char_type(0x9A));
16108 write_number(
static_cast<std::uint32_t
>(N));
16111 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16113 oa->write_character(to_char_type(0x9B));
16114 write_number(
static_cast<std::uint64_t
>(N));
16119 for (
const auto& el : *j.m_data.m_value.array)
16126 case value_t::binary:
16128 if (j.m_data.m_value.binary->has_subtype())
16130 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
16132 write_number(
static_cast<std::uint8_t
>(0xd8));
16133 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
16135 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
16137 write_number(
static_cast<std::uint8_t
>(0xd9));
16138 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
16140 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
16142 write_number(
static_cast<std::uint8_t
>(0xda));
16143 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
16145 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
16147 write_number(
static_cast<std::uint8_t
>(0xdb));
16148 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
16153 const auto N = j.m_data.m_value.binary->size();
16156 write_number(
static_cast<std::uint8_t
>(0x40 + N));
16158 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16160 oa->write_character(to_char_type(0x58));
16161 write_number(
static_cast<std::uint8_t
>(N));
16163 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16165 oa->write_character(to_char_type(0x59));
16166 write_number(
static_cast<std::uint16_t
>(N));
16168 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16170 oa->write_character(to_char_type(0x5A));
16171 write_number(
static_cast<std::uint32_t
>(N));
16174 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16176 oa->write_character(to_char_type(0x5B));
16177 write_number(
static_cast<std::uint64_t
>(N));
16182 oa->write_characters(
16183 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16189 case value_t::object:
16192 const auto N = j.m_data.m_value.object->size();
16195 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
16197 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16199 oa->write_character(to_char_type(0xB8));
16200 write_number(
static_cast<std::uint8_t
>(N));
16202 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16204 oa->write_character(to_char_type(0xB9));
16205 write_number(
static_cast<std::uint16_t
>(N));
16207 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16209 oa->write_character(to_char_type(0xBA));
16210 write_number(
static_cast<std::uint32_t
>(N));
16213 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16215 oa->write_character(to_char_type(0xBB));
16216 write_number(
static_cast<std::uint64_t
>(N));
16221 for (
const auto& el : *j.m_data.m_value.object)
16223 write_cbor(el.first);
16224 write_cbor(el.second);
16229 case value_t::discarded:
16242 case value_t::null:
16244 oa->write_character(to_char_type(0xC0));
16248 case value_t::boolean:
16250 oa->write_character(j.m_data.m_value.boolean
16251 ? to_char_type(0xC3)
16252 : to_char_type(0xC2));
16256 case value_t::number_integer:
16258 if (j.m_data.m_value.number_integer >= 0)
16263 if (j.m_data.m_value.number_unsigned < 128)
16266 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16268 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16271 oa->write_character(to_char_type(0xCC));
16272 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16274 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16277 oa->write_character(to_char_type(0xCD));
16278 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16280 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16283 oa->write_character(to_char_type(0xCE));
16284 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16286 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16289 oa->write_character(to_char_type(0xCF));
16290 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16295 if (j.m_data.m_value.number_integer >= -32)
16298 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16300 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
16301 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16304 oa->write_character(to_char_type(0xD0));
16305 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16307 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
16308 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16311 oa->write_character(to_char_type(0xD1));
16312 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
16314 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
16315 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16318 oa->write_character(to_char_type(0xD2));
16319 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
16321 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
16322 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16325 oa->write_character(to_char_type(0xD3));
16326 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
16332 case value_t::number_unsigned:
16334 if (j.m_data.m_value.number_unsigned < 128)
16337 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16339 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16342 oa->write_character(to_char_type(0xCC));
16343 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16345 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16348 oa->write_character(to_char_type(0xCD));
16349 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16351 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16354 oa->write_character(to_char_type(0xCE));
16355 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16357 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16360 oa->write_character(to_char_type(0xCF));
16361 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16366 case value_t::number_float:
16372 case value_t::string:
16375 const auto N = j.m_data.m_value.string->size();
16379 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
16381 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16384 oa->write_character(to_char_type(0xD9));
16385 write_number(
static_cast<std::uint8_t
>(N));
16387 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16390 oa->write_character(to_char_type(0xDA));
16391 write_number(
static_cast<std::uint16_t
>(N));
16393 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16396 oa->write_character(to_char_type(0xDB));
16397 write_number(
static_cast<std::uint32_t
>(N));
16401 oa->write_characters(
16402 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16403 j.m_data.m_value.string->size());
16407 case value_t::array:
16410 const auto N = j.m_data.m_value.array->size();
16414 write_number(
static_cast<std::uint8_t
>(0x90 | N));
16416 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16419 oa->write_character(to_char_type(0xDC));
16420 write_number(
static_cast<std::uint16_t
>(N));
16422 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16425 oa->write_character(to_char_type(0xDD));
16426 write_number(
static_cast<std::uint32_t
>(N));
16430 for (
const auto& el : *j.m_data.m_value.array)
16437 case value_t::binary:
16441 const bool use_ext = j.m_data.m_value.binary->has_subtype();
16444 const auto N = j.m_data.m_value.binary->size();
16445 if (N <= (std::numeric_limits<std::uint8_t>::max)())
16447 std::uint8_t output_type{};
16454 output_type = 0xD4;
16457 output_type = 0xD5;
16460 output_type = 0xD6;
16463 output_type = 0xD7;
16466 output_type = 0xD8;
16469 output_type = 0xC7;
16477 output_type = 0xC4;
16481 oa->write_character(to_char_type(output_type));
16484 write_number(
static_cast<std::uint8_t
>(N));
16487 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16489 const std::uint8_t output_type = use_ext
16493 oa->write_character(to_char_type(output_type));
16494 write_number(
static_cast<std::uint16_t
>(N));
16496 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16498 const std::uint8_t output_type = use_ext
16502 oa->write_character(to_char_type(output_type));
16503 write_number(
static_cast<std::uint32_t
>(N));
16509 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
16513 oa->write_characters(
16514 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16520 case value_t::object:
16523 const auto N = j.m_data.m_value.object->size();
16527 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
16529 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16532 oa->write_character(to_char_type(0xDE));
16533 write_number(
static_cast<std::uint16_t
>(N));
16535 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16538 oa->write_character(to_char_type(0xDF));
16539 write_number(
static_cast<std::uint32_t
>(N));
16543 for (
const auto& el : *j.m_data.m_value.object)
16545 write_msgpack(el.first);
16546 write_msgpack(el.second);
16551 case value_t::discarded:
16566 const bool use_type,
const bool add_prefix =
true,
16567 const bool use_bjdata =
false,
const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
16569 const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
16573 case value_t::null:
16577 oa->write_character(to_char_type(
'Z'));
16582 case value_t::boolean:
16586 oa->write_character(j.m_data.m_value.boolean
16587 ? to_char_type(
'T')
16588 : to_char_type(
'F'));
16593 case value_t::number_integer:
16595 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16599 case value_t::number_unsigned:
16601 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16605 case value_t::number_float:
16607 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16611 case value_t::string:
16615 oa->write_character(to_char_type(
'S'));
16617 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16618 oa->write_characters(
16619 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16620 j.m_data.m_value.string->size());
16624 case value_t::array:
16628 oa->write_character(to_char_type(
'['));
16631 bool prefix_required =
true;
16632 if (use_type && !j.m_data.m_value.array->empty())
16635 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16636 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16637 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16639 return ubjson_prefix(v, use_bjdata) == first_prefix;
16642 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16644 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16646 prefix_required =
false;
16647 oa->write_character(to_char_type(
'$'));
16648 oa->write_character(first_prefix);
16654 oa->write_character(to_char_type(
'#'));
16655 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16658 for (
const auto& el : *j.m_data.m_value.array)
16660 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16665 oa->write_character(to_char_type(
']'));
16671 case value_t::binary:
16675 oa->write_character(to_char_type(
'['));
16678 if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
16681 oa->write_character(to_char_type(
'$'));
16682 oa->write_character(bjdata_draft3 ?
'B' :
'U');
16687 oa->write_character(to_char_type(
'#'));
16688 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16693 oa->write_characters(
16694 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16695 j.m_data.m_value.binary->size());
16699 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16701 oa->write_character(to_char_type(bjdata_draft3 ?
'B' :
'U'));
16702 oa->write_character(j.m_data.m_value.binary->data()[i]);
16708 oa->write_character(to_char_type(
']'));
16714 case value_t::object:
16716 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
16718 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version))
16726 oa->write_character(to_char_type(
'{'));
16729 bool prefix_required =
true;
16730 if (use_type && !j.m_data.m_value.object->empty())
16733 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16734 const bool same_prefix = std::all_of(j.begin(), j.end(),
16735 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16737 return ubjson_prefix(v, use_bjdata) == first_prefix;
16740 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16742 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16744 prefix_required =
false;
16745 oa->write_character(to_char_type(
'$'));
16746 oa->write_character(first_prefix);
16752 oa->write_character(to_char_type(
'#'));
16753 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16756 for (
const auto& el : *j.m_data.m_value.object)
16758 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16759 oa->write_characters(
16760 reinterpret_cast<const CharType*
>(el.first.c_str()),
16762 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16767 oa->write_character(to_char_type(
'}'));
16773 case value_t::discarded:
16790 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16793 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
16796 static_cast<void>(j);
16797 return 1ul + name.size() + 1u;
16804 const std::uint8_t element_type)
16806 oa->write_character(to_char_type(element_type));
16807 oa->write_characters(
16808 reinterpret_cast<const CharType*
>(name.c_str()),
16818 write_bson_entry_header(name, 0x08);
16819 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
16826 const double value)
16828 write_bson_entry_header(name, 0x01);
16829 write_number<double>(value,
true);
16837 return sizeof(std::int32_t) + value.size() + 1ul;
16846 write_bson_entry_header(name, 0x02);
16848 write_number<std::int32_t>(
static_cast<std::int32_t
>(value.size() + 1ul),
true);
16849 oa->write_characters(
16850 reinterpret_cast<const CharType*
>(value.c_str()),
16859 write_bson_entry_header(name, 0x0A);
16867 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
16868 ?
sizeof(std::int32_t)
16869 :
sizeof(std::int64_t);
16876 const std::int64_t value)
16878 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16880 write_bson_entry_header(name, 0x10);
16881 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16885 write_bson_entry_header(name, 0x12);
16886 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16895 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16896 ?
sizeof(std::int32_t)
16897 :
sizeof(std::int64_t);
16904 const BasicJsonType& j)
16906 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16908 write_bson_entry_header(name, 0x10 );
16909 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16911 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16913 write_bson_entry_header(name, 0x12 );
16914 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16918 write_bson_entry_header(name, 0x11 );
16919 write_number<std::uint64_t>(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned),
true);
16927 const typename BasicJsonType::object_t& value)
16929 write_bson_entry_header(name, 0x03);
16930 write_bson_object(value);
16938 std::size_t array_index = 0ul;
16940 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
16942 return result + calc_bson_element_size(std::to_string(array_index++), el);
16945 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16953 return sizeof(std::int32_t) + value.size() + 1ul;
16960 const typename BasicJsonType::array_t& value)
16962 write_bson_entry_header(name, 0x04);
16963 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16965 std::size_t array_index = 0ul;
16967 for (
const auto& el : value)
16969 write_bson_element(std::to_string(array_index++), el);
16972 oa->write_character(to_char_type(0x00));
16981 write_bson_entry_header(name, 0x05);
16983 write_number<std::int32_t>(
static_cast<std::int32_t
>(value.size()),
true);
16984 write_number(value.has_subtype() ?
static_cast<std::uint8_t
>(value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16986 oa->write_characters(
reinterpret_cast<const CharType*
>(value.data()), value.size());
16994 const BasicJsonType& j)
16996 const auto header_size = calc_bson_entry_header_size(name, j);
16999 case value_t::object:
17000 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
17002 case value_t::array:
17003 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
17005 case value_t::binary:
17006 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
17008 case value_t::boolean:
17009 return header_size + 1ul;
17011 case value_t::number_float:
17012 return header_size + 8ul;
17014 case value_t::number_integer:
17015 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
17017 case value_t::number_unsigned:
17018 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
17020 case value_t::string:
17021 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
17023 case value_t::null:
17024 return header_size + 0ul;
17027 case value_t::discarded:
17042 const BasicJsonType& j)
17046 case value_t::object:
17047 return write_bson_object_entry(name, *j.m_data.m_value.object);
17049 case value_t::array:
17050 return write_bson_array(name, *j.m_data.m_value.array);
17052 case value_t::binary:
17053 return write_bson_binary(name, *j.m_data.m_value.binary);
17055 case value_t::boolean:
17056 return write_bson_boolean(name, j.m_data.m_value.boolean);
17058 case value_t::number_float:
17059 return write_bson_double(name, j.m_data.m_value.number_float);
17061 case value_t::number_integer:
17062 return write_bson_integer(name, j.m_data.m_value.number_integer);
17064 case value_t::number_unsigned:
17065 return write_bson_unsigned(name, j);
17067 case value_t::string:
17068 return write_bson_string(name, *j.m_data.m_value.string);
17070 case value_t::null:
17071 return write_bson_null(name);
17074 case value_t::discarded:
17090 const std::size_t document_size = std::accumulate(value.begin(), value.end(),
static_cast<std::size_t
>(0),
17091 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
17093 return result += calc_bson_element_size(el.first, el.second);
17096 return sizeof(std::int32_t) + document_size + 1ul;
17105 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
17107 for (
const auto& el : value)
17109 write_bson_element(el.first, el.second);
17112 oa->write_character(to_char_type(0x00));
17121 return to_char_type(0xFA);
17126 return to_char_type(0xFB);
17135 return to_char_type(0xCA);
17140 return to_char_type(0xCB);
17148 template<
typename NumberType,
typename std::enable_if<
17149 std::is_floating_point<NumberType>::value,
int>::type = 0>
17151 const bool add_prefix,
17152 const bool use_bjdata)
17156 oa->write_character(get_ubjson_float_prefix(n));
17158 write_number(n, use_bjdata);
17162 template<
typename NumberType,
typename std::enable_if<
17163 std::is_unsigned<NumberType>::value,
int>::type = 0>
17165 const bool add_prefix,
17166 const bool use_bjdata)
17168 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17172 oa->write_character(to_char_type(
'i'));
17174 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17176 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
17180 oa->write_character(to_char_type(
'U'));
17182 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17184 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17188 oa->write_character(to_char_type(
'I'));
17190 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17192 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
17196 oa->write_character(to_char_type(
'u'));
17198 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
17200 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17204 oa->write_character(to_char_type(
'l'));
17206 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17208 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
17212 oa->write_character(to_char_type(
'm'));
17214 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
17216 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17220 oa->write_character(to_char_type(
'L'));
17222 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17224 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
17228 oa->write_character(to_char_type(
'M'));
17230 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
17236 oa->write_character(to_char_type(
'H'));
17239 const auto number = BasicJsonType(n).dump();
17240 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17241 for (std::size_t i = 0; i < number.size(); ++i)
17243 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17249 template <
typename NumberType,
typename std::enable_if <
17250 std::is_signed<NumberType>::value&&
17251 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
17253 const bool add_prefix,
17254 const bool use_bjdata)
17256 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
17260 oa->write_character(to_char_type(
'i'));
17262 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
17264 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17268 oa->write_character(to_char_type(
'U'));
17270 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17272 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
17276 oa->write_character(to_char_type(
'I'));
17278 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17280 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
17284 oa->write_character(to_char_type(
'u'));
17286 write_number(
static_cast<uint16_t
>(n), use_bjdata);
17288 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
17292 oa->write_character(to_char_type(
'l'));
17294 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17296 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
17300 oa->write_character(to_char_type(
'm'));
17302 write_number(
static_cast<uint32_t>(n), use_bjdata);
17304 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
17308 oa->write_character(to_char_type(
'L'));
17310 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17317 oa->write_character(to_char_type(
'H'));
17320 const auto number = BasicJsonType(n).dump();
17321 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17322 for (std::size_t i = 0; i < number.size(); ++i)
17324 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17333 CharType
ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
17337 case value_t::null:
17340 case value_t::boolean:
17341 return j.m_data.m_value.boolean ?
'T' :
'F';
17343 case value_t::number_integer:
17345 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
17349 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
17353 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
17357 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
17361 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
17365 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
17369 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
17377 case value_t::number_unsigned:
17379 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17383 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17387 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17391 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
17395 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17399 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
17403 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17407 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
17415 case value_t::number_float:
17416 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
17418 case value_t::string:
17421 case value_t::array:
17422 case value_t::binary:
17425 case value_t::object:
17428 case value_t::discarded:
17449 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
17450 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'},
17451 {
"char",
'C'}, {
"byte",
'B'}
17455 auto it = bjdtype.find(
static_cast<string_t>(value.at(
key)));
17456 if (it == bjdtype.end())
17460 CharType dtype = it->second;
17462 key =
"_ArraySize_";
17463 std::size_t len = (value.at(
key).empty() ? 0 : 1);
17464 for (
const auto& el : value.at(
key))
17466 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
17469 key =
"_ArrayData_";
17470 if (value.at(
key).size() != len)
17475 oa->write_character(
'[');
17476 oa->write_character(
'$');
17477 oa->write_character(dtype);
17478 oa->write_character(
'#');
17480 key =
"_ArraySize_";
17481 write_ubjson(value.at(
key), use_count, use_type,
true,
true, bjdata_version);
17483 key =
"_ArrayData_";
17484 if (dtype ==
'U' || dtype ==
'C' || dtype ==
'B')
17486 for (
const auto& el : value.at(
key))
17488 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
17491 else if (dtype ==
'i')
17493 for (
const auto& el : value.at(
key))
17495 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
17498 else if (dtype ==
'u')
17500 for (
const auto& el : value.at(
key))
17502 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
17505 else if (dtype ==
'I')
17507 for (
const auto& el : value.at(
key))
17509 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
17512 else if (dtype ==
'm')
17514 for (
const auto& el : value.at(
key))
17516 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
17519 else if (dtype ==
'l')
17521 for (
const auto& el : value.at(
key))
17523 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
17526 else if (dtype ==
'M')
17528 for (
const auto& el : value.at(
key))
17530 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
17533 else if (dtype ==
'L')
17535 for (
const auto& el : value.at(
key))
17537 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
17540 else if (dtype ==
'd')
17542 for (
const auto& el : value.at(
key))
17544 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
17547 else if (dtype ==
'D')
17549 for (
const auto& el : value.at(
key))
17551 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
17574 template<
typename NumberType>
17578 std::array<CharType,
sizeof(NumberType)> vec{};
17579 std::memcpy(vec.data(), &n,
sizeof(NumberType));
17582 if (is_little_endian != OutputIsLittleEndian)
17585 std::reverse(vec.begin(), vec.end());
17588 oa->write_characters(vec.data(),
sizeof(NumberType));
17594#pragma GCC diagnostic push
17595#pragma GCC diagnostic ignored "-Wfloat-equal"
17597 if (!std::isfinite(n) || ((
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17598 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17599 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))))
17602 ? get_cbor_float_prefix(
static_cast<float>(n))
17603 : get_msgpack_float_prefix(
static_cast<float>(n)));
17604 write_number(
static_cast<float>(n));
17609 ? get_cbor_float_prefix(n)
17610 : get_msgpack_float_prefix(n));
17614#pragma GCC diagnostic pop
17623 template <
typename C = CharType,
17624 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
17627 return *
reinterpret_cast<char*
>(&x);
17630 template <
typename C = CharType,
17631 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
17641#ifdef JSON_HAS_CPP_26
17642 static_assert(std::is_trivially_copyable<CharType>::value,
"CharType must be trivially copyable");
17643 static_assert(std::is_trivially_default_constructible<CharType>::value,
"CharType must be trivially default constructible");
17645 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
17648 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17650 std::memcpy(&result, &x,
sizeof(x));
17654 template<
typename C = CharType,
17661 template <
typename InputCharType,
typename C = CharType,
17663 std::is_signed<C>::value &&
17664 std::is_signed<char>::value &&
17665 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
17697#include <algorithm>
17707#include <type_traits>
17727#include <type_traits>
17758template<
typename Target,
typename Source>
17761 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17764 std::memcpy(&target, &source,
sizeof(Source));
17770 static constexpr int kPrecision = 64;
17772 std::uint64_t f = 0;
17775 constexpr diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
17786 return {x.f - y.f, x.e};
17795 static_assert(kPrecision == 64,
"internal error");
17820 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17821 const std::uint64_t u_hi = x.f >> 32u;
17822 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17823 const std::uint64_t v_hi = y.f >> 32u;
17825 const std::uint64_t p0 = u_lo * v_lo;
17826 const std::uint64_t p1 = u_lo * v_hi;
17827 const std::uint64_t p2 = u_hi * v_lo;
17828 const std::uint64_t p3 = u_hi * v_hi;
17830 const std::uint64_t p0_hi = p0 >> 32u;
17831 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17832 const std::uint64_t p1_hi = p1 >> 32u;
17833 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17834 const std::uint64_t p2_hi = p2 >> 32u;
17836 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17847 Q += std::uint64_t{1} << (64u - 32u - 1u);
17849 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17851 return {h, x.e + y.e + 64};
17862 while ((x.f >> 63u) == 0)
17877 const int delta = x.e - target_exponent;
17882 return {x.f << delta, target_exponent};
17899template<
typename FloatType>
17912 static_assert(std::numeric_limits<FloatType>::is_iec559,
17913 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17915 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17916 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17917 constexpr int kMinExp = 1 - kBias;
17918 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17920 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17922 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(value));
17923 const std::uint64_t
E = bits >> (kPrecision - 1);
17924 const std::uint64_t F = bits & (kHiddenBit - 1);
17926 const bool is_denormal =
E == 0;
17927 const diyfp v = is_denormal
17928 ?
diyfp(F, kMinExp)
17929 :
diyfp(F + kHiddenBit,
static_cast<int>(
E) - kBias);
17952 const bool lower_boundary_is_closer = F == 0 &&
E > 1;
17954 const diyfp m_minus = lower_boundary_is_closer
17955 ?
diyfp((4 * v.
f) - 1, v.
e - 2)
17956 :
diyfp((2 * v.
f) - 1, v.
e - 1);
17959 const diyfp w_plus = diyfp::normalize(m_plus);
17962 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
17964 return {diyfp::normalize(v), w_minus, w_plus};
18091 constexpr int kCachedPowersMinDecExp = -300;
18092 constexpr int kCachedPowersDecStep = 8;
18094 static constexpr std::array<cached_power, 79> kCachedPowers =
18097 { 0xAB70FE17C79AC6CA, -1060, -300 },
18098 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
18099 { 0xBE5691EF416BD60C, -1007, -284 },
18100 { 0x8DD01FAD907FFC3C, -980, -276 },
18101 { 0xD3515C2831559A83, -954, -268 },
18102 { 0x9D71AC8FADA6C9B5, -927, -260 },
18103 { 0xEA9C227723EE8BCB, -901, -252 },
18104 { 0xAECC49914078536D, -874, -244 },
18105 { 0x823C12795DB6CE57, -847, -236 },
18106 { 0xC21094364DFB5637, -821, -228 },
18107 { 0x9096EA6F3848984F, -794, -220 },
18108 { 0xD77485CB25823AC7, -768, -212 },
18109 { 0xA086CFCD97BF97F4, -741, -204 },
18110 { 0xEF340A98172AACE5, -715, -196 },
18111 { 0xB23867FB2A35B28E, -688, -188 },
18112 { 0x84C8D4DFD2C63F3B, -661, -180 },
18113 { 0xC5DD44271AD3CDBA, -635, -172 },
18114 { 0x936B9FCEBB25C996, -608, -164 },
18115 { 0xDBAC6C247D62A584, -582, -156 },
18116 { 0xA3AB66580D5FDAF6, -555, -148 },
18117 { 0xF3E2F893DEC3F126, -529, -140 },
18118 { 0xB5B5ADA8AAFF80B8, -502, -132 },
18119 { 0x87625F056C7C4A8B, -475, -124 },
18120 { 0xC9BCFF6034C13053, -449, -116 },
18121 { 0x964E858C91BA2655, -422, -108 },
18122 { 0xDFF9772470297EBD, -396, -100 },
18123 { 0xA6DFBD9FB8E5B88F, -369, -92 },
18124 { 0xF8A95FCF88747D94, -343, -84 },
18125 { 0xB94470938FA89BCF, -316, -76 },
18126 { 0x8A08F0F8BF0F156B, -289, -68 },
18127 { 0xCDB02555653131B6, -263, -60 },
18128 { 0x993FE2C6D07B7FAC, -236, -52 },
18129 { 0xE45C10C42A2B3B06, -210, -44 },
18130 { 0xAA242499697392D3, -183, -36 },
18131 { 0xFD87B5F28300CA0E, -157, -28 },
18132 { 0xBCE5086492111AEB, -130, -20 },
18133 { 0x8CBCCC096F5088CC, -103, -12 },
18134 { 0xD1B71758E219652C, -77, -4 },
18135 { 0x9C40000000000000, -50, 4 },
18136 { 0xE8D4A51000000000, -24, 12 },
18137 { 0xAD78EBC5AC620000, 3, 20 },
18138 { 0x813F3978F8940984, 30, 28 },
18139 { 0xC097CE7BC90715B3, 56, 36 },
18140 { 0x8F7E32CE7BEA5C70, 83, 44 },
18141 { 0xD5D238A4ABE98068, 109, 52 },
18142 { 0x9F4F2726179A2245, 136, 60 },
18143 { 0xED63A231D4C4FB27, 162, 68 },
18144 { 0xB0DE65388CC8ADA8, 189, 76 },
18145 { 0x83C7088E1AAB65DB, 216, 84 },
18146 { 0xC45D1DF942711D9A, 242, 92 },
18147 { 0x924D692CA61BE758, 269, 100 },
18148 { 0xDA01EE641A708DEA, 295, 108 },
18149 { 0xA26DA3999AEF774A, 322, 116 },
18150 { 0xF209787BB47D6B85, 348, 124 },
18151 { 0xB454E4A179DD1877, 375, 132 },
18152 { 0x865B86925B9BC5C2, 402, 140 },
18153 { 0xC83553C5C8965D3D, 428, 148 },
18154 { 0x952AB45CFA97A0B3, 455, 156 },
18155 { 0xDE469FBD99A05FE3, 481, 164 },
18156 { 0xA59BC234DB398C25, 508, 172 },
18157 { 0xF6C69A72A3989F5C, 534, 180 },
18158 { 0xB7DCBF5354E9BECE, 561, 188 },
18159 { 0x88FCF317F22241E2, 588, 196 },
18160 { 0xCC20CE9BD35C78A5, 614, 204 },
18161 { 0x98165AF37B2153DF, 641, 212 },
18162 { 0xE2A0B5DC971F303A, 667, 220 },
18163 { 0xA8D9D1535CE3B396, 694, 228 },
18164 { 0xFB9B7CD9A4A7443C, 720, 236 },
18165 { 0xBB764C4CA7A44410, 747, 244 },
18166 { 0x8BAB8EEFB6409C1A, 774, 252 },
18167 { 0xD01FEF10A657842C, 800, 260 },
18168 { 0x9B10A4E5E9913129, 827, 268 },
18169 { 0xE7109BFBA19C0C9D, 853, 276 },
18170 { 0xAC2820D9623BF429, 880, 284 },
18171 { 0x80444B5E7AA7CF85, 907, 292 },
18172 { 0xBF21E44003ACDD2D, 933, 300 },
18173 { 0x8E679C2F5E44FF8F, 960, 308 },
18174 { 0xD433179D9C8CB841, 986, 316 },
18175 { 0x9E19DB92B4E31BA9, 1013, 324 },
18185 const int f =
kAlpha - e - 1;
18186 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
18188 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
18190 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
18192 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
18206 if (n >= 1000000000)
18208 pow10 = 1000000000;
18212 if (n >= 100000000)
18257inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
18258 std::uint64_t rest, std::uint64_t ten_k)
18285 && delta - rest >= ten_k
18286 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
18301 static_assert(
kAlpha >= -60,
"internal error");
18302 static_assert(
kGamma <= -32,
"internal error");
18319 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
18320 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
18329 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
18331 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
18332 std::uint64_t p2 = M_plus.
f & (one.f - 1);
18340 std::uint32_t pow10{};
18368 const std::uint32_t d = p1 / pow10;
18369 const std::uint32_t r = p1 % pow10;
18375 buffer[length++] =
static_cast<char>(
'0' + d);
18394 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
18399 decimal_exponent += n;
18410 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
18411 grisu2_round(buffer, length, dist, delta, rest, ten_n);
18472 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
18474 const std::uint64_t d = p2 >> -one.e;
18475 const std::uint64_t r = p2 & (one.f - 1);
18482 buffer[length++] =
static_cast<char>(
'0' + d);
18507 decimal_exponent -= m;
18515 const std::uint64_t ten_m = one.f;
18539inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
18556 const diyfp c_minus_k(cached.
f, cached.
e);
18559 const diyfp w = diyfp::mul(v, c_minus_k);
18560 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
18561 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
18584 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
18585 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
18587 decimal_exponent = -cached.
k;
18597template<
typename FloatType>
18599void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
18601 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
18602 "internal error: not enough precision");
18639inline
char* append_exponent(
char* buf,
int e)
18654 auto k =
static_cast<std::uint32_t
>(e);
18660 *buf++ =
static_cast<char>(
'0' + k);
18664 *buf++ =
static_cast<char>(
'0' + (k / 10));
18666 *buf++ =
static_cast<char>(
'0' + k);
18670 *buf++ =
static_cast<char>(
'0' + (k / 100));
18672 *buf++ =
static_cast<char>(
'0' + (k / 10));
18674 *buf++ =
static_cast<char>(
'0' + k);
18691inline
char* format_buffer(
char* buf,
int len,
int decimal_exponent,
18692 int min_exp,
int max_exp)
18698 const int n = len + decimal_exponent;
18704 if (k <= n && n <= max_exp)
18709 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18713 return buf + (
static_cast<size_t>(n) + 2);
18716 if (0 < n && n <= max_exp)
18723 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18725 return buf + (
static_cast<size_t>(k) + 1U);
18728 if (min_exp < n && n <= 0)
18733 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18736 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18737 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18752 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18754 buf += 1 +
static_cast<size_t>(k);
18773template<
typename FloatType>
18776char* to_chars(
char*
first, const
char* last, FloatType value)
18778 static_cast<void>(last);
18782 if (std::signbit(value))
18789#pragma GCC diagnostic push
18790#pragma GCC diagnostic ignored "-Wfloat-equal"
18801#pragma GCC diagnostic pop
18804 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10);
18811 int decimal_exponent = 0;
18812 dtoa_impl::grisu2(
first, len, decimal_exponent, value);
18814 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18817 constexpr int kMinExp = -4;
18819 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18822 JSON_ASSERT(last -
first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18823 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18825 return dtoa_impl::format_buffer(
first, len, decimal_exponent, kMinExp, kMaxExp);
18862template<
typename BasicJsonType>
18870 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18871 static constexpr std::uint8_t UTF8_REJECT = 1;
18882 , loc(
std::localeconv())
18883 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->thousands_sep)))
18884 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->decimal_point)))
18885 , indent_char(ichar)
18886 , indent_string(512, indent_char)
18887 , error_handler(error_handler_)
18920 const bool pretty_print,
18921 const bool ensure_ascii,
18922 const unsigned int indent_step,
18923 const unsigned int current_indent = 0)
18925 switch (val.m_data.m_type)
18927 case value_t::object:
18929 if (val.m_data.m_value.object->empty())
18931 o->write_characters(
"{}", 2);
18937 o->write_characters(
"{\n", 2);
18940 const auto new_indent = current_indent + indent_step;
18943 indent_string.resize(indent_string.size() * 2,
' ');
18947 auto i = val.m_data.m_value.object->cbegin();
18948 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18950 o->write_characters(indent_string.c_str(), new_indent);
18951 o->write_character(
'\"');
18952 dump_escaped(i->first, ensure_ascii);
18953 o->write_characters(
"\": ", 3);
18954 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18955 o->write_characters(
",\n", 2);
18959 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18960 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18961 o->write_characters(indent_string.c_str(), new_indent);
18962 o->write_character(
'\"');
18963 dump_escaped(i->first, ensure_ascii);
18964 o->write_characters(
"\": ", 3);
18965 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18967 o->write_character(
'\n');
18968 o->write_characters(indent_string.c_str(), current_indent);
18969 o->write_character(
'}');
18973 o->write_character(
'{');
18976 auto i = val.m_data.m_value.object->cbegin();
18977 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18979 o->write_character(
'\"');
18980 dump_escaped(i->first, ensure_ascii);
18981 o->write_characters(
"\":", 2);
18982 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18983 o->write_character(
',');
18987 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18988 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18989 o->write_character(
'\"');
18990 dump_escaped(i->first, ensure_ascii);
18991 o->write_characters(
"\":", 2);
18992 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18994 o->write_character(
'}');
19000 case value_t::array:
19002 if (val.m_data.m_value.array->empty())
19004 o->write_characters(
"[]", 2);
19010 o->write_characters(
"[\n", 2);
19013 const auto new_indent = current_indent + indent_step;
19016 indent_string.resize(indent_string.size() * 2,
' ');
19020 for (
auto i = val.m_data.m_value.array->cbegin();
19021 i != val.m_data.m_value.array->cend() - 1; ++i)
19023 o->write_characters(indent_string.c_str(), new_indent);
19024 dump(*i,
true, ensure_ascii, indent_step, new_indent);
19025 o->write_characters(
",\n", 2);
19030 o->write_characters(indent_string.c_str(), new_indent);
19031 dump(val.m_data.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
19033 o->write_character(
'\n');
19034 o->write_characters(indent_string.c_str(), current_indent);
19035 o->write_character(
']');
19039 o->write_character(
'[');
19042 for (
auto i = val.m_data.m_value.array->cbegin();
19043 i != val.m_data.m_value.array->cend() - 1; ++i)
19045 dump(*i,
false, ensure_ascii, indent_step, current_indent);
19046 o->write_character(
',');
19051 dump(val.m_data.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
19053 o->write_character(
']');
19059 case value_t::string:
19061 o->write_character(
'\"');
19062 dump_escaped(*val.m_data.m_value.string, ensure_ascii);
19063 o->write_character(
'\"');
19067 case value_t::binary:
19071 o->write_characters(
"{\n", 2);
19074 const auto new_indent = current_indent + indent_step;
19077 indent_string.resize(indent_string.size() * 2,
' ');
19080 o->write_characters(indent_string.c_str(), new_indent);
19082 o->write_characters(
"\"bytes\": [", 10);
19084 if (!val.m_data.m_value.binary->empty())
19086 for (
auto i = val.m_data.m_value.binary->cbegin();
19087 i != val.m_data.m_value.binary->cend() - 1; ++i)
19090 o->write_characters(
", ", 2);
19092 dump_integer(val.m_data.m_value.binary->back());
19095 o->write_characters(
"],\n", 3);
19096 o->write_characters(indent_string.c_str(), new_indent);
19098 o->write_characters(
"\"subtype\": ", 11);
19099 if (val.m_data.m_value.binary->has_subtype())
19101 dump_integer(val.m_data.m_value.binary->subtype());
19105 o->write_characters(
"null", 4);
19107 o->write_character(
'\n');
19108 o->write_characters(indent_string.c_str(), current_indent);
19109 o->write_character(
'}');
19113 o->write_characters(
"{\"bytes\":[", 10);
19115 if (!val.m_data.m_value.binary->empty())
19117 for (
auto i = val.m_data.m_value.binary->cbegin();
19118 i != val.m_data.m_value.binary->cend() - 1; ++i)
19121 o->write_character(
',');
19123 dump_integer(val.m_data.m_value.binary->back());
19126 o->write_characters(
"],\"subtype\":", 12);
19127 if (val.m_data.m_value.binary->has_subtype())
19129 dump_integer(val.m_data.m_value.binary->subtype());
19130 o->write_character(
'}');
19134 o->write_characters(
"null}", 5);
19140 case value_t::boolean:
19142 if (val.m_data.m_value.boolean)
19144 o->write_characters(
"true", 4);
19148 o->write_characters(
"false", 5);
19153 case value_t::number_integer:
19155 dump_integer(val.m_data.m_value.number_integer);
19159 case value_t::number_unsigned:
19161 dump_integer(val.m_data.m_value.number_unsigned);
19165 case value_t::number_float:
19167 dump_float(val.m_data.m_value.number_float);
19171 case value_t::discarded:
19173 o->write_characters(
"<discarded>", 11);
19177 case value_t::null:
19179 o->write_characters(
"null", 4);
19203 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
19205 std::uint32_t codepoint{};
19206 std::uint8_t state = UTF8_ACCEPT;
19207 std::size_t bytes = 0;
19210 std::size_t bytes_after_last_accept = 0;
19211 std::size_t undumped_chars = 0;
19213 for (std::size_t i = 0; i < s.size(); ++i)
19215 const auto byte =
static_cast<std::uint8_t
>(s[i]);
19217 switch (decode(state, codepoint,
byte))
19225 string_buffer[bytes++] =
'\\';
19226 string_buffer[bytes++] =
'b';
19232 string_buffer[bytes++] =
'\\';
19233 string_buffer[bytes++] =
't';
19239 string_buffer[bytes++] =
'\\';
19240 string_buffer[bytes++] =
'n';
19246 string_buffer[bytes++] =
'\\';
19247 string_buffer[bytes++] =
'f';
19253 string_buffer[bytes++] =
'\\';
19254 string_buffer[bytes++] =
'r';
19260 string_buffer[bytes++] =
'\\';
19261 string_buffer[bytes++] =
'\"';
19267 string_buffer[bytes++] =
'\\';
19268 string_buffer[bytes++] =
'\\';
19276 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
19278 if (codepoint <= 0xFFFF)
19281 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
19282 static_cast<std::uint16_t
>(codepoint)));
19288 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
19289 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
19290 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
19298 string_buffer[bytes++] = s[i];
19307 if (string_buffer.size() - bytes < 13)
19309 o->write_characters(string_buffer.data(), bytes);
19314 bytes_after_last_accept = bytes;
19315 undumped_chars = 0;
19321 switch (error_handler)
19323 case error_handler_t::strict:
19325 JSON_THROW(type_error::create(316,
concat(
"invalid UTF-8 byte at index ", std::to_string(i),
": 0x", hex_bytes(
byte | 0)),
nullptr));
19328 case error_handler_t::ignore:
19329 case error_handler_t::replace:
19335 if (undumped_chars > 0)
19342 bytes = bytes_after_last_accept;
19344 if (error_handler == error_handler_t::replace)
19349 string_buffer[bytes++] =
'\\';
19350 string_buffer[bytes++] =
'u';
19351 string_buffer[bytes++] =
'f';
19352 string_buffer[bytes++] =
'f';
19353 string_buffer[bytes++] =
'f';
19354 string_buffer[bytes++] =
'd';
19366 if (string_buffer.size() - bytes < 13)
19368 o->write_characters(string_buffer.data(), bytes);
19372 bytes_after_last_accept = bytes;
19375 undumped_chars = 0;
19378 state = UTF8_ACCEPT;
19393 string_buffer[bytes++] = s[i];
19407 o->write_characters(string_buffer.data(), bytes);
19413 switch (error_handler)
19415 case error_handler_t::strict:
19417 JSON_THROW(type_error::create(316,
concat(
"incomplete UTF-8 string; last byte: 0x", hex_bytes(
static_cast<std::uint8_t
>(s.back() | 0))),
nullptr));
19420 case error_handler_t::ignore:
19423 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19427 case error_handler_t::replace:
19430 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19434 o->write_characters(
"\\ufffd", 6);
19438 o->write_characters(
"\xEF\xBF\xBD", 3);
19458 unsigned int count_digits(number_unsigned_t x)
noexcept
19460 unsigned int n_digits = 1;
19469 return n_digits + 1;
19473 return n_digits + 2;
19477 return n_digits + 3;
19489 static std::string hex_bytes(std::uint8_t
byte)
19491 std::string result =
"FF";
19492 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
19493 result[0] = nibble_to_hex[
byte / 16];
19494 result[1] = nibble_to_hex[
byte % 16];
19499 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
19500 bool is_negative_number(NumberType x)
19505 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
19506 bool is_negative_number(NumberType )
19521 std::is_integral<NumberType>::value ||
19522 std::is_same<NumberType, number_unsigned_t>::value ||
19523 std::is_same<NumberType, number_integer_t>::value ||
19524 std::is_same<NumberType, binary_char_t>::value,
19526 void dump_integer(NumberType x)
19528 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
19531 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
19532 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
19533 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
19534 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
19535 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
19536 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
19537 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
19538 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
19539 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
19540 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
19547 o->write_character(
'0');
19552 auto buffer_ptr = number_buffer.begin();
19554 number_unsigned_t abs_value;
19556 unsigned int n_chars{};
19558 if (is_negative_number(x))
19561 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
19564 n_chars = 1 + count_digits(abs_value);
19568 abs_value =
static_cast<number_unsigned_t
>(
x);
19569 n_chars = count_digits(abs_value);
19577 buffer_ptr +=
static_cast<typename decltype(number_buffer)::difference_type
>(n_chars);
19581 while (abs_value >= 100)
19583 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
19585 *(--buffer_ptr) = digits_to_99[digits_index][1];
19586 *(--buffer_ptr) = digits_to_99[digits_index][0];
19589 if (abs_value >= 10)
19591 const auto digits_index =
static_cast<unsigned>(abs_value);
19592 *(--buffer_ptr) = digits_to_99[digits_index][1];
19593 *(--buffer_ptr) = digits_to_99[digits_index][0];
19597 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19600 o->write_characters(number_buffer.data(), n_chars);
19611 void dump_float(number_float_t x)
19614 if (!std::isfinite(x))
19616 o->write_characters(
"null", 4);
19625 static constexpr bool is_ieee_single_or_double
19626 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
19627 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
19629 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
19632 void dump_float(number_float_t x, std::true_type )
19634 auto* begin = number_buffer.data();
19635 auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
19637 o->write_characters(begin,
static_cast<size_t>(end - begin));
19640 void dump_float(number_float_t x, std::false_type )
19643 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
19647 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d,
x);
19652 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
19655 if (thousands_sep !=
'\0')
19658 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
19659 std::fill(end, number_buffer.end(),
'\0');
19660 JSON_ASSERT((end - number_buffer.begin()) <= len);
19661 len = (end - number_buffer.begin());
19665 if (decimal_point !=
'\0' && decimal_point !=
'.')
19668 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
19669 if (dec_pos != number_buffer.end())
19675 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
19678 const bool value_is_int_like =
19679 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
19682 return c ==
'.' || c ==
'e';
19685 if (value_is_int_like)
19687 o->write_characters(
".0", 2);
19712 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19714 static const std::array<std::uint8_t, 400> utf8d =
19717 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19718 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19719 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19720 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19721 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
19722 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19723 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19724 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19725 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19726 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19727 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
19728 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
19729 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
19730 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
19735 const std::uint8_t
type = utf8d[byte];
19737 codep = (state != UTF8_ACCEPT)
19738 ? (
byte & 0x3fu) | (codep << 6u)
19739 : (0xFFu >>
type) & (byte);
19741 const std::size_t index = 256u + (
static_cast<size_t>(state) * 16u) +
static_cast<size_t>(
type);
19743 state = utf8d[index];
19752 number_unsigned_t remove_sign(number_unsigned_t x)
19767 number_unsigned_t remove_sign(number_integer_t x)
noexcept
19769 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19770 return static_cast<number_unsigned_t
>(-(
x + 1)) + 1;
19775 output_adapter_t<char> o =
nullptr;
19778 std::array<char, 64> number_buffer{{}};
19781 const std::lconv* loc =
nullptr;
19783 const char thousands_sep =
'\0';
19785 const char decimal_point =
'\0';
19788 std::array<char, 512> string_buffer{{}};
19817#include <functional>
19818#include <initializer_list>
19821#include <stdexcept>
19822#include <type_traits>
19835template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19836 class Allocator = std::allocator<std::pair<const Key, T>>>
19841 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19846#ifdef JSON_HAS_CPP_14
19856 template <
class It>
19859 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19864 for (
auto it = this->begin(); it != this->end(); ++it)
19866 if (m_compare(it->first, key))
19868 return {it,
false};
19871 Container::emplace_back(key, std::forward<T>(t));
19872 return {std::prev(this->end()),
true};
19877 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19879 for (
auto it = this->begin(); it != this->end(); ++it)
19881 if (m_compare(it->first, key))
19883 return {it,
false};
19886 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19887 return {std::prev(this->end()),
true};
19892 return emplace(key, T{}).
first->second;
19899 return emplace(std::forward<KeyType>(key), T{}).
first->second;
19911 return at(std::forward<KeyType>(key));
19916 for (
auto it = this->begin(); it != this->end(); ++it)
19918 if (m_compare(it->first, key))
19924 JSON_THROW(std::out_of_range(
"key not found"));
19931 for (
auto it = this->begin(); it != this->end(); ++it)
19933 if (m_compare(it->first, key))
19939 JSON_THROW(std::out_of_range(
"key not found"));
19944 for (
auto it = this->begin(); it != this->end(); ++it)
19946 if (m_compare(it->first, key))
19952 JSON_THROW(std::out_of_range(
"key not found"));
19957 const T &
at(KeyType && key)
const
19959 for (
auto it = this->begin(); it != this->end(); ++it)
19961 if (m_compare(it->first, key))
19967 JSON_THROW(std::out_of_range(
"key not found"));
19972 for (
auto it = this->begin(); it != this->end(); ++it)
19974 if (m_compare(it->first, key))
19977 for (
auto next = it; ++next != this->end(); ++it)
19982 Container::pop_back();
19993 for (
auto it = this->begin(); it != this->end(); ++it)
19995 if (m_compare(it->first, key))
19998 for (
auto next = it; ++next != this->end(); ++it)
20003 Container::pop_back();
20012 return erase(pos, std::next(pos));
20022 const auto elements_affected = std::distance(
first, last);
20023 const auto offset = std::distance(Container::begin(),
first);
20045 for (
auto it =
first; std::next(it, elements_affected) != Container::end(); ++it)
20048 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
20056 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
20065 return Container::begin() + offset;
20070 for (
auto it = this->begin(); it != this->end(); ++it)
20072 if (m_compare(it->first, key))
20084 for (
auto it = this->begin(); it != this->end(); ++it)
20086 if (m_compare(it->first, key))
20096 for (
auto it = this->begin(); it != this->end(); ++it)
20098 if (m_compare(it->first, key))
20103 return Container::end();
20110 for (
auto it = this->begin(); it != this->end(); ++it)
20112 if (m_compare(it->first, key))
20117 return Container::end();
20122 for (
auto it = this->begin(); it != this->end(); ++it)
20124 if (m_compare(it->first, key))
20129 return Container::end();
20134 return emplace(value.first, std::move(value.second));
20139 for (
auto it = this->begin(); it != this->end(); ++it)
20141 if (m_compare(it->first, value.first))
20143 return {it,
false};
20146 Container::push_back(value);
20147 return {--this->end(),
true};
20150 template<
typename InputIt>
20151 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20152 std::input_iterator_tag>::value>::type;
20154 template<
typename InputIt,
typename = require_input_iter<InputIt>>
20157 for (
auto it =
first; it != last; ++it)
20170#if defined(JSON_HAS_CPP_17)
20171 #if JSON_HAS_STATIC_RTTI
20174 #include <string_view>
20204 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
20210 friend class ::nlohmann::json_pointer;
20214 template<
typename BasicJsonType,
typename InputType>
20215 friend class ::nlohmann::detail::parser;
20216 friend ::nlohmann::detail::serializer<basic_json>;
20217 template<
typename BasicJsonType>
20218 friend class ::nlohmann::detail::iter_impl;
20219 template<
typename BasicJsonType,
typename CharType>
20220 friend class ::nlohmann::detail::binary_writer;
20221 template<
typename BasicJsonType,
typename InputType,
typename SAX>
20222 friend class ::nlohmann::detail::binary_reader;
20223 template<
typename BasicJsonType,
typename InputAdapterType>
20224 friend class ::nlohmann::detail::json_sax_dom_parser;
20225 template<
typename BasicJsonType,
typename InputAdapterType>
20226 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
20227 friend class ::nlohmann::detail::exception;
20235 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
20237 template<
typename InputAdapterType>
20238 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
20239 InputAdapterType adapter,
20241 const bool allow_exceptions =
true,
20242 const bool ignore_comments =
false,
20243 const bool ignore_trailing_commas =
false
20246 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20247 std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
20252 template<
typename BasicJsonType>
20254 template<
typename BasicJsonType>
20256 template<
typename Iterator>
20260 template<
typename CharType>
20263 template<
typename InputType>
20265 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
20268 using serializer = ::nlohmann::detail::serializer<basic_json>;
20274 template<
typename T,
typename SFINAE>
20332 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
20334 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
20361 result[
"copyright"] =
"(C) 2013-2025 Niels Lohmann";
20362 result[
"name"] =
"JSON for Modern C++";
20363 result[
"url"] =
"https://github.com/nlohmann/json";
20364 result[
"version"][
"string"] =
20373 result[
"platform"] =
"win32";
20374#elif defined __linux__
20375 result[
"platform"] =
"linux";
20376#elif defined __APPLE__
20377 result[
"platform"] =
"apple";
20378#elif defined __unix__
20379 result[
"platform"] =
"unix";
20381 result[
"platform"] =
"unknown";
20384#if defined(__ICC) || defined(__INTEL_COMPILER)
20385 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
20386#elif defined(__clang__)
20387 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
20388#elif defined(__GNUC__) || defined(__GNUG__)
20389 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
20390 std::to_string(__GNUC__),
'.',
20391 std::to_string(__GNUC_MINOR__),
'.',
20392 std::to_string(__GNUC_PATCHLEVEL__))
20395#elif defined(__HP_cc) || defined(__HP_aCC)
20396 result[
"compiler"] =
"hp"
20397#elif defined(__IBMCPP__)
20398 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
20399#elif defined(_MSC_VER)
20400 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
20401#elif defined(__PGI)
20402 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
20403#elif defined(__SUNPRO_CC)
20404 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
20406 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
20409#if defined(_MSVC_LANG)
20410 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
20411#elif defined(__cplusplus)
20412 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
20414 result[
"compiler"][
"c++"] =
"unknown";
20432#if defined(JSON_HAS_CPP_14)
20435 using default_object_comparator_t = std::less<>;
20445 AllocatorType<std::pair<
const StringType,
20450 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
20474 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
20485 template<
typename T,
typename... Args>
20489 AllocatorType<T> alloc;
20490 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
20492 auto deleter = [&](T * obj)
20494 AllocatorTraits::deallocate(alloc, obj, 1);
20496 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
20497 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
20499 return obj.release();
20566 case value_t::object:
20568 object = create<object_t>();
20572 case value_t::array:
20574 array = create<array_t>();
20578 case value_t::string:
20580 string = create<string_t>(
"");
20584 case value_t::binary:
20586 binary = create<binary_t>();
20590 case value_t::boolean:
20592 boolean =
static_cast<boolean_t>(
false);
20596 case value_t::number_integer:
20602 case value_t::number_unsigned:
20608 case value_t::number_float:
20614 case value_t::null:
20620 case value_t::discarded:
20626 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0",
nullptr));
20666 (t == value_t::object &&
object ==
nullptr) ||
20667 (t == value_t::array && array ==
nullptr) ||
20668 (t == value_t::string &&
string ==
nullptr) ||
20669 (t == value_t::binary && binary ==
nullptr)
20675 if (t == value_t::array || t == value_t::object)
20678 std::vector<basic_json> stack;
20681 if (t == value_t::array)
20683 stack.reserve(array->size());
20684 std::move(array->begin(), array->end(), std::back_inserter(stack));
20688 stack.reserve(
object->size());
20689 for (
auto&& it : *
object)
20691 stack.push_back(std::move(it.second));
20695 while (!stack.empty())
20698 basic_json current_item(std::move(stack.back()));
20705 std::move(current_item.
m_data.m_value.array->begin(), current_item.
m_data.m_value.array->end(), std::back_inserter(stack));
20707 current_item.
m_data.m_value.array->clear();
20711 for (
auto&& it : *current_item.
m_data.m_value.object)
20713 stack.push_back(std::move(it.second));
20716 current_item.
m_data.m_value.object->clear();
20726 case value_t::object:
20728 AllocatorType<object_t> alloc;
20729 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20730 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20734 case value_t::array:
20736 AllocatorType<array_t> alloc;
20737 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20738 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20742 case value_t::string:
20744 AllocatorType<string_t> alloc;
20745 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20746 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20750 case value_t::binary:
20752 AllocatorType<binary_t> alloc;
20753 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20754 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20758 case value_t::null:
20759 case value_t::boolean:
20760 case value_t::number_integer:
20761 case value_t::number_unsigned:
20762 case value_t::number_float:
20763 case value_t::discarded:
20793 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
20794 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
20795 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
20796 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
20798#if JSON_DIAGNOSTICS
20802 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
20804 return j.m_parent ==
this;
20809 static_cast<void>(check_parents);
20814#if JSON_DIAGNOSTICS
20815 switch (m_data.m_type)
20817 case value_t::array:
20819 for (
auto& element : *m_data.m_value.array)
20821 element.m_parent =
this;
20826 case value_t::object:
20828 for (
auto& element : *m_data.m_value.object)
20830 element.second.m_parent =
this;
20835 case value_t::null:
20836 case value_t::string:
20837 case value_t::boolean:
20838 case value_t::number_integer:
20839 case value_t::number_unsigned:
20840 case value_t::number_float:
20841 case value_t::binary:
20842 case value_t::discarded:
20851#if JSON_DIAGNOSTICS
20852 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20854 (it + i)->m_parent =
this;
20857 static_cast<void>(count_set_parents);
20864#if JSON_DIAGNOSTICS
20879#ifdef JSON_HEDLEY_MSVC_VERSION
20880#pragma warning(push )
20881#pragma warning(disable : 4127)
20888#ifdef JSON_HEDLEY_MSVC_VERSION
20889#pragma warning( pop )
20894 static_cast<void>(j);
20895 static_cast<void>(old_capacity);
20927 assert_invariant();
20935 assert_invariant();
20940 template <
typename CompatibleType,
20945 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20946 std::forward<CompatibleType>(val))))
20948 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20950 assert_invariant();
20955 template <
typename BasicJsonType,
20959#if JSON_DIAGNOSTIC_POSITIONS
20960 : start_position(val.start_pos()),
20961 end_position(val.end_pos())
20964 using other_boolean_t =
typename BasicJsonType::boolean_t;
20965 using other_number_float_t =
typename BasicJsonType::number_float_t;
20966 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20967 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20968 using other_string_t =
typename BasicJsonType::string_t;
20969 using other_object_t =
typename BasicJsonType::object_t;
20970 using other_array_t =
typename BasicJsonType::array_t;
20971 using other_binary_t =
typename BasicJsonType::binary_t;
20973 switch (val.type())
20975 case value_t::boolean:
20976 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
20978 case value_t::number_float:
20979 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
20981 case value_t::number_integer:
20982 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
20984 case value_t::number_unsigned:
20985 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
20987 case value_t::string:
20988 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
20990 case value_t::object:
20991 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
20993 case value_t::array:
20994 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
20996 case value_t::binary:
20997 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
20999 case value_t::null:
21002 case value_t::discarded:
21003 m_data.m_type = value_t::discarded;
21011 assert_invariant();
21017 bool type_deduction =
true,
21018 value_t manual_type = value_t::array)
21022 bool is_an_object = std::all_of(init.begin(), init.end(),
21028 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
21032 if (!type_deduction)
21035 if (manual_type == value_t::array)
21037 is_an_object =
false;
21043 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
21050 m_data.m_type = value_t::object;
21051 m_data.m_value = value_t::object;
21053 for (
auto& element_ref : init)
21056 m_data.m_value.object->emplace(
21057 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
21058 std::move((*element.m_data.m_value.array)[1]));
21064 m_data.m_type = value_t::array;
21065 m_data.m_value.array = create<array_t>(init.begin(), init.end());
21069 assert_invariant();
21078 res.m_data.m_type = value_t::binary;
21079 res.m_data.m_value = init;
21086 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
21089 res.m_data.m_type = value_t::binary;
21090 res.m_data.m_value =
binary_t(init, subtype);
21100 res.m_data.m_type = value_t::binary;
21101 res.m_data.m_value = std::move(init);
21108 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
21111 res.m_data.m_type = value_t::binary;
21112 res.m_data.m_value =
binary_t(std::move(init), subtype);
21121 return basic_json(init,
false, value_t::array);
21129 return basic_json(init,
false, value_t::object);
21138 assert_invariant();
21143 template <
class InputIT,
typename std::enable_if <
21144 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
21145 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
21154 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
21158 m_data.m_type =
first.m_object->m_data.m_type;
21161 switch (m_data.m_type)
21163 case value_t::boolean:
21164 case value_t::number_float:
21165 case value_t::number_integer:
21166 case value_t::number_unsigned:
21167 case value_t::string:
21170 || !last.m_it.primitive_iterator.is_end()))
21172 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
first.m_object));
21177 case value_t::null:
21178 case value_t::object:
21179 case value_t::array:
21180 case value_t::binary:
21181 case value_t::discarded:
21186 switch (m_data.m_type)
21188 case value_t::number_integer:
21190 m_data.m_value.number_integer =
first.m_object->m_data.m_value.number_integer;
21194 case value_t::number_unsigned:
21196 m_data.m_value.number_unsigned =
first.m_object->m_data.m_value.number_unsigned;
21200 case value_t::number_float:
21202 m_data.m_value.number_float =
first.m_object->m_data.m_value.number_float;
21206 case value_t::boolean:
21208 m_data.m_value.boolean =
first.m_object->m_data.m_value.boolean;
21212 case value_t::string:
21214 m_data.m_value = *
first.m_object->m_data.m_value.string;
21218 case value_t::object:
21220 m_data.m_value.object = create<object_t>(
first.m_it.object_iterator,
21221 last.m_it.object_iterator);
21225 case value_t::array:
21227 m_data.m_value.array = create<array_t>(
first.m_it.array_iterator,
21228 last.m_it.array_iterator);
21232 case value_t::binary:
21234 m_data.m_value = *
first.m_object->m_data.m_value.binary;
21238 case value_t::null:
21239 case value_t::discarded:
21245 assert_invariant();
21252 template<
typename JsonRef,
21254 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
21262 , start_position(other.start_position)
21263 , end_position(other.end_position)
21266 m_data.m_type = other.
m_data.m_type;
21270 switch (m_data.m_type)
21272 case value_t::object:
21274 m_data.m_value = *other.
m_data.m_value.object;
21278 case value_t::array:
21280 m_data.m_value = *other.
m_data.m_value.array;
21284 case value_t::string:
21286 m_data.m_value = *other.
m_data.m_value.string;
21290 case value_t::boolean:
21292 m_data.m_value = other.
m_data.m_value.boolean;
21296 case value_t::number_integer:
21298 m_data.m_value = other.
m_data.m_value.number_integer;
21302 case value_t::number_unsigned:
21304 m_data.m_value = other.
m_data.m_value.number_unsigned;
21308 case value_t::number_float:
21310 m_data.m_value = other.
m_data.m_value.number_float;
21314 case value_t::binary:
21316 m_data.m_value = *other.
m_data.m_value.binary;
21320 case value_t::null:
21321 case value_t::discarded:
21327 assert_invariant();
21334 m_data(std::move(other.m_data))
21335#if JSON_DIAGNOSTIC_POSITIONS
21336 , start_position(other.start_position)
21337 , end_position(other.end_position)
21341 other.assert_invariant(
false);
21344 other.m_data.m_type = value_t::null;
21345 other.m_data.m_value = {};
21347#if JSON_DIAGNOSTIC_POSITIONS
21348 other.start_position = std::string::npos;
21349 other.end_position = std::string::npos;
21353 assert_invariant();
21359 std::is_nothrow_move_constructible<value_t>::value&&
21360 std::is_nothrow_move_assignable<value_t>::value&&
21361 std::is_nothrow_move_constructible<json_value>::value&&
21362 std::is_nothrow_move_assignable<json_value>::value&&
21363 std::is_nothrow_move_assignable<json_base_class_t>::value
21370 swap(m_data.m_type, other.m_data.m_type);
21371 swap(m_data.m_value, other.m_data.m_value);
21373#if JSON_DIAGNOSTIC_POSITIONS
21374 swap(start_position, other.start_position);
21375 swap(end_position, other.end_position);
21378 json_base_class_t::operator=(std::move(other));
21381 assert_invariant();
21389 assert_invariant(
false);
21406 const char indent_char =
' ',
21407 const bool ensure_ascii =
false,
21415 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
21419 s.dump(*
this,
false, ensure_ascii, 0);
21429 return m_data.m_type;
21436 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
21443 return is_array() || is_object();
21450 return m_data.m_type == value_t::null;
21457 return m_data.m_type == value_t::boolean;
21464 return is_number_integer() || is_number_float();
21471 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
21478 return m_data.m_type == value_t::number_unsigned;
21485 return m_data.m_type == value_t::number_float;
21492 return m_data.m_type == value_t::object;
21499 return m_data.m_type == value_t::array;
21506 return m_data.m_type == value_t::string;
21513 return m_data.m_type == value_t::binary;
21520 return m_data.m_type == value_t::discarded;
21527 return m_data.m_type;
21542 return m_data.m_value.boolean;
21551 return is_object() ? m_data.m_value.object :
nullptr;
21557 return is_object() ? m_data.m_value.object :
nullptr;
21563 return is_array() ? m_data.m_value.array :
nullptr;
21569 return is_array() ? m_data.m_value.array :
nullptr;
21575 return is_string() ? m_data.m_value.string :
nullptr;
21581 return is_string() ? m_data.m_value.string :
nullptr;
21587 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21593 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21599 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21605 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21611 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21617 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21623 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21629 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21635 return is_binary() ? m_data.m_value.binary :
nullptr;
21641 return is_binary() ? m_data.m_value.binary :
nullptr;
21655 template<
typename ReferenceType,
typename ThisType>
21659 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
21666 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
21676 template<
typename PointerType,
typename std::enable_if<
21677 std::is_pointer<PointerType>::value,
int>::type = 0>
21681 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21686 template <
typename PointerType,
typename std::enable_if <
21687 std::is_pointer<PointerType>::value&&
21688 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
21692 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21734 template <
typename ValueType,
21740 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21742 auto ret = ValueType();
21743 JSONSerializer<ValueType>::from_json(*
this, ret);
21777 template <
typename ValueType,
21782 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21784 return JSONSerializer<ValueType>::from_json(*
this);
21802 template <
typename BasicJsonType,
21825 template<
typename BasicJsonType,
21827 std::is_same<BasicJsonType, basic_json_t>::value,
21838 template<
typename PointerType,
21840 std::is_pointer<PointerType>::value,
21843 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21846 return get_ptr<PointerType>();
21873 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21874#if defined(JSON_HAS_CPP_14)
21878 noexcept(
std::declval<const
basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21884 static_assert(!std::is_reference<ValueTypeCV>::value,
21885 "get() cannot be used with reference types, you might want to use get_ref()");
21916 template<
typename PointerType,
typename std::enable_if<
21917 std::is_pointer<PointerType>::value,
int>::type = 0>
21921 return get_ptr<PointerType>();
21926 template <
typename ValueType,
21931 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
21932 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21934 JSONSerializer<ValueType>::from_json(*
this, v);
21940 template<
typename ValueType,
21951 typename T, std::size_t N,
21952 typename Array = T (&)[N],
21956 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21957 std::declval<const basic_json_t&>(), v)))
21959 JSONSerializer<Array>::from_json(*
this, v);
21965 template<
typename ReferenceType,
typename std::enable_if<
21966 std::is_reference<ReferenceType>::value,
int>::type = 0>
21970 return get_ref_impl<ReferenceType>(*
this);
21975 template <
typename ReferenceType,
typename std::enable_if <
21976 std::is_reference<ReferenceType>::value&&
21977 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
21981 return get_ref_impl<ReferenceType>(*
this);
22013 template <
typename ValueType,
typename std::enable_if <
22021#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
22024#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
22028 >::value,
int >::type = 0 >
22032 return get<ValueType>();
22044 return *get_ptr<binary_t*>();
22056 return *get_ptr<const binary_t*>();
22078 return set_parent(m_data.m_value.array->at(idx));
22083 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22101 return m_data.
m_value.array->at(idx);
22106 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22125 auto it = m_data.m_value.object->find(key);
22126 if (it == m_data.m_value.object->end())
22130 return set_parent(it->second);
22145 auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
22146 if (it == m_data.m_value.object->end())
22150 return set_parent(it->second);
22163 auto it = m_data.m_value.object->find(key);
22164 if (it == m_data.m_value.object->end())
22183 auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
22184 if (it == m_data.m_value.object->end())
22198 m_data.m_type = value_t::array;
22199 m_data.
m_value.array = create<array_t>();
22200 assert_invariant();
22207 if (idx >= m_data.m_value.array->size())
22209#if JSON_DIAGNOSTICS
22211 const auto old_size = m_data.m_value.array->size();
22212 const auto old_capacity = m_data.m_value.array->capacity();
22214 m_data.m_value.array->resize(idx + 1);
22216#if JSON_DIAGNOSTICS
22225 set_parents(begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
22228 assert_invariant();
22231 return m_data.m_value.array->operator[](idx);
22234 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22244 return m_data.
m_value.array->operator[](idx);
22247 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22257 m_data.m_type = value_t::object;
22258 m_data.
m_value.object = create<object_t>();
22259 assert_invariant();
22265 auto result = m_data.m_value.object->emplace(std::move(key),
nullptr);
22266 return set_parent(result.first->second);
22269 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22279 auto it = m_data.
m_value.object->find(key);
22284 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22289 template<
typename T>
22292 return operator[](
typename object_t::key_type(key));
22295 template<
typename T>
22298 return operator[](
typename object_t::key_type(key));
22310 m_data.m_type = value_t::object;
22311 m_data.
m_value.object = create<object_t>();
22312 assert_invariant();
22318 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
22319 return set_parent(result.first->second);
22322 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22334 auto it = m_data.
m_value.object->find(std::forward<KeyType>(key));
22339 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22343 template<
typename KeyType>
22347 template<
typename ValueType>
22350 string_t,
typename std::decay<ValueType>::type >;
22358 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22359 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
22365 const auto it = find(key);
22368 return it->template get<ValueType>();
22371 return default_value;
22379 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22383 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22384 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
22390 const auto it = find(key);
22393 return it->template get<ReturnType>();
22396 return std::forward<ValueType>(default_value);
22407 && is_comparable_with_object_key<KeyType>::value
22409 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22410 ValueType
value(KeyType && key,
const ValueType& default_value)
const
22416 const auto it = find(std::forward<KeyType>(key));
22419 return it->template get<ValueType>();
22422 return default_value;
22430 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
22434 && is_comparable_with_object_key<KeyType>::value
22436 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22437 ReturnType
value(KeyType && key, ValueType && default_value)
const
22443 const auto it = find(std::forward<KeyType>(key));
22446 return it->template get<ReturnType>();
22449 return std::forward<ValueType>(default_value);
22459 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22469 return ptr.
get_checked(
this).template get<ValueType>();
22473 return default_value;
22482 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22485 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22495 return ptr.
get_checked(
this).template get<ReturnType>();
22499 return std::forward<ValueType>(default_value);
22509 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22511 ValueType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
22513 return value(ptr.convert(), default_value);
22516 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
22520 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22522 ReturnType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const
22524 return value(ptr.convert(), std::forward<ValueType>(default_value));
22562 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22563 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22569 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22572 IteratorType result = end();
22574 switch (m_data.m_type)
22576 case value_t::boolean:
22577 case value_t::number_float:
22578 case value_t::number_integer:
22579 case value_t::number_unsigned:
22580 case value_t::string:
22581 case value_t::binary:
22585 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
22590 AllocatorType<string_t> alloc;
22591 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22592 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22593 m_data.m_value.string =
nullptr;
22595 else if (is_binary())
22597 AllocatorType<binary_t> alloc;
22598 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22599 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22600 m_data.m_value.binary =
nullptr;
22603 m_data.m_type = value_t::null;
22604 assert_invariant();
22608 case value_t::object:
22610 result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator);
22614 case value_t::array:
22616 result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator);
22620 case value_t::null:
22621 case value_t::discarded:
22632 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22633 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22639 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
22642 IteratorType result = end();
22644 switch (m_data.m_type)
22646 case value_t::boolean:
22647 case value_t::number_float:
22648 case value_t::number_integer:
22649 case value_t::number_unsigned:
22650 case value_t::string:
22651 case value_t::binary:
22654 || !last.m_it.primitive_iterator.is_end()))
22656 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
22661 AllocatorType<string_t> alloc;
22662 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22663 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22664 m_data.m_value.string =
nullptr;
22666 else if (is_binary())
22668 AllocatorType<binary_t> alloc;
22669 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22670 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22671 m_data.m_value.binary =
nullptr;
22674 m_data.m_type = value_t::null;
22675 assert_invariant();
22679 case value_t::object:
22681 result.m_it.object_iterator = m_data.m_value.object->erase(
first.m_it.object_iterator,
22682 last.m_it.object_iterator);
22686 case value_t::array:
22688 result.m_it.array_iterator = m_data.m_value.array->erase(
first.m_it.array_iterator,
22689 last.m_it.array_iterator);
22693 case value_t::null:
22694 case value_t::discarded:
22713 return m_data.m_value.object->erase(std::forward<KeyType>(key));
22726 const auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
22727 if (it != m_data.m_value.object->end())
22729 m_data.m_value.object->erase(it);
22743 return erase_internal(key);
22752 return erase_internal(std::forward<KeyType>(key));
22764 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22767 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
22788 auto result = end();
22792 result.m_it.object_iterator = m_data.m_value.object->find(key);
22802 auto result = cend();
22806 result.m_it.object_iterator = m_data.m_value.object->find(key);
22818 auto result = end();
22822 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
22834 auto result = cend();
22838 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
22849 return is_object() ? m_data.m_value.object->count(key) : 0;
22859 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(key)) : 0;
22864 bool contains(
const typename object_t::key_type& key)
const
22866 return is_object() && m_data.m_value.object->find(key) != m_data.m_value.object->end();
22875 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(key)) != m_data.m_value.object->end();
22885 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22887 bool contains(const typename ::nlohmann::
json_pointer<BasicJsonType>& ptr)
const
22889 return ptr.contains(
this);
22906 result.set_begin();
22922 result.set_begin();
23002 return ref.items();
23013 return ref.items();
23043 switch (m_data.m_type)
23045 case value_t::null:
23051 case value_t::array:
23054 return m_data.m_value.array->empty();
23057 case value_t::object:
23060 return m_data.m_value.object->empty();
23063 case value_t::string:
23064 case value_t::boolean:
23065 case value_t::number_integer:
23066 case value_t::number_unsigned:
23067 case value_t::number_float:
23068 case value_t::binary:
23069 case value_t::discarded:
23082 switch (m_data.m_type)
23084 case value_t::null:
23090 case value_t::array:
23093 return m_data.m_value.array->size();
23096 case value_t::object:
23099 return m_data.m_value.object->size();
23102 case value_t::string:
23103 case value_t::boolean:
23104 case value_t::number_integer:
23105 case value_t::number_unsigned:
23106 case value_t::number_float:
23107 case value_t::binary:
23108 case value_t::discarded:
23121 switch (m_data.m_type)
23123 case value_t::array:
23126 return m_data.m_value.array->max_size();
23129 case value_t::object:
23132 return m_data.m_value.object->max_size();
23135 case value_t::null:
23136 case value_t::string:
23137 case value_t::boolean:
23138 case value_t::number_integer:
23139 case value_t::number_unsigned:
23140 case value_t::number_float:
23141 case value_t::binary:
23142 case value_t::discarded:
23164 switch (m_data.m_type)
23166 case value_t::number_integer:
23168 m_data.m_value.number_integer = 0;
23172 case value_t::number_unsigned:
23174 m_data.m_value.number_unsigned = 0;
23178 case value_t::number_float:
23180 m_data.m_value.number_float = 0.0;
23184 case value_t::boolean:
23186 m_data.m_value.boolean =
false;
23190 case value_t::string:
23192 m_data.m_value.string->clear();
23196 case value_t::binary:
23198 m_data.m_value.binary->clear();
23202 case value_t::array:
23204 m_data.m_value.array->clear();
23208 case value_t::object:
23210 m_data.m_value.object->clear();
23214 case value_t::null:
23215 case value_t::discarded:
23234 m_data.m_type = value_t::array;
23235 m_data.m_value = value_t::array;
23236 assert_invariant();
23240 const auto old_capacity = m_data.m_value.array->capacity();
23241 m_data.m_value.array->push_back(std::move(val));
23242 set_parent(m_data.m_value.array->back(), old_capacity);
23250 push_back(std::move(val));
23267 m_data.m_type = value_t::array;
23268 m_data.m_value = value_t::array;
23269 assert_invariant();
23273 const auto old_capacity = m_data.m_value.array->capacity();
23274 m_data.m_value.array->push_back(val);
23275 set_parent(m_data.m_value.array->back(), old_capacity);
23299 m_data.m_type = value_t::object;
23300 m_data.m_value = value_t::object;
23301 assert_invariant();
23305 auto res = m_data.m_value.object->insert(val);
23306 set_parent(res.first->second);
23321 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
23323 basic_json&& key = init.begin()->moved_or_copied();
23324 push_back(
typename object_t::value_type(
23325 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23343 template<
class... Args>
23355 m_data.m_type = value_t::array;
23356 m_data.m_value = value_t::array;
23357 assert_invariant();
23361 const auto old_capacity = m_data.m_value.array->capacity();
23362 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
23363 return set_parent(m_data.m_value.array->back(), old_capacity);
23368 template<
class... Args>
23380 m_data.m_type = value_t::object;
23381 m_data.m_value = value_t::object;
23382 assert_invariant();
23386 auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
23387 set_parent(res.first->second);
23391 it.m_it.object_iterator = res.first;
23394 return {it, res.second};
23400 template<
typename... Args>
23406 auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator);
23407 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
23408 result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos;
23428 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23432 return insert_iterator(pos, val);
23442 return insert(pos, val);
23455 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23459 return insert_iterator(pos, cnt, val);
23478 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23484 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23489 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
23493 return insert_iterator(pos,
first.m_it.array_iterator, last.m_it.array_iterator);
23509 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23513 return insert_iterator(pos, ilist.begin(), ilist.end());
23529 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23535 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
23538 m_data.m_value.object->insert(
first.m_it.object_iterator, last.m_it.object_iterator);
23546 update(j.
begin(), j.
end(), merge_objects);
23556 m_data.m_type = value_t::object;
23557 m_data.m_value.object = create<object_t>();
23558 assert_invariant();
23569 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23578 for (
auto it =
first; it != last; ++it)
23580 if (merge_objects && it.value().is_object())
23582 auto it2 = m_data.m_value.object->find(it.key());
23583 if (it2 != m_data.m_value.object->end())
23585 it2->second.update(it.value(),
true);
23589 m_data.m_value.object->operator[](it.key()) = it.value();
23590#if JSON_DIAGNOSTICS
23591 m_data.m_value.object->operator[](it.key()).m_parent =
this;
23599 std::is_nothrow_move_constructible<value_t>::value&&
23600 std::is_nothrow_move_assignable<value_t>::value&&
23601 std::is_nothrow_move_constructible<json_value>::value&&
23602 std::is_nothrow_move_assignable<json_value>::value
23605 std::swap(m_data.m_type, other.m_data.m_type);
23606 std::swap(m_data.m_value, other.m_data.m_value);
23609 other.set_parents();
23610 assert_invariant();
23616 std::is_nothrow_move_constructible<value_t>::value&&
23617 std::is_nothrow_move_assignable<value_t>::value&&
23618 std::is_nothrow_move_constructible<json_value>::value&&
23619 std::is_nothrow_move_assignable<json_value>::value
23633 swap(*(m_data.m_value.array), other);
23649 swap(*(m_data.m_value.object), other);
23665 swap(*(m_data.m_value.string), other);
23681 swap(*(m_data.m_value.binary), other);
23691 void swap(
typename binary_t::container_type& other)
23697 swap(*(m_data.m_value.binary), other);
23701 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
23716#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23717 const auto lhs_type = lhs.type(); \
23718 const auto rhs_type = rhs.type(); \
23720 if (lhs_type == rhs_type) \
23722 switch (lhs_type) \
23724 case value_t::array: \
23725 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23727 case value_t::object: \
23728 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23730 case value_t::null: \
23731 return (null_result); \
23733 case value_t::string: \
23734 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23736 case value_t::boolean: \
23737 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23739 case value_t::number_integer: \
23740 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23742 case value_t::number_unsigned: \
23743 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23745 case value_t::number_float: \
23746 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23748 case value_t::binary: \
23749 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23751 case value_t::discarded: \
23753 return (unordered_result); \
23756 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23758 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23760 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23762 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23764 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23766 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23768 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23770 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23772 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23774 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23776 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23778 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23780 else if(compares_unordered(lhs, rhs))\
23782 return (unordered_result);\
23785 return (default_result);
23800#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23803 static_cast<void>(inverse);
23809 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
23811 return compares_unordered(*
this, rhs, inverse);
23815#if JSON_HAS_THREE_WAY_COMPARISON
23818 bool operator==(const_reference rhs)
const noexcept
23821#pragma GCC diagnostic push
23822#pragma GCC diagnostic ignored "-Wfloat-equal"
23824 const_reference lhs = *
this;
23827#pragma GCC diagnostic pop
23833 template<
typename ScalarType>
23834 requires std::is_scalar_v<ScalarType>
23835 bool operator==(ScalarType rhs)
const noexcept
23842 bool operator!=(const_reference rhs)
const noexcept
23844 if (compares_unordered(rhs,
true))
23853 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23855 const_reference lhs = *
this;
23859 std::partial_ordering::equivalent,
23860 std::partial_ordering::unordered,
23861 lhs_type <=> rhs_type)
23866 template<
typename ScalarType>
23867 requires std::is_scalar_v<ScalarType>
23868 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23873#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23880 bool operator<=(const_reference rhs)
const noexcept
23882 if (compares_unordered(rhs,
true))
23886 return !(rhs < *
this);
23891 template<
typename ScalarType>
23892 requires std::is_scalar_v<ScalarType>
23893 bool operator<=(ScalarType rhs)
const noexcept
23901 bool operator>=(const_reference rhs)
const noexcept
23903 if (compares_unordered(rhs,
true))
23907 return !(*
this < rhs);
23912 template<
typename ScalarType>
23913 requires std::is_scalar_v<ScalarType>
23914 bool operator>=(ScalarType rhs)
const noexcept
23922 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
23925#pragma GCC diagnostic push
23926#pragma GCC diagnostic ignored "-Wfloat-equal"
23930#pragma GCC diagnostic pop
23936 template<
typename ScalarType,
typename std::enable_if<
23937 std::is_scalar<ScalarType>::value,
int>::type = 0>
23938 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
23945 template<
typename ScalarType,
typename std::enable_if<
23946 std::is_scalar<ScalarType>::value,
int>::type = 0>
23947 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
23954 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
23956 if (compares_unordered(lhs, rhs,
true))
23960 return !(lhs == rhs);
23965 template<
typename ScalarType,
typename std::enable_if<
23966 std::is_scalar<ScalarType>::value,
int>::type = 0>
23967 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
23974 template<
typename ScalarType,
typename std::enable_if<
23975 std::is_scalar<ScalarType>::value,
int>::type = 0>
23976 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
23983 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
23993 template<
typename ScalarType,
typename std::enable_if<
23994 std::is_scalar<ScalarType>::value,
int>::type = 0>
23995 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
24002 template<
typename ScalarType,
typename std::enable_if<
24003 std::is_scalar<ScalarType>::value,
int>::type = 0>
24004 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
24011 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
24013 if (compares_unordered(lhs, rhs,
true))
24017 return !(rhs < lhs);
24022 template<
typename ScalarType,
typename std::enable_if<
24023 std::is_scalar<ScalarType>::value,
int>::type = 0>
24024 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
24031 template<
typename ScalarType,
typename std::enable_if<
24032 std::is_scalar<ScalarType>::value,
int>::type = 0>
24033 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
24040 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
24043 if (compares_unordered(lhs, rhs))
24047 return !(lhs <= rhs);
24052 template<
typename ScalarType,
typename std::enable_if<
24053 std::is_scalar<ScalarType>::value,
int>::type = 0>
24054 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
24061 template<
typename ScalarType,
typename std::enable_if<
24062 std::is_scalar<ScalarType>::value,
int>::type = 0>
24063 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
24070 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
24072 if (compares_unordered(lhs, rhs,
true))
24076 return !(lhs < rhs);
24081 template<
typename ScalarType,
typename std::enable_if<
24082 std::is_scalar<ScalarType>::value,
int>::type = 0>
24083 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
24090 template<
typename ScalarType,
typename std::enable_if<
24091 std::is_scalar<ScalarType>::value,
int>::type = 0>
24092 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
24098#undef JSON_IMPLEMENT_OPERATOR
24114 const bool pretty_print = o.width() > 0;
24115 const auto indentation = pretty_print ? o.width() : 0;
24122 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24149 template<
typename InputType>
24152 parser_callback_t cb =
nullptr,
24153 const bool allow_exceptions =
true,
24154 const bool ignore_comments =
false,
24155 const bool ignore_trailing_commas =
false)
24158 parser(
detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24164 template<
typename IteratorType>
24168 parser_callback_t cb =
nullptr,
24169 const bool allow_exceptions =
true,
24170 const bool ignore_comments =
false,
24171 const bool ignore_trailing_commas =
false)
24174 parser(
detail::input_adapter(std::move(
first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24181 parser_callback_t cb =
nullptr,
24182 const bool allow_exceptions =
true,
24183 const bool ignore_comments =
false,
24184 const bool ignore_trailing_commas =
false)
24187 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24193 template<
typename InputType>
24194 static bool accept(InputType&& i,
24195 const bool ignore_comments =
false,
24196 const bool ignore_trailing_commas =
false)
24198 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24203 template<
typename IteratorType>
24204 static bool accept(IteratorType
first, IteratorType last,
24205 const bool ignore_comments =
false,
24206 const bool ignore_trailing_commas =
false)
24214 const bool ignore_comments =
false,
24215 const bool ignore_trailing_commas =
false)
24217 return parser(i.get(),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24222 template <
typename InputType,
typename SAX>
24224 static
bool sax_parse(InputType&& i, SAX* sax,
24226 const
bool strict = true,
24227 const
bool ignore_comments = false,
24228 const
bool ignore_trailing_commas = false)
24231 return format == input_format_t::json
24232 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24238 template<
class IteratorType,
class SAX>
24240 static
bool sax_parse(IteratorType
first, IteratorType last, SAX* sax,
24242 const
bool strict = true,
24243 const
bool ignore_comments = false,
24244 const
bool ignore_trailing_commas = false)
24247 return format == input_format_t::json
24248 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24257 template <
typename SAX>
24260 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
24262 const
bool strict = true,
24263 const
bool ignore_comments = false,
24264 const
bool ignore_trailing_commas = false)
24267 return format == input_format_t::json
24269 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24283 return operator>>(i, j);
24305 switch (m_data.m_type)
24307 case value_t::null:
24309 case value_t::object:
24311 case value_t::array:
24313 case value_t::string:
24315 case value_t::boolean:
24317 case value_t::binary:
24319 case value_t::discarded:
24320 return "discarded";
24321 case value_t::number_integer:
24322 case value_t::number_unsigned:
24323 case value_t::number_float:
24338 value_t m_type = value_t::null;
24341 json_value m_value = {};
24344 : m_type(v), m_value(v)
24351 m_value.array = create<array_t>(cnt, val);
24362 m_value.destroy(m_type);
24368#if JSON_DIAGNOSTICS
24373#if JSON_DIAGNOSTIC_POSITIONS
24375 std::size_t start_position = std::string::npos;
24377 std::size_t end_position = std::string::npos;
24379 constexpr std::size_t start_pos() const noexcept
24381 return start_position;
24384 constexpr std::size_t end_pos() const noexcept
24386 return end_position;
24402 std::vector<std::uint8_t> result;
24403 to_cbor(j, result);
24425 std::vector<std::uint8_t> result;
24426 to_msgpack(j, result);
24447 const bool use_size =
false,
24448 const bool use_type =
false)
24450 std::vector<std::uint8_t> result;
24451 to_ubjson(j, result, use_size, use_type);
24458 const bool use_size =
false,
const bool use_type =
false)
24466 const bool use_size =
false,
const bool use_type =
false)
24474 const bool use_size =
false,
24475 const bool use_type =
false,
24478 std::vector<std::uint8_t> result;
24479 to_bjdata(j, result, use_size, use_type, version);
24486 const bool use_size =
false,
const bool use_type =
false,
24495 const bool use_size =
false,
const bool use_type =
false,
24505 std::vector<std::uint8_t> result;
24506 to_bson(j, result);
24526 template<
typename InputType>
24529 const bool strict =
true,
24530 const bool allow_exceptions =
true,
24536 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24537 return res ? result :
basic_json(value_t::discarded);
24542 template<
typename IteratorType>
24545 const bool strict =
true,
24546 const bool allow_exceptions =
true,
24552 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24553 return res ? result :
basic_json(value_t::discarded);
24556 template<
typename T>
24560 const
bool strict = true,
24561 const
bool allow_exceptions = true,
24564 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24570 const
bool strict = true,
24571 const
bool allow_exceptions = true,
24578 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24579 return res ? result :
basic_json(value_t::discarded);
24584 template<
typename InputType>
24587 const bool strict =
true,
24588 const bool allow_exceptions =
true)
24593 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24594 return res ? result :
basic_json(value_t::discarded);
24599 template<
typename IteratorType>
24602 const bool strict =
true,
24603 const bool allow_exceptions =
true)
24608 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24609 return res ? result :
basic_json(value_t::discarded);
24612 template<
typename T>
24616 const
bool strict = true,
24617 const
bool allow_exceptions = true)
24619 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24625 const
bool strict = true,
24626 const
bool allow_exceptions = true)
24632 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24633 return res ? result :
basic_json(value_t::discarded);
24638 template<
typename InputType>
24641 const bool strict =
true,
24642 const bool allow_exceptions =
true)
24647 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24648 return res ? result :
basic_json(value_t::discarded);
24653 template<
typename IteratorType>
24656 const bool strict =
true,
24657 const bool allow_exceptions =
true)
24662 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24663 return res ? result :
basic_json(value_t::discarded);
24666 template<
typename T>
24670 const
bool strict = true,
24671 const
bool allow_exceptions = true)
24673 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24679 const
bool strict = true,
24680 const
bool allow_exceptions = true)
24686 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24687 return res ? result :
basic_json(value_t::discarded);
24692 template<
typename InputType>
24695 const bool strict =
true,
24696 const bool allow_exceptions =
true)
24701 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24702 return res ? result :
basic_json(value_t::discarded);
24707 template<
typename IteratorType>
24710 const bool strict =
true,
24711 const bool allow_exceptions =
true)
24716 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24717 return res ? result :
basic_json(value_t::discarded);
24722 template<
typename InputType>
24725 const bool strict =
true,
24726 const bool allow_exceptions =
true)
24732 return res ? result :
basic_json(value_t::discarded);
24737 template<
typename IteratorType>
24740 const bool strict =
true,
24741 const bool allow_exceptions =
true)
24747 return res ? result :
basic_json(value_t::discarded);
24750 template<
typename T>
24754 const
bool strict = true,
24755 const
bool allow_exceptions = true)
24757 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24763 const
bool strict = true,
24764 const
bool allow_exceptions = true)
24771 return res ? result :
basic_json(value_t::discarded);
24789 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24793 return ptr.get_unchecked(
this);
24803 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24807 return ptr.get_unchecked(
this);
24817 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24821 return ptr.get_checked(
this);
24831 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24835 return ptr.get_checked(
this);
24869 enum class patch_operations {add, remove, replace, move, copy,
test, invalid};
24871 const auto get_op = [](
const string_t& op)
24875 return patch_operations::add;
24877 if (op ==
"remove")
24879 return patch_operations::remove;
24881 if (op ==
"replace")
24883 return patch_operations::replace;
24887 return patch_operations::move;
24891 return patch_operations::copy;
24895 return patch_operations::test;
24898 return patch_operations::invalid;
24913 if (top_pointer != ptr)
24915 result.
at(top_pointer);
24919 const auto last_path = ptr.
back();
24924 switch (parent.
m_data.m_type)
24926 case value_t::null:
24927 case value_t::object:
24930 parent[last_path] = val;
24934 case value_t::array:
24936 if (last_path ==
"-")
24943 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24947 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"), &parent));
24957 case value_t::string:
24958 case value_t::boolean:
24959 case value_t::number_integer:
24960 case value_t::number_unsigned:
24961 case value_t::number_float:
24962 case value_t::binary:
24963 case value_t::discarded:
24970 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24973 const auto last_path = ptr.
back();
24981 auto it = parent.
find(last_path);
24994 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
25001 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
25005 for (
const auto& val : json_patch)
25008 const auto get_value = [&val](
const string_t& op,
25013 auto it = val.
m_data.m_value.object->find(member);
25016 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
25029 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
25039 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
25043 const auto op = get_value(
"op",
"op",
true).template get<string_t>();
25044 const auto path = get_value(op,
"path",
true).template get<string_t>();
25047 switch (get_op(op))
25049 case patch_operations::add:
25051 operation_add(ptr, get_value(
"add",
"value",
false));
25055 case patch_operations::remove:
25057 operation_remove(ptr);
25061 case patch_operations::replace:
25064 result.
at(ptr) = get_value(
"replace",
"value",
false);
25068 case patch_operations::move:
25070 const auto from_path = get_value(
"move",
"from",
true).template get<string_t>();
25080 operation_remove(from_ptr);
25081 operation_add(ptr, v);
25085 case patch_operations::copy:
25087 const auto from_path = get_value(
"copy",
"from",
true).template get<string_t>();
25096 operation_add(ptr, v);
25100 case patch_operations::test:
25102 bool success =
false;
25107 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25123 case patch_operations::invalid:
25153 if (source == target)
25158 if (source.
type() != target.
type())
25163 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25168 switch (source.
type())
25170 case value_t::array:
25174 while (i < source.
size() && i < target.
size())
25177 auto temp_diff = diff(source[i], target[i], detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i)));
25178 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25187 while (i < source.
size())
25194 {
"path", detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i))}
25200 while (i < target.
size())
25205 {
"path", detail::concat<string_t>(path,
"/-")},
25206 {
"value", target[i]}
25214 case value_t::object:
25217 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25220 const auto path_key = detail::concat<string_t>(path,
'/',
detail::escape(it.key()));
25222 if (target.
find(it.key()) != target.
end())
25225 auto temp_diff = diff(it.value(), target[it.key()], path_key);
25226 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25233 {
"op",
"remove"}, {
"path", path_key}
25239 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25241 if (source.
find(it.key()) == source.
end())
25244 const auto path_key = detail::concat<string_t>(path,
'/',
detail::escape(it.key()));
25247 {
"op",
"add"}, {
"path", path_key},
25248 {
"value", it.value()}
25256 case value_t::null:
25257 case value_t::string:
25258 case value_t::boolean:
25259 case value_t::number_integer:
25260 case value_t::number_unsigned:
25261 case value_t::number_float:
25262 case value_t::binary:
25263 case value_t::discarded:
25269 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25296 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25298 if (it.value().is_null())
25304 operator[](it.key()).merge_patch(it.value());
25310 *
this = apply_patch;
25327inline namespace json_literals
25333#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25334 inline nlohmann::json
operator ""_json(
const char* s, std::size_t n)
25336 inline nlohmann::json
operator "" _json(
const char* s, std::size_t n)
25339 return nlohmann::json::parse(s, s + n);
25345#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25370 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
25372 return nlohmann::detail::hash(j);
25378struct less< ::nlohmann::detail::value_t>
25385 ::nlohmann::detail::value_t rhs)
const noexcept
25387#if JSON_HAS_THREE_WAY_COMPARISON
25388 return std::is_lt(lhs <=> rhs);
25390 return ::nlohmann::detail::operator<(lhs, rhs);
25396#ifndef JSON_HAS_CPP_20
25401inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
25402 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
25403 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
25412#if JSON_USE_GLOBAL_UDLS
25413 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25414 using nlohmann::literals::json_literals::operator
""_json;
25415 using nlohmann::literals::json_literals::operator
""_json_pointer;
25417 using nlohmann::literals::json_literals::operator
"" _json;
25418 using nlohmann::literals::json_literals::operator
"" _json_pointer;
25434#if defined(__clang__)
25435 #pragma clang diagnostic pop
25440#undef JSON_INTERNAL_CATCH
25442#undef JSON_PRIVATE_UNLESS_TESTED
25443#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25444#undef NLOHMANN_BASIC_JSON_TPL
25445#undef JSON_EXPLICIT
25446#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
25447#undef JSON_INLINE_VARIABLE
25448#undef JSON_NO_UNIQUE_ADDRESS
25449#undef JSON_DISABLE_ENUM_SERIALIZATION
25450#undef JSON_USE_GLOBAL_UDLS
25452#ifndef JSON_TEST_KEEP_MACROS
25455 #undef JSON_HAS_CPP_11
25456 #undef JSON_HAS_CPP_14
25457 #undef JSON_HAS_CPP_17
25458 #undef JSON_HAS_CPP_20
25459 #undef JSON_HAS_CPP_23
25460 #undef JSON_HAS_CPP_26
25461 #undef JSON_HAS_FILESYSTEM
25462 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
25463 #undef JSON_HAS_THREE_WAY_COMPARISON
25464 #undef JSON_HAS_RANGES
25465 #undef JSON_HAS_STATIC_RTTI
25466 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
25480#undef JSON_HEDLEY_ALWAYS_INLINE
25481#undef JSON_HEDLEY_ARM_VERSION
25482#undef JSON_HEDLEY_ARM_VERSION_CHECK
25483#undef JSON_HEDLEY_ARRAY_PARAM
25484#undef JSON_HEDLEY_ASSUME
25485#undef JSON_HEDLEY_BEGIN_C_DECLS
25486#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25487#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25488#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25489#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25490#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25491#undef JSON_HEDLEY_CLANG_HAS_FEATURE
25492#undef JSON_HEDLEY_CLANG_HAS_WARNING
25493#undef JSON_HEDLEY_COMPCERT_VERSION
25494#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25495#undef JSON_HEDLEY_CONCAT
25496#undef JSON_HEDLEY_CONCAT3
25497#undef JSON_HEDLEY_CONCAT3_EX
25498#undef JSON_HEDLEY_CONCAT_EX
25499#undef JSON_HEDLEY_CONST
25500#undef JSON_HEDLEY_CONSTEXPR
25501#undef JSON_HEDLEY_CONST_CAST
25502#undef JSON_HEDLEY_CPP_CAST
25503#undef JSON_HEDLEY_CRAY_VERSION
25504#undef JSON_HEDLEY_CRAY_VERSION_CHECK
25505#undef JSON_HEDLEY_C_DECL
25506#undef JSON_HEDLEY_DEPRECATED
25507#undef JSON_HEDLEY_DEPRECATED_FOR
25508#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25509#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25510#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25511#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25512#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25513#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
25514#undef JSON_HEDLEY_DIAGNOSTIC_POP
25515#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25516#undef JSON_HEDLEY_DMC_VERSION
25517#undef JSON_HEDLEY_DMC_VERSION_CHECK
25518#undef JSON_HEDLEY_EMPTY_BASES
25519#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25520#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25521#undef JSON_HEDLEY_END_C_DECLS
25522#undef JSON_HEDLEY_FLAGS
25523#undef JSON_HEDLEY_FLAGS_CAST
25524#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25525#undef JSON_HEDLEY_GCC_HAS_BUILTIN
25526#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25527#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25528#undef JSON_HEDLEY_GCC_HAS_EXTENSION
25529#undef JSON_HEDLEY_GCC_HAS_FEATURE
25530#undef JSON_HEDLEY_GCC_HAS_WARNING
25531#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25532#undef JSON_HEDLEY_GCC_VERSION
25533#undef JSON_HEDLEY_GCC_VERSION_CHECK
25534#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25535#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25536#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25537#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25538#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25539#undef JSON_HEDLEY_GNUC_HAS_FEATURE
25540#undef JSON_HEDLEY_GNUC_HAS_WARNING
25541#undef JSON_HEDLEY_GNUC_VERSION
25542#undef JSON_HEDLEY_GNUC_VERSION_CHECK
25543#undef JSON_HEDLEY_HAS_ATTRIBUTE
25544#undef JSON_HEDLEY_HAS_BUILTIN
25545#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25546#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25547#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25548#undef JSON_HEDLEY_HAS_EXTENSION
25549#undef JSON_HEDLEY_HAS_FEATURE
25550#undef JSON_HEDLEY_HAS_WARNING
25551#undef JSON_HEDLEY_IAR_VERSION
25552#undef JSON_HEDLEY_IAR_VERSION_CHECK
25553#undef JSON_HEDLEY_IBM_VERSION
25554#undef JSON_HEDLEY_IBM_VERSION_CHECK
25555#undef JSON_HEDLEY_IMPORT
25556#undef JSON_HEDLEY_INLINE
25557#undef JSON_HEDLEY_INTEL_CL_VERSION
25558#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25559#undef JSON_HEDLEY_INTEL_VERSION
25560#undef JSON_HEDLEY_INTEL_VERSION_CHECK
25561#undef JSON_HEDLEY_IS_CONSTANT
25562#undef JSON_HEDLEY_IS_CONSTEXPR_
25563#undef JSON_HEDLEY_LIKELY
25564#undef JSON_HEDLEY_MALLOC
25565#undef JSON_HEDLEY_MCST_LCC_VERSION
25566#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
25567#undef JSON_HEDLEY_MESSAGE
25568#undef JSON_HEDLEY_MSVC_VERSION
25569#undef JSON_HEDLEY_MSVC_VERSION_CHECK
25570#undef JSON_HEDLEY_NEVER_INLINE
25571#undef JSON_HEDLEY_NON_NULL
25572#undef JSON_HEDLEY_NO_ESCAPE
25573#undef JSON_HEDLEY_NO_RETURN
25574#undef JSON_HEDLEY_NO_THROW
25575#undef JSON_HEDLEY_NULL
25576#undef JSON_HEDLEY_PELLES_VERSION
25577#undef JSON_HEDLEY_PELLES_VERSION_CHECK
25578#undef JSON_HEDLEY_PGI_VERSION
25579#undef JSON_HEDLEY_PGI_VERSION_CHECK
25580#undef JSON_HEDLEY_PREDICT
25581#undef JSON_HEDLEY_PRINTF_FORMAT
25582#undef JSON_HEDLEY_PRIVATE
25583#undef JSON_HEDLEY_PUBLIC
25584#undef JSON_HEDLEY_PURE
25585#undef JSON_HEDLEY_REINTERPRET_CAST
25586#undef JSON_HEDLEY_REQUIRE
25587#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25588#undef JSON_HEDLEY_REQUIRE_MSG
25589#undef JSON_HEDLEY_RESTRICT
25590#undef JSON_HEDLEY_RETURNS_NON_NULL
25591#undef JSON_HEDLEY_SENTINEL
25592#undef JSON_HEDLEY_STATIC_ASSERT
25593#undef JSON_HEDLEY_STATIC_CAST
25594#undef JSON_HEDLEY_STRINGIFY
25595#undef JSON_HEDLEY_STRINGIFY_EX
25596#undef JSON_HEDLEY_SUNPRO_VERSION
25597#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25598#undef JSON_HEDLEY_TINYC_VERSION
25599#undef JSON_HEDLEY_TINYC_VERSION_CHECK
25600#undef JSON_HEDLEY_TI_ARMCL_VERSION
25601#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25602#undef JSON_HEDLEY_TI_CL2000_VERSION
25603#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25604#undef JSON_HEDLEY_TI_CL430_VERSION
25605#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25606#undef JSON_HEDLEY_TI_CL6X_VERSION
25607#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25608#undef JSON_HEDLEY_TI_CL7X_VERSION
25609#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25610#undef JSON_HEDLEY_TI_CLPRU_VERSION
25611#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25612#undef JSON_HEDLEY_TI_VERSION
25613#undef JSON_HEDLEY_TI_VERSION_CHECK
25614#undef JSON_HEDLEY_UNAVAILABLE
25615#undef JSON_HEDLEY_UNLIKELY
25616#undef JSON_HEDLEY_UNPREDICTABLE
25617#undef JSON_HEDLEY_UNREACHABLE
25618#undef JSON_HEDLEY_UNREACHABLE_RETURN
25619#undef JSON_HEDLEY_VERSION
25620#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25621#undef JSON_HEDLEY_VERSION_DECODE_MINOR
25622#undef JSON_HEDLEY_VERSION_DECODE_REVISION
25623#undef JSON_HEDLEY_VERSION_ENCODE
25624#undef JSON_HEDLEY_WARNING
25625#undef JSON_HEDLEY_WARN_UNUSED_RESULT
25626#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25627#undef JSON_HEDLEY_FALL_THROUGH
a class to store JSON values
constexpr bool is_string() const noexcept
return whether value is a string
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
reference operator[](KeyType &&key)
access specified object element
json_value(object_t &&value)
constructor for rvalue objects
size_type size() const noexcept
returns the number of elements
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
number_unsigned_t number_unsigned
number (unsigned integer)
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
::nlohmann::detail::iteration_proxy< Iterator > iteration_proxy
const_iterator end() const noexcept
returns an iterator to one past the last element
reference back()
access the last element
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
number_float_t number_float
number (floating-point)
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
json_value(const array_t &value)
constructor for arrays
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
const_reference front() const
access the first element
constexpr bool is_array() const noexcept
return whether value is an array
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
data(size_type cnt, const basic_json &val)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
::nlohmann::detail::json_base_class< CustomBaseClass > json_base_class_t
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
std::size_t size_type
a type to represent container sizes
constexpr bool is_structured() const noexcept
return whether type is structured
json_value(boolean_t v) noexcept
constructor for booleans
const_reference operator[](KeyType &&key) const
access specified object element
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
void swap(binary_t &other)
exchanges the values
ReferenceType get_ref()
get a reference value (implicit)
size_type max_size() const noexcept
returns the maximum possible number of elements
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
::nlohmann::detail::iter_impl< BasicJsonType > iter_impl
ReferenceType get_ref() const
get a reference value (implicit)
constexpr bool is_discarded() const noexcept
return whether value is discarded
reference operator+=(initializer_list_t init)
add an object to an object
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
void push_back(basic_json &&val)
add an object to an array
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
::nlohmann::detail::json_reverse_iterator< Base > json_reverse_iterator
const_reference back() const
access the last element
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
reference operator+=(const basic_json &val)
add an object to an array
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false, const bool ignore_trailing_commas=false)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
static allocator_type get_allocator()
returns the allocator associated with the container
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
reference at(KeyType &&key)
access specified object element with bounds checking
iterator end() noexcept
returns an iterator to one past the last element
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
json_value(array_t &&value)
constructor for rvalue arrays
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
void push_back(initializer_list_t init)
add an object to an object
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
ValueType & get_to(ValueType &v) const
get a value (explicit)
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
iterator begin() noexcept
returns an iterator to the first element
array_t * array
array (stored with pointer to save storage)
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
json_value(string_t &&value)
constructor for rvalue strings
const_iterator cend() const noexcept
returns an iterator to one past the last element
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
basic_json flatten() const
return flattened JSON value
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
size_type erase(KeyType &&key)
remove element from a JSON object given a key
::nlohmann::detail::primitive_iterator_t primitive_iterator_t
json_value(const string_t &value)
constructor for strings
const binary_t & get_binary() const
get a binary value
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
::nlohmann::detail::binary_reader< basic_json, InputType > binary_reader
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
const_reference at(KeyType &&key) const
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
IteratorType erase(IteratorType pos)
remove element given an iterator
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
NumberFloatType number_float_t
a type for a number (floating-point)
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
string_t * string
string (stored with pointer to save storage)
AllocatorType< basic_json > allocator_type
the allocator type
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
reference set_parent(reference j, std::size_t old_capacity=detail::unknown_size())
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
reference operator[](T *key)
access specified array element with bounds checking
reference at(size_type idx)
access specified array element with bounds checking
iterator find(KeyType &&key)
find an element in a JSON object
binary_t * binary
binary (stored with pointer to save storage)
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
BooleanType boolean_t
a type for a boolean
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const string_t &path="")
creates a diff as a JSON patch
::nlohmann::detail::internal_iterator< BasicJsonType > internal_iterator
std::conditional< detail::is_c_string_uncvref< ValueType >::value, string_t, typename std::decay< ValueType >::type > value_return_type
access specified array element with bounds checking
size_type erase_internal(KeyType &&key)
access specified array element with bounds checking
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
reference operator+=(const typename object_t::value_type &val)
add an object to an object
const_iterator cbegin() const noexcept
returns a const iterator to the first element
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
reference operator[](typename object_t::key_type key)
access specified object element
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
~basic_json() noexcept
destructor
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
json_value(const object_t &value)
constructor for objects
void swap(typename binary_t::container_type &other)
exchanges the values
binary_t & get_binary()
get a binary value
const_iterator begin() const noexcept
returns an iterator to the first element
constexpr bool is_number() const noexcept
return whether value is a number
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
const_reference operator[](T *key) const
access specified array element with bounds checking
reference operator[](size_type idx)
access specified array element
basic_json(const JsonRef &ref)
explicitly create a binary array (without subtype)
JSONSerializer< T, SFINAE > json_serializer
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
NumberIntegerType number_integer_t
a type for a number (integer)
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
constexpr bool is_binary() const noexcept
return whether value is a binary array
void swap(object_t &other)
exchanges the values
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
basic_json unflatten() const
unflatten a previously flattened JSON value
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
bool empty() const noexcept
checks whether the container is empty.
void swap(array_t &other)
exchanges the values
void erase(const size_type idx)
remove element from a JSON array given an index
reference operator+=(basic_json &&val)
add an object to an array
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
reference emplace_back(Args &&... args)
add an object to an array
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
StringType string_t
a type for a string
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
void push_back(const basic_json &val)
add an object to an array
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
json_value m_value
the value of the current element
number_integer_t number_integer
number (integer)
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
constexpr bool is_boolean() const noexcept
return whether value is a boolean
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
reference front()
access the first element
constexpr bool is_primitive() const noexcept
return whether type is primitive
constexpr bool is_null() const noexcept
return whether value is null
void clear() noexcept
clears the contents
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
json_value(value_t t)
constructor for empty values of a given type
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
json_value()=default
default constructor (for null values)
basic_json(basic_json &&other) noexcept
move constructor
iter_impl< basic_json > iterator
an iterator for a basic_json container
basic_json(const value_t v)
create an empty value with a given type
const_reference operator[](size_type idx) const
access specified array element
std::ptrdiff_t difference_type
a type to represent differences between iterators
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
void swap(string_t &other)
exchanges the values
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
::nlohmann::detail::binary_writer< basic_json, CharType > binary_writer
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
json_value(const binary_t &value)
constructor for binary arrays (internal type)
const_reference at(size_type idx) const
access specified array element with bounds checking
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
basic_json(const basic_json &other)
copy constructor
void push_back(const typename object_t::value_type &val)
add an object to an object
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
constexpr bool is_object() const noexcept
return whether value is an object
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
iterator insert_iterator(const_iterator pos, Args &&... args)
Helper for insertion of an iterator.
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
const_iterator find(KeyType &&key) const
find an element in a JSON object
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
an internal type for a backed binary type
bool operator!=(const byte_container_with_subtype &rhs) const
byte_container_with_subtype() noexcept(noexcept(container_type()))
std::uint64_t subtype_type
bool operator==(const byte_container_with_subtype &rhs) const
BinaryType container_type
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
constexpr subtype_type subtype() const noexcept
return the binary subtype
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
void clear_subtype() noexcept
clears the binary subtype
deserialization of CBOR, MessagePack, and UBJSON values
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result, bool inside_ndarray=false)
determine the type and size for a container
binary_reader(const binary_reader &)=delete
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
typename BasicJsonType::string_t string_t
std::pair< char_int_type, string_t > bjd_type
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
typename InputAdapterType::char_type char_type
bool parse_msgpack_internal()
std::string get_token_string() const
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool get_msgpack_string(string_t &result)
reads a MessagePack string
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
InputAdapterType ia
input adapter
bool get_ubjson_high_precision_number()
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
binary_reader(binary_reader &&)=default
static void byte_swap(NumberType &number)
char_int_type get_ignore_noop()
bool get_ubjson_value(const char_int_type prefix)
bool get_ubjson_ndarray_size(std::vector< size_t > &dim)
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
bool get_msgpack_object(const std::size_t len)
typename char_traits< char_type >::int_type char_int_type
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
typename BasicJsonType::binary_t binary_t
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
binary_reader & operator=(const binary_reader &)=delete
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
bool get_number(const input_format_t format, NumberType &result)
typename BasicJsonType::number_integer_t number_integer_t
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_msgpack_array(const std::size_t len)
char_int_type get()
get next character from the input
typename BasicJsonType::number_float_t number_float_t
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
bool parse_ubjson_internal(const bool get_char=true)
bool get_ubjson_size_value(std::size_t &result, bool &is_ndarray, char_int_type prefix=0)
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
bool get_to(T &dest, const input_format_t format, const char *context)
get_to read into a primitive type
bool get_cbor_string(string_t &result)
reads a CBOR string
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
binary_reader & operator=(binary_reader &&)=default
serialization to CBOR and MessagePack values
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
void write_bson(const BasicJsonType &j)
typename BasicJsonType::binary_t binary_t
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
typename BasicJsonType::string_t string_t
static constexpr CharType to_char_type(std::uint8_t x) noexcept
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false, const bjdata_version_t bjdata_version=bjdata_version_t::draft2)
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
static CharType to_char_type(std::uint8_t x) noexcept
static constexpr CharType get_cbor_float_prefix(double)
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static constexpr CharType get_ubjson_float_prefix(double)
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
static constexpr CharType get_msgpack_float_prefix(double)
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
static constexpr CharType to_char_type(InputCharType x) noexcept
void write_bson_object(const typename BasicJsonType::object_t &value)
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
static std::size_t calc_bson_string_size(const string_t &value)
void write_number(const NumberType n, const bool OutputIsLittleEndian=false)
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
typename BasicJsonType::number_float_t number_float_t
CharType ubjson_prefix(const BasicJsonType &j, const bool use_bjdata) const noexcept
determine the type prefix of container values
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
static constexpr CharType get_ubjson_float_prefix(float)
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
bool write_bjdata_ndarray(const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type, const bjdata_version_t bjdata_version)
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
void write_msgpack(const BasicJsonType &j)
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
void write_compact_float(const number_float_t n, detail::input_format_t format)
void write_cbor(const BasicJsonType &j)
static constexpr CharType get_cbor_float_prefix(float)
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
static constexpr CharType get_msgpack_float_prefix(float)
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
static std::size_t calc_bson_integer_size(const std::int64_t value)
general exception of the basic_json class
static std::string get_byte_positions(const BasicJsonType *leaf_element)
const int id
the id of the exception
static std::string diagnostics(std::nullptr_t)
std::runtime_error m
an exception object as storage for error messages
static std::string name(const std::string &ename, int id_)
const char * what() const noexcept override
returns the explanatory string
static std::string diagnostics(const BasicJsonType *leaf_element)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
iter_impl operator+(difference_type i) const
add to iterator
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
bool operator<(const iter_impl &other) const
comparison: smaller
bool operator<=(const iter_impl &other) const
comparison: less than or equal
iter_impl & operator-=(difference_type i)
subtract from iterator
iter_impl & operator--()
pre-decrement (–it)
const object_t::key_type & key() const
return the key of an object iterator
bool operator==(const IterImpl &other) const
comparison: equal
iter_impl operator++(int) &
post-increment (it++)
iter_impl & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
pointer operator->() const
dereference the iterator
friend other_iter_impl
allow basic_json to access private members
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
difference_type operator-(const iter_impl &other) const
return difference
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
reference value() const
return the value of an iterator
bool operator>(const iter_impl &other) const
comparison: greater than
typename BasicJsonType::array_t array_t
typename BasicJsonType::object_t object_t
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
iter_impl & operator++()
pre-increment (++it)
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl operator-(difference_type i) const
subtract from iterator
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
bool operator!=(const IterImpl &other) const
comparison: not equal
iter_impl operator--(int) &
post-decrement (it–)
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
void set_end() noexcept
set the iterator past the last value
iteration_proxy_value operator++(int) &
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
std::ptrdiff_t difference_type
string_type empty_str
an empty string (to return a reference for primitive values)
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
std::size_t array_index_last
last stringified array index
std::size_t array_index
an index for arrays (used to create key names)
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
const string_type & key() const
return key of the iterator
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
string_type array_index_str
a string representation of the array index
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
IteratorType anchor
the iterator
proxy class for the items() function
IteratorType::pointer container
the container to iterate
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
iteration_proxy & operator=(iteration_proxy const &)=default
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
json_ref(value_type &&value)
value_type const & operator*() const
value_type const * operator->() const
json_ref(std::initializer_list< json_ref > init)
json_ref(Args &&... args)
value_type moved_or_copied() const
a template for a reverse iterator class
json_reverse_iterator operator++(int) &
post-increment (it++)
json_reverse_iterator operator--(int) &
post-decrement (it–)
json_reverse_iterator & operator++()
pre-increment (++it)
std::ptrdiff_t difference_type
json_reverse_iterator & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
difference_type operator-(const json_reverse_iterator &other) const
return difference
typename Base::reference reference
the reference type for the pointed-to element
reference value() const
return the value of an iterator
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
json_reverse_iterator & operator--()
pre-decrement (–it)
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator operator+(difference_type i) const
add to iterator
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_integer(number_integer_t)
bool start_array(std::size_t=detail::unknown_size())
bool number_unsigned(number_unsigned_t)
bool start_object(std::size_t=detail::unknown_size())
typename BasicJsonType::binary_t binary_t
bool number_float(number_float_t, const string_t &)
bool parse_error(std::size_t, const std::string &, const detail::exception &)
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::string_t string_t
bool start_array(std::size_t len)
typename BasicJsonType::parser_callback_t parser_callback_t
typename BasicJsonType::parse_event_t parse_event_t
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool number_integer(number_integer_t val)
bool parse_error(std::size_t, const std::string &, const Exception &ex)
typename BasicJsonType::number_float_t number_float_t
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
lexer< BasicJsonType, InputAdapterType > lexer_t
bool number_unsigned(number_unsigned_t val)
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
bool binary(binary_t &val)
typename BasicJsonType::string_t string_t
bool string(string_t &val)
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
BasicJsonType & root
the parsed JSON value
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::binary_t binary_t
~json_sax_dom_callback_parser()=default
bool start_object(std::size_t len)
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
SAX implementation to create a JSON value from SAX events.
bool number_float(number_float_t val, const string_t &)
bool number_unsigned(number_unsigned_t val)
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
typename BasicJsonType::binary_t binary_t
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
bool start_object(std::size_t len)
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
~json_sax_dom_parser()=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool parse_error(std::size_t, const std::string &, const Exception &ex)
lexer< BasicJsonType, InputAdapterType > lexer_t
bool start_array(std::size_t len)
typename BasicJsonType::number_float_t number_float_t
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
BasicJsonType & root
the parsed JSON value
json_sax_dom_parser(json_sax_dom_parser &&)=default
constexpr bool is_errored() const
bool string(string_t &val)
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_integer(number_integer_t val)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
void reset() noexcept
reset token_buffer; current character is beginning of token
bool skip_bom()
skip the UTF-8 byte order mark
string_t token_buffer
buffer for variable-length tokens (numbers, strings)
int get_codepoint()
get codepoint from 4 hex characters following \u
token_type scan_string()
scan a string literal
number_integer_t value_integer
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
char_int_type current
the current character
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
std::string get_token_string() const
return the last read token (for errors only).
typename BasicJsonType::number_float_t number_float_t
constexpr number_integer_t get_number_integer() const noexcept
return integer value
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
constexpr position_t get_position() const noexcept
return position of last read token
static void strtof(float &f, const char *str, char **endptr) noexcept
const char_int_type decimal_point_char
the decimal point
number_unsigned_t value_unsigned
typename BasicJsonType::number_integer_t number_integer_t
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
typename char_traits< char_type >::int_type char_int_type
bool scan_comment()
scan a comment
typename lexer_base< BasicJsonType >::token_type token_type
const char * error_message
a description of occurred lexer errors
lexer & operator=(lexer &&)=default
bool next_unget
whether the next get() call should just return current
lexer(const lexer &)=delete
std::size_t decimal_point_position
the position of the decimal point in the input
typename InputAdapterType::char_type char_type
InputAdapterType ia
input adapter
lexer & operator=(lexer &)=delete
token_type scan_number()
scan a number literal
number_float_t value_float
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
std::vector< char_type > token_string
raw input token string (for error messages)
void add(char_int_type c)
add a character to token_buffer
position_t position
the start position of the current token
void unget()
unget current character (read it again on next get)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
output_adapter(StringType &s)
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(std::vector< CharType, AllocatorType > &vec)
output adapter for output streams
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
void write_character(CharType c) override
std::basic_ostream< CharType > & stream
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
output adapter for byte vectors
std::vector< CharType, AllocatorType > & v
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
void write_character(CharType c) override
exception indicating a parse error
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
static std::string position_string(const position_t &pos)
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
const std::size_t byte
byte index of the parse error
parse_error(int id_, std::size_t byte_, const char *what_arg)
std::string exception_message(const token_type expected, const std::string &context)
typename lexer_t::token_type token_type
void parse(const bool strict, BasicJsonType &result)
public parser interface
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
lexer< BasicJsonType, InputAdapterType > lexer_t
bool accept(const bool strict=true)
public accept interface
typename BasicJsonType::number_float_t number_float_t
token_type get_token()
get next token from lexer
parser(InputAdapterType &&adapter, parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool ignore_comments=false, const bool ignore_trailing_commas_=false)
a parser reading from an input adapter
primitive_iterator_t & operator++() noexcept
primitive_iterator_t & operator-=(difference_type n) noexcept
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
primitive_iterator_t & operator--() noexcept
void set_end() noexcept
set iterator to a defined past the end
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr bool is_end() const noexcept
return whether the iterator is at end
primitive_iterator_t operator++(int) &noexcept
primitive_iterator_t & operator+=(difference_type n) noexcept
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr difference_type get_value() const noexcept
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t operator+(difference_type n) noexcept
void set_begin() noexcept
set iterator to a defined beginning
primitive_iterator_t operator--(int) &noexcept
std::ptrdiff_t difference_type
typename BasicJsonType::binary_t::value_type binary_char_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
string_t indent_string
the indentation string
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
serializer & operator=(serializer &&)=delete
typename BasicJsonType::string_t string_t
const char indent_char
the indentation character
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
BasicJsonType & get_checked(BasicJsonType *ptr) const
json_pointer< string_t > convert() const &
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
static BasicJsonType::size_type array_index(const string_t &s)
typename string_t_helper< RefStringType >::type string_t
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
json_pointer(const string_t &s="")
create JSON pointer
static std::vector< string_t > split(const string_t &reference_string)
split the string input to reference tokens
bool empty() const noexcept
return whether pointer points to the root document
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
void pop_back()
remove last reference token
string_t to_string() const
return a string representation of the JSON pointer
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
json_pointer< string_t > convert() &&
std::vector< string_t > reference_tokens
the reference tokens
static void flatten(const string_t &reference_string, const BasicJsonType &value, BasicJsonType &result)
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
json_pointer parent_pointer() const
returns the parent of this JSON pointer
static BasicJsonType unflatten(const BasicJsonType &value)
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
const string_t & back() const
return last reference token
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
bool contains(const BasicJsonType *ptr) const
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
bool operator>(const Length &left, const Length &right)
Check if left has a value greater than right.
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_INLINE_VARIABLE
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_PRIVATE_UNLESS_TESTED
#define NLOHMANN_JSON_VERSION_PATCH
#define JSON_HEDLEY_LIKELY(expr)
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
#define JSON_HEDLEY_RETURNS_NON_NULL
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
#define NLOHMANN_JSON_NAMESPACE_END
#define JSON_NO_UNIQUE_ADDRESS
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
#define NLOHMANN_JSON_NAMESPACE_BEGIN
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
#define JSON_DIAGNOSTIC_POSITIONS
JSON_INLINE_VARIABLE constexpr const auto & from_json
JSON_INLINE_VARIABLE constexpr const auto & to_json
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k.
cached_power get_cached_power_for_binary_exponent(int e)
For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached power-of-ten c = f_c ...
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
Compute the (normalized) diyfp representing the input number 'value' and its boundaries.
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer m...
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+.
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
constexpr bool is_transparent()
constexpr bool is_c_string()
detail namespace with internal helper functions
input_format_t
the supported input formats
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
typename make_void< Ts... >::type void_t
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
OutStringType concat(Args &&... args)
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
decltype(T::to_json(std::declval< Args >()...)) to_json_function
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
decltype(std::declval< T >().template get< U >()) get_template_function
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
typename T::pointer pointer_t
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
typename utility_internal::Gen< T, N >::type make_integer_sequence
typename T::value_type value_type_t
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
void int_to_string(StringType &target, std::size_t value)
T conditional_static_cast(U value)
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
typename std::enable_if< B, T >::type enable_if_t
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
typename T::mapped_type mapped_type_t
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
bool little_endianness(int num=1) noexcept
determine system byte order
cbor_tag_handler_t
how to treat CBOR tags
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(T::from_json(std::declval< Args >()...)) from_json_function
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
make_integer_sequence< size_t, N > make_index_sequence
std::integral_constant< bool, Value > bool_constant
void concat_into(OutStringType &)
typename T::key_type key_type_t
constexpr bool value_in_range_of(T val)
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
constexpr std::size_t unknown_size()
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
StringType to_string(std::size_t value)
typename detector< nonesuch, void, Op, Args... >::type detected_t
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
std::size_t hash(const BasicJsonType &j)
hash a JSON value
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
typename T::iterator_category iterator_category_t
void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect.
decltype(input_adapter(std::declval< std::string >())) string_input_adapter_type
std::size_t combine(std::size_t seed, std::size_t h) noexcept
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
decltype(std::declval< T & >().end_array()) end_array_function_t
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
void to_json(BasicJsonType &j, T b) noexcept
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
decltype(std::declval< T & >().null()) null_function_t
make_index_sequence< sizeof...(Ts)> index_sequence_for
typename T::difference_type difference_type_t
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
typename T::is_transparent detect_is_transparent
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
typename T::reference reference_t
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
decltype(std::declval< T & >().end_object()) end_object_function_t
bjdata_version_t
how to encode BJData
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
typename T::key_compare detect_key_compare
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect.
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
is_detected< string_can_append, StringType, Arg > detect_string_can_append
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
std::istream & operator>>(std::istream &is, Angles &a)
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
-ns3 Test suite for the ns3 wrapper script
-ray-to-three-gpp-ch-calibration
#define E(name, start, end)
std::ostream & operator<<(std::ostream &os, const PairObject &obj)
Stream insertion operator.
namespace for Niels Lohmann
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
typename BasicJsonType::object_t object_t
typename BasicJsonType::default_object_comparator_t object_comparator_t
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
static constexpr int_type eof() noexcept
static char_type to_char_type(int_type i) noexcept
static int_type to_int_type(char_type c) noexcept
static char_type to_char_type(int_type i) noexcept
static constexpr int_type eof() noexcept
static int_type to_int_type(char_type c) noexcept
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
primitive_iterator_t primitive_iterator
generic iterator for all other types
std::numeric_limits< RealIntegerType > RealLimits
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
typename BasicJsonType::object_t object_t
static constexpr auto value
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
typename BasicJsonType::object_t object_t
ConstructibleStringType laundered_type
static constexpr auto value
static constexpr bool value
typename std::iterator_traits< T >::value_type value_type
static one test(decltype(&C::capacity))
detected_t< result_of_end, t_ref > sentinel
detected_t< result_of_begin, t_ref > iterator
typename std::add_lvalue_reference< T >::type t_ref
static constexpr bool value
static constexpr auto is_iterator_begin
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::exception exception_t
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::exception exception_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
ptrdiff_t difference_type
std::random_access_iterator_tag iterator_category
typename It::iterator_category iterator_category
typename It::difference_type difference_type
typename It::value_type value_type
typename It::reference reference
typename It::pointer pointer
Default base class of the basic_json class.
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t lines_read
the number of lines read
std::size_t chars_read_total
the total number of characters read
static JSON_INLINE_VARIABLE constexpr T value
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
static constexpr bool test(T val)
static constexpr bool test(T)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
std::vector< std::pair< const Key, T >, Allocator > Container
std::pair< iterator, bool > insert(value_type &&value)
typename Container::value_type value_type
std::equal_to< Key > key_compare
iterator erase(iterator pos)
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
T & operator[](KeyType &&key)
typename Container::iterator iterator
const T & at(KeyType &&key) const
const T & operator[](KeyType &&key) const
iterator find(const key_type &key)
iterator erase(iterator first, iterator last)
const T & at(const key_type &key) const
const_iterator find(const key_type &key) const
T & operator[](const key_type &key)
size_type erase(KeyType &&key)
typename Container::size_type size_type
ordered_map() noexcept(noexcept(Container()))
void insert(InputIt first, InputIt last)
size_type count(const key_type &key) const
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
size_type erase(const key_type &key)
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
std::pair< iterator, bool > insert(const value_type &value)
size_type count(KeyType &&key) const
ordered_map(It first, It last, const Allocator &alloc=Allocator())
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
const T & operator[](const key_type &key) const
iterator find(KeyType &&key)
T & at(const key_type &key)
typename Container::const_iterator const_iterator
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values