18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
60#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
63 #warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 12
70#define NLOHMANN_JSON_VERSION_PATCH 0
72#ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76#ifndef JSON_DIAGNOSTIC_POSITIONS
77 #define JSON_DIAGNOSTIC_POSITIONS 0
80#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
81 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
85 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
87 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
90#if JSON_DIAGNOSTIC_POSITIONS
91 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
93 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
96#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
97 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
99 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
102#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
103 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
107#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
108#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
109 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
111#define NLOHMANN_JSON_ABI_TAGS \
112 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
113 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
114 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
115 NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
118#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
119 _v ## major ## _ ## minor ## _ ## patch
120#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
121 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
123#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
124#define NLOHMANN_JSON_NAMESPACE_VERSION
126#define NLOHMANN_JSON_NAMESPACE_VERSION \
127 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
128 NLOHMANN_JSON_VERSION_MINOR, \
129 NLOHMANN_JSON_VERSION_PATCH)
133#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
134#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
135 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
137#ifndef NLOHMANN_JSON_NAMESPACE
138#define NLOHMANN_JSON_NAMESPACE \
139 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
140 NLOHMANN_JSON_ABI_TAGS, \
141 NLOHMANN_JSON_NAMESPACE_VERSION)
144#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
145#define NLOHMANN_JSON_NAMESPACE_BEGIN \
148 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
149 NLOHMANN_JSON_ABI_TAGS, \
150 NLOHMANN_JSON_NAMESPACE_VERSION) \
154#ifndef NLOHMANN_JSON_NAMESPACE_END
155#define NLOHMANN_JSON_NAMESPACE_END \
173#include <forward_list>
178#include <type_traits>
179#include <unordered_map>
242#include <type_traits>
287template<
class Default,
289 template<
class...>
class Op,
297template<
class Default,
template<
class...>
class Op,
class... Args>
304template<
template<
class...>
class Op,
class... Args>
307template<
template<
class...>
class Op,
class... Args>
310template<
template<
class...>
class Op,
class... Args>
313template<
class Default,
template<
class...>
class Op,
class... Args>
316template<
class Default,
template<
class...>
class Op,
class... Args>
319template<
class Expected,
template<
class...>
class Op,
class... Args>
322template<
class To,
template<
class...>
class Op,
class... Args>
324 std::is_convertible<
detected_t<Op, Args...>, To>;
345#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
346#if defined(JSON_HEDLEY_VERSION)
347 #undef JSON_HEDLEY_VERSION
349#define JSON_HEDLEY_VERSION 15
351#if defined(JSON_HEDLEY_STRINGIFY_EX)
352 #undef JSON_HEDLEY_STRINGIFY_EX
354#define JSON_HEDLEY_STRINGIFY_EX(x) #x
356#if defined(JSON_HEDLEY_STRINGIFY)
357 #undef JSON_HEDLEY_STRINGIFY
359#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
361#if defined(JSON_HEDLEY_CONCAT_EX)
362 #undef JSON_HEDLEY_CONCAT_EX
364#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
366#if defined(JSON_HEDLEY_CONCAT)
367 #undef JSON_HEDLEY_CONCAT
369#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
371#if defined(JSON_HEDLEY_CONCAT3_EX)
372 #undef JSON_HEDLEY_CONCAT3_EX
374#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
376#if defined(JSON_HEDLEY_CONCAT3)
377 #undef JSON_HEDLEY_CONCAT3
379#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
381#if defined(JSON_HEDLEY_VERSION_ENCODE)
382 #undef JSON_HEDLEY_VERSION_ENCODE
384#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
386#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
387 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
389#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
391#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
392 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
394#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
396#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
397 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
399#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
401#if defined(JSON_HEDLEY_GNUC_VERSION)
402 #undef JSON_HEDLEY_GNUC_VERSION
404#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
405 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
406#elif defined(__GNUC__)
407 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
410#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
411 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
413#if defined(JSON_HEDLEY_GNUC_VERSION)
414 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
416 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
419#if defined(JSON_HEDLEY_MSVC_VERSION)
420 #undef JSON_HEDLEY_MSVC_VERSION
422#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
423 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
424#elif defined(_MSC_FULL_VER) && !defined(__ICL)
425 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
426#elif defined(_MSC_VER) && !defined(__ICL)
427 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
430#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
431 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
433#if !defined(JSON_HEDLEY_MSVC_VERSION)
434 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
435#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
436 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
437#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
438 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
440 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
443#if defined(JSON_HEDLEY_INTEL_VERSION)
444 #undef JSON_HEDLEY_INTEL_VERSION
446#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
447 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
448#elif defined(__INTEL_COMPILER) && !defined(__ICL)
449 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
452#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
453 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
455#if defined(JSON_HEDLEY_INTEL_VERSION)
456 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
458 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
461#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
462 #undef JSON_HEDLEY_INTEL_CL_VERSION
464#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
465 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
468#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
469 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
471#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
472 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
474 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
477#if defined(JSON_HEDLEY_PGI_VERSION)
478 #undef JSON_HEDLEY_PGI_VERSION
480#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
481 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
484#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
485 #undef JSON_HEDLEY_PGI_VERSION_CHECK
487#if defined(JSON_HEDLEY_PGI_VERSION)
488 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
490 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
493#if defined(JSON_HEDLEY_SUNPRO_VERSION)
494 #undef JSON_HEDLEY_SUNPRO_VERSION
496#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
497 #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)
498#elif defined(__SUNPRO_C)
499 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
500#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
501 #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)
502#elif defined(__SUNPRO_CC)
503 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
506#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
507 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
509#if defined(JSON_HEDLEY_SUNPRO_VERSION)
510 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
515#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
516 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
518#if defined(__EMSCRIPTEN__)
519 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
522#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
523 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
525#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
526 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
528 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
531#if defined(JSON_HEDLEY_ARM_VERSION)
532 #undef JSON_HEDLEY_ARM_VERSION
534#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
535 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
536#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
537 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
540#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
541 #undef JSON_HEDLEY_ARM_VERSION_CHECK
543#if defined(JSON_HEDLEY_ARM_VERSION)
544 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
546 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
549#if defined(JSON_HEDLEY_IBM_VERSION)
550 #undef JSON_HEDLEY_IBM_VERSION
552#if defined(__ibmxl__)
553 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
554#elif defined(__xlC__) && defined(__xlC_ver__)
555 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
556#elif defined(__xlC__)
557 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
560#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
561 #undef JSON_HEDLEY_IBM_VERSION_CHECK
563#if defined(JSON_HEDLEY_IBM_VERSION)
564 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
566 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
569#if defined(JSON_HEDLEY_TI_VERSION)
570 #undef JSON_HEDLEY_TI_VERSION
573 defined(__TI_COMPILER_VERSION__) && \
575 defined(__TMS470__) || defined(__TI_ARM__) || \
576 defined(__MSP430__) || \
577 defined(__TMS320C2000__) \
579#if (__TI_COMPILER_VERSION__ >= 16000000)
580 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
584#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
585 #undef JSON_HEDLEY_TI_VERSION_CHECK
587#if defined(JSON_HEDLEY_TI_VERSION)
588 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
590 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
593#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
594 #undef JSON_HEDLEY_TI_CL2000_VERSION
596#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
597 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
600#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
601 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
603#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
604 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
606 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
609#if defined(JSON_HEDLEY_TI_CL430_VERSION)
610 #undef JSON_HEDLEY_TI_CL430_VERSION
612#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
613 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
616#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
617 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
619#if defined(JSON_HEDLEY_TI_CL430_VERSION)
620 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
622 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
625#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
626 #undef JSON_HEDLEY_TI_ARMCL_VERSION
628#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
629 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
632#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
633 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
635#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
636 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
638 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
641#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
642 #undef JSON_HEDLEY_TI_CL6X_VERSION
644#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
645 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
648#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
649 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
651#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
652 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
654 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
657#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
658 #undef JSON_HEDLEY_TI_CL7X_VERSION
660#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
661 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
664#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
665 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
667#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
668 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
670 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
673#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
674 #undef JSON_HEDLEY_TI_CLPRU_VERSION
676#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
677 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
680#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
681 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
683#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
684 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
686 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
689#if defined(JSON_HEDLEY_CRAY_VERSION)
690 #undef JSON_HEDLEY_CRAY_VERSION
693 #if defined(_RELEASE_PATCHLEVEL)
694 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
696 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
700#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
701 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
703#if defined(JSON_HEDLEY_CRAY_VERSION)
704 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
706 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
709#if defined(JSON_HEDLEY_IAR_VERSION)
710 #undef JSON_HEDLEY_IAR_VERSION
712#if defined(__IAR_SYSTEMS_ICC__)
714 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
716 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
720#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
721 #undef JSON_HEDLEY_IAR_VERSION_CHECK
723#if defined(JSON_HEDLEY_IAR_VERSION)
724 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
726 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
729#if defined(JSON_HEDLEY_TINYC_VERSION)
730 #undef JSON_HEDLEY_TINYC_VERSION
732#if defined(__TINYC__)
733 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
736#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
737 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
739#if defined(JSON_HEDLEY_TINYC_VERSION)
740 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
742 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
745#if defined(JSON_HEDLEY_DMC_VERSION)
746 #undef JSON_HEDLEY_DMC_VERSION
749 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
752#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
753 #undef JSON_HEDLEY_DMC_VERSION_CHECK
755#if defined(JSON_HEDLEY_DMC_VERSION)
756 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
758 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
761#if defined(JSON_HEDLEY_COMPCERT_VERSION)
762 #undef JSON_HEDLEY_COMPCERT_VERSION
764#if defined(__COMPCERT_VERSION__)
765 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
768#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
769 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
771#if defined(JSON_HEDLEY_COMPCERT_VERSION)
772 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
774 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
777#if defined(JSON_HEDLEY_PELLES_VERSION)
778 #undef JSON_HEDLEY_PELLES_VERSION
781 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
784#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
785 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
787#if defined(JSON_HEDLEY_PELLES_VERSION)
788 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
790 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
793#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
794 #undef JSON_HEDLEY_MCST_LCC_VERSION
796#if defined(__LCC__) && defined(__LCC_MINOR__)
797 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
800#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
801 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
803#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
804 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
806 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
809#if defined(JSON_HEDLEY_GCC_VERSION)
810 #undef JSON_HEDLEY_GCC_VERSION
813 defined(JSON_HEDLEY_GNUC_VERSION) && \
814 !defined(__clang__) && \
815 !defined(JSON_HEDLEY_INTEL_VERSION) && \
816 !defined(JSON_HEDLEY_PGI_VERSION) && \
817 !defined(JSON_HEDLEY_ARM_VERSION) && \
818 !defined(JSON_HEDLEY_CRAY_VERSION) && \
819 !defined(JSON_HEDLEY_TI_VERSION) && \
820 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
821 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
822 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
823 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
824 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
825 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
826 !defined(__COMPCERT__) && \
827 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
828 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
831#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
832 #undef JSON_HEDLEY_GCC_VERSION_CHECK
834#if defined(JSON_HEDLEY_GCC_VERSION)
835 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
837 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
840#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
841 #undef JSON_HEDLEY_HAS_ATTRIBUTE
844 defined(__has_attribute) && \
846 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
848# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
850# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
853#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
854 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
856#if defined(__has_attribute)
857 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
859 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
862#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
863 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
865#if defined(__has_attribute)
866 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
868 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
871#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
872 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
875 defined(__has_cpp_attribute) && \
876 defined(__cplusplus) && \
877 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
878 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
883#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
884 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
886#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
887 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
889 !defined(JSON_HEDLEY_PGI_VERSION) && \
890 !defined(JSON_HEDLEY_IAR_VERSION) && \
891 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
892 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
893 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
895 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
898#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
899 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
901#if defined(__has_cpp_attribute) && defined(__cplusplus)
902 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
904 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
907#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
908 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
910#if defined(__has_cpp_attribute) && defined(__cplusplus)
911 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
913 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
916#if defined(JSON_HEDLEY_HAS_BUILTIN)
917 #undef JSON_HEDLEY_HAS_BUILTIN
919#if defined(__has_builtin)
920 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
922 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
925#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
926 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
928#if defined(__has_builtin)
929 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
931 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
934#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
935 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
937#if defined(__has_builtin)
938 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
940 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
943#if defined(JSON_HEDLEY_HAS_FEATURE)
944 #undef JSON_HEDLEY_HAS_FEATURE
946#if defined(__has_feature)
947 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
949 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
952#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
953 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
955#if defined(__has_feature)
956 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
958 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
961#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
962 #undef JSON_HEDLEY_GCC_HAS_FEATURE
964#if defined(__has_feature)
965 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
967 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
970#if defined(JSON_HEDLEY_HAS_EXTENSION)
971 #undef JSON_HEDLEY_HAS_EXTENSION
973#if defined(__has_extension)
974 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
976 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
979#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
980 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
982#if defined(__has_extension)
983 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
985 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
988#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
989 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
991#if defined(__has_extension)
992 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
994 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
997#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
998 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1000#if defined(__has_declspec_attribute)
1001 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1003 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1006#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1007 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1009#if defined(__has_declspec_attribute)
1010 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1012 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1015#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1016 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1018#if defined(__has_declspec_attribute)
1019 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1021 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1024#if defined(JSON_HEDLEY_HAS_WARNING)
1025 #undef JSON_HEDLEY_HAS_WARNING
1027#if defined(__has_warning)
1028 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1030 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1033#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1034 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1036#if defined(__has_warning)
1037 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1039 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1042#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1043 #undef JSON_HEDLEY_GCC_HAS_WARNING
1045#if defined(__has_warning)
1046 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1048 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1052 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1053 defined(__clang__) || \
1054 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1055 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1056 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1057 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1058 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1059 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1060 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1061 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1062 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1063 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1064 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1065 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1066 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1067 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1068 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1069 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1070 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1071#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1072 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1074 #define JSON_HEDLEY_PRAGMA(value)
1077#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1078 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1080#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1081 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1083#if defined(__clang__)
1084 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1085 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1086#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1089#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1090 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1091 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1093 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1094 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1095 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1096 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1097#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1098 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1099 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1101 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1102 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1103 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1104 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1105 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1106 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1107 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1108 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1109#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1111 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1113 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1114 #define JSON_HEDLEY_DIAGNOSTIC_POP
1119#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1120 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1122#if defined(__cplusplus)
1123# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1124# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1125# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1126# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1127 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1128 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1129 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1130 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1132 JSON_HEDLEY_DIAGNOSTIC_POP
1134# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1135 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1136 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1137 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1139 JSON_HEDLEY_DIAGNOSTIC_POP
1142# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1143 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1144 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1146 JSON_HEDLEY_DIAGNOSTIC_POP
1150#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1151 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1154#if defined(JSON_HEDLEY_CONST_CAST)
1155 #undef JSON_HEDLEY_CONST_CAST
1157#if defined(__cplusplus)
1158# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1160 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1161 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1162 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1163# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1164 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1165 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1167 JSON_HEDLEY_DIAGNOSTIC_POP \
1170# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1173#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1174 #undef JSON_HEDLEY_REINTERPRET_CAST
1176#if defined(__cplusplus)
1177 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1179 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1182#if defined(JSON_HEDLEY_STATIC_CAST)
1183 #undef JSON_HEDLEY_STATIC_CAST
1185#if defined(__cplusplus)
1186 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1188 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1191#if defined(JSON_HEDLEY_CPP_CAST)
1192 #undef JSON_HEDLEY_CPP_CAST
1194#if defined(__cplusplus)
1195# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1196# define JSON_HEDLEY_CPP_CAST(T, expr) \
1197 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1198 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1200 JSON_HEDLEY_DIAGNOSTIC_POP
1201# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1202# define JSON_HEDLEY_CPP_CAST(T, expr) \
1203 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1204 _Pragma("diag_suppress=Pe137") \
1205 JSON_HEDLEY_DIAGNOSTIC_POP
1207# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1210# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1213#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1214 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1216#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1217 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1218#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1219 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1220#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1221 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1222#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1223 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1224#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1225 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1226#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1227 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1228#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1229 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1230#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1233 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1234 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1235 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1236 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1237 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1238 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1239 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1240 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1241 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1242 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1243 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1244 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1245#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1246 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1247#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1248 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1249#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1251#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1257#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1258 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1260#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1261 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1262#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1263 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1264#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1265 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1266#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1267 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1268#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1269 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1270#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1271 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1273 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1274 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1275 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1276 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1277 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1278#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1280#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1282#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1288#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1289 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1291#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1292 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1293#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1295#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1297#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1298 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1299#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1301#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1303#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1305#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1308 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1309 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1310 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1312#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1314#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1320#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1321 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1323#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1324 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1325#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1327#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1333#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1334 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1336#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1337 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1338#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1339 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1340#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1341 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1342#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1343 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1345 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1348#if defined(JSON_HEDLEY_DEPRECATED)
1349 #undef JSON_HEDLEY_DEPRECATED
1351#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1352 #undef JSON_HEDLEY_DEPRECATED_FOR
1355 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1356 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1357 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1358 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1360 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1361 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1362 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1363 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1364 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1365 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1366 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1367 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1368 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1369 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1370 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1371 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1372 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1373 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1374#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1375 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1376 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1378 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1379 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1380 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1381 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1382 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1383 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1384 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1385 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1386 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1387 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1388 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1389 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1390 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1391 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1392 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1393 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1394 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1395 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1397 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1398 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1399 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1400 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1401 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1402#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1403 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1404 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1406 #define JSON_HEDLEY_DEPRECATED(since)
1407 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1410#if defined(JSON_HEDLEY_UNAVAILABLE)
1411 #undef JSON_HEDLEY_UNAVAILABLE
1414 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1415 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1416 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1417 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1418 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1420 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1423#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1424 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1426#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1427 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1430 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1431 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1432 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1433 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1434 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1435 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1436 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1437 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1438 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1439 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1440 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1441 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1442 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1443 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1444 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1445 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1446 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1447 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1449#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1451 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1452#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1454 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1455#elif defined(_Check_return_)
1456 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1457 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1459 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1460 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1463#if defined(JSON_HEDLEY_SENTINEL)
1464 #undef JSON_HEDLEY_SENTINEL
1467 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1468 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1469 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1470 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1471 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1472 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1474 #define JSON_HEDLEY_SENTINEL(position)
1477#if defined(JSON_HEDLEY_NO_RETURN)
1478 #undef JSON_HEDLEY_NO_RETURN
1480#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1481 #define JSON_HEDLEY_NO_RETURN __noreturn
1483 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1484 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1485 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1486#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1487 #define JSON_HEDLEY_NO_RETURN _Noreturn
1488#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1489 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1491 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1492 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1493 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1494 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1495 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1496 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1497 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1498 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1499 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1500 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1501 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1502 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1503 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1504 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1505 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1506 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1507 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1508 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1509#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1510 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1512 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1513 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1514 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1515#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1516 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1517#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1518 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1519#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1520 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1522 #define JSON_HEDLEY_NO_RETURN
1525#if defined(JSON_HEDLEY_NO_ESCAPE)
1526 #undef JSON_HEDLEY_NO_ESCAPE
1528#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1529 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1531 #define JSON_HEDLEY_NO_ESCAPE
1534#if defined(JSON_HEDLEY_UNREACHABLE)
1535 #undef JSON_HEDLEY_UNREACHABLE
1537#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1538 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1540#if defined(JSON_HEDLEY_ASSUME)
1541 #undef JSON_HEDLEY_ASSUME
1544 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1545 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1546 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1547 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1548#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1549 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1551 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1552 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1553 #if defined(__cplusplus)
1554 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1556 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1560 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1561 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1562 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1563 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1564 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1565 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1566 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1567 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1568#elif defined(JSON_HEDLEY_ASSUME)
1569 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1571#if !defined(JSON_HEDLEY_ASSUME)
1572 #if defined(JSON_HEDLEY_UNREACHABLE)
1573 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1575 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1578#if defined(JSON_HEDLEY_UNREACHABLE)
1580 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1581 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1582 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1584 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1587 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1589#if !defined(JSON_HEDLEY_UNREACHABLE)
1590 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1594#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1595 #pragma clang diagnostic ignored "-Wpedantic"
1597#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1598 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1600#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1601 #if defined(__clang__)
1602 #pragma clang diagnostic ignored "-Wvariadic-macros"
1603 #elif defined(JSON_HEDLEY_GCC_VERSION)
1604 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1607#if defined(JSON_HEDLEY_NON_NULL)
1608 #undef JSON_HEDLEY_NON_NULL
1611 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1612 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1613 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1614 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1615 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1617 #define JSON_HEDLEY_NON_NULL(...)
1621#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1622 #undef JSON_HEDLEY_PRINTF_FORMAT
1624#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1625 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1626#elif 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__(gnu_printf, string_idx, first_to_check)))
1629 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1630 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1631 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1632 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1633 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1634 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1635 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1636 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1637 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1638 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1639 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1640 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1641 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1642 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1643 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1644 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1645 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1646 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1647#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1648 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1650 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1653#if defined(JSON_HEDLEY_CONSTEXPR)
1654 #undef JSON_HEDLEY_CONSTEXPR
1656#if defined(__cplusplus)
1657 #if __cplusplus >= 201103L
1658 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1661#if !defined(JSON_HEDLEY_CONSTEXPR)
1662 #define JSON_HEDLEY_CONSTEXPR
1665#if defined(JSON_HEDLEY_PREDICT)
1666 #undef JSON_HEDLEY_PREDICT
1668#if defined(JSON_HEDLEY_LIKELY)
1669 #undef JSON_HEDLEY_LIKELY
1671#if defined(JSON_HEDLEY_UNLIKELY)
1672 #undef JSON_HEDLEY_UNLIKELY
1674#if defined(JSON_HEDLEY_UNPREDICTABLE)
1675 #undef JSON_HEDLEY_UNPREDICTABLE
1677#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1678 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1681 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1682 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1683 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1684# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1685# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1686# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1687# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1688# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1690 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1691 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1692 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1693 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1694 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1695 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1696 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1697 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1698 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1699 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1700 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1701 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1702 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1703 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1704 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1705 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1706# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1707 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1708# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1710 double hedley_probability_ = (probability); \
1711 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1713# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1715 double hedley_probability_ = (probability); \
1716 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1718# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1719# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1721# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1722# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1723# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1724# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1725# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1727#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1728 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1731#if defined(JSON_HEDLEY_MALLOC)
1732 #undef JSON_HEDLEY_MALLOC
1735 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1736 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1737 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1738 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1739 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1740 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1741 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1742 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1743 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1744 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1745 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1746 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1747 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1748 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1749 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1750 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1751 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1752 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1753 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1754#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1755 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1757 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1758 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1759 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1761 #define JSON_HEDLEY_MALLOC
1764#if defined(JSON_HEDLEY_PURE)
1765 #undef JSON_HEDLEY_PURE
1768 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1769 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1770 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1771 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1772 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1773 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1774 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1775 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1776 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1777 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1778 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1779 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1780 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1781 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1784 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1785 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1786 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1787# define JSON_HEDLEY_PURE __attribute__((__pure__))
1788#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1789# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1790#elif defined(__cplusplus) && \
1792 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1793 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1794 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1796# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1798# define JSON_HEDLEY_PURE
1801#if defined(JSON_HEDLEY_CONST)
1802 #undef JSON_HEDLEY_CONST
1805 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1806 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1807 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1808 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1809 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1810 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1811 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1812 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1813 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1814 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1815 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1816 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1817 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1818 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1819 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1820 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1821 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1822 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1823 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1824 #define JSON_HEDLEY_CONST __attribute__((__const__))
1826 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1827 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1829 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1832#if defined(JSON_HEDLEY_RESTRICT)
1833 #undef JSON_HEDLEY_RESTRICT
1835#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1836 #define JSON_HEDLEY_RESTRICT restrict
1838 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1839 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1840 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1841 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1842 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1843 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1844 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1845 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1846 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1847 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1848 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1849 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1850 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1851 defined(__clang__) || \
1852 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1853 #define JSON_HEDLEY_RESTRICT __restrict
1854#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1855 #define JSON_HEDLEY_RESTRICT _Restrict
1857 #define JSON_HEDLEY_RESTRICT
1860#if defined(JSON_HEDLEY_INLINE)
1861 #undef JSON_HEDLEY_INLINE
1864 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1865 (defined(__cplusplus) && (__cplusplus >= 199711L))
1866 #define JSON_HEDLEY_INLINE inline
1868 defined(JSON_HEDLEY_GCC_VERSION) || \
1869 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1870 #define JSON_HEDLEY_INLINE __inline__
1872 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1873 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1874 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1875 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1876 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1877 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1878 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1879 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1880 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1881 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1882 #define JSON_HEDLEY_INLINE __inline
1884 #define JSON_HEDLEY_INLINE
1887#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1888 #undef JSON_HEDLEY_ALWAYS_INLINE
1891 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1892 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1893 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1894 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1895 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1896 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1897 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1898 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1899 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1900 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1901 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1902 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1903 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1904 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1905 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1906 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1907 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1908 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1909 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1910# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1912 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1913 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1914# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1915#elif defined(__cplusplus) && \
1917 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1918 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1919 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1920 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1921 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1922 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1924# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1925#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1926# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1928# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1931#if defined(JSON_HEDLEY_NEVER_INLINE)
1932 #undef JSON_HEDLEY_NEVER_INLINE
1935 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1936 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1937 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1938 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1939 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1940 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1941 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1942 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1943 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1944 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1945 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1946 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1947 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1948 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1949 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1950 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1951 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1952 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1953 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1954 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1956 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1957 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1958 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1959#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1960 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1961#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1962 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1963#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1964 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1965#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1966 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1967#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1968 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1970 #define JSON_HEDLEY_NEVER_INLINE
1973#if defined(JSON_HEDLEY_PRIVATE)
1974 #undef JSON_HEDLEY_PRIVATE
1976#if defined(JSON_HEDLEY_PUBLIC)
1977 #undef JSON_HEDLEY_PUBLIC
1979#if defined(JSON_HEDLEY_IMPORT)
1980 #undef JSON_HEDLEY_IMPORT
1982#if defined(_WIN32) || defined(__CYGWIN__)
1983# define JSON_HEDLEY_PRIVATE
1984# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1985# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1988 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1989 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1990 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1991 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1992 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1993 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1995 defined(__TI_EABI__) && \
1997 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1998 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2001 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2002# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2003# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2005# define JSON_HEDLEY_PRIVATE
2006# define JSON_HEDLEY_PUBLIC
2008# define JSON_HEDLEY_IMPORT extern
2011#if defined(JSON_HEDLEY_NO_THROW)
2012 #undef JSON_HEDLEY_NO_THROW
2015 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2016 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2017 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2018 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2019 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2021 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2022 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2023 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2024 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2026 #define JSON_HEDLEY_NO_THROW
2029#if defined(JSON_HEDLEY_FALL_THROUGH)
2030 #undef JSON_HEDLEY_FALL_THROUGH
2033 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2034 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2035 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2036 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2037#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2038 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2039#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2040 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2041#elif defined(__fallthrough)
2042 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2044 #define JSON_HEDLEY_FALL_THROUGH
2047#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2048 #undef JSON_HEDLEY_RETURNS_NON_NULL
2051 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2052 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2053 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2054 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2055#elif defined(_Ret_notnull_)
2056 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2058 #define JSON_HEDLEY_RETURNS_NON_NULL
2061#if defined(JSON_HEDLEY_ARRAY_PARAM)
2062 #undef JSON_HEDLEY_ARRAY_PARAM
2065 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2066 !defined(__STDC_NO_VLA__) && \
2067 !defined(__cplusplus) && \
2068 !defined(JSON_HEDLEY_PGI_VERSION) && \
2069 !defined(JSON_HEDLEY_TINYC_VERSION)
2070 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2072 #define JSON_HEDLEY_ARRAY_PARAM(name)
2075#if defined(JSON_HEDLEY_IS_CONSTANT)
2076 #undef JSON_HEDLEY_IS_CONSTANT
2078#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2079 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2083#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2084 #undef JSON_HEDLEY_IS_CONSTEXPR_
2087 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2088 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2089 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2090 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2091 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2092 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2094 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2095 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2096 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2097 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2099#if !defined(__cplusplus)
2101 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2102 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2103 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2104 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2105 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2106 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2107 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2108#if defined(__INTPTR_TYPE__)
2109 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2112 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2116 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2117 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2118 !defined(JSON_HEDLEY_PGI_VERSION) && \
2119 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2120 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2121 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2122 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2123 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2124 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2125#if defined(__INTPTR_TYPE__)
2126 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2129 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2132 defined(JSON_HEDLEY_GCC_VERSION) || \
2133 defined(JSON_HEDLEY_INTEL_VERSION) || \
2134 defined(JSON_HEDLEY_TINYC_VERSION) || \
2135 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2136 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2137 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2138 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2139 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2140 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2142# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2146 ((void*) ((expr) * 0L) ) : \
2147((struct { char v[sizeof(void) * 2]; } *) 1) \
2153#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2154 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2155 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2157 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2159 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2160 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2162 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2165#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2166 #undef JSON_HEDLEY_BEGIN_C_DECLS
2168#if defined(JSON_HEDLEY_END_C_DECLS)
2169 #undef JSON_HEDLEY_END_C_DECLS
2171#if defined(JSON_HEDLEY_C_DECL)
2172 #undef JSON_HEDLEY_C_DECL
2174#if defined(__cplusplus)
2175 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2176 #define JSON_HEDLEY_END_C_DECLS }
2177 #define JSON_HEDLEY_C_DECL extern "C"
2179 #define JSON_HEDLEY_BEGIN_C_DECLS
2180 #define JSON_HEDLEY_END_C_DECLS
2181 #define JSON_HEDLEY_C_DECL
2184#if defined(JSON_HEDLEY_STATIC_ASSERT)
2185 #undef JSON_HEDLEY_STATIC_ASSERT
2188 !defined(__cplusplus) && ( \
2189 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2190 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2191 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2192 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2193 defined(_Static_assert) \
2195# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2197 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2198 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2199 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2200# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2202# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2205#if defined(JSON_HEDLEY_NULL)
2206 #undef JSON_HEDLEY_NULL
2208#if defined(__cplusplus)
2209 #if __cplusplus >= 201103L
2210 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2212 #define JSON_HEDLEY_NULL NULL
2214 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2217 #define JSON_HEDLEY_NULL NULL
2219 #define JSON_HEDLEY_NULL ((void*) 0)
2222#if defined(JSON_HEDLEY_MESSAGE)
2223 #undef JSON_HEDLEY_MESSAGE
2225#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2226# define JSON_HEDLEY_MESSAGE(msg) \
2227 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2228 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2229 JSON_HEDLEY_PRAGMA(message msg) \
2230 JSON_HEDLEY_DIAGNOSTIC_POP
2232 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2233 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2234# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2235#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2236# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2237#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2238# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2239#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2240# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2242# define JSON_HEDLEY_MESSAGE(msg)
2245#if defined(JSON_HEDLEY_WARNING)
2246 #undef JSON_HEDLEY_WARNING
2248#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2249# define JSON_HEDLEY_WARNING(msg) \
2250 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2251 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2252 JSON_HEDLEY_PRAGMA(clang warning msg) \
2253 JSON_HEDLEY_DIAGNOSTIC_POP
2255 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2256 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2257 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2258# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2260 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2261 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2262# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2264# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2267#if defined(JSON_HEDLEY_REQUIRE)
2268 #undef JSON_HEDLEY_REQUIRE
2270#if defined(JSON_HEDLEY_REQUIRE_MSG)
2271 #undef JSON_HEDLEY_REQUIRE_MSG
2273#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2274# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2275# define JSON_HEDLEY_REQUIRE(expr) \
2276 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2277 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2278 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2279 JSON_HEDLEY_DIAGNOSTIC_POP
2280# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2281 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2282 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2283 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2284 JSON_HEDLEY_DIAGNOSTIC_POP
2286# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2287# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2290# define JSON_HEDLEY_REQUIRE(expr)
2291# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2294#if defined(JSON_HEDLEY_FLAGS)
2295 #undef JSON_HEDLEY_FLAGS
2297#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2298 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2300 #define JSON_HEDLEY_FLAGS
2303#if defined(JSON_HEDLEY_FLAGS_CAST)
2304 #undef JSON_HEDLEY_FLAGS_CAST
2306#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2307# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2308 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2309 _Pragma("warning(disable:188)") \
2311 JSON_HEDLEY_DIAGNOSTIC_POP \
2314# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2317#if defined(JSON_HEDLEY_EMPTY_BASES)
2318 #undef JSON_HEDLEY_EMPTY_BASES
2321 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2322 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2323 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2325 #define JSON_HEDLEY_EMPTY_BASES
2330#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2331 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2333#if defined(__clang__)
2334 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2336 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2339#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2340 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2342#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2344#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2345 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2347#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2349#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2350 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2352#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2354#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2355 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2357#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2359#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2360 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2362#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2364#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2365 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2367#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2369#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2370 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2372#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2384#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2385 #if defined(__clang__)
2386 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2387 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2389 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2390 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2391 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2398#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)
2399 #if (defined(__cplusplus) && __cplusplus > 202302L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202302L)
2400 #define JSON_HAS_CPP_26
2401 #define JSON_HAS_CPP_23
2402 #define JSON_HAS_CPP_20
2403 #define JSON_HAS_CPP_17
2404 #define JSON_HAS_CPP_14
2405 #elif (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
2406 #define JSON_HAS_CPP_23
2407 #define JSON_HAS_CPP_20
2408 #define JSON_HAS_CPP_17
2409 #define JSON_HAS_CPP_14
2410 #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
2411 #define JSON_HAS_CPP_20
2412 #define JSON_HAS_CPP_17
2413 #define JSON_HAS_CPP_14
2414 #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2415 #define JSON_HAS_CPP_17
2416 #define JSON_HAS_CPP_14
2417 #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2418 #define JSON_HAS_CPP_14
2421 #define JSON_HAS_CPP_11
2425 #if __has_include(<version>)
2430#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2431 #ifdef JSON_HAS_CPP_17
2432 #if defined(__cpp_lib_filesystem)
2433 #define JSON_HAS_FILESYSTEM 1
2434 #elif defined(__cpp_lib_experimental_filesystem)
2435 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2436 #elif !defined(__has_include)
2437 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2438 #elif __has_include(<filesystem>)
2439 #define JSON_HAS_FILESYSTEM 1
2440 #elif __has_include(<experimental/filesystem>)
2441 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2445 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2446 #undef JSON_HAS_FILESYSTEM
2447 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2451 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2452 #undef JSON_HAS_FILESYSTEM
2453 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2457 #if defined(__clang_major__) && __clang_major__ < 7
2458 #undef JSON_HAS_FILESYSTEM
2459 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2463 #if defined(_MSC_VER) && _MSC_VER < 1914
2464 #undef JSON_HAS_FILESYSTEM
2465 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2469 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2470 #undef JSON_HAS_FILESYSTEM
2471 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2475 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2476 #undef JSON_HAS_FILESYSTEM
2477 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2482#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2483 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2486#ifndef JSON_HAS_FILESYSTEM
2487 #define JSON_HAS_FILESYSTEM 0
2490#ifndef JSON_HAS_THREE_WAY_COMPARISON
2491 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2492 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2493 #define JSON_HAS_THREE_WAY_COMPARISON 1
2495 #define JSON_HAS_THREE_WAY_COMPARISON 0
2499#ifndef JSON_HAS_RANGES
2501 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2502 #define JSON_HAS_RANGES 0
2503 #elif defined(__cpp_lib_ranges)
2504 #define JSON_HAS_RANGES 1
2506 #define JSON_HAS_RANGES 0
2510#ifndef JSON_HAS_STATIC_RTTI
2511 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2512 #define JSON_HAS_STATIC_RTTI 1
2514 #define JSON_HAS_STATIC_RTTI 0
2518#ifdef JSON_HAS_CPP_17
2519 #define JSON_INLINE_VARIABLE inline
2521 #define JSON_INLINE_VARIABLE
2524#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2525 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2527 #define JSON_NO_UNIQUE_ADDRESS
2531#if defined(__clang__)
2532 #pragma clang diagnostic push
2533 #pragma clang diagnostic ignored "-Wdocumentation"
2534 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2538#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2539 #define JSON_THROW(exception) throw exception
2540 #define JSON_TRY try
2541 #define JSON_CATCH(exception) catch(exception)
2542 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2545 #define JSON_THROW(exception) std::abort()
2546 #define JSON_TRY if(true)
2547 #define JSON_CATCH(exception) if(false)
2548 #define JSON_INTERNAL_CATCH(exception) if(false)
2552#if defined(JSON_THROW_USER)
2554 #define JSON_THROW JSON_THROW_USER
2556#if defined(JSON_TRY_USER)
2558 #define JSON_TRY JSON_TRY_USER
2560#if defined(JSON_CATCH_USER)
2562 #define JSON_CATCH JSON_CATCH_USER
2563 #undef JSON_INTERNAL_CATCH
2564 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2566#if defined(JSON_INTERNAL_CATCH_USER)
2567 #undef JSON_INTERNAL_CATCH
2568 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2572#if !defined(JSON_ASSERT)
2574 #define JSON_ASSERT(x) assert(x)
2578#if defined(JSON_TESTS_PRIVATE)
2579 #define JSON_PRIVATE_UNLESS_TESTED public
2581 #define JSON_PRIVATE_UNLESS_TESTED private
2589#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2590 template<typename BasicJsonType> \
2591 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2594 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2596 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2597 auto it = std::find_if(std::begin(m), std::end(m), \
2598 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2600 return ej_pair.first == e; \
2602 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2604 template<typename BasicJsonType> \
2605 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2608 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2610 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2611 auto it = std::find_if(std::begin(m), std::end(m), \
2612 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2614 return ej_pair.second == j; \
2616 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2622#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2623 template<template<typename, typename, typename...> class ObjectType, \
2624 template<typename, typename...> class ArrayType, \
2625 class StringType, class BooleanType, class NumberIntegerType, \
2626 class NumberUnsignedType, class NumberFloatType, \
2627 template<typename> class AllocatorType, \
2628 template<typename, typename = void> class JSONSerializer, \
2630 class CustomBaseClass>
2632#define NLOHMANN_BASIC_JSON_TPL \
2633 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2634 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2635 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2639#define NLOHMANN_JSON_EXPAND( x ) x
2640#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
2641#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2642 NLOHMANN_JSON_PASTE64, \
2643 NLOHMANN_JSON_PASTE63, \
2644 NLOHMANN_JSON_PASTE62, \
2645 NLOHMANN_JSON_PASTE61, \
2646 NLOHMANN_JSON_PASTE60, \
2647 NLOHMANN_JSON_PASTE59, \
2648 NLOHMANN_JSON_PASTE58, \
2649 NLOHMANN_JSON_PASTE57, \
2650 NLOHMANN_JSON_PASTE56, \
2651 NLOHMANN_JSON_PASTE55, \
2652 NLOHMANN_JSON_PASTE54, \
2653 NLOHMANN_JSON_PASTE53, \
2654 NLOHMANN_JSON_PASTE52, \
2655 NLOHMANN_JSON_PASTE51, \
2656 NLOHMANN_JSON_PASTE50, \
2657 NLOHMANN_JSON_PASTE49, \
2658 NLOHMANN_JSON_PASTE48, \
2659 NLOHMANN_JSON_PASTE47, \
2660 NLOHMANN_JSON_PASTE46, \
2661 NLOHMANN_JSON_PASTE45, \
2662 NLOHMANN_JSON_PASTE44, \
2663 NLOHMANN_JSON_PASTE43, \
2664 NLOHMANN_JSON_PASTE42, \
2665 NLOHMANN_JSON_PASTE41, \
2666 NLOHMANN_JSON_PASTE40, \
2667 NLOHMANN_JSON_PASTE39, \
2668 NLOHMANN_JSON_PASTE38, \
2669 NLOHMANN_JSON_PASTE37, \
2670 NLOHMANN_JSON_PASTE36, \
2671 NLOHMANN_JSON_PASTE35, \
2672 NLOHMANN_JSON_PASTE34, \
2673 NLOHMANN_JSON_PASTE33, \
2674 NLOHMANN_JSON_PASTE32, \
2675 NLOHMANN_JSON_PASTE31, \
2676 NLOHMANN_JSON_PASTE30, \
2677 NLOHMANN_JSON_PASTE29, \
2678 NLOHMANN_JSON_PASTE28, \
2679 NLOHMANN_JSON_PASTE27, \
2680 NLOHMANN_JSON_PASTE26, \
2681 NLOHMANN_JSON_PASTE25, \
2682 NLOHMANN_JSON_PASTE24, \
2683 NLOHMANN_JSON_PASTE23, \
2684 NLOHMANN_JSON_PASTE22, \
2685 NLOHMANN_JSON_PASTE21, \
2686 NLOHMANN_JSON_PASTE20, \
2687 NLOHMANN_JSON_PASTE19, \
2688 NLOHMANN_JSON_PASTE18, \
2689 NLOHMANN_JSON_PASTE17, \
2690 NLOHMANN_JSON_PASTE16, \
2691 NLOHMANN_JSON_PASTE15, \
2692 NLOHMANN_JSON_PASTE14, \
2693 NLOHMANN_JSON_PASTE13, \
2694 NLOHMANN_JSON_PASTE12, \
2695 NLOHMANN_JSON_PASTE11, \
2696 NLOHMANN_JSON_PASTE10, \
2697 NLOHMANN_JSON_PASTE9, \
2698 NLOHMANN_JSON_PASTE8, \
2699 NLOHMANN_JSON_PASTE7, \
2700 NLOHMANN_JSON_PASTE6, \
2701 NLOHMANN_JSON_PASTE5, \
2702 NLOHMANN_JSON_PASTE4, \
2703 NLOHMANN_JSON_PASTE3, \
2704 NLOHMANN_JSON_PASTE2, \
2705 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2706#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2707#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2708#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2709#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2710#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2711#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)
2712#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)
2713#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)
2714#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)
2715#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)
2716#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)
2717#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)
2718#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)
2719#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)
2720#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)
2721#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)
2722#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)
2723#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)
2724#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)
2725#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)
2726#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)
2727#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)
2728#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)
2729#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)
2730#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)
2731#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)
2732#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)
2733#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)
2734#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)
2735#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)
2736#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)
2737#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)
2738#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)
2739#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)
2740#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)
2741#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)
2742#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)
2743#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)
2744#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)
2745#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)
2746#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)
2747#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)
2748#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)
2749#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)
2750#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)
2751#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)
2752#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)
2753#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)
2754#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)
2755#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)
2756#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)
2757#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)
2758#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)
2759#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)
2760#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)
2761#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)
2762#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)
2763#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)
2764#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)
2765#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)
2766#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)
2767#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)
2768#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)
2770#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2771#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2772#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;
2780#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2781 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2782 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2783 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2784 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2792#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2793 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2794 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2795 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2796 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__)) }
2804#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2805 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2806 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2814#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2815 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2816 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2817 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2818 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2826#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2827 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2828 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2829 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2830 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__)) }
2838#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2839 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2840 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2848#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2849 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2850 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__)) } \
2851 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2852 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__)) }
2860#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2861 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2862 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__)) } \
2863 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2864 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__)) }
2872#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2873 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2874 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__)) }
2882#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2883 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2884 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__)) } \
2885 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2886 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__)) }
2894#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2895 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2896 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__)) } \
2897 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2898 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__)) }
2906#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2907 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2908 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__)) }
2916#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2917 namespace detail { \
2918 using std::std_name; \
2920 template<typename... T> \
2921 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2924 namespace detail2 { \
2925 struct std_name##_tag \
2929 template<typename... T> \
2930 std_name##_tag std_name(T&&...); \
2932 template<typename... T> \
2933 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2935 template<typename... T> \
2936 struct would_call_std_##std_name \
2938 static constexpr auto const value = ::nlohmann::detail:: \
2939 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2943 template<typename... T> \
2944 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2948#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2949 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2952#if JSON_USE_IMPLICIT_CONVERSIONS
2953 #define JSON_EXPLICIT
2955 #define JSON_EXPLICIT explicit
2958#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2959 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2962#ifndef JSON_USE_GLOBAL_UDLS
2963 #define JSON_USE_GLOBAL_UDLS 1
2966#if JSON_HAS_THREE_WAY_COMPARISON
3029#if JSON_HAS_THREE_WAY_COMPARISON
3030 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
3035 static constexpr std::array<std::uint8_t, 9> order = {{
3042 const auto l_index =
static_cast<std::size_t
>(lhs);
3043 const auto r_index =
static_cast<std::size_t
>(rhs);
3044#if JSON_HAS_THREE_WAY_COMPARISON
3045 if (l_index < order.size() && r_index < order.size())
3047 return order[l_index] <=> order[r_index];
3049 return std::partial_ordering::unordered;
3051 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3059#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
3062 return std::is_lt(lhs <=> rhs);
3100template<
typename StringType>
3102 const StringType& t)
3105 for (
auto pos = s.find(f);
3106 pos != StringType::npos;
3107 s.replace(pos, f.size(), t),
3108 pos = s.find(f, pos + t.size()))
3119template<
typename StringType>
3134template<
typename StringType>
3175 constexpr operator size_t()
const
3200#include <type_traits>
3211using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3213#ifdef JSON_HAS_CPP_14
3216using std::enable_if_t;
3217using std::index_sequence;
3218using std::make_index_sequence;
3219using std::index_sequence_for;
3224template<
bool B,
typename T =
void>
3251template <
typename T, T... Ints>
3255 static constexpr std::size_t
size() noexcept
3257 return sizeof...(Ints);
3266template <
size_t... Ints>
3269namespace utility_internal
3272template <
typename Seq,
size_t SeqSize,
size_t Rem>
3276template <
typename T, T... Ints,
size_t SeqSize>
3282template <
typename T, T... Ints,
size_t SeqSize>
3290template <
typename T,
size_t N>
3297template <
typename T>
3312template <
typename T, T N>
3328template <
typename... Ts>
3346#ifndef JSON_HAS_CPP_17
3347 template<
typename T>
3351template<
typename T,
typename... Args>
3352constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3354 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3374#include <type_traits>
3376#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3403template<
typename It,
typename =
void>
3406template<
typename It>
3410 typename It::reference, typename It::iterator_category >>
3421template<
typename T,
typename =
void>
3500#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3501 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3526 template<
typename T =
void,
typename SFINAE =
void>
3531 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3533 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3534 class StringType = std::string,
class BooleanType = bool,
3535 class NumberIntegerType = std::int64_t,
3536 class NumberUnsignedType = std::uint64_t,
3537 class NumberFloatType = double,
3538 template<
typename U>
class AllocatorType = std::allocator,
3539 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3541 class BinaryType = std::vector<std::uint8_t>,
3542 class CustomBaseClass =
void>
3547 template<
typename RefStringType>
3558 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3603template<
typename BasicJsonContext>
3605 std::integral_constant < bool,
3606 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3607 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3648template<
typename T,
typename... Args>
3651template<
typename T,
typename... Args>
3654template<
typename T,
typename U>
3658template<
typename BasicJsonType,
typename T,
typename =
void>
3665template <
typename BasicJsonType,
typename T>
3671template<
typename BasicJsonType,
typename T>
3674 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3678 const BasicJsonType&, T&>
::value;
3683template<
typename BasicJsonType,
typename T,
typename =
void>
3686template<
typename BasicJsonType,
typename T>
3689 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3698template<
typename BasicJsonType,
typename T,
typename =
void>
3701template<
typename BasicJsonType,
typename T>
3704 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3715struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3718template<
typename BasicJsonType>
3723 using type =
typename std::conditional < has_key_compare<object_t>::value,
3727template<
typename BasicJsonType>
3759 return static_cast<int_type>(std::char_traits<char>::eof());
3783 return static_cast<int_type>(std::char_traits<char>::eof());
3787#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3789struct char_traits<
std::byte> : std::char_traits<char>
3791 using char_type = std::byte;
3792 using int_type = uint64_t;
3794 static int_type to_int_type(char_type c)
noexcept
3796 return static_cast<int_type
>(std::to_integer<unsigned char>(c));
3799 static char_type to_char_type(int_type i)
noexcept
3801 return std::byte(
static_cast<unsigned char>(i));
3804 static constexpr int_type eof() noexcept
3806 return static_cast<int_type
>(std::char_traits<char>::eof());
3818template<
class B,
class... Bn>
3820: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3823template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3828template <
typename T>
3831template <
typename T1,
typename T2>
3833 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3835template <
typename T1,
typename T2>
3837 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3839template <
typename... Ts>
3841 :
conjunction<is_default_constructible<Ts>...> {};
3843template <
typename... Ts>
3845 :
conjunction<is_default_constructible<Ts>...> {};
3847template <
typename T,
typename... Args>
3850template <
typename T1,
typename T2>
3853template <
typename T1,
typename T2>
3856template <
typename... Ts>
3859template <
typename... Ts>
3862template<
typename T,
typename =
void>
3884 using t_ref =
typename std::add_lvalue_reference<T>::type;
3892 static constexpr auto is_iterator_begin =
3896 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3909template<
typename T,
typename =
void>
3915template<
typename BasicJsonType,
typename CompatibleObjectType,
3919template<
typename BasicJsonType,
typename CompatibleObjectType>
3921 BasicJsonType, CompatibleObjectType,
3930 typename CompatibleObjectType::key_type>
::value &&
3932 typename CompatibleObjectType::mapped_type>
::value;
3935template<
typename BasicJsonType,
typename CompatibleObjectType>
3939template<
typename BasicJsonType,
typename ConstructibleObjectType,
3943template<
typename BasicJsonType,
typename ConstructibleObjectType>
3945 BasicJsonType, ConstructibleObjectType,
3953 (std::is_move_assignable<ConstructibleObjectType>::value ||
3954 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3956 typename object_t::key_type>
::value &&
3958 typename object_t::mapped_type,
3959 typename ConstructibleObjectType::mapped_type >
::value)) ||
3961 typename ConstructibleObjectType::mapped_type>
::value ||
3964 typename ConstructibleObjectType::mapped_type >
::value);
3967template<
typename BasicJsonType,
typename ConstructibleObjectType>
3970 ConstructibleObjectType> {};
3972template<
typename BasicJsonType,
typename CompatibleStringType>
3979template<
typename BasicJsonType,
typename ConstructibleStringType>
3983#ifdef __INTEL_COMPILER
3984 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3996template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3999template<
typename BasicJsonType,
typename CompatibleArrayType>
4001 BasicJsonType, CompatibleArrayType,
4007 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
4014template<
typename BasicJsonType,
typename CompatibleArrayType>
4018template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
4021template<
typename BasicJsonType,
typename ConstructibleArrayType>
4023 BasicJsonType, ConstructibleArrayType,
4025 typename BasicJsonType::value_type>
::value >>
4026 : std::true_type {};
4028template<
typename BasicJsonType,
typename ConstructibleArrayType>
4030 BasicJsonType, ConstructibleArrayType,
4032 typename BasicJsonType::value_type>
::value&&
4035(std::is_move_assignable<ConstructibleArrayType>::value ||
4036 std::is_copy_assignable<ConstructibleArrayType>::value)&&
4042!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
4044detected_t<range_value_t, ConstructibleArrayType >>
::value >>
4050 typename BasicJsonType::array_t::value_type>
::value ||
4058template<
typename BasicJsonType,
typename ConstructibleArrayType>
4062template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
4066template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4068 RealIntegerType, CompatibleNumberIntegerType,
4070 std::is_integral<CompatibleNumberIntegerType>
::value&&
4071 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
4079 CompatibleNumberIntegerType>
::value &&
4080 CompatibleLimits::is_integer &&
4081 RealLimits::is_signed == CompatibleLimits::is_signed;
4084template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4087 CompatibleNumberIntegerType> {};
4089template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
4092template<
typename BasicJsonType,
typename CompatibleType>
4094 BasicJsonType, CompatibleType,
4101template<
typename BasicJsonType,
typename CompatibleType>
4105template<
typename T1,
typename T2>
4108template<
typename T1,
typename... Args>
4111template<
typename BasicJsonType,
typename T>
4114template<
typename BasicJsonType>
4117template<
typename BasicJsonType>
4122template<
template <
typename...>
class Primary,
typename T>
4125template<
template <
typename...>
class Primary,
typename... Args>
4132template<
typename Compare,
typename A,
typename B,
typename =
void>
4135template<
typename Compare,
typename A,
typename B>
4137decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4138decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4139>> : std::true_type {};
4146template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4150 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4152 && (!RequireTransparentComparator
4153 || is_detected <detect_is_transparent, Comparator>::value)
4156 std::false_type >::type;
4164template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4168 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4169 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4172 std::false_type >::type;
4174template<
typename ObjectType,
typename KeyType>
4178template<
typename BasicJsonType,
typename KeyType>
4182 typename BasicJsonType::object_t, KeyType >
::value,
4184 std::false_type >::type;
4188template <
typename T>
4198 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4205template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4208 return static_cast<T
>(
value);
4211template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4217template<
typename... Types>
4220template<
typename... Types>
4223template<
typename... Types>
4227template<
typename... Types>
4231template<
typename OfType,
typename T>
4233 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4236template<
typename OfType,
typename T,
4237 bool OfTypeSigned = std::is_signed<OfType>::value,
4238 bool TSigned = std::is_signed<T>::value>
4241template<
typename OfType,
typename T>
4246 using CommonType =
typename std::common_type<OfType, T>::type;
4247 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4251template<
typename OfType,
typename T>
4256 using CommonType =
typename std::common_type<OfType, T>::type;
4257 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4261template<
typename OfType,
typename T>
4266 using CommonType =
typename std::common_type<OfType, T>::type;
4267 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4271template<
typename OfType,
typename T>
4276 using CommonType =
typename std::common_type<OfType, T>::type;
4277 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4278 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4282template<
typename OfType,
typename T,
4283 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4287template<
typename OfType,
typename T>
4296template<
typename OfType,
typename T>
4305template<
typename OfType,
typename T>
4324 using TUnExt =
typename std::remove_extent<T>::type;
4325 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4326 using TUnPtr =
typename std::remove_pointer<T>::type;
4327 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4329 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4330 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4395template<
typename... Args>
4396inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4398template<
typename StringType,
typename... Args>
4399inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4401template<
typename... Args>
4407template<
typename... Args>
4414template<
typename StringType,
typename... Args>
4420template<
typename OutStringType>
4424template<
typename StringType,
typename Arg>
4427template<
typename StringType,
typename Arg>
4430template<
typename StringType,
typename Arg>
4433template<
typename StringType,
typename Arg>
4436template<
typename StringType,
typename Arg>
4437using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4439template<
typename StringType,
typename Arg>
4442template<
typename StringType,
typename Arg>
4443using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4445template<
typename StringType,
typename Arg>
4448template <
typename OutStringType,
typename Arg,
typename... Args,
4449 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4451inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4453template <
typename OutStringType,
typename Arg,
typename... Args,
4454 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4457inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4459template <
typename OutStringType,
typename Arg,
typename... Args,
4460 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4464inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4466template<
typename OutStringType,
typename Arg,
typename... Args,
4468inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4470 out.append(std::forward<Arg>(arg));
4474template <
typename OutStringType,
typename Arg,
typename... Args,
4475 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4476 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4477inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4479 out += std::forward<Arg>(arg);
4483template <
typename OutStringType,
typename Arg,
typename... Args,
4484 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4485 && !detect_string_can_append_op<OutStringType, Arg>::value
4486 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4487inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4489 out.append(arg.begin(), arg.end());
4493template <
typename OutStringType,
typename Arg,
typename... Args,
4494 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4495 && !detect_string_can_append_op<OutStringType, Arg>::value
4496 && !detect_string_can_append_iter<OutStringType, Arg>::value
4497 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4498inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4500 out.append(arg.data(), arg.size());
4504template<
typename OutStringType = std::string,
typename... Args>
4524#if defined(__clang__)
4525 #pragma clang diagnostic push
4526 #pragma clang diagnostic ignored "-Wweak-vtables"
4543 const char*
what() const noexcept
override
4553 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4555 static std::string
name(
const std::string& ename,
int id_)
4557 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4565 template<
typename BasicJsonType>
4569 std::vector<std::string> tokens;
4570 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4572 switch (current->m_parent->type())
4576 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4578 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4580 tokens.emplace_back(std::to_string(i));
4589 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4591 if (&element.second == current)
4593 tokens.emplace_back(element.first.c_str());
4618 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4619 [](
const std::string & a,
const std::string & b)
4621 return concat(a,
'/', detail::escape(b));
4624 return concat(
'(', str,
") ", get_byte_positions(leaf_element));
4626 return get_byte_positions(leaf_element);
4632 std::runtime_error m;
4633#if JSON_DIAGNOSTIC_POSITIONS
4634 template<
typename BasicJsonType>
4635 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4637 if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
4639 return concat(
"(bytes ", std::to_string(leaf_element->start_pos()),
"-", std::to_string(leaf_element->end_pos()),
") ");
4644 template<
typename BasicJsonType>
4645 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4647 static_cast<void>(leaf_element);
4667 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4675 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4676 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4679 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4681 return {id_, byte_, w.c_str()};
4696 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4699 static std::string position_string(
const position_t& pos)
4711 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4715 return {id_, w.c_str()};
4729 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4733 return {id_, w.c_str()};
4746 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4750 return {id_, w.c_str()};
4763 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4767 return {id_, w.c_str()};
4778#if defined(__clang__)
4779 #pragma clang diagnostic pop
4824#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4825#include <experimental/filesystem>
4829namespace std_fs = std::experimental::filesystem;
4832#elif JSON_HAS_FILESYSTEM
4833#include <filesystem>
4837namespace std_fs = std::filesystem;
4850#ifdef JSON_HAS_CPP_17
4854#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4855 #include <string_view>
4862template<
typename BasicJsonType>
4863inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t&
n)
4872#ifdef JSON_HAS_CPP_17
4873template<
typename BasicJsonType,
typename T>
4874void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4882 opt.emplace(j.template
get<T>());
4888template <
typename BasicJsonType,
typename ArithmeticType,
4889 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4890 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4894 switch (
static_cast<value_t>(j))
4898 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4903 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4908 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4924template<
typename BasicJsonType>
4925inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4931 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4934template<
typename BasicJsonType>
4935inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4941 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4945 typename BasicJsonType,
typename StringType,
4947 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4948 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4949 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4950 && !is_json_ref<StringType>::value,
int > = 0 >
4958 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4961template<
typename BasicJsonType>
4962inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4967template<
typename BasicJsonType>
4968inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4973template<
typename BasicJsonType>
4974inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4979#if !JSON_DISABLE_ENUM_SERIALIZATION
4980template<
typename BasicJsonType,
typename EnumType,
4981 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4984 typename std::underlying_type<EnumType>::type val;
4986 e =
static_cast<EnumType
>(val);
4991template<
typename BasicJsonType,
typename T,
typename Allocator,
4992 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4993inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
5000 std::transform(j.rbegin(), j.rend(),
5001 std::front_inserter(l), [](
const BasicJsonType & i)
5003 return i.template get<T>();
5008template<
typename BasicJsonType,
typename T,
5009 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
5010inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
5017 std::transform(j.begin(), j.end(), std::begin(l),
5018 [](
const BasicJsonType & elem)
5020 return elem.template get<T>();
5024template<
typename BasicJsonType,
typename T, std::
size_t N>
5026->
decltype(j.template
get<T>(), void())
5028 for (std::size_t i = 0; i < N; ++i)
5030 arr[i] = j.at(i).template
get<T>();
5034template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2>
5036->
decltype(j.template
get<T>(), void())
5038 for (std::size_t i1 = 0; i1 < N1; ++i1)
5040 for (std::size_t i2 = 0; i2 < N2; ++i2)
5042 arr[i1][i2] = j.at(i1).at(i2).template
get<T>();
5047template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3>
5049->
decltype(j.template
get<T>(), void())
5051 for (std::size_t i1 = 0; i1 < N1; ++i1)
5053 for (std::size_t i2 = 0; i2 < N2; ++i2)
5055 for (std::size_t i3 = 0; i3 < N3; ++i3)
5057 arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template
get<T>();
5063template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3, std::
size_t N4>
5064auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3][N4])
5065->
decltype(j.template
get<T>(), void())
5067 for (std::size_t i1 = 0; i1 < N1; ++i1)
5069 for (std::size_t i2 = 0; i2 < N2; ++i2)
5071 for (std::size_t i3 = 0; i3 < N3; ++i3)
5073 for (std::size_t i4 = 0; i4 < N4; ++i4)
5075 arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template
get<T>();
5082template<
typename BasicJsonType>
5085 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
5088template<
typename BasicJsonType,
typename T, std::
size_t N>
5091->
decltype(j.template
get<T>(), void())
5093 for (std::size_t i = 0; i < N; ++i)
5095 arr[i] = j.at(i).template
get<T>();
5099template<
typename BasicJsonType,
typename ConstructibleArrayType,
5101 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5105 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
5111 ConstructibleArrayType
ret;
5112 ret.reserve(j.size());
5113 std::transform(j.begin(), j.end(),
5114 std::inserter(
ret, end(
ret)), [](
const BasicJsonType & i)
5120 arr = std::move(
ret);
5123template<
typename BasicJsonType,
typename ConstructibleArrayType,
5125 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5132 ConstructibleArrayType
ret;
5134 j.begin(), j.end(), std::inserter(
ret, end(
ret)),
5135 [](
const BasicJsonType & i)
5141 arr = std::move(
ret);
5144template <
typename BasicJsonType,
typename ConstructibleArrayType,
5146 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
5147 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
5149 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
5150 !is_basic_json<ConstructibleArrayType>::value,
5152auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
5165template <
typename BasicJsonType,
typename T, std::size_t... Idx >
5169 return { { std::forward<BasicJsonType>(j).at(Idx).template
get<T>()... } };
5172template <
typename BasicJsonType,
typename T, std::
size_t N >
5184template<
typename BasicJsonType>
5185inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
5192 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5195template<
typename BasicJsonType,
typename ConstructibleObjectType,
5196 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5197inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5204 ConstructibleObjectType
ret;
5205 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5206 using value_type =
typename ConstructibleObjectType::value_type;
5208 inner_object->begin(), inner_object->end(),
5209 std::inserter(
ret,
ret.begin()),
5210 [](
typename BasicJsonType::object_t::value_type
const &
p)
5212 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5214 obj = std::move(
ret);
5221template <
typename BasicJsonType,
typename ArithmeticType,
5223 std::is_arithmetic<ArithmeticType>::value&&
5224 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5225 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5226 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5227 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5229inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5231 switch (
static_cast<value_t>(j))
5235 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5240 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5245 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5250 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5265template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5268 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5271template<
typename BasicJsonType>
5277template <
typename BasicJsonType,
class A1,
class A2 >
5280 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
5281 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
5284template<
typename BasicJsonType,
typename A1,
typename A2>
5290template<
typename BasicJsonType,
typename... Args>
5296template<
typename BasicJsonType,
typename... Args>
5302template<
typename BasicJsonType,
typename TupleRelated>
5311 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5314template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5316 typename BasicJsonType::string_t, Key >
::value >>
5317inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5324 for (
const auto&
p : j)
5334template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5336 typename BasicJsonType::string_t, Key >
::value >>
5337inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5344 for (
const auto&
p : j)
5354#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5355template<
typename BasicJsonType>
5356inline void from_json(
const BasicJsonType& j, std_fs::path&
p)
5362 const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5366#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
5367 p = std_fs::path(std::u8string_view(
reinterpret_cast<const char8_t*
>(s.data()), s.size()));
5369 p = std_fs::u8path(s);
5376 template<
typename BasicJsonType,
typename T>
5378 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5379 ->
decltype(
from_json(j, std::forward<T>(val)))
5381 return from_json(j, std::forward<T>(val));
5387#ifndef JSON_HAS_CPP_17
5396#ifndef JSON_HAS_CPP_17
5415#ifdef JSON_HAS_CPP_17
5424#include <type_traits>
5474template<
typename StringType>
5478 using std::to_string;
5482template<
typename StringType>
5500template<
typename IteratorType>
class iteration_proxy_value
5508 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5512 IteratorType anchor{};
5514 std::size_t array_index = 0;
5516 mutable std::size_t array_index_last = 0;
5525 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5527 : anchor(
std::move(it))
5528 , array_index(array_index_)
5535 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5538 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5568 return anchor == o.anchor;
5574 return anchor != o.anchor;
5582 switch (anchor.m_object->type())
5587 if (array_index != array_index_last)
5590 array_index_last = array_index;
5592 return array_index_str;
5597 return anchor.key();
5614 typename IteratorType::reference
value()
const
5616 return anchor.value();
5621template<
typename IteratorType>
class iteration_proxy
5625 typename IteratorType::pointer container =
nullptr;
5632 : container(&cont) {}
5656template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5657auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5664template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5665auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5680#if defined(__clang__)
5682 #pragma clang diagnostic push
5683 #pragma clang diagnostic ignored "-Wmismatched-tags"
5685template<
typename IteratorType>
5686class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5687 :
public std::integral_constant<std::size_t, 2> {};
5689template<std::
size_t N,
typename IteratorType>
5690class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5694 get<N>(std::declval <
5695 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5697#if defined(__clang__)
5698 #pragma clang diagnostic pop
5704 template <
typename IteratorType>
5705 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5737 template<
typename BasicJsonType>
5738 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5740 j.m_data.m_value.destroy(j.m_data.m_type);
5742 j.m_data.m_value = b;
5743 j.assert_invariant();
5750 template<
typename BasicJsonType>
5751 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5753 j.m_data.m_value.destroy(j.m_data.m_type);
5755 j.m_data.m_value = s;
5756 j.assert_invariant();
5759 template<
typename BasicJsonType>
5760 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5762 j.m_data.m_value.destroy(j.m_data.m_type);
5764 j.m_data.m_value = std::move(s);
5765 j.assert_invariant();
5768 template <
typename BasicJsonType,
typename CompatibleStringType,
5769 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5771 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5773 j.m_data.m_value.destroy(j.m_data.m_type);
5775 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5776 j.assert_invariant();
5783 template<
typename BasicJsonType>
5784 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5786 j.m_data.m_value.destroy(j.m_data.m_type);
5788 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5789 j.assert_invariant();
5792 template<
typename BasicJsonType>
5793 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5795 j.m_data.m_value.destroy(j.m_data.m_type);
5797 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5798 j.assert_invariant();
5805 template<
typename BasicJsonType>
5806 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5808 j.m_data.m_value.destroy(j.m_data.m_type);
5810 j.m_data.m_value = val;
5811 j.assert_invariant();
5818 template<
typename BasicJsonType>
5819 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5821 j.m_data.m_value.destroy(j.m_data.m_type);
5823 j.m_data.m_value = val;
5824 j.assert_invariant();
5831 template<
typename BasicJsonType>
5832 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5834 j.m_data.m_value.destroy(j.m_data.m_type);
5836 j.m_data.m_value = val;
5837 j.assert_invariant();
5844 template<
typename BasicJsonType>
5845 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5847 j.m_data.m_value.destroy(j.m_data.m_type);
5849 j.m_data.m_value = arr;
5851 j.assert_invariant();
5854 template<
typename BasicJsonType>
5855 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5857 j.m_data.m_value.destroy(j.m_data.m_type);
5859 j.m_data.m_value = std::move(arr);
5861 j.assert_invariant();
5864 template <
typename BasicJsonType,
typename CompatibleArrayType,
5865 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5867 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5872 j.m_data.m_value.destroy(j.m_data.m_type);
5874 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5876 j.assert_invariant();
5879 template<
typename BasicJsonType>
5880 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5882 j.m_data.m_value.destroy(j.m_data.m_type);
5885 j.m_data.m_value.array->reserve(arr.size());
5886 for (
const bool x : arr)
5888 j.m_data.m_value.array->push_back(x);
5889 j.set_parent(j.m_data.m_value.array->back());
5891 j.assert_invariant();
5894 template<
typename BasicJsonType,
typename T,
5896 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5898 j.m_data.m_value.destroy(j.m_data.m_type);
5901 j.m_data.m_value.array->resize(arr.size());
5904 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5907 j.assert_invariant();
5914 template<
typename BasicJsonType>
5915 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5917 j.m_data.m_value.destroy(j.m_data.m_type);
5919 j.m_data.m_value = obj;
5921 j.assert_invariant();
5924 template<
typename BasicJsonType>
5925 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5927 j.m_data.m_value.destroy(j.m_data.m_type);
5929 j.m_data.m_value = std::move(obj);
5931 j.assert_invariant();
5934 template <
typename BasicJsonType,
typename CompatibleObjectType,
5935 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5936 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5941 j.m_data.m_value.destroy(j.m_data.m_type);
5943 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5945 j.assert_invariant();
5953#ifdef JSON_HAS_CPP_17
5954template<
typename BasicJsonType,
typename T,
5955 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
5956void to_json(BasicJsonType& j,
const std::optional<T>& opt)
noexcept
5958 if (opt.has_value())
5969template<
typename BasicJsonType,
typename T,
5970 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5971inline void to_json(BasicJsonType& j, T b)
noexcept
5976template <
typename BasicJsonType,
typename BoolRef,
5978 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5979 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5980 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5981 && !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>,
5982 typename BasicJsonType::boolean_t >
::value))
5983 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5984inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5989template<
typename BasicJsonType,
typename CompatibleString,
5990 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5991inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5996template<
typename BasicJsonType>
5997inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
6002template<
typename BasicJsonType,
typename FloatType,
6003 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
6004inline void to_json(BasicJsonType& j, FloatType val)
noexcept
6009template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
6010 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
6011inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
6016template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
6017 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
6018inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
6023#if !JSON_DISABLE_ENUM_SERIALIZATION
6024template<
typename BasicJsonType,
typename EnumType,
6025 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
6026inline void to_json(BasicJsonType& j, EnumType e)
noexcept
6028 using underlying_type =
typename std::underlying_type<EnumType>::type;
6034template<
typename BasicJsonType>
6035inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
6040template <
typename BasicJsonType,
typename CompatibleArrayType,
6041 enable_if_t < is_compatible_array_type<BasicJsonType,
6043 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
6045 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
6046 !is_basic_json<CompatibleArrayType>::value,
6048inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
6053template<
typename BasicJsonType>
6054inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
6059template<
typename BasicJsonType,
typename T,
6060 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
6061inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
6066template<
typename BasicJsonType>
6067inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
6072template <
typename BasicJsonType,
typename CompatibleObjectType,
6073 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
6074inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
6079template<
typename BasicJsonType>
6080inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6086 typename BasicJsonType,
typename T, std::size_t N,
6087 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
6090inline void to_json(BasicJsonType& j,
const T(&arr)[N])
6095template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
6096inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>&
p)
6098 j = {
p.first,
p.second };
6102template<
typename BasicJsonType,
typename T,
6106 j = { {b.key(), b.value()} };
6109template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
6112 j = { std::get<Idx>(t)... };
6115template<
typename BasicJsonType,
typename Tuple>
6118 using array_t =
typename BasicJsonType::array_t;
6122template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
6123inline void to_json(BasicJsonType& j,
const T& t)
6128#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
6129#if defined(__cpp_lib_char8_t)
6130template<
typename BasicJsonType,
typename Tr,
typename Allocator>
6131inline void to_json(BasicJsonType& j,
const std::basic_string<char8_t, Tr, Allocator>& s)
6133 using OtherAllocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<char>;
6134 j = std::basic_string<char, std::char_traits<char>, OtherAllocator>(s.begin(), s.end(), s.get_allocator());
6138template<
typename BasicJsonType>
6139inline void to_json(BasicJsonType& j,
const std_fs::path&
p)
6149 template<
typename BasicJsonType,
typename T>
6150 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
6151 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
6153 return to_json(j, std::forward<T>(val));
6158#ifndef JSON_HAS_CPP_17
6167#ifndef JSON_HAS_CPP_17
6179template<
typename ValueType,
typename>
6184 template<
typename BasicJsonType,
typename TargetType = ValueType>
6185 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
6186 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
6187 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
6189 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
6194 template<
typename BasicJsonType,
typename TargetType = ValueType>
6204 template<
typename BasicJsonType,
typename TargetType = ValueType>
6205 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
6206 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
6207 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
6209 ::nlohmann::to_json(j, std::forward<TargetType>(val));
6237template<
typename BinaryType>
6262 , m_subtype(subtype_)
6263 , m_has_subtype(true)
6269 , m_subtype(subtype_)
6270 , m_has_subtype(true)
6275 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
6276 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
6281 return !(rhs == *
this);
6288 m_subtype = subtype_;
6289 m_has_subtype =
true;
6296 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
6303 return m_has_subtype;
6311 m_has_subtype =
false;
6316 bool m_has_subtype =
false;
6340#include <functional>
6352inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6354 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6369template<
typename BasicJsonType>
6370std::size_t
hash(
const BasicJsonType& j)
6372 using string_t =
typename BasicJsonType::string_t;
6373 using number_integer_t =
typename BasicJsonType::number_integer_t;
6374 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6375 using number_float_t =
typename BasicJsonType::number_float_t;
6377 const auto type =
static_cast<std::size_t
>(j.type());
6380 case BasicJsonType::value_t::null:
6381 case BasicJsonType::value_t::discarded:
6386 case BasicJsonType::value_t::object:
6388 auto seed =
combine(type, j.size());
6389 for (
const auto& element : j.items())
6391 const auto h = std::hash<string_t> {}(element.key());
6398 case BasicJsonType::value_t::array:
6400 auto seed =
combine(type, j.size());
6401 for (
const auto& element : j)
6408 case BasicJsonType::value_t::string:
6410 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6414 case BasicJsonType::value_t::boolean:
6416 const auto h = std::hash<bool> {}(j.template
get<bool>());
6420 case BasicJsonType::value_t::number_integer:
6426 case BasicJsonType::value_t::number_unsigned:
6432 case BasicJsonType::value_t::number_float:
6438 case BasicJsonType::value_t::binary:
6440 auto seed =
combine(type, j.get_binary().size());
6441 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6443 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6444 for (
const auto byte : j.get_binary())
6446 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6483#ifdef __cpp_lib_byteswap
6507#include <type_traits>
6561 return std::fgetc(m_file);
6568 return fread(dest, 1,
sizeof(T) * count, m_file);
6596 is->clear(is->rdstate() & std::ios::eofbit);
6601 : is(&i), sb(i.rdbuf())
6610 : is(rhs.is), sb(rhs.sb)
6621 auto res = sb->sbumpc();
6625 is->clear(is->rdstate() | std::ios::eofbit);
6633 auto res =
static_cast<std::size_t
>(sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(count *
sizeof(T))));
6636 is->clear(is->rdstate() | std::ios::eofbit);
6643 std::istream* is =
nullptr;
6644 std::streambuf* sb =
nullptr;
6650template<
typename IteratorType>
6654 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6657 : current(
std::move(first)), end(
std::move(last))
6665 std::advance(current, 1);
6676 auto* ptr =
reinterpret_cast<char*
>(dest);
6677 for (std::size_t read_index = 0; read_index < count *
sizeof(T); ++read_index)
6681 ptr[read_index] =
static_cast<char>(*current);
6682 std::advance(current, 1);
6689 return count *
sizeof(T);
6693 IteratorType current;
6696 template<
typename BaseInputAdapter,
size_t T>
6701 return current == end;
6705template<
typename BaseInputAdapter,
size_t T>
6708template<
typename BaseInputAdapter>
6713 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6714 size_t& utf8_bytes_index,
6715 size_t& utf8_bytes_filled)
6717 utf8_bytes_index = 0;
6721 utf8_bytes[0] = std::char_traits<char>::eof();
6722 utf8_bytes_filled = 1;
6727 const auto wc = input.get_character();
6732 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6733 utf8_bytes_filled = 1;
6735 else if (wc <= 0x7FF)
6737 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6738 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6739 utf8_bytes_filled = 2;
6741 else if (wc <= 0xFFFF)
6743 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6744 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6745 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6746 utf8_bytes_filled = 3;
6748 else if (wc <= 0x10FFFF)
6750 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6751 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6752 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6753 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6754 utf8_bytes_filled = 4;
6759 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6760 utf8_bytes_filled = 1;
6766template<
typename BaseInputAdapter>
6771 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6772 size_t& utf8_bytes_index,
6773 size_t& utf8_bytes_filled)
6775 utf8_bytes_index = 0;
6779 utf8_bytes[0] = std::char_traits<char>::eof();
6780 utf8_bytes_filled = 1;
6785 const auto wc = input.get_character();
6790 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6791 utf8_bytes_filled = 1;
6793 else if (wc <= 0x7FF)
6795 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6796 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6797 utf8_bytes_filled = 2;
6799 else if (0xD800 > wc || wc >= 0xE000)
6801 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6802 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6803 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6804 utf8_bytes_filled = 3;
6810 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6811 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6812 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6813 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6814 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6815 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6816 utf8_bytes_filled = 4;
6820 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6821 utf8_bytes_filled = 1;
6829template<
typename BaseInputAdapter,
typename W
ideCharType>
6836 : base_adapter(base) {}
6841 if (utf8_bytes_index == utf8_bytes_filled)
6843 fill_buffer<sizeof(WideCharType)>();
6851 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6852 return utf8_bytes[utf8_bytes_index++];
6863 BaseInputAdapter base_adapter;
6872 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6875 std::size_t utf8_bytes_index = 0;
6877 std::size_t utf8_bytes_filled = 0;
6880template<
typename IteratorType,
typename Enable =
void>
6884 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6889 return adapter_type(std::move(first), std::move(last));
6903template<
typename IteratorType>
6907 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6918template<
typename IteratorType>
6922 return factory_type::create(first, last);
6929namespace container_input_adapter_factory_impl
6935template<
typename ContainerType,
typename Enable =
void>
6938template<
typename ContainerType>
6940 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6952template<
typename ContainerType>
6965 if (file ==
nullptr)
6967 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));
6986template <
typename CharT,
6987 typename std::enable_if <
6988 std::is_pointer<CharT>::value&&
6989 !std::is_array<CharT>::value&&
6990 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6991 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6997 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));
6999 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
7000 const auto* ptr =
reinterpret_cast<const char*
>(b);
7004template<
typename T, std::
size_t N>
7016 template <
typename CharT,
7017 typename std::enable_if <
7018 std::is_pointer<CharT>::value&&
7019 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
7020 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
7023 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
7025 template<
class IteratorType,
7026 typename std::enable_if<
7027 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
7034 return std::move(ia);
7057#include <type_traits>
7079#include <initializer_list>
7101template<
typename BasicJsonType>
7135 return "<uninitialized>";
7137 return "true literal";
7139 return "false literal";
7141 return "null literal";
7143 return "string literal";
7147 return "number literal";
7161 return "<parse error>";
7163 return "end of input";
7165 return "'[', '{', or a literal";
7168 return "unknown token";
7178template<
typename BasicJsonType,
typename InputAdapterType>
7181 using number_integer_t =
typename BasicJsonType::number_integer_t;
7182 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7183 using number_float_t =
typename BasicJsonType::number_float_t;
7184 using string_t =
typename BasicJsonType::string_t;
7185 using char_type =
typename InputAdapterType::char_type;
7191 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7192 : ia(
std::move(adapter))
7193 , ignore_comments(ignore_comments_)
7194 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7211 static char get_decimal_point() noexcept
7213 const auto* loc = localeconv();
7215 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7243 const auto factors = { 12u, 8u, 4u, 0u };
7244 for (
const auto factor : factors)
7248 if (current >=
'0' && current <=
'9')
7250 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7252 else if (current >=
'A' && current <=
'F')
7254 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7256 else if (current >=
'a' && current <=
'f')
7258 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7266 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7285 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7287 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7290 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7299 error_message =
"invalid string: ill-formed UTF-8 byte";
7336 case char_traits<char_type>::eof():
7338 error_message =
"invalid string: missing closing quote";
7339 return token_type::parse_error;
7345 return token_type::value_string;
7389 const int codepoint1 = get_codepoint();
7390 int codepoint = codepoint1;
7394 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7395 return token_type::parse_error;
7399 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7404 const int codepoint2 = get_codepoint();
7408 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7409 return token_type::parse_error;
7416 codepoint =
static_cast<int>(
7418 (
static_cast<unsigned int>(codepoint1) << 10u)
7420 +
static_cast<unsigned int>(codepoint2)
7428 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7429 return token_type::parse_error;
7434 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7435 return token_type::parse_error;
7442 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7443 return token_type::parse_error;
7448 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7451 if (codepoint < 0x80)
7454 add(
static_cast<char_int_type
>(codepoint));
7456 else if (codepoint <= 0x7FF)
7459 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7460 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7462 else if (codepoint <= 0xFFFF)
7465 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7466 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7467 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7472 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7473 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7474 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7475 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7483 error_message =
"invalid string: forbidden character after backslash";
7484 return token_type::parse_error;
7493 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7494 return token_type::parse_error;
7499 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7500 return token_type::parse_error;
7505 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7506 return token_type::parse_error;
7511 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7512 return token_type::parse_error;
7517 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7518 return token_type::parse_error;
7523 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7524 return token_type::parse_error;
7529 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7530 return token_type::parse_error;
7535 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7536 return token_type::parse_error;
7541 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7542 return token_type::parse_error;
7547 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7548 return token_type::parse_error;
7553 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7554 return token_type::parse_error;
7559 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7560 return token_type::parse_error;
7565 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7566 return token_type::parse_error;
7571 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7572 return token_type::parse_error;
7577 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7578 return token_type::parse_error;
7583 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7584 return token_type::parse_error;
7589 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7590 return token_type::parse_error;
7595 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7596 return token_type::parse_error;
7601 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7602 return token_type::parse_error;
7607 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7608 return token_type::parse_error;
7613 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7614 return token_type::parse_error;
7619 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7620 return token_type::parse_error;
7625 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7626 return token_type::parse_error;
7631 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7632 return token_type::parse_error;
7637 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7638 return token_type::parse_error;
7643 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7644 return token_type::parse_error;
7649 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7650 return token_type::parse_error;
7655 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7656 return token_type::parse_error;
7661 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7662 return token_type::parse_error;
7667 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7668 return token_type::parse_error;
7673 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7674 return token_type::parse_error;
7679 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7680 return token_type::parse_error;
7817 return token_type::parse_error;
7827 return token_type::parse_error;
7851 return token_type::parse_error;
7861 return token_type::parse_error;
7871 return token_type::parse_error;
7883 return token_type::parse_error;
7893 return token_type::parse_error;
7901 error_message =
"invalid string: ill-formed UTF-8 byte";
7902 return token_type::parse_error;
7925 case char_traits<char_type>::eof():
7942 case char_traits<char_type>::eof():
7945 error_message =
"invalid comment; missing closing '*/'";
7973 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7980 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7982 f = std::strtof(str, endptr);
7986 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7988 f = std::strtod(str, endptr);
7992 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7994 f = std::strtold(str, endptr);
8037 token_type scan_number()
8044 token_type number_type = token_type::value_unsigned;
8052 goto scan_number_minus;
8058 goto scan_number_zero;
8072 goto scan_number_any1;
8082 number_type = token_type::value_integer;
8088 goto scan_number_zero;
8102 goto scan_number_any1;
8107 error_message =
"invalid number; expected digit after '-'";
8108 return token_type::parse_error;
8118 add(decimal_point_char);
8119 decimal_point_position = token_buffer.size() - 1;
8120 goto scan_number_decimal1;
8127 goto scan_number_exponent;
8131 goto scan_number_done;
8150 goto scan_number_any1;
8155 add(decimal_point_char);
8156 decimal_point_position = token_buffer.size() - 1;
8157 goto scan_number_decimal1;
8164 goto scan_number_exponent;
8168 goto scan_number_done;
8171scan_number_decimal1:
8173 number_type = token_type::value_float;
8188 goto scan_number_decimal2;
8193 error_message =
"invalid number; expected digit after '.'";
8194 return token_type::parse_error;
8198scan_number_decimal2:
8214 goto scan_number_decimal2;
8221 goto scan_number_exponent;
8225 goto scan_number_done;
8228scan_number_exponent:
8230 number_type = token_type::value_float;
8237 goto scan_number_sign;
8252 goto scan_number_any2;
8258 "invalid number; expected '+', '-', or digit after exponent";
8259 return token_type::parse_error;
8279 goto scan_number_any2;
8284 error_message =
"invalid number; expected digit after exponent sign";
8285 return token_type::parse_error;
8305 goto scan_number_any2;
8309 goto scan_number_done;
8317 char* endptr =
nullptr;
8321 if (number_type == token_type::value_unsigned)
8323 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8326 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8328 if (errno != ERANGE)
8330 value_unsigned =
static_cast<number_unsigned_t
>(x);
8331 if (value_unsigned == x)
8333 return token_type::value_unsigned;
8337 else if (number_type == token_type::value_integer)
8339 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8342 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8344 if (errno != ERANGE)
8346 value_integer =
static_cast<number_integer_t
>(x);
8347 if (value_integer == x)
8349 return token_type::value_integer;
8356 strtof(value_float, token_buffer.data(), &endptr);
8359 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8361 return token_type::value_float;
8370 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8371 token_type return_type)
8373 JSON_ASSERT(char_traits<char_type>::to_char_type(current) == literal_text[0]);
8374 for (std::size_t i = 1; i < length; ++i)
8378 error_message =
"invalid literal";
8379 return token_type::parse_error;
8390 void reset() noexcept
8392 token_buffer.clear();
8393 token_string.clear();
8394 decimal_point_position = std::string::npos;
8395 token_string.push_back(char_traits<char_type>::to_char_type(current));
8410 ++position.chars_read_total;
8411 ++position.chars_read_current_line;
8420 current = ia.get_character();
8425 token_string.push_back(char_traits<char_type>::to_char_type(current));
8428 if (current ==
'\n')
8430 ++position.lines_read;
8431 position.chars_read_current_line = 0;
8449 --position.chars_read_total;
8452 if (position.chars_read_current_line == 0)
8454 if (position.lines_read > 0)
8456 --position.lines_read;
8461 --position.chars_read_current_line;
8467 token_string.pop_back();
8472 void add(char_int_type c)
8474 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8485 return value_integer;
8491 return value_unsigned;
8504 if (decimal_point_char !=
'.' && decimal_point_position != std::string::npos)
8506 token_buffer[decimal_point_position] =
'.';
8508 return token_buffer;
8528 for (
const auto c : token_string)
8530 if (
static_cast<unsigned char>(c) <=
'\x1F')
8533 std::array<char, 9> cs{{}};
8534 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8535 result += cs.data();
8540 result.push_back(
static_cast<std::string::value_type
>(c));
8551 return error_message;
8567 return get() == 0xBB &&
get() == 0xBF;
8582 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8588 if (position.chars_read_total == 0 && !skip_bom())
8590 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8591 return token_type::parse_error;
8598 while (ignore_comments && current ==
'/')
8600 if (!scan_comment())
8602 return token_type::parse_error;
8613 return token_type::begin_array;
8615 return token_type::end_array;
8617 return token_type::begin_object;
8619 return token_type::end_object;
8621 return token_type::name_separator;
8623 return token_type::value_separator;
8628 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
8629 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8633 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
8634 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8638 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
8639 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8644 return scan_string();
8658 return scan_number();
8664 return token_type::end_of_input;
8668 error_message =
"invalid literal";
8669 return token_type::parse_error;
8675 InputAdapterType ia;
8678 const bool ignore_comments =
false;
8684 bool next_unget =
false;
8690 std::vector<char_type> token_string {};
8693 string_t token_buffer {};
8696 const char* error_message =
"";
8699 number_integer_t value_integer = 0;
8700 number_unsigned_t value_unsigned = 0;
8701 number_float_t value_float = 0;
8704 const char_int_type decimal_point_char =
'.';
8706 std::size_t decimal_point_position = std::string::npos;
8726template<
typename BasicJsonType>
8830 const std::string& last_token,
8845 return (std::numeric_limits<std::size_t>::max)();
8861template<
typename BasicJsonType,
typename InputAdapterType>
8878 : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
8890 handle_value(
nullptr);
8926 handle_value(std::move(val));
8932 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
8934#if JSON_DIAGNOSTIC_POSITIONS
8941 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8947 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
8959 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
8968#if JSON_DIAGNOSTIC_POSITIONS
8972 ref_stack.back()->end_position = m_lexer_ref->get_position();
8976 ref_stack.back()->set_parents();
8977 ref_stack.pop_back();
8983 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
8985#if JSON_DIAGNOSTIC_POSITIONS
8990 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8996 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
9007#if JSON_DIAGNOSTIC_POSITIONS
9011 ref_stack.back()->end_position = m_lexer_ref->get_position();
9015 ref_stack.back()->set_parents();
9016 ref_stack.pop_back();
9020 template<
class Exception>
9022 const Exception& ex)
9025 static_cast<void>(ex);
9026 if (allow_exceptions)
9040#if JSON_DIAGNOSTIC_POSITIONS
9041 void handle_diagnostic_positions_for_json_value(BasicJsonType&
v)
9048 v.end_position = m_lexer_ref->get_position();
9052 case value_t::boolean:
9055 v.start_position =
v.end_position - (
v.m_data.m_value.boolean ? 4 : 5);
9062 v.start_position =
v.end_position - 4;
9066 case value_t::string:
9069 v.start_position =
v.end_position -
v.m_data.m_value.string->size() - 2;
9078 case value_t::discarded:
9080 v.end_position = std::string::npos;
9081 v.start_position =
v.end_position;
9085 case value_t::binary:
9086 case value_t::number_integer:
9087 case value_t::number_unsigned:
9088 case value_t::number_float:
9090 v.start_position =
v.end_position - m_lexer_ref->get_string().size();
9093 case value_t::object:
9094 case value_t::array:
9114 template<
typename Value>
9116 BasicJsonType* handle_value(Value&&
v)
9118 if (ref_stack.empty())
9120 root = BasicJsonType(std::forward<Value>(
v));
9122#if JSON_DIAGNOSTIC_POSITIONS
9123 handle_diagnostic_positions_for_json_value(root);
9129 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9131 if (ref_stack.back()->is_array())
9133 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(
v));
9135#if JSON_DIAGNOSTIC_POSITIONS
9136 handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
9139 return &(ref_stack.back()->m_data.m_value.array->back());
9144 *object_element = BasicJsonType(std::forward<Value>(
v));
9146#if JSON_DIAGNOSTIC_POSITIONS
9147 handle_diagnostic_positions_for_json_value(*object_element);
9150 return object_element;
9154 BasicJsonType& root;
9156 std::vector<BasicJsonType*> ref_stack {};
9158 BasicJsonType* object_element =
nullptr;
9160 bool errored =
false;
9162 const bool allow_exceptions =
true;
9164 lexer_t* m_lexer_ref =
nullptr;
9167template<
typename BasicJsonType,
typename InputAdapterType>
9182 const bool allow_exceptions_ =
true,
9184 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9186 keep_stack.push_back(
true);
9198 handle_value(
nullptr);
9234 handle_value(std::move(val));
9241 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
9242 keep_stack.push_back(keep);
9244 auto val = handle_value(BasicJsonType::value_t::object,
true);
9245 ref_stack.push_back(val.second);
9247 if (ref_stack.back())
9250#if JSON_DIAGNOSTIC_POSITIONS
9257 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9264 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
9272 BasicJsonType k = BasicJsonType(val);
9275 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
9276 key_keep_stack.push_back(keep);
9279 if (keep && ref_stack.back())
9281 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
9289 if (ref_stack.back())
9291 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
9296#if JSON_DIAGNOSTIC_POSITIONS
9298 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9304#if JSON_DIAGNOSTIC_POSITIONS
9308 ref_stack.back()->end_position = m_lexer_ref->get_position();
9312 ref_stack.back()->set_parents();
9318 ref_stack.pop_back();
9319 keep_stack.pop_back();
9321 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
9324 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
9326 if (it->is_discarded())
9328 ref_stack.back()->erase(it);
9339 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
9340 keep_stack.push_back(keep);
9342 auto val = handle_value(BasicJsonType::value_t::array,
true);
9343 ref_stack.push_back(val.second);
9345 if (ref_stack.back())
9348#if JSON_DIAGNOSTIC_POSITIONS
9355 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9362 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
9373 if (ref_stack.back())
9375 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
9379#if JSON_DIAGNOSTIC_POSITIONS
9383 ref_stack.back()->end_position = m_lexer_ref->get_position();
9387 ref_stack.back()->set_parents();
9394#if JSON_DIAGNOSTIC_POSITIONS
9396 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9403 ref_stack.pop_back();
9404 keep_stack.pop_back();
9407 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
9409 ref_stack.back()->m_data.m_value.array->pop_back();
9415 template<
class Exception>
9417 const Exception& ex)
9420 static_cast<void>(ex);
9421 if (allow_exceptions)
9435#if JSON_DIAGNOSTIC_POSITIONS
9436 void handle_diagnostic_positions_for_json_value(BasicJsonType&
v)
9443 v.end_position = m_lexer_ref->get_position();
9447 case value_t::boolean:
9450 v.start_position =
v.end_position - (
v.m_data.m_value.boolean ? 4 : 5);
9457 v.start_position =
v.end_position - 4;
9461 case value_t::string:
9464 v.start_position =
v.end_position -
v.m_data.m_value.string->size() - 2;
9468 case value_t::discarded:
9470 v.end_position = std::string::npos;
9471 v.start_position =
v.end_position;
9475 case value_t::binary:
9476 case value_t::number_integer:
9477 case value_t::number_unsigned:
9478 case value_t::number_float:
9480 v.start_position =
v.end_position - m_lexer_ref->get_string().size();
9484 case value_t::object:
9485 case value_t::array:
9514 template<
typename Value>
9515 std::pair<bool, BasicJsonType*> handle_value(Value&&
v,
const bool skip_callback =
false)
9521 if (!keep_stack.back())
9523 return {
false,
nullptr};
9527 auto value = BasicJsonType(std::forward<Value>(
v));
9529#if JSON_DIAGNOSTIC_POSITIONS
9530 handle_diagnostic_positions_for_json_value(value);
9534 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
9539 return {
false,
nullptr};
9542 if (ref_stack.empty())
9544 root = std::move(value);
9545 return {
true, & root};
9550 if (!ref_stack.back())
9552 return {
false,
nullptr};
9556 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9559 if (ref_stack.back()->is_array())
9561 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
9562 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
9569 const bool store_element = key_keep_stack.back();
9570 key_keep_stack.pop_back();
9574 return {
false,
nullptr};
9578 *object_element = std::move(value);
9579 return {
true, object_element};
9583 BasicJsonType& root;
9585 std::vector<BasicJsonType*> ref_stack {};
9587 std::vector<bool> keep_stack {};
9589 std::vector<bool> key_keep_stack {};
9591 BasicJsonType* object_element =
nullptr;
9593 bool errored =
false;
9597 const bool allow_exceptions =
true;
9599 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
9601 lexer_t* m_lexer_ref =
nullptr;
9604template<
typename BasicJsonType>
9718 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9720template<
typename T,
typename Integer>
9722 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9724template<
typename T,
typename Un
signed>
9726 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9728template<
typename T,
typename Float,
typename String>
9730 std::declval<Float>(), std::declval<const String&>()));
9732template<
typename T,
typename String>
9734 decltype(std::declval<T&>().string(std::declval<String&>()));
9736template<
typename T,
typename Binary>
9738 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9742 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9744template<
typename T,
typename String>
9746 decltype(std::declval<T&>().key(std::declval<String&>()));
9753 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9758template<
typename T,
typename Exception>
9760 std::declval<std::size_t>(), std::declval<const std::string&>(),
9761 std::declval<const Exception&>()));
9763template<
typename SAX,
typename BasicJsonType>
9768 "BasicJsonType must be of type basic_json<...>");
9770 using number_integer_t =
typename BasicJsonType::number_integer_t;
9771 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9772 using number_float_t =
typename BasicJsonType::number_float_t;
9773 using string_t =
typename BasicJsonType::string_t;
9774 using binary_t =
typename BasicJsonType::binary_t;
9775 using exception_t =
typename BasicJsonType::exception;
9794template<
typename SAX,
typename BasicJsonType>
9799 "BasicJsonType must be of type basic_json<...>");
9801 using number_integer_t =
typename BasicJsonType::number_integer_t;
9802 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9803 using number_float_t =
typename BasicJsonType::number_float_t;
9804 using string_t =
typename BasicJsonType::string_t;
9805 using binary_t =
typename BasicJsonType::binary_t;
9806 using exception_t =
typename BasicJsonType::exception;
9810 "Missing/invalid function: bool null()");
9812 "Missing/invalid function: bool boolean(bool)");
9814 "Missing/invalid function: bool boolean(bool)");
9817 number_integer_t>::value,
9818 "Missing/invalid function: bool number_integer(number_integer_t)");
9821 number_unsigned_t>::value,
9822 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9824 number_float_t, string_t>::value,
9825 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9828 "Missing/invalid function: bool string(string_t&)");
9831 "Missing/invalid function: bool binary(binary_t&)");
9833 "Missing/invalid function: bool start_object(std::size_t)");
9835 "Missing/invalid function: bool key(string_t&)");
9837 "Missing/invalid function: bool end_object()");
9839 "Missing/invalid function: bool start_array(std::size_t)");
9841 "Missing/invalid function: bool end_array()");
9844 "Missing/invalid function: bool parse_error(std::size_t, const "
9845 "std::string&, const exception&)");
9879 return *
reinterpret_cast<char*
>(&num) == 1;
9889template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
9892 using number_integer_t =
typename BasicJsonType::number_integer_t;
9893 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9894 using number_float_t =
typename BasicJsonType::number_float_t;
9895 using string_t =
typename BasicJsonType::string_t;
9896 using binary_t =
typename BasicJsonType::binary_t;
9897 using json_sax_t = SAX;
9898 using char_type =
typename InputAdapterType::char_type;
9907 explicit binary_reader(InputAdapterType&& adapter,
const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format)
9930 const
bool strict = true,
9934 bool result =
false;
9938 case input_format_t::bson:
9939 result = parse_bson_internal();
9942 case input_format_t::cbor:
9943 result = parse_cbor_internal(
true, tag_handler);
9946 case input_format_t::msgpack:
9947 result = parse_msgpack_internal();
9950 case input_format_t::ubjson:
9951 case input_format_t::bjdata:
9952 result = parse_ubjson_internal();
9955 case input_format_t::json:
9963 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9974 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
9975 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9991 bool parse_bson_internal()
9993 std::int32_t document_size{};
9994 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10006 return sax->end_object();
10016 bool get_bson_cstr(string_t& result)
10018 auto out = std::back_inserter(result);
10026 if (current == 0x00)
10030 *out++ =
static_cast<typename string_t::value_type
>(current);
10045 template<
typename NumberType>
10046 bool get_bson_string(
const NumberType len, string_t& result)
10050 auto last_token = get_token_string();
10051 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10052 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
10055 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) &&
get() != char_traits<char_type>::eof();
10067 template<
typename NumberType>
10068 bool get_bson_binary(
const NumberType len, binary_t& result)
10072 auto last_token = get_token_string();
10073 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10074 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
10078 std::uint8_t subtype{};
10079 get_number<std::uint8_t>(input_format_t::bson, subtype);
10080 result.set_subtype(subtype);
10082 return get_binary(input_format_t::bson, len, result);
10095 bool parse_bson_element_internal(
const char_int_type element_type,
10096 const std::size_t element_type_parse_position)
10098 switch (element_type)
10103 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10108 std::int32_t len{};
10110 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
10115 return parse_bson_internal();
10120 return parse_bson_array();
10125 std::int32_t len{};
10127 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
10132 return sax->boolean(
get() != 0);
10137 return sax->null();
10142 std::int32_t
value{};
10143 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10148 std::int64_t
value{};
10149 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10154 std::uint64_t
value{};
10155 return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
10160 std::array<char, 3> cr{{}};
10161 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
10162 const std::string cr_str{cr.data()};
10163 return sax->parse_error(element_type_parse_position, cr_str,
10164 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
10181 bool parse_bson_element_list(
const bool is_array)
10185 while (
auto element_type =
get())
10192 const std::size_t element_type_parse_position = chars_read;
10198 if (!is_array && !sax->key(key))
10203 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
10219 bool parse_bson_array()
10221 std::int32_t document_size{};
10222 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10234 return sax->end_array();
10249 bool parse_cbor_internal(
const bool get_char,
10250 const cbor_tag_handler_t tag_handler)
10252 switch (get_char ?
get() : current)
10255 case char_traits<char_type>::eof():
10283 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10287 std::uint8_t number{};
10288 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10293 std::uint16_t number{};
10294 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10299 std::uint32_t number{};
10300 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10305 std::uint64_t number{};
10306 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10334 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
10338 std::uint8_t number{};
10339 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10344 std::uint16_t number{};
10345 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10350 std::uint32_t number{};
10351 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10356 std::uint64_t number{};
10357 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
10358 -
static_cast<number_integer_t
>(number));
10393 return get_cbor_binary(b) && sax->binary(b);
10428 return get_cbor_string(s) && sax->string(s);
10456 return get_cbor_array(
10457 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10461 std::uint8_t len{};
10462 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10467 std::uint16_t len{};
10468 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10473 std::uint32_t len{};
10474 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10479 std::uint64_t len{};
10480 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10511 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10515 std::uint8_t len{};
10516 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10521 std::uint16_t len{};
10522 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10527 std::uint32_t len{};
10528 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10533 std::uint64_t len{};
10534 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10560 switch (tag_handler)
10562 case cbor_tag_handler_t::error:
10564 auto last_token = get_token_string();
10565 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10566 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10569 case cbor_tag_handler_t::ignore:
10576 std::uint8_t subtype_to_ignore{};
10577 get_number(input_format_t::cbor, subtype_to_ignore);
10582 std::uint16_t subtype_to_ignore{};
10583 get_number(input_format_t::cbor, subtype_to_ignore);
10588 std::uint32_t subtype_to_ignore{};
10589 get_number(input_format_t::cbor, subtype_to_ignore);
10594 std::uint64_t subtype_to_ignore{};
10595 get_number(input_format_t::cbor, subtype_to_ignore);
10601 return parse_cbor_internal(
true, tag_handler);
10604 case cbor_tag_handler_t::store:
10612 std::uint8_t subtype{};
10613 get_number(input_format_t::cbor, subtype);
10619 std::uint16_t subtype{};
10620 get_number(input_format_t::cbor, subtype);
10626 std::uint32_t subtype{};
10627 get_number(input_format_t::cbor, subtype);
10633 std::uint64_t subtype{};
10634 get_number(input_format_t::cbor, subtype);
10639 return parse_cbor_internal(
true, tag_handler);
10642 return get_cbor_binary(b) && sax->binary(b);
10652 return sax->boolean(
false);
10655 return sax->boolean(
true);
10658 return sax->null();
10662 const auto byte1_raw =
get();
10667 const auto byte2_raw =
get();
10673 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10674 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10684 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10685 const double val = [&half]
10687 const int exp = (half >> 10u) & 0x1Fu;
10688 const unsigned int mant = half & 0x3FFu;
10694 return std::ldexp(mant, -24);
10697 ? std::numeric_limits<double>::infinity()
10698 :
std::numeric_limits<double>::quiet_NaN();
10700 return std::ldexp(mant + 1024, exp - 25);
10703 return sax->number_float((half & 0x8000u) != 0
10704 ?
static_cast<number_float_t
>(-val)
10705 :
static_cast<number_float_t
>(val),
"");
10711 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10717 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10722 auto last_token = get_token_string();
10723 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10724 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10740 bool get_cbor_string(string_t& result)
10775 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10780 std::uint8_t len{};
10781 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10786 std::uint16_t len{};
10787 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10792 std::uint32_t len{};
10793 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10798 std::uint64_t len{};
10799 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10804 while (
get() != 0xFF)
10807 if (!get_cbor_string(chunk))
10811 result.append(chunk);
10818 auto last_token = get_token_string();
10819 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10820 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10836 bool get_cbor_binary(binary_t& result)
10871 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10876 std::uint8_t len{};
10877 return get_number(input_format_t::cbor, len) &&
10878 get_binary(input_format_t::cbor, len, result);
10883 std::uint16_t len{};
10884 return get_number(input_format_t::cbor, len) &&
10885 get_binary(input_format_t::cbor, len, result);
10890 std::uint32_t len{};
10891 return get_number(input_format_t::cbor, len) &&
10892 get_binary(input_format_t::cbor, len, result);
10897 std::uint64_t len{};
10898 return get_number(input_format_t::cbor, len) &&
10899 get_binary(input_format_t::cbor, len, result);
10904 while (
get() != 0xFF)
10907 if (!get_cbor_binary(chunk))
10911 result.insert(result.end(), chunk.begin(), chunk.end());
10918 auto last_token = get_token_string();
10919 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10920 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));
10931 bool get_cbor_array(
const std::size_t len,
10932 const cbor_tag_handler_t tag_handler)
10941 for (std::size_t i = 0; i < len; ++i)
10951 while (
get() != 0xFF)
10960 return sax->end_array();
10969 bool get_cbor_object(
const std::size_t len,
10970 const cbor_tag_handler_t tag_handler)
10982 for (std::size_t i = 0; i < len; ++i)
10999 while (
get() != 0xFF)
11015 return sax->end_object();
11025 bool parse_msgpack_internal()
11030 case char_traits<char_type>::eof():
11162 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
11181 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11200 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11240 return get_msgpack_string(s) && sax->string(s);
11244 return sax->null();
11247 return sax->boolean(
false);
11250 return sax->boolean(
true);
11265 return get_msgpack_binary(b) && sax->binary(b);
11271 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11277 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11282 std::uint8_t number{};
11283 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11288 std::uint16_t number{};
11289 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11294 std::uint32_t number{};
11295 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11300 std::uint64_t number{};
11301 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11306 std::int8_t number{};
11307 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11312 std::int16_t number{};
11313 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11318 std::int32_t number{};
11319 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11324 std::int64_t number{};
11325 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11330 std::uint16_t len{};
11331 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
11336 std::uint32_t len{};
11337 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
11342 std::uint16_t len{};
11343 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
11348 std::uint32_t len{};
11349 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
11385 return sax->number_integer(
static_cast<std::int8_t
>(current));
11389 auto last_token = get_token_string();
11390 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11391 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
11406 bool get_msgpack_string(string_t& result)
11449 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
11454 std::uint8_t len{};
11455 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11460 std::uint16_t len{};
11461 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11466 std::uint32_t len{};
11467 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11472 auto last_token = get_token_string();
11473 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11474 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
11489 bool get_msgpack_binary(binary_t& result)
11492 auto assign_and_return_true = [&result](std::int8_t subtype)
11494 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
11502 std::uint8_t len{};
11503 return get_number(input_format_t::msgpack, len) &&
11504 get_binary(input_format_t::msgpack, len, result);
11509 std::uint16_t len{};
11510 return get_number(input_format_t::msgpack, len) &&
11511 get_binary(input_format_t::msgpack, len, result);
11516 std::uint32_t len{};
11517 return get_number(input_format_t::msgpack, len) &&
11518 get_binary(input_format_t::msgpack, len, result);
11523 std::uint8_t len{};
11524 std::int8_t subtype{};
11525 return get_number(input_format_t::msgpack, len) &&
11526 get_number(input_format_t::msgpack, subtype) &&
11527 get_binary(input_format_t::msgpack, len, result) &&
11528 assign_and_return_true(subtype);
11533 std::uint16_t len{};
11534 std::int8_t subtype{};
11535 return get_number(input_format_t::msgpack, len) &&
11536 get_number(input_format_t::msgpack, subtype) &&
11537 get_binary(input_format_t::msgpack, len, result) &&
11538 assign_and_return_true(subtype);
11543 std::uint32_t len{};
11544 std::int8_t subtype{};
11545 return get_number(input_format_t::msgpack, len) &&
11546 get_number(input_format_t::msgpack, subtype) &&
11547 get_binary(input_format_t::msgpack, len, result) &&
11548 assign_and_return_true(subtype);
11553 std::int8_t subtype{};
11554 return get_number(input_format_t::msgpack, subtype) &&
11555 get_binary(input_format_t::msgpack, 1, result) &&
11556 assign_and_return_true(subtype);
11561 std::int8_t subtype{};
11562 return get_number(input_format_t::msgpack, subtype) &&
11563 get_binary(input_format_t::msgpack, 2, result) &&
11564 assign_and_return_true(subtype);
11569 std::int8_t subtype{};
11570 return get_number(input_format_t::msgpack, subtype) &&
11571 get_binary(input_format_t::msgpack, 4, result) &&
11572 assign_and_return_true(subtype);
11577 std::int8_t subtype{};
11578 return get_number(input_format_t::msgpack, subtype) &&
11579 get_binary(input_format_t::msgpack, 8, result) &&
11580 assign_and_return_true(subtype);
11585 std::int8_t subtype{};
11586 return get_number(input_format_t::msgpack, subtype) &&
11587 get_binary(input_format_t::msgpack, 16, result) &&
11588 assign_and_return_true(subtype);
11600 bool get_msgpack_array(
const std::size_t len)
11607 for (std::size_t i = 0; i < len; ++i)
11615 return sax->end_array();
11622 bool get_msgpack_object(
const std::size_t len)
11630 for (std::size_t i = 0; i < len; ++i)
11645 return sax->end_object();
11659 bool parse_ubjson_internal(
const bool get_char =
true)
11661 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11678 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
11694 std::uint8_t len{};
11695 return get_number(input_format, len) && get_string(input_format, len, result);
11701 return get_number(input_format, len) && get_string(input_format, len, result);
11706 std::int16_t len{};
11707 return get_number(input_format, len) && get_string(input_format, len, result);
11712 std::int32_t len{};
11713 return get_number(input_format, len) && get_string(input_format, len, result);
11718 std::int64_t len{};
11719 return get_number(input_format, len) && get_string(input_format, len, result);
11724 if (input_format != input_format_t::bjdata)
11728 std::uint16_t len{};
11729 return get_number(input_format, len) && get_string(input_format, len, result);
11734 if (input_format != input_format_t::bjdata)
11738 std::uint32_t len{};
11739 return get_number(input_format, len) && get_string(input_format, len, result);
11744 if (input_format != input_format_t::bjdata)
11748 std::uint64_t len{};
11749 return get_number(input_format, len) && get_string(input_format, len, result);
11755 auto last_token = get_token_string();
11756 std::string message;
11758 if (input_format != input_format_t::bjdata)
11760 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11764 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11766 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11773 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11775 std::pair<std::size_t, char_int_type> size_and_type;
11777 bool no_ndarray =
true;
11784 if (size_and_type.first != npos)
11786 if (size_and_type.second != 0)
11788 if (size_and_type.second !=
'N')
11790 for (std::size_t i = 0; i < size_and_type.first; ++i)
11796 dim.push_back(dimlen);
11802 for (std::size_t i = 0; i < size_and_type.first; ++i)
11808 dim.push_back(dimlen);
11814 while (current !=
']')
11820 dim.push_back(dimlen);
11838 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11842 prefix = get_ignore_noop();
11849 std::uint8_t number{};
11854 result =
static_cast<std::size_t
>(number);
11860 std::int8_t number{};
11867 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11868 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11870 result =
static_cast<std::size_t
>(number);
11876 std::int16_t number{};
11883 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11884 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11886 result =
static_cast<std::size_t
>(number);
11892 std::int32_t number{};
11899 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11900 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11902 result =
static_cast<std::size_t
>(number);
11908 std::int64_t number{};
11915 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11916 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11918 if (!value_in_range_of<std::size_t>(number))
11920 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11921 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11923 result =
static_cast<std::size_t
>(number);
11929 if (input_format != input_format_t::bjdata)
11933 std::uint16_t number{};
11938 result =
static_cast<std::size_t
>(number);
11944 if (input_format != input_format_t::bjdata)
11948 std::uint32_t number{};
11953 result = conditional_static_cast<std::size_t>(number);
11959 if (input_format != input_format_t::bjdata)
11963 std::uint64_t number{};
11968 if (!value_in_range_of<std::size_t>(number))
11970 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11971 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11979 if (input_format != input_format_t::bjdata)
11985 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));
11987 std::vector<size_t> dim;
11992 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11994 result = dim.at(dim.size() - 1);
12008 string_t
key =
"_ArraySize_";
12009 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
12021 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));
12025 if (result == 0 || result == npos)
12027 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));
12035 return sax->end_array();
12044 auto last_token = get_token_string();
12045 std::string message;
12047 if (input_format != input_format_t::bjdata)
12049 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
12053 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
12055 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
12069 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
12071 result.first = npos;
12073 bool is_ndarray =
false;
12077 if (current ==
'$')
12079 result.second =
get();
12080 if (input_format == input_format_t::bjdata
12081 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
12083 auto last_token = get_token_string();
12084 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12085 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
12100 auto last_token = get_token_string();
12101 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12102 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
12105 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12106 if (input_format == input_format_t::bjdata && is_ndarray)
12108 if (inside_ndarray)
12110 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12111 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
12113 result.second |= (1 << 8);
12118 if (current ==
'#')
12120 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12121 if (input_format == input_format_t::bjdata && is_ndarray)
12123 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12124 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
12136 bool get_ubjson_value(
const char_int_type prefix)
12140 case char_traits<char_type>::eof():
12141 return unexpect_eof(input_format,
"value");
12144 return sax->boolean(
true);
12146 return sax->boolean(
false);
12149 return sax->null();
12153 if (input_format != input_format_t::bjdata)
12157 std::uint8_t number{};
12158 return get_number(input_format, number) && sax->number_unsigned(number);
12163 std::uint8_t number{};
12164 return get_number(input_format, number) && sax->number_unsigned(number);
12169 std::int8_t number{};
12170 return get_number(input_format, number) && sax->number_integer(number);
12175 std::int16_t number{};
12176 return get_number(input_format, number) && sax->number_integer(number);
12181 std::int32_t number{};
12182 return get_number(input_format, number) && sax->number_integer(number);
12187 std::int64_t number{};
12188 return get_number(input_format, number) && sax->number_integer(number);
12193 if (input_format != input_format_t::bjdata)
12197 std::uint16_t number{};
12198 return get_number(input_format, number) && sax->number_unsigned(number);
12203 if (input_format != input_format_t::bjdata)
12207 std::uint32_t number{};
12208 return get_number(input_format, number) && sax->number_unsigned(number);
12213 if (input_format != input_format_t::bjdata)
12217 std::uint64_t number{};
12218 return get_number(input_format, number) && sax->number_unsigned(number);
12223 if (input_format != input_format_t::bjdata)
12227 const auto byte1_raw =
get();
12232 const auto byte2_raw =
get();
12238 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
12239 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
12249 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
12250 const double val = [&half]
12252 const int exp = (half >> 10u) & 0x1Fu;
12253 const unsigned int mant = half & 0x3FFu;
12259 return std::ldexp(mant, -24);
12262 ? std::numeric_limits<double>::infinity()
12263 :
std::numeric_limits<double>::quiet_NaN();
12265 return std::ldexp(mant + 1024, exp - 25);
12268 return sax->number_float((half & 0x8000u) != 0
12269 ?
static_cast<number_float_t
>(-val)
12270 :
static_cast<number_float_t
>(val),
"");
12276 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12282 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12287 return get_ubjson_high_precision_number();
12299 auto last_token = get_token_string();
12300 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
12301 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
12303 string_t s(1,
static_cast<typename string_t::value_type
>(current));
12304 return sax->string(s);
12310 return get_ubjson_string(s) && sax->string(s);
12314 return get_ubjson_array();
12317 return get_ubjson_object();
12322 auto last_token = get_token_string();
12323 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));
12329 bool get_ubjson_array()
12331 std::pair<std::size_t, char_int_type> size_and_type;
12340 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12342 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
12343 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)
12345 return p.first < t;
12347 string_t
key =
"_ArrayType_";
12350 auto last_token = get_token_string();
12351 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12352 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
12355 string_t type = it->second;
12361 if (size_and_type.second ==
'C' || size_and_type.second ==
'B')
12363 size_and_type.second =
'U';
12366 key =
"_ArrayData_";
12372 for (std::size_t i = 0; i < size_and_type.first; ++i)
12380 return (sax->end_array() && sax->end_object());
12384 if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second ==
'B')
12387 return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
12390 if (size_and_type.first != npos)
12397 if (size_and_type.second != 0)
12399 if (size_and_type.second !=
'N')
12401 for (std::size_t i = 0; i < size_and_type.first; ++i)
12412 for (std::size_t i = 0; i < size_and_type.first; ++i)
12428 while (current !=
']')
12438 return sax->end_array();
12444 bool get_ubjson_object()
12446 std::pair<std::size_t, char_int_type> size_and_type;
12453 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12455 auto last_token = get_token_string();
12456 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12457 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
12461 if (size_and_type.first != npos)
12468 if (size_and_type.second != 0)
12470 for (std::size_t i = 0; i < size_and_type.first; ++i)
12485 for (std::size_t i = 0; i < size_and_type.first; ++i)
12506 while (current !=
'}')
12521 return sax->end_object();
12527 bool get_ubjson_high_precision_number()
12530 std::size_t size{};
12531 bool no_ndarray =
true;
12532 auto res = get_ubjson_size_value(size, no_ndarray);
12539 std::vector<char> number_vector;
12540 for (std::size_t i = 0; i < size; ++i)
12547 number_vector.push_back(
static_cast<char>(current));
12553 const auto result_number = number_lexer.scan();
12554 const auto number_string = number_lexer.get_token_string();
12555 const auto result_remainder = number_lexer.scan();
12561 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12562 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12565 switch (result_number)
12567 case token_type::value_integer:
12568 return sax->number_integer(number_lexer.get_number_integer());
12569 case token_type::value_unsigned:
12570 return sax->number_unsigned(number_lexer.get_number_unsigned());
12571 case token_type::value_float:
12572 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12573 case token_type::uninitialized:
12574 case token_type::literal_true:
12575 case token_type::literal_false:
12576 case token_type::literal_null:
12577 case token_type::value_string:
12578 case token_type::begin_array:
12579 case token_type::begin_object:
12580 case token_type::end_array:
12581 case token_type::end_object:
12582 case token_type::name_separator:
12583 case token_type::value_separator:
12584 case token_type::parse_error:
12585 case token_type::end_of_input:
12586 case token_type::literal_or_value:
12588 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12589 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12606 char_int_type
get()
12609 return current = ia.get_character();
12621 bool get_to(T& dest,
const input_format_t format,
const char* context)
12623 auto new_chars_read = ia.get_elements(&dest);
12624 chars_read += new_chars_read;
12629 sax->parse_error(chars_read,
"<end of file>", parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12638 char_int_type get_ignore_noop()
12644 while (current ==
'N');
12649 template<
class NumberType>
12650 static void byte_swap(NumberType& number)
12652 constexpr std::size_t sz =
sizeof(number);
12653#ifdef __cpp_lib_byteswap
12654 if constexpr (sz == 1)
12658 else if constexpr(std::is_integral_v<NumberType>)
12660 number = std::byteswap(number);
12666 auto* ptr =
reinterpret_cast<std::uint8_t*
>(&number);
12667 for (std::size_t i = 0; i < sz / 2; ++i)
12671#ifdef __cpp_lib_byteswap
12691 template<
typename NumberType,
bool InputIsLittleEndian = false>
12692 bool get_number(
const input_format_t format, NumberType& result)
12700 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
12721 template<
typename NumberType>
12722 bool get_string(
const input_format_t format,
12723 const NumberType len,
12726 bool success =
true;
12727 for (NumberType i = 0; i < len; i++)
12735 result.push_back(
static_cast<typename string_t::value_type
>(current));
12754 template<
typename NumberType>
12755 bool get_binary(
const input_format_t format,
12756 const NumberType len,
12759 bool success =
true;
12760 for (NumberType i = 0; i < len; i++)
12768 result.push_back(
static_cast<std::uint8_t
>(current));
12779 bool unexpect_eof(const input_format_t format, const
char* context)
const
12783 return sax->parse_error(chars_read,
"<end of file>",
12784 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12792 std::string get_token_string()
const
12794 std::array<char, 3> cr{{}};
12795 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12796 return std::string{cr.data()};
12805 std::string exception_message(
const input_format_t format,
12806 const std::string&
detail,
12807 const std::string& context)
const
12809 std::string error_msg =
"syntax error while parsing ";
12813 case input_format_t::cbor:
12814 error_msg +=
"CBOR";
12817 case input_format_t::msgpack:
12818 error_msg +=
"MessagePack";
12821 case input_format_t::ubjson:
12822 error_msg +=
"UBJSON";
12825 case input_format_t::bson:
12826 error_msg +=
"BSON";
12829 case input_format_t::bjdata:
12830 error_msg +=
"BJData";
12833 case input_format_t::json:
12845 InputAdapterType ia;
12848 char_int_type current = char_traits<char_type>::eof();
12851 std::size_t chars_read = 0;
12860 json_sax_t* sax =
nullptr;
12863#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12864 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12866#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12867 make_array<bjd_type>( \
12868 bjd_type{'B', "byte"}, \
12869 bjd_type{'C', "char"}, \
12870 bjd_type{'D', "double"}, \
12871 bjd_type{'I', "int16"}, \
12872 bjd_type{'L', "int64"}, \
12873 bjd_type{'M', "uint64"}, \
12874 bjd_type{'U', "uint8"}, \
12875 bjd_type{'d', "single"}, \
12876 bjd_type{'i', "int8"}, \
12877 bjd_type{'l', "int32"}, \
12878 bjd_type{'m', "uint32"}, \
12879 bjd_type{'u', "uint16"})
12887 using bjd_type = std::pair<char_int_type, string_t>;
12892#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12893#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12896#ifndef JSON_HAS_CPP_17
12897 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12898 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12921#include <functional>
12966template<
typename BasicJsonType>
12968 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12975template<
typename BasicJsonType,
typename InputAdapterType>
12978 using number_integer_t =
typename BasicJsonType::number_integer_t;
12979 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12980 using number_float_t =
typename BasicJsonType::number_float_t;
12981 using string_t =
typename BasicJsonType::string_t;
12989 const bool allow_exceptions_ =
true,
12990 const bool ignore_comments =
false,
12991 const bool ignore_trailing_commas_ =
false)
12992 : callback(
std::move(cb))
12993 , m_lexer(
std::move(adapter), ignore_comments)
12994 , allow_exceptions(allow_exceptions_)
12995 , ignore_trailing_commas(ignore_trailing_commas_)
13011 void parse(
const bool strict, BasicJsonType& result)
13016 sax_parse_internal(&sdp);
13019 if (
strict && (get_token() != token_type::end_of_input))
13022 m_lexer.get_token_string(),
13023 parse_error::create(101, m_lexer.get_position(),
13024 exception_message(token_type::end_of_input,
"value"),
nullptr));
13030 result = value_t::discarded;
13036 if (result.is_discarded())
13044 sax_parse_internal(&sdp);
13047 if (
strict && (get_token() != token_type::end_of_input))
13050 m_lexer.get_token_string(),
13051 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13057 result = value_t::discarded;
13062 result.assert_invariant();
13074 return sax_parse(&sax_acceptor,
strict);
13077 template<
typename SAX>
13079 bool sax_parse(SAX* sax, const
bool strict = true)
13082 const bool result = sax_parse_internal(sax);
13085 if (result &&
strict && (get_token() != token_type::end_of_input))
13087 return sax->parse_error(m_lexer.get_position(),
13088 m_lexer.get_token_string(),
13089 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13096 template<
typename SAX>
13098 bool sax_parse_internal(SAX* sax)
13102 std::vector<bool> states;
13104 bool skip_to_state_evaluation =
false;
13108 if (!skip_to_state_evaluation)
13111 switch (last_token)
13113 case token_type::begin_object:
13121 if (get_token() == token_type::end_object)
13133 return sax->parse_error(m_lexer.get_position(),
13134 m_lexer.get_token_string(),
13135 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13145 return sax->parse_error(m_lexer.get_position(),
13146 m_lexer.get_token_string(),
13147 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13151 states.push_back(
false);
13158 case token_type::begin_array:
13166 if (get_token() == token_type::end_array)
13176 states.push_back(
true);
13182 case token_type::value_float:
13184 const auto res = m_lexer.get_number_float();
13188 return sax->parse_error(m_lexer.get_position(),
13189 m_lexer.get_token_string(),
13190 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
13201 case token_type::literal_false:
13210 case token_type::literal_null:
13219 case token_type::literal_true:
13228 case token_type::value_integer:
13237 case token_type::value_string:
13246 case token_type::value_unsigned:
13255 case token_type::parse_error:
13258 return sax->parse_error(m_lexer.get_position(),
13259 m_lexer.get_token_string(),
13260 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
13262 case token_type::end_of_input:
13266 return sax->parse_error(m_lexer.get_position(),
13267 m_lexer.get_token_string(),
13268 parse_error::create(101, m_lexer.get_position(),
13269 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
13272 return sax->parse_error(m_lexer.get_position(),
13273 m_lexer.get_token_string(),
13274 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13276 case token_type::uninitialized:
13277 case token_type::end_array:
13278 case token_type::end_object:
13279 case token_type::name_separator:
13280 case token_type::value_separator:
13281 case token_type::literal_or_value:
13284 return sax->parse_error(m_lexer.get_position(),
13285 m_lexer.get_token_string(),
13286 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13292 skip_to_state_evaluation =
false;
13296 if (states.empty())
13306 if (get_token() == token_type::value_separator)
13312 if (!(ignore_trailing_commas && last_token == token_type::end_array))
13332 skip_to_state_evaluation =
true;
13336 return sax->parse_error(m_lexer.get_position(),
13337 m_lexer.get_token_string(),
13338 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
13345 if (get_token() == token_type::value_separator)
13350 if (!(ignore_trailing_commas && last_token == token_type::end_object))
13355 return sax->parse_error(m_lexer.get_position(),
13356 m_lexer.get_token_string(),
13357 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13368 return sax->parse_error(m_lexer.get_position(),
13369 m_lexer.get_token_string(),
13370 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13393 skip_to_state_evaluation =
true;
13397 return sax->parse_error(m_lexer.get_position(),
13398 m_lexer.get_token_string(),
13399 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
13404 token_type get_token()
13406 return last_token = m_lexer.scan();
13409 std::string exception_message(
const token_type expected,
const std::string& context)
13411 std::string error_msg =
"syntax error ";
13413 if (!context.empty())
13415 error_msg +=
concat(
"while parsing ", context,
' ');
13420 if (last_token == token_type::parse_error)
13422 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
13423 m_lexer.get_token_string(),
'\'');
13427 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
13430 if (expected != token_type::uninitialized)
13432 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
13440 const parser_callback_t<BasicJsonType> callback =
nullptr;
13442 token_type last_token = token_type::uninitialized;
13446 const bool allow_exceptions =
true;
13448 const bool ignore_trailing_commas =
false;
13500 using difference_type = std::ptrdiff_t;
13501 static constexpr difference_type begin_value = 0;
13502 static constexpr difference_type end_value = begin_value + 1;
13506 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
13517 m_it = begin_value;
13529 return m_it == begin_value;
13535 return m_it == end_value;
13540 return lhs.m_it == rhs.m_it;
13545 return lhs.m_it < rhs.m_it;
13550 auto result = *
this;
13557 return lhs.m_it - rhs.m_it;
13568 auto result = *
this;
13581 auto result = *
this;
13616 typename BasicJsonType::object_t::iterator object_iterator {};
13618 typename BasicJsonType::array_t::iterator array_iterator {};
13638#include <type_traits>
13679template<
typename BasicJsonType>
13686 friend BasicJsonType;
13690 using object_t =
typename BasicJsonType::object_t;
13691 using array_t =
typename BasicJsonType::array_t;
13694 "iter_impl only accepts (const) basic_json");
13696 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13697 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value,
13698 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13713 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13714 typename BasicJsonType::const_pointer,
13715 typename BasicJsonType::pointer>::type;
13718 typename std::conditional<std::is_const<BasicJsonType>::value,
13719 typename BasicJsonType::const_reference,
13720 typename BasicJsonType::reference>::type;
13737 switch (m_object->m_data.m_type)
13739 case value_t::object:
13741 m_it.object_iterator =
typename object_t::iterator();
13745 case value_t::array:
13747 m_it.array_iterator =
typename array_t::iterator();
13751 case value_t::null:
13752 case value_t::string:
13753 case value_t::boolean:
13754 case value_t::number_integer:
13755 case value_t::number_unsigned:
13756 case value_t::number_float:
13757 case value_t::binary:
13758 case value_t::discarded:
13784 : m_object(other.m_object), m_it(other.m_it)
13795 if (&other !=
this)
13797 m_object = other.m_object;
13809 : m_object(other.m_object), m_it(other.m_it)
13820 m_object = other.m_object;
13830 void set_begin() noexcept
13834 switch (m_object->m_data.m_type)
13836 case value_t::object:
13838 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13842 case value_t::array:
13844 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13848 case value_t::null:
13851 m_it.primitive_iterator.set_end();
13855 case value_t::string:
13856 case value_t::boolean:
13857 case value_t::number_integer:
13858 case value_t::number_unsigned:
13859 case value_t::number_float:
13860 case value_t::binary:
13861 case value_t::discarded:
13864 m_it.primitive_iterator.set_begin();
13878 switch (m_object->m_data.m_type)
13880 case value_t::object:
13882 m_it.object_iterator = m_object->m_data.m_value.object->end();
13886 case value_t::array:
13888 m_it.array_iterator = m_object->m_data.m_value.array->end();
13892 case value_t::null:
13893 case value_t::string:
13894 case value_t::boolean:
13895 case value_t::number_integer:
13896 case value_t::number_unsigned:
13897 case value_t::number_float:
13898 case value_t::binary:
13899 case value_t::discarded:
13902 m_it.primitive_iterator.set_end();
13917 switch (m_object->m_data.m_type)
13919 case value_t::object:
13921 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13922 return m_it.object_iterator->second;
13925 case value_t::array:
13927 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13928 return *m_it.array_iterator;
13931 case value_t::null:
13932 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13934 case value_t::string:
13935 case value_t::boolean:
13936 case value_t::number_integer:
13937 case value_t::number_unsigned:
13938 case value_t::number_float:
13939 case value_t::binary:
13940 case value_t::discarded:
13948 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13961 switch (m_object->m_data.m_type)
13963 case value_t::object:
13965 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13966 return &(m_it.object_iterator->second);
13969 case value_t::array:
13971 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13972 return &*m_it.array_iterator;
13975 case value_t::null:
13976 case value_t::string:
13977 case value_t::boolean:
13978 case value_t::number_integer:
13979 case value_t::number_unsigned:
13980 case value_t::number_float:
13981 case value_t::binary:
13982 case value_t::discarded:
13990 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14001 auto result = *
this;
14014 switch (m_object->m_data.m_type)
14016 case value_t::object:
14018 std::advance(m_it.object_iterator, 1);
14022 case value_t::array:
14024 std::advance(m_it.array_iterator, 1);
14028 case value_t::null:
14029 case value_t::string:
14030 case value_t::boolean:
14031 case value_t::number_integer:
14032 case value_t::number_unsigned:
14033 case value_t::number_float:
14034 case value_t::binary:
14035 case value_t::discarded:
14038 ++m_it.primitive_iterator;
14052 auto result = *
this;
14065 switch (m_object->m_data.m_type)
14067 case value_t::object:
14069 std::advance(m_it.object_iterator, -1);
14073 case value_t::array:
14075 std::advance(m_it.array_iterator, -1);
14079 case value_t::null:
14080 case value_t::string:
14081 case value_t::boolean:
14082 case value_t::number_integer:
14083 case value_t::number_unsigned:
14084 case value_t::number_float:
14085 case value_t::binary:
14086 case value_t::discarded:
14089 --m_it.primitive_iterator;
14101 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 >
14107 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14111 if (m_object ==
nullptr)
14116 switch (m_object->m_data.m_type)
14118 case value_t::object:
14119 return (m_it.object_iterator == other.m_it.object_iterator);
14121 case value_t::array:
14122 return (m_it.array_iterator == other.m_it.array_iterator);
14124 case value_t::null:
14125 case value_t::string:
14126 case value_t::boolean:
14127 case value_t::number_integer:
14128 case value_t::number_unsigned:
14129 case value_t::number_float:
14130 case value_t::binary:
14131 case value_t::discarded:
14133 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
14141 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 >
14156 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14160 if (m_object ==
nullptr)
14166 switch (m_object->m_data.m_type)
14168 case value_t::object:
14169 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
14171 case value_t::array:
14172 return (m_it.array_iterator < other.
m_it.array_iterator);
14174 case value_t::null:
14175 case value_t::string:
14176 case value_t::boolean:
14177 case value_t::number_integer:
14178 case value_t::number_unsigned:
14179 case value_t::number_float:
14180 case value_t::binary:
14181 case value_t::discarded:
14183 return (m_it.primitive_iterator < other.
m_it.primitive_iterator);
14193 return !other.operator < (*this);
14202 return !operator<=(other);
14222 switch (m_object->m_data.m_type)
14224 case value_t::object:
14225 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14227 case value_t::array:
14229 std::advance(m_it.array_iterator, i);
14233 case value_t::null:
14234 case value_t::string:
14235 case value_t::boolean:
14236 case value_t::number_integer:
14237 case value_t::number_unsigned:
14238 case value_t::number_float:
14239 case value_t::binary:
14240 case value_t::discarded:
14243 m_it.primitive_iterator += i;
14257 return operator+=(-i);
14266 auto result = *
this;
14288 auto result = *
this;
14301 switch (m_object->m_data.m_type)
14303 case value_t::object:
14304 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14306 case value_t::array:
14307 return m_it.array_iterator - other.
m_it.array_iterator;
14309 case value_t::null:
14310 case value_t::string:
14311 case value_t::boolean:
14312 case value_t::number_integer:
14313 case value_t::number_unsigned:
14314 case value_t::number_float:
14315 case value_t::binary:
14316 case value_t::discarded:
14318 return m_it.primitive_iterator - other.
m_it.primitive_iterator;
14330 switch (m_object->m_data.m_type)
14332 case value_t::object:
14333 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
14335 case value_t::array:
14336 return *std::next(m_it.array_iterator,
n);
14338 case value_t::null:
14339 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14341 case value_t::string:
14342 case value_t::boolean:
14343 case value_t::number_integer:
14344 case value_t::number_unsigned:
14345 case value_t::number_float:
14346 case value_t::binary:
14347 case value_t::discarded:
14355 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14364 const typename object_t::key_type&
key()
const
14370 return m_it.object_iterator->first;
14373 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
14382 return operator*();
14441template<
typename Base>
14509 return *(this->operator+(
n));
14513 auto key() const -> decltype(
std::declval<Base>().key())
14515 auto it = --this->base();
14522 auto it = --this->base();
14523 return it.operator * ();
14543#include <type_traits>
14566 std::is_same<T, void>::value,
14585#include <algorithm>
14613template<
typename RefStringType>
14623 template<
typename T>
14624 struct string_t_helper
14632 using type = StringType;
14637 using string_t =
typename string_t_helper<RefStringType>::type;
14642 : reference_tokens(split(s))
14649 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14653 return detail::concat(a,
'/', detail::escape(b));
14679 reference_tokens.insert(reference_tokens.end(),
14680 ptr.reference_tokens.begin(),
14681 ptr.reference_tokens.end());
14689 push_back(std::move(token));
14697 return *
this /= std::to_string(array_idx);
14745 reference_tokens.pop_back();
14757 return reference_tokens.back();
14764 reference_tokens.push_back(token);
14771 reference_tokens.push_back(std::move(token));
14778 return reference_tokens.empty();
14792 template<
typename BasicJsonType>
14793 static typename BasicJsonType::size_type array_index(
const string_t& s)
14795 using size_type =
typename BasicJsonType::size_type;
14809 const char*
p = s.c_str();
14810 char* p_end =
nullptr;
14812 const unsigned long long res = std::strtoull(
p, &p_end, 10);
14822 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14827 return static_cast<size_type
>(res);
14839 result.reference_tokens = {reference_tokens[0]};
14852 template<
typename BasicJsonType>
14853 BasicJsonType& get_and_create(BasicJsonType& j)
const
14859 for (
const auto& reference_token : reference_tokens)
14861 switch (result->type())
14865 if (reference_token ==
"0")
14868 result = &result->operator[](0);
14873 result = &result->operator[](reference_token);
14881 result = &result->operator[](reference_token);
14888 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14932 template<
typename BasicJsonType>
14933 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14935 for (
const auto& reference_token : reference_tokens)
14938 if (ptr->is_null())
14942 std::all_of(reference_token.begin(), reference_token.end(),
14943 [](
const unsigned char x)
14945 return std::isdigit(x);
14949 *ptr = (nums || reference_token ==
"-")
14954 switch (ptr->type())
14959 ptr = &ptr->operator[](reference_token);
14965 if (reference_token ==
"-")
14968 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14973 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15000 template<
typename BasicJsonType>
15001 BasicJsonType& get_checked(BasicJsonType* ptr)
const
15003 for (
const auto& reference_token : reference_tokens)
15005 switch (ptr->type())
15010 ptr = &ptr->at(reference_token);
15020 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15021 ") is out of range"), ptr));
15025 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15058 template<
typename BasicJsonType>
15059 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
15061 for (
const auto& reference_token : reference_tokens)
15063 switch (ptr->type())
15068 ptr = &ptr->operator[](reference_token);
15081 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15107 template<
typename BasicJsonType>
15108 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
15110 for (
const auto& reference_token : reference_tokens)
15112 switch (ptr->type())
15117 ptr = &ptr->at(reference_token);
15127 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15128 ") is out of range"), ptr));
15132 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15156 template<
typename BasicJsonType>
15157 bool contains(
const BasicJsonType* ptr)
const
15159 for (
const auto& reference_token : reference_tokens)
15161 switch (ptr->type())
15165 if (!ptr->contains(reference_token))
15171 ptr = &ptr->operator[](reference_token);
15182 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
15194 for (std::size_t i = 1; i < reference_token.size(); i++)
15204 const auto idx = array_index<BasicJsonType>(reference_token);
15205 if (idx >= ptr->size())
15211 ptr = &ptr->operator[](idx);
15245 static std::vector<string_t> split(
const string_t& reference_string)
15247 std::vector<string_t> result;
15250 if (reference_string.empty())
15266 std::size_t slash = reference_string.find_first_of(
'/', 1),
15273 start = (slash == string_t::npos) ? 0 : slash + 1,
15275 slash = reference_string.find_first_of(
'/', start))
15279 auto reference_token = reference_string.substr(start, slash - start);
15282 for (std::size_t pos = reference_token.find_first_of(
'~');
15283 pos != string_t::npos;
15284 pos = reference_token.find_first_of(
'~', pos + 1))
15290 (reference_token[pos + 1] !=
'0' &&
15291 reference_token[pos + 1] !=
'1')))
15299 result.push_back(reference_token);
15313 template<
typename BasicJsonType>
15314 static void flatten(
const string_t& reference_string,
15315 const BasicJsonType& value,
15316 BasicJsonType& result)
15318 switch (
value.type())
15322 if (
value.m_data.m_value.array->empty())
15325 result[reference_string] =
nullptr;
15330 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
15333 value.m_data.m_value.array->operator[](i), result);
15341 if (
value.m_data.m_value.object->empty())
15344 result[reference_string] =
nullptr;
15349 for (
const auto& element : *
value.m_data.m_value.object)
15368 result[reference_string] =
value;
15384 template<
typename BasicJsonType>
15385 static BasicJsonType
15386 unflatten(
const BasicJsonType& value)
15393 BasicJsonType result;
15396 for (
const auto& element : *
value.m_data.m_value.object)
15407 json_pointer(element.first).get_and_create(result) = element.second;
15417 result.reference_tokens = reference_tokens;
15424 result.reference_tokens = std::move(reference_tokens);
15429#if JSON_HAS_THREE_WAY_COMPARISON
15432 template<
typename RefStringTypeRhs>
15435 return reference_tokens == rhs.reference_tokens;
15447 template<
typename RefStringTypeRhs>
15450 return reference_tokens <=> rhs.reference_tokens;
15455 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15462 template<
typename RefStringTypeLhs,
typename StringType>
15465 const StringType& rhs);
15469 template<
typename RefStringTypeRhs,
typename StringType>
15471 friend bool operator==(
const StringType& lhs,
15476 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15483 template<
typename RefStringTypeLhs,
typename StringType>
15486 const StringType& rhs);
15490 template<
typename RefStringTypeRhs,
typename StringType>
15492 friend bool operator!=(
const StringType& lhs,
15496 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15504 std::vector<string_t> reference_tokens;
15507#if !JSON_HAS_THREE_WAY_COMPARISON
15509template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15513 return lhs.reference_tokens == rhs.reference_tokens;
15516template<
typename RefStringTypeLhs,
15520 const StringType& rhs)
15525template<
typename RefStringTypeRhs,
15528inline
bool operator==(const StringType& lhs,
15534template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15538 return !(lhs == rhs);
15541template<
typename RefStringTypeLhs,
15545 const StringType& rhs)
15547 return !(lhs == rhs);
15550template<
typename RefStringTypeRhs,
15553inline
bool operator!=(const StringType& lhs,
15556 return !(lhs == rhs);
15559template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15563 return lhs.reference_tokens < rhs.reference_tokens;
15580#include <initializer_list>
15592template<
typename BasicJsonType>
15603 : value_ref(&
value)
15607 : owned_value(init)
15612 enable_if_t<std::is_constructible<value_type, Args...>::value,
int> = 0 >
15614 : owned_value(
std::forward<Args>(args)...)
15626 if (value_ref ==
nullptr)
15628 return std::move(owned_value);
15635 return value_ref ? *value_ref : owned_value;
15644 mutable value_type owned_value =
nullptr;
15645 value_type
const* value_ref =
nullptr;
15674#include <algorithm>
15700#include <algorithm>
15734template<typename CharType>
15738template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15752 void write_characters(const CharType* s,
std::
size_t length)
override
15754 v.insert(
v.end(), s, s + length);
15758 std::vector<CharType, AllocatorType>&
v;
15763template<
typename CharType>
15777 void write_characters(const CharType* s,
std::
size_t length)
override
15779 stream.write(s,
static_cast<std::streamsize
>(length));
15783 std::basic_ostream<CharType>& stream;
15788template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15802 void write_characters(const CharType* s,
std::
size_t length)
override
15804 str.append(s, length);
15811template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15815 template<
typename AllocatorType = std::allocator<CharType>>
15860template<
typename BasicJsonType,
typename CharType>
15863 using string_t =
typename BasicJsonType::string_t;
15864 using binary_t =
typename BasicJsonType::binary_t;
15865 using number_float_t =
typename BasicJsonType::number_float_t;
15886 case value_t::object:
15888 write_bson_object(*j.m_data.m_value.object);
15892 case value_t::null:
15893 case value_t::array:
15894 case value_t::string:
15895 case value_t::boolean:
15896 case value_t::number_integer:
15897 case value_t::number_unsigned:
15898 case value_t::number_float:
15899 case value_t::binary:
15900 case value_t::discarded:
15903 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15915 case value_t::null:
15917 oa->write_character(to_char_type(0xF6));
15921 case value_t::boolean:
15923 oa->write_character(j.m_data.m_value.boolean
15924 ? to_char_type(0xF5)
15925 : to_char_type(0xF4));
15929 case value_t::number_integer:
15931 if (j.m_data.m_value.number_integer >= 0)
15936 if (j.m_data.m_value.number_integer <= 0x17)
15938 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15940 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15942 oa->write_character(to_char_type(0x18));
15943 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15945 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15947 oa->write_character(to_char_type(0x19));
15948 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15950 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15952 oa->write_character(to_char_type(0x1A));
15953 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15957 oa->write_character(to_char_type(0x1B));
15958 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15965 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15966 if (j.m_data.m_value.number_integer >= -24)
15968 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15970 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15972 oa->write_character(to_char_type(0x38));
15973 write_number(
static_cast<std::uint8_t
>(positive_number));
15975 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15977 oa->write_character(to_char_type(0x39));
15978 write_number(
static_cast<std::uint16_t
>(positive_number));
15980 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15982 oa->write_character(to_char_type(0x3A));
15983 write_number(
static_cast<std::uint32_t
>(positive_number));
15987 oa->write_character(to_char_type(0x3B));
15988 write_number(
static_cast<std::uint64_t
>(positive_number));
15994 case value_t::number_unsigned:
15996 if (j.m_data.m_value.number_unsigned <= 0x17)
15998 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16000 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16002 oa->write_character(to_char_type(0x18));
16003 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16005 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16007 oa->write_character(to_char_type(0x19));
16008 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
16010 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16012 oa->write_character(to_char_type(0x1A));
16013 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
16017 oa->write_character(to_char_type(0x1B));
16018 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
16023 case value_t::number_float:
16025 if (std::isnan(j.m_data.m_value.number_float))
16028 oa->write_character(to_char_type(0xF9));
16029 oa->write_character(to_char_type(0x7E));
16030 oa->write_character(to_char_type(0x00));
16032 else if (std::isinf(j.m_data.m_value.number_float))
16035 oa->write_character(to_char_type(0xf9));
16036 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
16037 oa->write_character(to_char_type(0x00));
16046 case value_t::string:
16049 const auto N = j.m_data.m_value.string->size();
16052 write_number(
static_cast<std::uint8_t
>(0x60 + N));
16054 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16056 oa->write_character(to_char_type(0x78));
16057 write_number(
static_cast<std::uint8_t
>(N));
16059 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16061 oa->write_character(to_char_type(0x79));
16062 write_number(
static_cast<std::uint16_t
>(N));
16064 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16066 oa->write_character(to_char_type(0x7A));
16067 write_number(
static_cast<std::uint32_t
>(N));
16070 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16072 oa->write_character(to_char_type(0x7B));
16073 write_number(
static_cast<std::uint64_t
>(N));
16078 oa->write_characters(
16079 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16080 j.m_data.m_value.string->size());
16084 case value_t::array:
16087 const auto N = j.m_data.m_value.array->size();
16090 write_number(
static_cast<std::uint8_t
>(0x80 + N));
16092 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16094 oa->write_character(to_char_type(0x98));
16095 write_number(
static_cast<std::uint8_t
>(N));
16097 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16099 oa->write_character(to_char_type(0x99));
16100 write_number(
static_cast<std::uint16_t
>(N));
16102 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16104 oa->write_character(to_char_type(0x9A));
16105 write_number(
static_cast<std::uint32_t
>(N));
16108 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16110 oa->write_character(to_char_type(0x9B));
16111 write_number(
static_cast<std::uint64_t
>(N));
16116 for (
const auto& el : *j.m_data.m_value.array)
16123 case value_t::binary:
16125 if (j.m_data.m_value.binary->has_subtype())
16127 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
16129 write_number(
static_cast<std::uint8_t
>(0xd8));
16130 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
16132 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
16134 write_number(
static_cast<std::uint8_t
>(0xd9));
16135 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
16137 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
16139 write_number(
static_cast<std::uint8_t
>(0xda));
16140 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
16142 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
16144 write_number(
static_cast<std::uint8_t
>(0xdb));
16145 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
16150 const auto N = j.m_data.m_value.binary->size();
16153 write_number(
static_cast<std::uint8_t
>(0x40 + N));
16155 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16157 oa->write_character(to_char_type(0x58));
16158 write_number(
static_cast<std::uint8_t
>(N));
16160 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16162 oa->write_character(to_char_type(0x59));
16163 write_number(
static_cast<std::uint16_t
>(N));
16165 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16167 oa->write_character(to_char_type(0x5A));
16168 write_number(
static_cast<std::uint32_t
>(N));
16171 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16173 oa->write_character(to_char_type(0x5B));
16174 write_number(
static_cast<std::uint64_t
>(N));
16179 oa->write_characters(
16180 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16186 case value_t::object:
16189 const auto N = j.m_data.m_value.object->size();
16192 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
16194 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16196 oa->write_character(to_char_type(0xB8));
16197 write_number(
static_cast<std::uint8_t
>(N));
16199 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16201 oa->write_character(to_char_type(0xB9));
16202 write_number(
static_cast<std::uint16_t
>(N));
16204 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16206 oa->write_character(to_char_type(0xBA));
16207 write_number(
static_cast<std::uint32_t
>(N));
16210 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16212 oa->write_character(to_char_type(0xBB));
16213 write_number(
static_cast<std::uint64_t
>(N));
16218 for (
const auto& el : *j.m_data.m_value.object)
16220 write_cbor(el.first);
16221 write_cbor(el.second);
16226 case value_t::discarded:
16239 case value_t::null:
16241 oa->write_character(to_char_type(0xC0));
16245 case value_t::boolean:
16247 oa->write_character(j.m_data.m_value.boolean
16248 ? to_char_type(0xC3)
16249 : to_char_type(0xC2));
16253 case value_t::number_integer:
16255 if (j.m_data.m_value.number_integer >= 0)
16260 if (j.m_data.m_value.number_unsigned < 128)
16263 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16265 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16268 oa->write_character(to_char_type(0xCC));
16269 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16271 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16274 oa->write_character(to_char_type(0xCD));
16275 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16277 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16280 oa->write_character(to_char_type(0xCE));
16281 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16283 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16286 oa->write_character(to_char_type(0xCF));
16287 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16292 if (j.m_data.m_value.number_integer >= -32)
16295 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16297 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
16298 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16301 oa->write_character(to_char_type(0xD0));
16302 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16304 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
16305 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16308 oa->write_character(to_char_type(0xD1));
16309 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
16311 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
16312 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16315 oa->write_character(to_char_type(0xD2));
16316 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
16318 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
16319 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16322 oa->write_character(to_char_type(0xD3));
16323 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
16329 case value_t::number_unsigned:
16331 if (j.m_data.m_value.number_unsigned < 128)
16334 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16336 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16339 oa->write_character(to_char_type(0xCC));
16340 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16342 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16345 oa->write_character(to_char_type(0xCD));
16346 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16348 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16351 oa->write_character(to_char_type(0xCE));
16352 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16354 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16357 oa->write_character(to_char_type(0xCF));
16358 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16363 case value_t::number_float:
16369 case value_t::string:
16372 const auto N = j.m_data.m_value.string->size();
16376 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
16378 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16381 oa->write_character(to_char_type(0xD9));
16382 write_number(
static_cast<std::uint8_t
>(N));
16384 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16387 oa->write_character(to_char_type(0xDA));
16388 write_number(
static_cast<std::uint16_t
>(N));
16390 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16393 oa->write_character(to_char_type(0xDB));
16394 write_number(
static_cast<std::uint32_t
>(N));
16398 oa->write_characters(
16399 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16400 j.m_data.m_value.string->size());
16404 case value_t::array:
16407 const auto N = j.m_data.m_value.array->size();
16411 write_number(
static_cast<std::uint8_t
>(0x90 | N));
16413 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16416 oa->write_character(to_char_type(0xDC));
16417 write_number(
static_cast<std::uint16_t
>(N));
16419 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16422 oa->write_character(to_char_type(0xDD));
16423 write_number(
static_cast<std::uint32_t
>(N));
16427 for (
const auto& el : *j.m_data.m_value.array)
16434 case value_t::binary:
16438 const bool use_ext = j.m_data.m_value.binary->has_subtype();
16441 const auto N = j.m_data.m_value.binary->size();
16442 if (N <= (std::numeric_limits<std::uint8_t>::max)())
16444 std::uint8_t output_type{};
16451 output_type = 0xD4;
16454 output_type = 0xD5;
16457 output_type = 0xD6;
16460 output_type = 0xD7;
16463 output_type = 0xD8;
16466 output_type = 0xC7;
16474 output_type = 0xC4;
16478 oa->write_character(to_char_type(output_type));
16481 write_number(
static_cast<std::uint8_t
>(N));
16484 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16486 const std::uint8_t output_type = use_ext
16490 oa->write_character(to_char_type(output_type));
16491 write_number(
static_cast<std::uint16_t
>(N));
16493 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16495 const std::uint8_t output_type = use_ext
16499 oa->write_character(to_char_type(output_type));
16500 write_number(
static_cast<std::uint32_t
>(N));
16506 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
16510 oa->write_characters(
16511 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16517 case value_t::object:
16520 const auto N = j.m_data.m_value.object->size();
16524 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
16526 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16529 oa->write_character(to_char_type(0xDE));
16530 write_number(
static_cast<std::uint16_t
>(N));
16532 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16535 oa->write_character(to_char_type(0xDF));
16536 write_number(
static_cast<std::uint32_t
>(N));
16540 for (
const auto& el : *j.m_data.m_value.object)
16542 write_msgpack(el.first);
16543 write_msgpack(el.second);
16548 case value_t::discarded:
16563 const bool use_type,
const bool add_prefix =
true,
16564 const bool use_bjdata =
false,
const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
16566 const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
16570 case value_t::null:
16574 oa->write_character(to_char_type(
'Z'));
16579 case value_t::boolean:
16583 oa->write_character(j.m_data.m_value.boolean
16584 ? to_char_type(
'T')
16585 : to_char_type(
'F'));
16590 case value_t::number_integer:
16592 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16596 case value_t::number_unsigned:
16598 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16602 case value_t::number_float:
16604 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16608 case value_t::string:
16612 oa->write_character(to_char_type(
'S'));
16614 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16615 oa->write_characters(
16616 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16617 j.m_data.m_value.string->size());
16621 case value_t::array:
16625 oa->write_character(to_char_type(
'['));
16628 bool prefix_required =
true;
16629 if (use_type && !j.m_data.m_value.array->empty())
16632 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16633 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16634 [
this, first_prefix, use_bjdata](
const BasicJsonType &
v)
16636 return ubjson_prefix(v, use_bjdata) == first_prefix;
16639 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16641 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16643 prefix_required =
false;
16644 oa->write_character(to_char_type(
'$'));
16645 oa->write_character(first_prefix);
16651 oa->write_character(to_char_type(
'#'));
16652 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16655 for (
const auto& el : *j.m_data.m_value.array)
16657 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16662 oa->write_character(to_char_type(
']'));
16668 case value_t::binary:
16672 oa->write_character(to_char_type(
'['));
16675 if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
16678 oa->write_character(to_char_type(
'$'));
16679 oa->write_character(bjdata_draft3 ?
'B' :
'U');
16684 oa->write_character(to_char_type(
'#'));
16685 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16690 oa->write_characters(
16691 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16692 j.m_data.m_value.binary->size());
16696 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16698 oa->write_character(to_char_type(bjdata_draft3 ?
'B' :
'U'));
16699 oa->write_character(j.m_data.m_value.binary->data()[i]);
16705 oa->write_character(to_char_type(
']'));
16711 case value_t::object:
16713 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())
16715 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version))
16723 oa->write_character(to_char_type(
'{'));
16726 bool prefix_required =
true;
16727 if (use_type && !j.m_data.m_value.object->empty())
16730 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16731 const bool same_prefix = std::all_of(j.begin(), j.end(),
16732 [
this, first_prefix, use_bjdata](
const BasicJsonType &
v)
16734 return ubjson_prefix(v, use_bjdata) == first_prefix;
16737 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16739 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16741 prefix_required =
false;
16742 oa->write_character(to_char_type(
'$'));
16743 oa->write_character(first_prefix);
16749 oa->write_character(to_char_type(
'#'));
16750 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16753 for (
const auto& el : *j.m_data.m_value.object)
16755 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16756 oa->write_characters(
16757 reinterpret_cast<const CharType*
>(el.first.c_str()),
16759 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16764 oa->write_character(to_char_type(
'}'));
16770 case value_t::discarded:
16785 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
16787 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16790 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
16793 static_cast<void>(j);
16794 return 1ul + name.size() + 1u;
16800 void write_bson_entry_header(
const string_t& name,
16801 const std::uint8_t element_type)
16803 oa->write_character(to_char_type(element_type));
16804 oa->write_characters(
16805 reinterpret_cast<const CharType*
>(
name.c_str()),
16812 void write_bson_boolean(
const string_t& name,
16815 write_bson_entry_header(name, 0x08);
16816 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
16822 void write_bson_double(
const string_t& name,
16823 const double value)
16825 write_bson_entry_header(name, 0x01);
16826 write_number<double>(value,
true);
16832 static std::size_t calc_bson_string_size(
const string_t& value)
16834 return sizeof(std::int32_t) +
value.size() + 1ul;
16840 void write_bson_string(
const string_t& name,
16843 write_bson_entry_header(name, 0x02);
16845 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16846 oa->write_characters(
16847 reinterpret_cast<const CharType*
>(
value.c_str()),
16854 void write_bson_null(
const string_t& name)
16856 write_bson_entry_header(name, 0x0A);
16862 static std::size_t calc_bson_integer_size(
const std::int64_t value)
16864 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
16865 ?
sizeof(std::int32_t)
16866 :
sizeof(std::int64_t);
16872 void write_bson_integer(
const string_t& name,
16873 const std::int64_t value)
16875 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16877 write_bson_entry_header(name, 0x10);
16878 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16882 write_bson_entry_header(name, 0x12);
16883 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16890 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
16892 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16893 ?
sizeof(std::int32_t)
16894 : sizeof(
std::int64_t);
16900 void write_bson_unsigned(
const string_t& name,
16901 const BasicJsonType& j)
16903 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16905 write_bson_entry_header(name, 0x10 );
16906 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16908 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16910 write_bson_entry_header(name, 0x12 );
16911 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16915 write_bson_entry_header(name, 0x11 );
16916 write_number<std::uint64_t>(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned),
true);
16923 void write_bson_object_entry(
const string_t& name,
16924 const typename BasicJsonType::object_t& value)
16926 write_bson_entry_header(name, 0x03);
16927 write_bson_object(value);
16933 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16935 std::size_t array_index = 0ul;
16937 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)
16939 return result + calc_bson_element_size(std::to_string(array_index++), el);
16942 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16948 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16950 return sizeof(std::int32_t) +
value.size() + 1ul;
16956 void write_bson_array(
const string_t& name,
16957 const typename BasicJsonType::array_t& value)
16959 write_bson_entry_header(name, 0x04);
16960 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16962 std::size_t array_index = 0ul;
16964 for (
const auto& el : value)
16966 write_bson_element(std::to_string(array_index++), el);
16969 oa->write_character(to_char_type(0x00));
16975 void write_bson_binary(
const string_t& name,
16978 write_bson_entry_header(name, 0x05);
16980 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16981 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16983 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16990 static std::size_t calc_bson_element_size(
const string_t& name,
16991 const BasicJsonType& j)
16993 const auto header_size = calc_bson_entry_header_size(name, j);
16996 case value_t::object:
16997 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16999 case value_t::array:
17000 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
17002 case value_t::binary:
17003 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
17005 case value_t::boolean:
17006 return header_size + 1ul;
17008 case value_t::number_float:
17009 return header_size + 8ul;
17011 case value_t::number_integer:
17012 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
17014 case value_t::number_unsigned:
17015 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
17017 case value_t::string:
17018 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
17020 case value_t::null:
17021 return header_size + 0ul;
17024 case value_t::discarded:
17038 void write_bson_element(
const string_t& name,
17039 const BasicJsonType& j)
17043 case value_t::object:
17044 return write_bson_object_entry(name, *j.m_data.m_value.object);
17046 case value_t::array:
17047 return write_bson_array(name, *j.m_data.m_value.array);
17049 case value_t::binary:
17050 return write_bson_binary(name, *j.m_data.m_value.binary);
17052 case value_t::boolean:
17053 return write_bson_boolean(name, j.m_data.m_value.boolean);
17055 case value_t::number_float:
17056 return write_bson_double(name, j.m_data.m_value.number_float);
17058 case value_t::number_integer:
17059 return write_bson_integer(name, j.m_data.m_value.number_integer);
17061 case value_t::number_unsigned:
17062 return write_bson_unsigned(name, j);
17064 case value_t::string:
17065 return write_bson_string(name, *j.m_data.m_value.string);
17067 case value_t::null:
17068 return write_bson_null(name);
17071 case value_t::discarded:
17085 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
17087 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
17088 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
17090 return result += calc_bson_element_size(el.first, el.second);
17093 return sizeof(std::int32_t) + document_size + 1ul;
17100 void write_bson_object(
const typename BasicJsonType::object_t& value)
17102 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
17104 for (
const auto& el : value)
17106 write_bson_element(el.first, el.second);
17109 oa->write_character(to_char_type(0x00));
17116 static constexpr CharType get_cbor_float_prefix(
float )
17118 return to_char_type(0xFA);
17121 static constexpr CharType get_cbor_float_prefix(
double )
17123 return to_char_type(0xFB);
17130 static constexpr CharType get_msgpack_float_prefix(
float )
17132 return to_char_type(0xCA);
17135 static constexpr CharType get_msgpack_float_prefix(
double )
17137 return to_char_type(0xCB);
17145 template<
typename NumberType,
typename std::enable_if<
17146 std::is_floating_point<NumberType>::value,
int>::type = 0>
17147 void write_number_with_ubjson_prefix(
const NumberType
n,
17148 const bool add_prefix,
17149 const bool use_bjdata)
17153 oa->write_character(get_ubjson_float_prefix(
n));
17155 write_number(
n, use_bjdata);
17159 template<
typename NumberType,
typename std::enable_if<
17160 std::is_unsigned<NumberType>::value,
int>::type = 0>
17161 void write_number_with_ubjson_prefix(
const NumberType
n,
17162 const bool add_prefix,
17163 const bool use_bjdata)
17165 if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17169 oa->write_character(to_char_type(
'i'));
17171 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
17173 else if (
n <= (std::numeric_limits<std::uint8_t>::max)())
17177 oa->write_character(to_char_type(
'U'));
17179 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
17181 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17185 oa->write_character(to_char_type(
'I'));
17187 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
17189 else if (use_bjdata &&
n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
17193 oa->write_character(to_char_type(
'u'));
17195 write_number(
static_cast<std::uint16_t
>(
n), use_bjdata);
17197 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17201 oa->write_character(to_char_type(
'l'));
17203 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
17205 else if (use_bjdata &&
n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
17209 oa->write_character(to_char_type(
'm'));
17211 write_number(
static_cast<std::uint32_t
>(
n), use_bjdata);
17213 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17217 oa->write_character(to_char_type(
'L'));
17219 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
17221 else if (use_bjdata &&
n <= (std::numeric_limits<uint64_t>::max)())
17225 oa->write_character(to_char_type(
'M'));
17227 write_number(
static_cast<std::uint64_t
>(
n), use_bjdata);
17233 oa->write_character(to_char_type(
'H'));
17236 const auto number = BasicJsonType(
n).dump();
17237 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17238 for (std::size_t i = 0; i < number.size(); ++i)
17240 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17246 template <
typename NumberType,
typename std::enable_if <
17247 std::is_signed<NumberType>::value&&
17248 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
17249 void write_number_with_ubjson_prefix(
const NumberType
n,
17250 const bool add_prefix,
17251 const bool use_bjdata)
17253 if ((std::numeric_limits<std::int8_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int8_t>::max)())
17257 oa->write_character(to_char_type(
'i'));
17259 write_number(
static_cast<std::int8_t
>(
n), use_bjdata);
17261 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)()))
17265 oa->write_character(to_char_type(
'U'));
17267 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
17269 else if ((std::numeric_limits<std::int16_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int16_t>::max)())
17273 oa->write_character(to_char_type(
'I'));
17275 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
17277 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)())))
17281 oa->write_character(to_char_type(
'u'));
17283 write_number(
static_cast<uint16_t
>(
n), use_bjdata);
17285 else if ((std::numeric_limits<std::int32_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int32_t>::max)())
17289 oa->write_character(to_char_type(
'l'));
17291 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
17293 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)())))
17297 oa->write_character(to_char_type(
'm'));
17299 write_number(
static_cast<uint32_t
>(
n), use_bjdata);
17301 else if ((std::numeric_limits<std::int64_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int64_t>::max)())
17305 oa->write_character(to_char_type(
'L'));
17307 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
17314 oa->write_character(to_char_type(
'H'));
17317 const auto number = BasicJsonType(
n).dump();
17318 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17319 for (std::size_t i = 0; i < number.size(); ++i)
17321 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17330 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
17334 case value_t::null:
17337 case value_t::boolean:
17338 return j.m_data.m_value.boolean ?
'T' :
'F';
17340 case value_t::number_integer:
17342 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)())
17346 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)())
17350 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)())
17354 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)()))
17358 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)())
17362 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)()))
17366 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)())
17374 case value_t::number_unsigned:
17376 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17380 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17384 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17388 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
17392 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17396 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
17400 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17404 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
17412 case value_t::number_float:
17413 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
17415 case value_t::string:
17418 case value_t::array:
17419 case value_t::binary:
17422 case value_t::object:
17425 case value_t::discarded:
17431 static constexpr CharType get_ubjson_float_prefix(
float )
17436 static constexpr CharType get_ubjson_float_prefix(
double )
17444 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type,
const bjdata_version_t bjdata_version)
17446 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
17447 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'},
17448 {
"char",
'C'}, {
"byte",
'B'}
17453 if (it == bjdtype.end())
17457 CharType dtype = it->second;
17459 key =
"_ArraySize_";
17460 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
17461 for (
const auto& el :
value.at(
key))
17463 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
17466 key =
"_ArrayData_";
17472 oa->write_character(
'[');
17473 oa->write_character(
'$');
17474 oa->write_character(dtype);
17475 oa->write_character(
'#');
17477 key =
"_ArraySize_";
17478 write_ubjson(
value.at(
key), use_count, use_type,
true,
true, bjdata_version);
17480 key =
"_ArrayData_";
17481 if (dtype ==
'U' || dtype ==
'C' || dtype ==
'B')
17483 for (
const auto& el :
value.at(
key))
17485 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
17488 else if (dtype ==
'i')
17490 for (
const auto& el :
value.at(
key))
17492 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
17495 else if (dtype ==
'u')
17497 for (
const auto& el :
value.at(
key))
17499 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
17502 else if (dtype ==
'I')
17504 for (
const auto& el :
value.at(
key))
17506 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
17509 else if (dtype ==
'm')
17511 for (
const auto& el :
value.at(
key))
17513 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
17516 else if (dtype ==
'l')
17518 for (
const auto& el :
value.at(
key))
17520 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
17523 else if (dtype ==
'M')
17525 for (
const auto& el :
value.at(
key))
17527 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
17530 else if (dtype ==
'L')
17532 for (
const auto& el :
value.at(
key))
17534 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
17537 else if (dtype ==
'd')
17539 for (
const auto& el :
value.at(
key))
17541 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
17544 else if (dtype ==
'D')
17546 for (
const auto& el :
value.at(
key))
17548 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
17571 template<
typename NumberType>
17572 void write_number(
const NumberType
n,
const bool OutputIsLittleEndian =
false)
17575 std::array<CharType,
sizeof(NumberType)> vec{};
17576 std::memcpy(vec.data(), &
n,
sizeof(NumberType));
17579 if (is_little_endian != OutputIsLittleEndian)
17582 std::reverse(vec.begin(), vec.end());
17585 oa->write_characters(vec.data(),
sizeof(NumberType));
17591#pragma GCC diagnostic push
17592#pragma GCC diagnostic ignored "-Wfloat-equal"
17594 if (
static_cast<double>(
n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17595 static_cast<double>(
n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17596 static_cast<double>(
static_cast<float>(
n)) ==
static_cast<double>(
n))
17599 ? get_cbor_float_prefix(
static_cast<float>(
n))
17600 : get_msgpack_float_prefix(
static_cast<float>(
n)));
17601 write_number(
static_cast<float>(
n));
17606 ? get_cbor_float_prefix(
n)
17607 : get_msgpack_float_prefix(
n));
17611#pragma GCC diagnostic pop
17620 template <
typename C = CharType,
17621 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
17624 return *
reinterpret_cast<char*
>(&x);
17627 template <
typename C = CharType,
17628 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
17638#ifdef JSON_HAS_CPP_26
17639 static_assert(std::is_trivially_copyable<CharType>::value,
"CharType must be trivially copyable");
17640 static_assert(std::is_trivially_default_constructible<CharType>::value,
"CharType must be trivially default constructible");
17642 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
17645 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17647 std::memcpy(&result, &x,
sizeof(x));
17651 template<
typename C = CharType,
17658 template <
typename InputCharType,
typename C = CharType,
17660 std::is_signed<C>::value &&
17661 std::is_signed<char>::value &&
17662 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
17694#include <algorithm>
17704#include <type_traits>
17724#include <type_traits>
17755template<
typename Target,
typename Source>
17758 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17761 std::memcpy(&target, &source,
sizeof(Source));
17767 static constexpr int kPrecision = 64;
17769 std::uint64_t f = 0;
17772 constexpr diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
17783 return {x.f - y.f, x.e};
17792 static_assert(kPrecision == 64,
"internal error");
17817 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17818 const std::uint64_t u_hi = x.f >> 32u;
17819 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17820 const std::uint64_t v_hi = y.f >> 32u;
17822 const std::uint64_t p0 = u_lo * v_lo;
17823 const std::uint64_t
p1 = u_lo * v_hi;
17824 const std::uint64_t
p2 = u_hi * v_lo;
17825 const std::uint64_t p3 = u_hi * v_hi;
17827 const std::uint64_t p0_hi = p0 >> 32u;
17828 const std::uint64_t p1_lo =
p1 & 0xFFFFFFFFu;
17829 const std::uint64_t p1_hi =
p1 >> 32u;
17830 const std::uint64_t p2_lo =
p2 & 0xFFFFFFFFu;
17831 const std::uint64_t p2_hi =
p2 >> 32u;
17833 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17844 Q += std::uint64_t{1} << (64u - 32u - 1u);
17846 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17848 return {h, x.e + y.e + 64};
17859 while ((x.f >> 63u) == 0)
17874 const int delta = x.e - target_exponent;
17879 return {x.f << delta, target_exponent};
17896template<
typename FloatType>
17909 static_assert(std::numeric_limits<FloatType>::is_iec559,
17910 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17912 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17913 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17914 constexpr int kMinExp = 1 - kBias;
17915 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17917 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17919 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
17920 const std::uint64_t
E = bits >> (kPrecision - 1);
17921 const std::uint64_t F = bits & (kHiddenBit - 1);
17923 const bool is_denormal =
E == 0;
17924 const diyfp v = is_denormal
17925 ?
diyfp(F, kMinExp)
17926 :
diyfp(F + kHiddenBit,
static_cast<int>(
E) - kBias);
17949 const bool lower_boundary_is_closer = F == 0 &&
E > 1;
17951 const diyfp m_minus = lower_boundary_is_closer
17952 ?
diyfp((4 *
v.f) - 1,
v.e - 2)
17953 :
diyfp((2 *
v.f) - 1,
v.e - 1);
17956 const diyfp w_plus = diyfp::normalize(m_plus);
17959 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
17961 return {diyfp::normalize(
v), w_minus, w_plus};
18088 constexpr int kCachedPowersMinDecExp = -300;
18089 constexpr int kCachedPowersDecStep = 8;
18091 static constexpr std::array<cached_power, 79> kCachedPowers =
18094 { 0xAB70FE17C79AC6CA, -1060, -300 },
18095 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
18096 { 0xBE5691EF416BD60C, -1007, -284 },
18097 { 0x8DD01FAD907FFC3C, -980, -276 },
18098 { 0xD3515C2831559A83, -954, -268 },
18099 { 0x9D71AC8FADA6C9B5, -927, -260 },
18100 { 0xEA9C227723EE8BCB, -901, -252 },
18101 { 0xAECC49914078536D, -874, -244 },
18102 { 0x823C12795DB6CE57, -847, -236 },
18103 { 0xC21094364DFB5637, -821, -228 },
18104 { 0x9096EA6F3848984F, -794, -220 },
18105 { 0xD77485CB25823AC7, -768, -212 },
18106 { 0xA086CFCD97BF97F4, -741, -204 },
18107 { 0xEF340A98172AACE5, -715, -196 },
18108 { 0xB23867FB2A35B28E, -688, -188 },
18109 { 0x84C8D4DFD2C63F3B, -661, -180 },
18110 { 0xC5DD44271AD3CDBA, -635, -172 },
18111 { 0x936B9FCEBB25C996, -608, -164 },
18112 { 0xDBAC6C247D62A584, -582, -156 },
18113 { 0xA3AB66580D5FDAF6, -555, -148 },
18114 { 0xF3E2F893DEC3F126, -529, -140 },
18115 { 0xB5B5ADA8AAFF80B8, -502, -132 },
18116 { 0x87625F056C7C4A8B, -475, -124 },
18117 { 0xC9BCFF6034C13053, -449, -116 },
18118 { 0x964E858C91BA2655, -422, -108 },
18119 { 0xDFF9772470297EBD, -396, -100 },
18120 { 0xA6DFBD9FB8E5B88F, -369, -92 },
18121 { 0xF8A95FCF88747D94, -343, -84 },
18122 { 0xB94470938FA89BCF, -316, -76 },
18123 { 0x8A08F0F8BF0F156B, -289, -68 },
18124 { 0xCDB02555653131B6, -263, -60 },
18125 { 0x993FE2C6D07B7FAC, -236, -52 },
18126 { 0xE45C10C42A2B3B06, -210, -44 },
18127 { 0xAA242499697392D3, -183, -36 },
18128 { 0xFD87B5F28300CA0E, -157, -28 },
18129 { 0xBCE5086492111AEB, -130, -20 },
18130 { 0x8CBCCC096F5088CC, -103, -12 },
18131 { 0xD1B71758E219652C, -77, -4 },
18132 { 0x9C40000000000000, -50, 4 },
18133 { 0xE8D4A51000000000, -24, 12 },
18134 { 0xAD78EBC5AC620000, 3, 20 },
18135 { 0x813F3978F8940984, 30, 28 },
18136 { 0xC097CE7BC90715B3, 56, 36 },
18137 { 0x8F7E32CE7BEA5C70, 83, 44 },
18138 { 0xD5D238A4ABE98068, 109, 52 },
18139 { 0x9F4F2726179A2245, 136, 60 },
18140 { 0xED63A231D4C4FB27, 162, 68 },
18141 { 0xB0DE65388CC8ADA8, 189, 76 },
18142 { 0x83C7088E1AAB65DB, 216, 84 },
18143 { 0xC45D1DF942711D9A, 242, 92 },
18144 { 0x924D692CA61BE758, 269, 100 },
18145 { 0xDA01EE641A708DEA, 295, 108 },
18146 { 0xA26DA3999AEF774A, 322, 116 },
18147 { 0xF209787BB47D6B85, 348, 124 },
18148 { 0xB454E4A179DD1877, 375, 132 },
18149 { 0x865B86925B9BC5C2, 402, 140 },
18150 { 0xC83553C5C8965D3D, 428, 148 },
18151 { 0x952AB45CFA97A0B3, 455, 156 },
18152 { 0xDE469FBD99A05FE3, 481, 164 },
18153 { 0xA59BC234DB398C25, 508, 172 },
18154 { 0xF6C69A72A3989F5C, 534, 180 },
18155 { 0xB7DCBF5354E9BECE, 561, 188 },
18156 { 0x88FCF317F22241E2, 588, 196 },
18157 { 0xCC20CE9BD35C78A5, 614, 204 },
18158 { 0x98165AF37B2153DF, 641, 212 },
18159 { 0xE2A0B5DC971F303A, 667, 220 },
18160 { 0xA8D9D1535CE3B396, 694, 228 },
18161 { 0xFB9B7CD9A4A7443C, 720, 236 },
18162 { 0xBB764C4CA7A44410, 747, 244 },
18163 { 0x8BAB8EEFB6409C1A, 774, 252 },
18164 { 0xD01FEF10A657842C, 800, 260 },
18165 { 0x9B10A4E5E9913129, 827, 268 },
18166 { 0xE7109BFBA19C0C9D, 853, 276 },
18167 { 0xAC2820D9623BF429, 880, 284 },
18168 { 0x80444B5E7AA7CF85, 907, 292 },
18169 { 0xBF21E44003ACDD2D, 933, 300 },
18170 { 0x8E679C2F5E44FF8F, 960, 308 },
18171 { 0xD433179D9C8CB841, 986, 316 },
18172 { 0x9E19DB92B4E31BA9, 1013, 324 },
18182 const int f =
kAlpha - e - 1;
18183 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
18185 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
18187 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
18189 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
18203 if (
n >= 1000000000)
18205 pow10 = 1000000000;
18209 if (
n >= 100000000)
18254inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
18255 std::uint64_t rest, std::uint64_t ten_k)
18282 && delta - rest >= ten_k
18283 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
18298 static_assert(
kAlpha >= -60,
"internal error");
18299 static_assert(
kGamma <= -32,
"internal error");
18316 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
18317 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
18326 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
18328 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
18329 std::uint64_t
p2 = M_plus.
f & (one.f - 1);
18337 std::uint32_t pow10{};
18365 const std::uint32_t d =
p1 / pow10;
18366 const std::uint32_t r =
p1 % pow10;
18372 buffer[length++] =
static_cast<char>(
'0' + d);
18391 const std::uint64_t rest = (std::uint64_t{
p1} << -one.e) +
p2;
18396 decimal_exponent +=
n;
18407 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
18408 grisu2_round(buffer, length, dist, delta, rest, ten_n);
18469 JSON_ASSERT(
p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
18471 const std::uint64_t d =
p2 >> -one.e;
18472 const std::uint64_t r =
p2 & (one.f - 1);
18479 buffer[length++] =
static_cast<char>(
'0' + d);
18504 decimal_exponent -= m;
18512 const std::uint64_t ten_m = one.f;
18536inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
18553 const diyfp c_minus_k(cached.
f, cached.
e);
18556 const diyfp w = diyfp::mul(
v, c_minus_k);
18557 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
18558 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
18581 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
18582 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
18584 decimal_exponent = -cached.
k;
18594template<
typename FloatType>
18596void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
18598 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
18599 "internal error: not enough precision");
18636inline
char* append_exponent(
char* buf,
int e)
18651 auto k =
static_cast<std::uint32_t
>(e);
18657 *buf++ =
static_cast<char>(
'0' + k);
18661 *buf++ =
static_cast<char>(
'0' + (k / 10));
18663 *buf++ =
static_cast<char>(
'0' + k);
18667 *buf++ =
static_cast<char>(
'0' + (k / 100));
18669 *buf++ =
static_cast<char>(
'0' + (k / 10));
18671 *buf++ =
static_cast<char>(
'0' + k);
18688inline
char* format_buffer(
char* buf,
int len,
int decimal_exponent,
18689 int min_exp,
int max_exp)
18695 const int n = len + decimal_exponent;
18701 if (k <=
n &&
n <= max_exp)
18706 std::memset(buf + k,
'0',
static_cast<size_t>(
n) -
static_cast<size_t>(k));
18710 return buf + (
static_cast<size_t>(
n) + 2);
18713 if (0 <
n &&
n <= max_exp)
18720 std::memmove(buf + (
static_cast<size_t>(
n) + 1), buf +
n,
static_cast<size_t>(k) -
static_cast<size_t>(
n));
18722 return buf + (
static_cast<size_t>(k) + 1U);
18725 if (min_exp <
n &&
n <= 0)
18730 std::memmove(buf + (2 +
static_cast<size_t>(-
n)), buf,
static_cast<size_t>(k));
18733 std::memset(buf + 2,
'0',
static_cast<size_t>(-
n));
18734 return buf + (2U +
static_cast<size_t>(-
n) +
static_cast<size_t>(k));
18749 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18751 buf += 1 +
static_cast<size_t>(k);
18770template<
typename FloatType>
18773char* to_chars(
char* first, const
char* last, FloatType value)
18775 static_cast<void>(last);
18779 if (std::signbit(
value))
18786#pragma GCC diagnostic push
18787#pragma GCC diagnostic ignored "-Wfloat-equal"
18798#pragma GCC diagnostic pop
18801 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18808 int decimal_exponent = 0;
18809 dtoa_impl::grisu2(first, len, decimal_exponent,
value);
18811 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18814 constexpr int kMinExp = -4;
18816 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18819 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18820 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18822 return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
18859template<
typename BasicJsonType>
18862 using string_t =
typename BasicJsonType::string_t;
18863 using number_float_t =
typename BasicJsonType::number_float_t;
18864 using number_integer_t =
typename BasicJsonType::number_integer_t;
18865 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18866 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
18867 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18868 static constexpr std::uint8_t UTF8_REJECT = 1;
18879 , loc(
std::localeconv())
18880 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->thousands_sep)))
18881 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->decimal_point)))
18882 , indent_char(ichar)
18883 , indent_string(512, indent_char)
18884 , error_handler(error_handler_)
18917 const bool pretty_print,
18918 const bool ensure_ascii,
18919 const unsigned int indent_step,
18920 const unsigned int current_indent = 0)
18922 switch (val.m_data.m_type)
18924 case value_t::object:
18926 if (val.m_data.m_value.object->empty())
18928 o->write_characters(
"{}", 2);
18934 o->write_characters(
"{\n", 2);
18937 const auto new_indent = current_indent + indent_step;
18940 indent_string.resize(indent_string.size() * 2,
' ');
18944 auto i = val.m_data.m_value.object->cbegin();
18945 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18947 o->write_characters(indent_string.c_str(), new_indent);
18948 o->write_character(
'\"');
18949 dump_escaped(i->first, ensure_ascii);
18950 o->write_characters(
"\": ", 3);
18951 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18952 o->write_characters(
",\n", 2);
18956 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18957 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18958 o->write_characters(indent_string.c_str(), new_indent);
18959 o->write_character(
'\"');
18960 dump_escaped(i->first, ensure_ascii);
18961 o->write_characters(
"\": ", 3);
18962 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18964 o->write_character(
'\n');
18965 o->write_characters(indent_string.c_str(), current_indent);
18966 o->write_character(
'}');
18970 o->write_character(
'{');
18973 auto i = val.m_data.m_value.object->cbegin();
18974 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18976 o->write_character(
'\"');
18977 dump_escaped(i->first, ensure_ascii);
18978 o->write_characters(
"\":", 2);
18979 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18980 o->write_character(
',');
18984 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18985 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18986 o->write_character(
'\"');
18987 dump_escaped(i->first, ensure_ascii);
18988 o->write_characters(
"\":", 2);
18989 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18991 o->write_character(
'}');
18997 case value_t::array:
18999 if (val.m_data.m_value.array->empty())
19001 o->write_characters(
"[]", 2);
19007 o->write_characters(
"[\n", 2);
19010 const auto new_indent = current_indent + indent_step;
19013 indent_string.resize(indent_string.size() * 2,
' ');
19017 for (
auto i = val.m_data.m_value.array->cbegin();
19018 i != val.m_data.m_value.array->cend() - 1; ++i)
19020 o->write_characters(indent_string.c_str(), new_indent);
19021 dump(*i,
true, ensure_ascii, indent_step, new_indent);
19022 o->write_characters(
",\n", 2);
19027 o->write_characters(indent_string.c_str(), new_indent);
19028 dump(val.m_data.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
19030 o->write_character(
'\n');
19031 o->write_characters(indent_string.c_str(), current_indent);
19032 o->write_character(
']');
19036 o->write_character(
'[');
19039 for (
auto i = val.m_data.m_value.array->cbegin();
19040 i != val.m_data.m_value.array->cend() - 1; ++i)
19042 dump(*i,
false, ensure_ascii, indent_step, current_indent);
19043 o->write_character(
',');
19048 dump(val.m_data.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
19050 o->write_character(
']');
19056 case value_t::string:
19058 o->write_character(
'\"');
19059 dump_escaped(*val.m_data.m_value.string, ensure_ascii);
19060 o->write_character(
'\"');
19064 case value_t::binary:
19068 o->write_characters(
"{\n", 2);
19071 const auto new_indent = current_indent + indent_step;
19074 indent_string.resize(indent_string.size() * 2,
' ');
19077 o->write_characters(indent_string.c_str(), new_indent);
19079 o->write_characters(
"\"bytes\": [", 10);
19081 if (!val.m_data.m_value.binary->empty())
19083 for (
auto i = val.m_data.m_value.binary->cbegin();
19084 i != val.m_data.m_value.binary->cend() - 1; ++i)
19087 o->write_characters(
", ", 2);
19089 dump_integer(val.m_data.m_value.binary->back());
19092 o->write_characters(
"],\n", 3);
19093 o->write_characters(indent_string.c_str(), new_indent);
19095 o->write_characters(
"\"subtype\": ", 11);
19096 if (val.m_data.m_value.binary->has_subtype())
19098 dump_integer(val.m_data.m_value.binary->subtype());
19102 o->write_characters(
"null", 4);
19104 o->write_character(
'\n');
19105 o->write_characters(indent_string.c_str(), current_indent);
19106 o->write_character(
'}');
19110 o->write_characters(
"{\"bytes\":[", 10);
19112 if (!val.m_data.m_value.binary->empty())
19114 for (
auto i = val.m_data.m_value.binary->cbegin();
19115 i != val.m_data.m_value.binary->cend() - 1; ++i)
19118 o->write_character(
',');
19120 dump_integer(val.m_data.m_value.binary->back());
19123 o->write_characters(
"],\"subtype\":", 12);
19124 if (val.m_data.m_value.binary->has_subtype())
19126 dump_integer(val.m_data.m_value.binary->subtype());
19127 o->write_character(
'}');
19131 o->write_characters(
"null}", 5);
19137 case value_t::boolean:
19139 if (val.m_data.m_value.boolean)
19141 o->write_characters(
"true", 4);
19145 o->write_characters(
"false", 5);
19150 case value_t::number_integer:
19152 dump_integer(val.m_data.m_value.number_integer);
19156 case value_t::number_unsigned:
19158 dump_integer(val.m_data.m_value.number_unsigned);
19162 case value_t::number_float:
19164 dump_float(val.m_data.m_value.number_float);
19168 case value_t::discarded:
19170 o->write_characters(
"<discarded>", 11);
19174 case value_t::null:
19176 o->write_characters(
"null", 4);
19200 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
19202 std::uint32_t codepoint{};
19203 std::uint8_t state = UTF8_ACCEPT;
19204 std::size_t bytes = 0;
19207 std::size_t bytes_after_last_accept = 0;
19208 std::size_t undumped_chars = 0;
19210 for (std::size_t i = 0; i < s.size(); ++i)
19212 const auto byte =
static_cast<std::uint8_t
>(s[i]);
19214 switch (decode(state, codepoint,
byte))
19222 string_buffer[bytes++] =
'\\';
19223 string_buffer[bytes++] =
'b';
19229 string_buffer[bytes++] =
'\\';
19230 string_buffer[bytes++] =
't';
19236 string_buffer[bytes++] =
'\\';
19237 string_buffer[bytes++] =
'n';
19243 string_buffer[bytes++] =
'\\';
19244 string_buffer[bytes++] =
'f';
19250 string_buffer[bytes++] =
'\\';
19251 string_buffer[bytes++] =
'r';
19257 string_buffer[bytes++] =
'\\';
19258 string_buffer[bytes++] =
'\"';
19264 string_buffer[bytes++] =
'\\';
19265 string_buffer[bytes++] =
'\\';
19273 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
19275 if (codepoint <= 0xFFFF)
19278 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
19279 static_cast<std::uint16_t
>(codepoint)));
19285 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
19286 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
19287 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
19295 string_buffer[bytes++] = s[i];
19304 if (string_buffer.size() - bytes < 13)
19306 o->write_characters(string_buffer.data(), bytes);
19311 bytes_after_last_accept = bytes;
19312 undumped_chars = 0;
19318 switch (error_handler)
19320 case error_handler_t::strict:
19322 JSON_THROW(type_error::create(316,
concat(
"invalid UTF-8 byte at index ", std::to_string(i),
": 0x", hex_bytes(
byte | 0)),
nullptr));
19325 case error_handler_t::ignore:
19326 case error_handler_t::replace:
19332 if (undumped_chars > 0)
19339 bytes = bytes_after_last_accept;
19341 if (error_handler == error_handler_t::replace)
19346 string_buffer[bytes++] =
'\\';
19347 string_buffer[bytes++] =
'u';
19348 string_buffer[bytes++] =
'f';
19349 string_buffer[bytes++] =
'f';
19350 string_buffer[bytes++] =
'f';
19351 string_buffer[bytes++] =
'd';
19363 if (string_buffer.size() - bytes < 13)
19365 o->write_characters(string_buffer.data(), bytes);
19369 bytes_after_last_accept = bytes;
19372 undumped_chars = 0;
19375 state = UTF8_ACCEPT;
19390 string_buffer[bytes++] = s[i];
19404 o->write_characters(string_buffer.data(), bytes);
19410 switch (error_handler)
19412 case error_handler_t::strict:
19414 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));
19417 case error_handler_t::ignore:
19420 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19424 case error_handler_t::replace:
19427 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19431 o->write_characters(
"\\ufffd", 6);
19435 o->write_characters(
"\xEF\xBF\xBD", 3);
19455 unsigned int count_digits(number_unsigned_t x)
noexcept
19457 unsigned int n_digits = 1;
19466 return n_digits + 1;
19470 return n_digits + 2;
19474 return n_digits + 3;
19486 static std::string hex_bytes(std::uint8_t
byte)
19488 std::string result =
"FF";
19489 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
19490 result[0] = nibble_to_hex[
byte / 16];
19491 result[1] = nibble_to_hex[
byte % 16];
19496 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
19497 bool is_negative_number(NumberType x)
19502 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
19503 bool is_negative_number(NumberType )
19518 std::is_integral<NumberType>::value ||
19519 std::is_same<NumberType, number_unsigned_t>::value ||
19520 std::is_same<NumberType, number_integer_t>::value ||
19521 std::is_same<NumberType, binary_char_t>::value,
19523 void dump_integer(NumberType x)
19525 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
19528 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
19529 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
19530 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
19531 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
19532 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
19533 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
19534 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
19535 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
19536 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
19537 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
19544 o->write_character(
'0');
19549 auto buffer_ptr = number_buffer.begin();
19551 number_unsigned_t abs_value;
19553 unsigned int n_chars{};
19555 if (is_negative_number(x))
19558 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
19561 n_chars = 1 + count_digits(abs_value);
19565 abs_value =
static_cast<number_unsigned_t
>(x);
19566 n_chars = count_digits(abs_value);
19574 buffer_ptr +=
static_cast<typename decltype(number_buffer)::difference_type
>(n_chars);
19578 while (abs_value >= 100)
19580 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
19582 *(--buffer_ptr) = digits_to_99[digits_index][1];
19583 *(--buffer_ptr) = digits_to_99[digits_index][0];
19586 if (abs_value >= 10)
19588 const auto digits_index =
static_cast<unsigned>(abs_value);
19589 *(--buffer_ptr) = digits_to_99[digits_index][1];
19590 *(--buffer_ptr) = digits_to_99[digits_index][0];
19594 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19597 o->write_characters(number_buffer.data(), n_chars);
19608 void dump_float(number_float_t x)
19611 if (!std::isfinite(x))
19613 o->write_characters(
"null", 4);
19622 static constexpr bool is_ieee_single_or_double
19623 = (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) ||
19624 (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);
19626 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
19629 void dump_float(number_float_t x, std::true_type )
19631 auto* begin = number_buffer.data();
19632 auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
19634 o->write_characters(begin,
static_cast<size_t>(end - begin));
19637 void dump_float(number_float_t x, std::false_type )
19640 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
19644 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
19649 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
19652 if (thousands_sep !=
'\0')
19655 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
19656 std::fill(end, number_buffer.end(),
'\0');
19657 JSON_ASSERT((end - number_buffer.begin()) <= len);
19658 len = (end - number_buffer.begin());
19662 if (decimal_point !=
'\0' && decimal_point !=
'.')
19665 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
19666 if (dec_pos != number_buffer.end())
19672 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
19675 const bool value_is_int_like =
19676 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
19679 return c ==
'.' || c ==
'e';
19682 if (value_is_int_like)
19684 o->write_characters(
".0", 2);
19709 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19711 static const std::array<std::uint8_t, 400> utf8d =
19714 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,
19715 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,
19716 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,
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 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,
19719 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,
19720 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,
19721 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19722 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19723 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19724 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,
19725 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,
19726 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,
19727 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
19732 const std::uint8_t type = utf8d[byte];
19734 codep = (state != UTF8_ACCEPT)
19735 ? (
byte & 0x3fu) | (codep << 6u)
19736 : (0xFFu >> type) & (byte);
19738 const std::size_t index = 256u + (
static_cast<size_t>(state) * 16u) +
static_cast<size_t>(type);
19740 state = utf8d[index];
19749 number_unsigned_t remove_sign(number_unsigned_t x)
19764 number_unsigned_t remove_sign(number_integer_t x)
noexcept
19766 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19767 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
19772 output_adapter_t<char> o =
nullptr;
19775 std::array<char, 64> number_buffer{{}};
19778 const std::lconv* loc =
nullptr;
19780 const char thousands_sep =
'\0';
19782 const char decimal_point =
'\0';
19785 std::array<char, 512> string_buffer{{}};
19814#include <functional>
19815#include <initializer_list>
19818#include <stdexcept>
19819#include <type_traits>
19832template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19833 class Allocator = std::allocator<std::pair<const Key, T>>>
19838 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19843#ifdef JSON_HAS_CPP_14
19853 template <
class It>
19856 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19861 for (
auto it = this->begin(); it != this->end(); ++it)
19863 if (m_compare(it->first, key))
19865 return {it,
false};
19868 Container::emplace_back(key, std::forward<T>(t));
19869 return {std::prev(this->end()),
true};
19874 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19876 for (
auto it = this->begin(); it != this->end(); ++it)
19878 if (m_compare(it->first, key))
19880 return {it,
false};
19883 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19884 return {std::prev(this->end()),
true};
19889 return emplace(key, T{}).first->second;
19896 return emplace(std::forward<KeyType>(key), T{}).first->second;
19908 return at(std::forward<KeyType>(key));
19913 for (
auto it = this->begin(); it != this->end(); ++it)
19915 if (m_compare(it->first, key))
19921 JSON_THROW(std::out_of_range(
"key not found"));
19928 for (
auto it = this->begin(); it != this->end(); ++it)
19930 if (m_compare(it->first, key))
19936 JSON_THROW(std::out_of_range(
"key not found"));
19941 for (
auto it = this->begin(); it != this->end(); ++it)
19943 if (m_compare(it->first, key))
19949 JSON_THROW(std::out_of_range(
"key not found"));
19954 const T &
at(KeyType && key)
const
19956 for (
auto it = this->begin(); it != this->end(); ++it)
19958 if (m_compare(it->first, key))
19964 JSON_THROW(std::out_of_range(
"key not found"));
19969 for (
auto it = this->begin(); it != this->end(); ++it)
19971 if (m_compare(it->first, key))
19974 for (
auto next = it; ++next != this->end(); ++it)
19979 Container::pop_back();
19990 for (
auto it = this->begin(); it != this->end(); ++it)
19992 if (m_compare(it->first, key))
19995 for (
auto next = it; ++next != this->end(); ++it)
20000 Container::pop_back();
20009 return erase(pos, std::next(pos));
20019 const auto elements_affected = std::distance(first, last);
20020 const auto offset = std::distance(Container::begin(), first);
20042 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
20045 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
20053 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
20062 return Container::begin() + offset;
20067 for (
auto it = this->begin(); it != this->end(); ++it)
20069 if (m_compare(it->first, key))
20081 for (
auto it = this->begin(); it != this->end(); ++it)
20083 if (m_compare(it->first, key))
20093 for (
auto it = this->begin(); it != this->end(); ++it)
20095 if (m_compare(it->first, key))
20100 return Container::end();
20107 for (
auto it = this->begin(); it != this->end(); ++it)
20109 if (m_compare(it->first, key))
20114 return Container::end();
20119 for (
auto it = this->begin(); it != this->end(); ++it)
20121 if (m_compare(it->first, key))
20126 return Container::end();
20131 return emplace(value.first, std::move(value.second));
20136 for (
auto it = this->begin(); it != this->end(); ++it)
20138 if (m_compare(it->first, value.first))
20140 return {it,
false};
20143 Container::push_back(value);
20144 return {--this->end(),
true};
20147 template<
typename InputIt>
20148 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20149 std::input_iterator_tag>::value>::type;
20151 template<
typename InputIt,
typename = require_input_iter<InputIt>>
20154 for (
auto it = first; it != last; ++it)
20167#if defined(JSON_HAS_CPP_17)
20168 #if JSON_HAS_STATIC_RTTI
20171 #include <string_view>
20201 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
20207 friend class ::nlohmann::json_pointer;
20211 template<
typename BasicJsonType,
typename InputType>
20212 friend class ::nlohmann::detail::parser;
20213 friend ::nlohmann::detail::serializer<basic_json>;
20214 template<
typename BasicJsonType>
20215 friend class ::nlohmann::detail::iter_impl;
20216 template<
typename BasicJsonType,
typename CharType>
20217 friend class ::nlohmann::detail::binary_writer;
20218 template<
typename BasicJsonType,
typename InputType,
typename SAX>
20219 friend class ::nlohmann::detail::binary_reader;
20220 template<
typename BasicJsonType,
typename InputAdapterType>
20221 friend class ::nlohmann::detail::json_sax_dom_parser;
20222 template<
typename BasicJsonType,
typename InputAdapterType>
20223 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
20224 friend class ::nlohmann::detail::exception;
20228 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
20232 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
20234 template<
typename InputAdapterType>
20235 static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
20236 InputAdapterType adapter,
20238 const bool allow_exceptions =
true,
20239 const bool ignore_comments =
false,
20240 const bool ignore_trailing_commas =
false
20243 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20244 std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
20248 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
20249 template<
typename BasicJsonType>
20250 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
20251 template<
typename BasicJsonType>
20252 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
20253 template<
typename Iterator>
20254 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
20255 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
20257 template<
typename CharType>
20258 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
20260 template<
typename InputType>
20261 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
20262 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
20265 using serializer = ::nlohmann::detail::serializer<basic_json>;
20271 template<
typename T,
typename SFINAE>
20329 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
20331 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
20358 result[
"copyright"] =
"(C) 2013-2025 Niels Lohmann";
20359 result[
"name"] =
"JSON for Modern C++";
20360 result[
"url"] =
"https://github.com/nlohmann/json";
20361 result[
"version"][
"string"] =
20370 result[
"platform"] =
"win32";
20371#elif defined __linux__
20372 result[
"platform"] =
"linux";
20373#elif defined __APPLE__
20374 result[
"platform"] =
"apple";
20375#elif defined __unix__
20376 result[
"platform"] =
"unix";
20378 result[
"platform"] =
"unknown";
20381#if defined(__ICC) || defined(__INTEL_COMPILER)
20382 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
20383#elif defined(__clang__)
20384 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
20385#elif defined(__GNUC__) || defined(__GNUG__)
20386 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
20387 std::to_string(__GNUC__),
'.',
20388 std::to_string(__GNUC_MINOR__),
'.',
20389 std::to_string(__GNUC_PATCHLEVEL__))
20392#elif defined(__HP_cc) || defined(__HP_aCC)
20393 result[
"compiler"] =
"hp"
20394#elif defined(__IBMCPP__)
20395 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
20396#elif defined(_MSC_VER)
20397 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
20398#elif defined(__PGI)
20399 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
20400#elif defined(__SUNPRO_CC)
20401 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
20403 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
20406#if defined(_MSVC_LANG)
20407 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
20408#elif defined(__cplusplus)
20409 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
20411 result[
"compiler"][
"c++"] =
"unknown";
20429#if defined(JSON_HAS_CPP_14)
20432 using default_object_comparator_t = std::less<>;
20442 AllocatorType<std::pair<
const StringType,
20447 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
20471 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
20482 template<
typename T,
typename... Args>
20484 static T* create(Args&& ... args)
20486 AllocatorType<T> alloc;
20487 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
20489 auto deleter = [&](T * obj)
20491 AllocatorTraits::deallocate(alloc, obj, 1);
20493 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
20494 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
20496 return obj.release();
20542 number_integer_t number_integer;
20544 number_unsigned_t number_unsigned;
20546 number_float_t number_float;
20549 json_value() =
default;
20551 json_value(boolean_t
v) noexcept : boolean(
v) {}
20559 json_value(value_t t)
20563 case value_t::object:
20565 object = create<object_t>();
20569 case value_t::array:
20571 array = create<array_t>();
20575 case value_t::string:
20577 string = create<string_t>(
"");
20581 case value_t::binary:
20583 binary = create<binary_t>();
20587 case value_t::boolean:
20589 boolean =
static_cast<boolean_t
>(
false);
20593 case value_t::number_integer:
20599 case value_t::number_unsigned:
20605 case value_t::number_float:
20611 case value_t::null:
20617 case value_t::discarded:
20623 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0",
nullptr));
20631 json_value(
const string_t& value) :
string(create<string_t>(
value)) {}
20634 json_value(string_t&& value) :
string(create<string_t>(
std::move(
value))) {}
20637 json_value(
const object_t& value) :
object(create<object_t>(
value)) {}
20640 json_value(object_t&& value) :
object(create<object_t>(
std::move(
value))) {}
20643 json_value(
const array_t& value) :
array(create<array_t>(
value)) {}
20646 json_value(array_t&& value) :
array(create<array_t>(
std::move(
value))) {}
20649 json_value(
const typename binary_t::container_type& value) :
binary(create<binary_t>(
value)) {}
20652 json_value(
typename binary_t::container_type&& value) :
binary(create<binary_t>(
std::move(
value))) {}
20655 json_value(
const binary_t& value) :
binary(create<binary_t>(
value)) {}
20658 json_value(binary_t&& value) :
binary(create<binary_t>(
std::move(
value))) {}
20660 void destroy(value_t t)
20663 (t == value_t::object &&
object ==
nullptr) ||
20664 (t == value_t::array && array ==
nullptr) ||
20665 (t == value_t::string &&
string ==
nullptr) ||
20666 (t == value_t::binary && binary ==
nullptr)
20672 if (t == value_t::array || t == value_t::object)
20675 std::vector<basic_json> stack;
20678 if (t == value_t::array)
20680 stack.reserve(
array->size());
20681 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
20685 stack.reserve(
object->size());
20686 for (
auto&& it : *
object)
20688 stack.push_back(std::move(it.second));
20692 while (!stack.empty())
20695 basic_json current_item(std::move(stack.back()));
20700 if (current_item.is_array())
20702 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
20704 current_item.m_data.m_value.array->clear();
20706 else if (current_item.is_object())
20708 for (
auto&& it : *current_item.m_data.m_value.object)
20710 stack.push_back(std::move(it.second));
20713 current_item.m_data.m_value.object->clear();
20723 case value_t::object:
20725 AllocatorType<object_t> alloc;
20726 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20727 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20731 case value_t::array:
20733 AllocatorType<array_t> alloc;
20734 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20735 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20739 case value_t::string:
20741 AllocatorType<string_t> alloc;
20742 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20743 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20747 case value_t::binary:
20749 AllocatorType<binary_t> alloc;
20750 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20751 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20755 case value_t::null:
20756 case value_t::boolean:
20757 case value_t::number_integer:
20758 case value_t::number_unsigned:
20759 case value_t::number_float:
20760 case value_t::discarded:
20788 void assert_invariant(
bool check_parents =
true) const noexcept
20790 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
20791 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
20792 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
20793 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
20795#if JSON_DIAGNOSTICS
20799 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
20801 return j.m_parent ==
this;
20806 static_cast<void>(check_parents);
20811#if JSON_DIAGNOSTICS
20812 switch (m_data.m_type)
20814 case value_t::array:
20816 for (
auto& element : *m_data.m_value.array)
20818 element.m_parent =
this;
20823 case value_t::object:
20825 for (
auto& element : *m_data.m_value.object)
20827 element.second.m_parent =
this;
20832 case value_t::null:
20833 case value_t::string:
20834 case value_t::boolean:
20835 case value_t::number_integer:
20836 case value_t::number_unsigned:
20837 case value_t::number_float:
20838 case value_t::binary:
20839 case value_t::discarded:
20846 iterator set_parents(iterator it,
typename iterator::difference_type count_set_parents)
20848#if JSON_DIAGNOSTICS
20849 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20851 (it + i)->m_parent =
this;
20854 static_cast<void>(count_set_parents);
20861#if JSON_DIAGNOSTICS
20876#ifdef JSON_HEDLEY_MSVC_VERSION
20877#pragma warning(push )
20878#pragma warning(disable : 4127)
20885#ifdef JSON_HEDLEY_MSVC_VERSION
20886#pragma warning( pop )
20891 static_cast<void>(j);
20892 static_cast<void>(old_capacity);
20924 assert_invariant();
20932 assert_invariant();
20937 template <
typename CompatibleType,
20942 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20943 std::forward<CompatibleType>(val))))
20945 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20947 assert_invariant();
20952 template <
typename BasicJsonType,
20956#if JSON_DIAGNOSTIC_POSITIONS
20957 : start_position(val.start_pos()),
20958 end_position(val.end_pos())
20961 using other_boolean_t =
typename BasicJsonType::boolean_t;
20962 using other_number_float_t =
typename BasicJsonType::number_float_t;
20963 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20964 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20965 using other_string_t =
typename BasicJsonType::string_t;
20966 using other_object_t =
typename BasicJsonType::object_t;
20967 using other_array_t =
typename BasicJsonType::array_t;
20968 using other_binary_t =
typename BasicJsonType::binary_t;
20970 switch (val.type())
20972 case value_t::boolean:
20973 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
20975 case value_t::number_float:
20976 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
20978 case value_t::number_integer:
20979 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
20981 case value_t::number_unsigned:
20982 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
20984 case value_t::string:
20985 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
20987 case value_t::object:
20988 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
20990 case value_t::array:
20991 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
20993 case value_t::binary:
20994 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
20996 case value_t::null:
20999 case value_t::discarded:
21000 m_data.m_type = value_t::discarded;
21008 assert_invariant();
21014 bool type_deduction =
true,
21015 value_t manual_type = value_t::array)
21019 bool is_an_object = std::all_of(init.begin(), init.end(),
21025 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
21029 if (!type_deduction)
21032 if (manual_type == value_t::array)
21034 is_an_object =
false;
21040 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
21047 m_data.m_type = value_t::object;
21048 m_data.m_value = value_t::object;
21050 for (
auto& element_ref : init)
21053 m_data.m_value.object->emplace(
21054 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
21055 std::move((*element.m_data.m_value.array)[1]));
21061 m_data.m_type = value_t::array;
21062 m_data.m_value.array = create<array_t>(init.begin(), init.end());
21066 assert_invariant();
21075 res.m_data.m_type = value_t::binary;
21076 res.m_data.m_value = init;
21083 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
21086 res.m_data.m_type = value_t::binary;
21087 res.m_data.m_value =
binary_t(init, subtype);
21097 res.m_data.m_type = value_t::binary;
21098 res.m_data.m_value = std::move(init);
21105 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
21108 res.m_data.m_type = value_t::binary;
21109 res.m_data.m_value =
binary_t(std::move(init), subtype);
21118 return basic_json(init,
false, value_t::array);
21126 return basic_json(init,
false, value_t::object);
21135 assert_invariant();
21140 template <
class InputIT,
typename std::enable_if <
21141 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
21142 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
21151 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
21155 m_data.m_type = first.m_object->m_data.m_type;
21158 switch (m_data.m_type)
21160 case value_t::boolean:
21161 case value_t::number_float:
21162 case value_t::number_integer:
21163 case value_t::number_unsigned:
21164 case value_t::string:
21167 || !last.m_it.primitive_iterator.is_end()))
21169 JSON_THROW(invalid_iterator::create(204,
"iterators out of range", first.m_object));
21174 case value_t::null:
21175 case value_t::object:
21176 case value_t::array:
21177 case value_t::binary:
21178 case value_t::discarded:
21183 switch (m_data.m_type)
21185 case value_t::number_integer:
21187 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
21191 case value_t::number_unsigned:
21193 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
21197 case value_t::number_float:
21199 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
21203 case value_t::boolean:
21205 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
21209 case value_t::string:
21211 m_data.m_value = *first.m_object->m_data.m_value.string;
21215 case value_t::object:
21217 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
21218 last.m_it.object_iterator);
21222 case value_t::array:
21224 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
21225 last.m_it.array_iterator);
21229 case value_t::binary:
21231 m_data.m_value = *first.m_object->m_data.m_value.binary;
21235 case value_t::null:
21236 case value_t::discarded:
21238 JSON_THROW(invalid_iterator::create(206,
detail::concat(
"cannot construct with iterators from ", first.m_object->type_name()), first.m_object));
21242 assert_invariant();
21249 template<
typename JsonRef,
21251 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
21257 : json_base_class_t(other)
21259 , start_position(other.start_position)
21260 , end_position(other.end_position)
21263 m_data.m_type = other.
m_data.m_type;
21265 other.assert_invariant();
21267 switch (m_data.m_type)
21269 case value_t::object:
21271 m_data.m_value = *other.m_data.m_value.object;
21275 case value_t::array:
21277 m_data.m_value = *other.m_data.m_value.array;
21281 case value_t::string:
21283 m_data.m_value = *other.m_data.m_value.string;
21287 case value_t::boolean:
21289 m_data.m_value = other.m_data.m_value.boolean;
21293 case value_t::number_integer:
21295 m_data.m_value = other.m_data.m_value.number_integer;
21299 case value_t::number_unsigned:
21301 m_data.m_value = other.m_data.m_value.number_unsigned;
21305 case value_t::number_float:
21307 m_data.m_value = other.m_data.m_value.number_float;
21311 case value_t::binary:
21313 m_data.m_value = *other.m_data.m_value.binary;
21317 case value_t::null:
21318 case value_t::discarded:
21324 assert_invariant();
21330 : json_base_class_t(std::forward<json_base_class_t>(other)),
21331 m_data(std::move(other.m_data))
21332#if JSON_DIAGNOSTIC_POSITIONS
21333 , start_position(other.start_position)
21334 , end_position(other.end_position)
21338 other.assert_invariant(
false);
21341 other.m_data.m_type = value_t::null;
21342 other.m_data.m_value = {};
21344#if JSON_DIAGNOSTIC_POSITIONS
21345 other.start_position = std::string::npos;
21346 other.end_position = std::string::npos;
21350 assert_invariant();
21356 std::is_nothrow_move_constructible<value_t>::value&&
21357 std::is_nothrow_move_assignable<value_t>::value&&
21358 std::is_nothrow_move_constructible<json_value>::value&&
21359 std::is_nothrow_move_assignable<json_value>::value&&
21360 std::is_nothrow_move_assignable<json_base_class_t>::value
21364 other.assert_invariant();
21367 swap(m_data.m_type, other.m_data.m_type);
21368 swap(m_data.m_value, other.m_data.m_value);
21370#if JSON_DIAGNOSTIC_POSITIONS
21371 swap(start_position, other.start_position);
21372 swap(end_position, other.end_position);
21375 json_base_class_t::operator=(std::move(other));
21378 assert_invariant();
21386 assert_invariant(
false);
21403 const char indent_char =
' ',
21404 const bool ensure_ascii =
false,
21412 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
21416 s.dump(*
this,
false, ensure_ascii, 0);
21426 return m_data.m_type;
21433 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
21440 return is_array() || is_object();
21447 return m_data.m_type == value_t::null;
21454 return m_data.m_type == value_t::boolean;
21461 return is_number_integer() || is_number_float();
21468 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
21475 return m_data.m_type == value_t::number_unsigned;
21482 return m_data.m_type == value_t::number_float;
21489 return m_data.m_type == value_t::object;
21496 return m_data.m_type == value_t::array;
21503 return m_data.m_type == value_t::string;
21510 return m_data.m_type == value_t::binary;
21517 return m_data.m_type == value_t::discarded;
21524 return m_data.m_type;
21535 boolean_t get_impl(boolean_t* )
const
21539 return m_data.m_value.boolean;
21546 object_t* get_impl_ptr(object_t* )
noexcept
21548 return is_object() ? m_data.m_value.object :
nullptr;
21552 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
21554 return is_object() ? m_data.m_value.object :
nullptr;
21558 array_t* get_impl_ptr(array_t* )
noexcept
21560 return is_array() ? m_data.m_value.array :
nullptr;
21564 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
21566 return is_array() ? m_data.m_value.array :
nullptr;
21572 return is_string() ? m_data.m_value.string :
nullptr;
21578 return is_string() ? m_data.m_value.string :
nullptr;
21582 boolean_t* get_impl_ptr(boolean_t* )
noexcept
21584 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21588 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
21590 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21596 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21602 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21608 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21614 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21620 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21626 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21632 return is_binary() ? m_data.m_value.binary :
nullptr;
21638 return is_binary() ? m_data.m_value.binary :
nullptr;
21652 template<
typename ReferenceType,
typename ThisType>
21653 static ReferenceType get_ref_impl(ThisType& obj)
21656 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
21663 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
21673 template<
typename PointerType,
typename std::enable_if<
21674 std::is_pointer<PointerType>::value,
int>::type = 0>
21675 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21678 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21683 template <
typename PointerType,
typename std::enable_if <
21684 std::is_pointer<PointerType>::value&&
21685 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
21686 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21689 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21731 template <
typename ValueType,
21737 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21739 auto ret = ValueType();
21740 JSONSerializer<ValueType>::from_json(*
this,
ret);
21774 template <
typename ValueType,
21779 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21781 return JSONSerializer<ValueType>::from_json(*
this);
21799 template <
typename BasicJsonType,
21822 template<
typename BasicJsonType,
21824 std::is_same<BasicJsonType, basic_json_t>::value,
21835 template<
typename PointerType,
21837 std::is_pointer<PointerType>::value,
21840 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21843 return get_ptr<PointerType>();
21870 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21871#if defined(JSON_HAS_CPP_14)
21875 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21881 static_assert(!std::is_reference<ValueTypeCV>::value,
21882 "get() cannot be used with reference types, you might want to use get_ref()");
21913 template<
typename PointerType,
typename std::enable_if<
21914 std::is_pointer<PointerType>::value,
int>::type = 0>
21915 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template get_ptr<PointerType>())
21918 return get_ptr<PointerType>();
21923 template <
typename ValueType,
21928 ValueType &
get_to(ValueType&
v)
const noexcept(
noexcept(
21929 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(),
v)))
21931 JSONSerializer<ValueType>::from_json(*
this,
v);
21937 template<
typename ValueType,
21948 typename T, std::size_t N,
21949 typename Array = T (&)[N],
21953 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21954 std::declval<const basic_json_t&>(),
v)))
21956 JSONSerializer<Array>::from_json(*
this,
v);
21962 template<
typename ReferenceType,
typename std::enable_if<
21963 std::is_reference<ReferenceType>::value,
int>::type = 0>
21967 return get_ref_impl<ReferenceType>(*
this);
21972 template <
typename ReferenceType,
typename std::enable_if <
21973 std::is_reference<ReferenceType>::value&&
21974 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
21978 return get_ref_impl<ReferenceType>(*
this);
22010 template <
typename ValueType,
typename std::enable_if <
22018#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
22021#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
22025 >::value,
int >::type = 0 >
22029 return get<ValueType>();
22041 return *get_ptr<binary_t*>();
22053 return *get_ptr<const binary_t*>();
22075 return set_parent(m_data.m_value.array->at(idx));
22080 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22098 return m_data.m_value.array->at(idx);
22103 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22123 if (it == m_data.m_value.object->end())
22127 return set_parent(it->second);
22142 auto it = m_data.
m_value.object->find(std::forward<KeyType>(
key));
22143 if (it == m_data.m_value.object->end())
22147 return set_parent(it->second);
22161 if (it == m_data.m_value.object->end())
22180 auto it = m_data.
m_value.object->find(std::forward<KeyType>(
key));
22181 if (it == m_data.m_value.object->end())
22195 m_data.m_type = value_t::array;
22196 m_data.m_value.array = create<array_t>();
22197 assert_invariant();
22204 if (idx >= m_data.m_value.array->size())
22206#if JSON_DIAGNOSTICS
22208 const auto old_size = m_data.m_value.array->size();
22209 const auto old_capacity = m_data.m_value.array->capacity();
22211 m_data.m_value.array->resize(idx + 1);
22213#if JSON_DIAGNOSTICS
22222 set_parents(begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
22225 assert_invariant();
22228 return m_data.m_value.array->operator[](idx);
22231 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22241 return m_data.m_value.array->operator[](idx);
22244 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22254 m_data.m_type = value_t::object;
22255 m_data.m_value.object = create<object_t>();
22256 assert_invariant();
22262 auto result = m_data.m_value.object->emplace(std::move(
key),
nullptr);
22263 return set_parent(result.first->second);
22266 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22276 auto it = m_data.m_value.object->find(
key);
22281 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22286 template<
typename T>
22289 return operator[](
typename object_t::key_type(
key));
22292 template<
typename T>
22295 return operator[](
typename object_t::key_type(
key));
22307 m_data.m_type = value_t::object;
22308 m_data.m_value.object = create<object_t>();
22309 assert_invariant();
22315 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
22316 return set_parent(result.first->second);
22319 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22331 auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22336 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22340 template<
typename KeyType>
22342 object_comparator_t,
const typename object_t::key_type&, KeyType >;
22344 template<
typename ValueType>
22345 using value_return_type = std::conditional <
22347 string_t,
typename std::decay<ValueType>::type >;
22355 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22356 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const
22362 const auto it = find(
key);
22365 return it->template get<ValueType>();
22368 return default_value;
22376 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22380 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22381 ReturnType
value(
const typename object_t::key_type&
key, ValueType && default_value)
const
22387 const auto it = find(
key);
22390 return it->template get<ReturnType>();
22393 return std::forward<ValueType>(default_value);
22404 && is_comparable_with_object_key<KeyType>::value
22406 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22407 ValueType
value(KeyType &&
key,
const ValueType& default_value)
const
22413 const auto it = find(std::forward<KeyType>(
key));
22416 return it->template get<ValueType>();
22419 return default_value;
22427 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
22431 && is_comparable_with_object_key<KeyType>::value
22433 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22434 ReturnType
value(KeyType &&
key, ValueType && default_value)
const
22440 const auto it = find(std::forward<KeyType>(
key));
22443 return it->template get<ReturnType>();
22446 return std::forward<ValueType>(default_value);
22456 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22466 return ptr.get_checked(
this).template get<ValueType>();
22470 return default_value;
22479 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22482 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22492 return ptr.get_checked(
this).template get<ReturnType>();
22496 return std::forward<ValueType>(default_value);
22506 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22508 ValueType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
22510 return value(ptr.convert(), default_value);
22513 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
22517 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22519 ReturnType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const
22521 return value(ptr.convert(), std::forward<ValueType>(default_value));
22559 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22560 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22566 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22569 IteratorType result = end();
22571 switch (m_data.m_type)
22573 case value_t::boolean:
22574 case value_t::number_float:
22575 case value_t::number_integer:
22576 case value_t::number_unsigned:
22577 case value_t::string:
22578 case value_t::binary:
22582 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
22587 AllocatorType<string_t> alloc;
22588 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22589 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22590 m_data.m_value.string =
nullptr;
22592 else if (is_binary())
22594 AllocatorType<binary_t> alloc;
22595 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22596 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22597 m_data.m_value.binary =
nullptr;
22600 m_data.m_type = value_t::null;
22601 assert_invariant();
22605 case value_t::object:
22607 result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator);
22611 case value_t::array:
22613 result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator);
22617 case value_t::null:
22618 case value_t::discarded:
22629 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22630 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22631 IteratorType
erase(IteratorType first, IteratorType last)
22636 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
22639 IteratorType result = end();
22641 switch (m_data.m_type)
22643 case value_t::boolean:
22644 case value_t::number_float:
22645 case value_t::number_integer:
22646 case value_t::number_unsigned:
22647 case value_t::string:
22648 case value_t::binary:
22651 || !last.m_it.primitive_iterator.is_end()))
22653 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
22658 AllocatorType<string_t> alloc;
22659 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22660 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22661 m_data.m_value.string =
nullptr;
22663 else if (is_binary())
22665 AllocatorType<binary_t> alloc;
22666 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22667 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22668 m_data.m_value.binary =
nullptr;
22671 m_data.m_type = value_t::null;
22672 assert_invariant();
22676 case value_t::object:
22678 result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator,
22679 last.m_it.object_iterator);
22683 case value_t::array:
22685 result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator,
22686 last.m_it.array_iterator);
22690 case value_t::null:
22691 case value_t::discarded:
22702 size_type erase_internal(KeyType &&
key)
22710 return m_data.m_value.object->erase(std::forward<KeyType>(
key));
22715 size_type erase_internal(KeyType &&
key)
22723 const auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22724 if (it != m_data.m_value.object->end())
22726 m_data.m_value.object->erase(it);
22740 return erase_internal(
key);
22749 return erase_internal(std::forward<KeyType>(
key));
22761 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22764 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
22785 auto result = end();
22789 result.m_it.object_iterator = m_data.m_value.object->find(
key);
22799 auto result = cend();
22803 result.m_it.object_iterator = m_data.m_value.object->find(
key);
22815 auto result = end();
22819 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
22831 auto result = cend();
22835 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
22846 return is_object() ? m_data.m_value.object->count(
key) : 0;
22856 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(
key)) : 0;
22863 return is_object() && m_data.m_value.object->find(
key) != m_data.m_value.object->end();
22872 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(
key)) != m_data.m_value.object->end();
22879 return ptr.contains(
this);
22882 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22884 bool contains(const typename ::nlohmann::
json_pointer<BasicJsonType>& ptr)
const
22886 return ptr.contains(
this);
22903 result.set_begin();
22919 result.set_begin();
22999 return ref.items();
23010 return ref.items();
23017 return iteration_proxy<iterator>(*
this);
23022 iteration_proxy<const_iterator>
items() const noexcept
23024 return iteration_proxy<const_iterator>(*
this);
23040 switch (m_data.m_type)
23042 case value_t::null:
23048 case value_t::array:
23051 return m_data.m_value.array->empty();
23054 case value_t::object:
23057 return m_data.m_value.object->empty();
23060 case value_t::string:
23061 case value_t::boolean:
23062 case value_t::number_integer:
23063 case value_t::number_unsigned:
23064 case value_t::number_float:
23065 case value_t::binary:
23066 case value_t::discarded:
23079 switch (m_data.m_type)
23081 case value_t::null:
23087 case value_t::array:
23090 return m_data.m_value.array->size();
23093 case value_t::object:
23096 return m_data.m_value.object->size();
23099 case value_t::string:
23100 case value_t::boolean:
23101 case value_t::number_integer:
23102 case value_t::number_unsigned:
23103 case value_t::number_float:
23104 case value_t::binary:
23105 case value_t::discarded:
23118 switch (m_data.m_type)
23120 case value_t::array:
23123 return m_data.m_value.array->max_size();
23126 case value_t::object:
23129 return m_data.m_value.object->max_size();
23132 case value_t::null:
23133 case value_t::string:
23134 case value_t::boolean:
23135 case value_t::number_integer:
23136 case value_t::number_unsigned:
23137 case value_t::number_float:
23138 case value_t::binary:
23139 case value_t::discarded:
23161 switch (m_data.m_type)
23163 case value_t::number_integer:
23165 m_data.m_value.number_integer = 0;
23169 case value_t::number_unsigned:
23171 m_data.m_value.number_unsigned = 0;
23175 case value_t::number_float:
23177 m_data.m_value.number_float = 0.0;
23181 case value_t::boolean:
23183 m_data.m_value.boolean =
false;
23187 case value_t::string:
23189 m_data.m_value.string->clear();
23193 case value_t::binary:
23195 m_data.m_value.binary->clear();
23199 case value_t::array:
23201 m_data.m_value.array->clear();
23205 case value_t::object:
23207 m_data.m_value.object->clear();
23211 case value_t::null:
23212 case value_t::discarded:
23231 m_data.m_type = value_t::array;
23232 m_data.m_value = value_t::array;
23233 assert_invariant();
23237 const auto old_capacity = m_data.m_value.array->capacity();
23238 m_data.m_value.array->push_back(std::move(val));
23239 set_parent(m_data.m_value.array->back(), old_capacity);
23247 push_back(std::move(val));
23264 m_data.m_type = value_t::array;
23265 m_data.m_value = value_t::array;
23266 assert_invariant();
23270 const auto old_capacity = m_data.m_value.array->capacity();
23271 m_data.m_value.array->push_back(val);
23272 set_parent(m_data.m_value.array->back(), old_capacity);
23296 m_data.m_type = value_t::object;
23297 m_data.m_value = value_t::object;
23298 assert_invariant();
23302 auto res = m_data.m_value.object->insert(val);
23303 set_parent(res.first->second);
23318 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
23321 push_back(
typename object_t::value_type(
23322 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23340 template<
class... Args>
23352 m_data.m_type = value_t::array;
23353 m_data.m_value = value_t::array;
23354 assert_invariant();
23358 const auto old_capacity = m_data.
m_value.array->capacity();
23359 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
23360 return set_parent(m_data.m_value.array->back(), old_capacity);
23365 template<
class... Args>
23377 m_data.m_type = value_t::object;
23378 m_data.m_value = value_t::object;
23379 assert_invariant();
23383 auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
23384 set_parent(res.first->second);
23388 it.m_it.object_iterator = res.first;
23391 return {it, res.second};
23397 template<
typename... Args>
23403 auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator);
23404 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
23405 result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos;
23425 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23429 return insert_iterator(pos, val);
23439 return insert(pos, val);
23452 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23456 return insert_iterator(pos, cnt, val);
23475 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23481 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23486 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
23490 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
23506 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23510 return insert_iterator(pos, ilist.begin(), ilist.end());
23526 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23532 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
23535 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
23543 update(j.
begin(), j.
end(), merge_objects);
23553 m_data.m_type = value_t::object;
23554 m_data.m_value.object = create<object_t>();
23555 assert_invariant();
23566 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23572 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
23575 for (
auto it = first; it != last; ++it)
23577 if (merge_objects && it.value().is_object())
23579 auto it2 = m_data.m_value.object->find(it.key());
23580 if (it2 != m_data.m_value.object->end())
23582 it2->second.update(it.value(),
true);
23586 m_data.m_value.object->operator[](it.key()) = it.value();
23587#if JSON_DIAGNOSTICS
23588 m_data.m_value.object->operator[](it.key()).m_parent =
this;
23596 std::is_nothrow_move_constructible<value_t>::value&&
23597 std::is_nothrow_move_assignable<value_t>::value&&
23598 std::is_nothrow_move_constructible<json_value>::value&&
23599 std::is_nothrow_move_assignable<json_value>::value
23602 std::swap(m_data.m_type, other.m_data.m_type);
23603 std::swap(m_data.m_value, other.m_data.m_value);
23606 other.set_parents();
23607 assert_invariant();
23613 std::is_nothrow_move_constructible<value_t>::value&&
23614 std::is_nothrow_move_assignable<value_t>::value&&
23615 std::is_nothrow_move_constructible<json_value>::value&&
23616 std::is_nothrow_move_assignable<json_value>::value
23630 swap(*(m_data.m_value.array), other);
23646 swap(*(m_data.m_value.object), other);
23662 swap(*(m_data.m_value.string), other);
23678 swap(*(m_data.m_value.binary), other);
23688 void swap(
typename binary_t::container_type& other)
23694 swap(*(m_data.m_value.binary), other);
23698 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
23713#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23714 const auto lhs_type = lhs.type(); \
23715 const auto rhs_type = rhs.type(); \
23717 if (lhs_type == rhs_type) \
23719 switch (lhs_type) \
23721 case value_t::array: \
23722 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23724 case value_t::object: \
23725 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23727 case value_t::null: \
23728 return (null_result); \
23730 case value_t::string: \
23731 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23733 case value_t::boolean: \
23734 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23736 case value_t::number_integer: \
23737 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23739 case value_t::number_unsigned: \
23740 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23742 case value_t::number_float: \
23743 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23745 case value_t::binary: \
23746 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23748 case value_t::discarded: \
23750 return (unordered_result); \
23753 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23755 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23757 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23759 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23761 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23763 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23765 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23767 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23769 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23771 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23773 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23775 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23777 else if(compares_unordered(lhs, rhs))\
23779 return (unordered_result);\
23782 return (default_result);
23797#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23800 static_cast<void>(inverse);
23806 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
23808 return compares_unordered(*
this, rhs, inverse);
23812#if JSON_HAS_THREE_WAY_COMPARISON
23815 bool operator==(const_reference rhs)
const noexcept
23818#pragma GCC diagnostic push
23819#pragma GCC diagnostic ignored "-Wfloat-equal"
23821 const_reference lhs = *
this;
23824#pragma GCC diagnostic pop
23830 template<
typename ScalarType>
23831 requires std::is_scalar_v<ScalarType>
23832 bool operator==(ScalarType rhs)
const noexcept
23839 bool operator!=(const_reference rhs)
const noexcept
23841 if (compares_unordered(rhs,
true))
23850 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23852 const_reference lhs = *
this;
23856 std::partial_ordering::equivalent,
23857 std::partial_ordering::unordered,
23858 lhs_type <=> rhs_type)
23863 template<
typename ScalarType>
23864 requires std::is_scalar_v<ScalarType>
23865 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23870#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23877 bool operator<=(const_reference rhs)
const noexcept
23879 if (compares_unordered(rhs,
true))
23883 return !(rhs < *
this);
23888 template<
typename ScalarType>
23889 requires std::is_scalar_v<ScalarType>
23890 bool operator<=(ScalarType rhs)
const noexcept
23898 bool operator>=(const_reference rhs)
const noexcept
23900 if (compares_unordered(rhs,
true))
23904 return !(*
this < rhs);
23909 template<
typename ScalarType>
23910 requires std::is_scalar_v<ScalarType>
23911 bool operator>=(ScalarType rhs)
const noexcept
23919 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
23922#pragma GCC diagnostic push
23923#pragma GCC diagnostic ignored "-Wfloat-equal"
23927#pragma GCC diagnostic pop
23933 template<
typename ScalarType,
typename std::enable_if<
23934 std::is_scalar<ScalarType>::value,
int>::type = 0>
23935 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
23942 template<
typename ScalarType,
typename std::enable_if<
23943 std::is_scalar<ScalarType>::value,
int>::type = 0>
23944 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
23951 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
23953 if (compares_unordered(lhs, rhs,
true))
23957 return !(lhs == rhs);
23962 template<
typename ScalarType,
typename std::enable_if<
23963 std::is_scalar<ScalarType>::value,
int>::type = 0>
23964 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
23971 template<
typename ScalarType,
typename std::enable_if<
23972 std::is_scalar<ScalarType>::value,
int>::type = 0>
23973 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
23980 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
23990 template<
typename ScalarType,
typename std::enable_if<
23991 std::is_scalar<ScalarType>::value,
int>::type = 0>
23992 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
23999 template<
typename ScalarType,
typename std::enable_if<
24000 std::is_scalar<ScalarType>::value,
int>::type = 0>
24001 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
24008 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
24010 if (compares_unordered(lhs, rhs,
true))
24014 return !(rhs < lhs);
24019 template<
typename ScalarType,
typename std::enable_if<
24020 std::is_scalar<ScalarType>::value,
int>::type = 0>
24021 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
24028 template<
typename ScalarType,
typename std::enable_if<
24029 std::is_scalar<ScalarType>::value,
int>::type = 0>
24030 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
24037 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
24040 if (compares_unordered(lhs, rhs))
24044 return !(lhs <= rhs);
24049 template<
typename ScalarType,
typename std::enable_if<
24050 std::is_scalar<ScalarType>::value,
int>::type = 0>
24051 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
24058 template<
typename ScalarType,
typename std::enable_if<
24059 std::is_scalar<ScalarType>::value,
int>::type = 0>
24060 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
24067 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
24069 if (compares_unordered(lhs, rhs,
true))
24073 return !(lhs < rhs);
24078 template<
typename ScalarType,
typename std::enable_if<
24079 std::is_scalar<ScalarType>::value,
int>::type = 0>
24080 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
24087 template<
typename ScalarType,
typename std::enable_if<
24088 std::is_scalar<ScalarType>::value,
int>::type = 0>
24089 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
24095#undef JSON_IMPLEMENT_OPERATOR
24108 friend std::ostream& operator<<(std::ostream& o,
const basic_json& j)
24111 const bool pretty_print = o.width() > 0;
24112 const auto indentation = pretty_print ? o.width() : 0;
24119 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24130 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
24146 template<
typename InputType>
24149 parser_callback_t cb =
nullptr,
24150 const bool allow_exceptions =
true,
24151 const bool ignore_comments =
false,
24152 const bool ignore_trailing_commas =
false)
24155 parser(
detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24161 template<
typename IteratorType>
24165 parser_callback_t cb =
nullptr,
24166 const bool allow_exceptions =
true,
24167 const bool ignore_comments =
false,
24168 const bool ignore_trailing_commas =
false)
24171 parser(
detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24178 parser_callback_t cb =
nullptr,
24179 const bool allow_exceptions =
true,
24180 const bool ignore_comments =
false,
24181 const bool ignore_trailing_commas =
false)
24184 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24190 template<
typename InputType>
24191 static bool accept(InputType&& i,
24192 const bool ignore_comments =
false,
24193 const bool ignore_trailing_commas =
false)
24195 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24200 template<
typename IteratorType>
24201 static bool accept(IteratorType first, IteratorType last,
24202 const bool ignore_comments =
false,
24203 const bool ignore_trailing_commas =
false)
24205 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24211 const bool ignore_comments =
false,
24212 const bool ignore_trailing_commas =
false)
24214 return parser(i.get(),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24219 template <
typename InputType,
typename SAX>
24221 static
bool sax_parse(InputType&& i, SAX* sax,
24223 const
bool strict = true,
24224 const
bool ignore_comments = false,
24225 const
bool ignore_trailing_commas = false)
24228 return format == input_format_t::json
24229 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24235 template<
class IteratorType,
class SAX>
24237 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24239 const
bool strict = true,
24240 const
bool ignore_comments = false,
24241 const
bool ignore_trailing_commas = false)
24244 return format == input_format_t::json
24245 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24254 template <
typename SAX>
24257 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
24259 const
bool strict = true,
24260 const
bool ignore_comments = false,
24261 const
bool ignore_trailing_commas = false)
24264 return format == input_format_t::json
24266 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24280 return operator>>(i, j);
24302 switch (m_data.m_type)
24304 case value_t::null:
24306 case value_t::object:
24308 case value_t::array:
24310 case value_t::string:
24312 case value_t::boolean:
24314 case value_t::binary:
24316 case value_t::discarded:
24317 return "discarded";
24318 case value_t::number_integer:
24319 case value_t::number_unsigned:
24320 case value_t::number_float:
24335 value_t m_type = value_t::null;
24338 json_value m_value = {};
24341 : m_type(
v), m_value(
v)
24348 m_value.array = create<array_t>(cnt, val);
24352 data(data&&) noexcept = default;
24353 data(const data&) noexcept = delete;
24354 data& operator=(data&&) noexcept = delete;
24355 data& operator=(const data&) noexcept = delete;
24359 m_value.destroy(m_type);
24365#if JSON_DIAGNOSTICS
24370#if JSON_DIAGNOSTIC_POSITIONS
24372 std::size_t start_position = std::string::npos;
24374 std::size_t end_position = std::string::npos;
24376 constexpr std::size_t start_pos() const noexcept
24378 return start_position;
24381 constexpr std::size_t end_pos() const noexcept
24383 return end_position;
24399 std::vector<std::uint8_t> result;
24400 to_cbor(j, result);
24408 binary_writer<std::uint8_t>(o).write_cbor(j);
24415 binary_writer<char>(o).write_cbor(j);
24422 std::vector<std::uint8_t> result;
24423 to_msgpack(j, result);
24431 binary_writer<std::uint8_t>(o).write_msgpack(j);
24438 binary_writer<char>(o).write_msgpack(j);
24444 const bool use_size =
false,
24445 const bool use_type =
false)
24447 std::vector<std::uint8_t> result;
24448 to_ubjson(j, result, use_size, use_type);
24455 const bool use_size =
false,
const bool use_type =
false)
24457 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
24463 const bool use_size =
false,
const bool use_type =
false)
24465 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
24471 const bool use_size =
false,
24472 const bool use_type =
false,
24475 std::vector<std::uint8_t> result;
24476 to_bjdata(j, result, use_size, use_type, version);
24483 const bool use_size =
false,
const bool use_type =
false,
24486 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24492 const bool use_size =
false,
const bool use_type =
false,
24495 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24502 std::vector<std::uint8_t> result;
24503 to_bson(j, result);
24511 binary_writer<std::uint8_t>(o).write_bson(j);
24518 binary_writer<char>(o).write_bson(j);
24523 template<
typename InputType>
24526 const bool strict =
true,
24527 const bool allow_exceptions =
true,
24533 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).
sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24534 return res ? result :
basic_json(value_t::discarded);
24539 template<
typename IteratorType>
24542 const bool strict =
true,
24543 const bool allow_exceptions =
true,
24549 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).
sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24550 return res ? result :
basic_json(value_t::discarded);
24553 template<
typename T>
24557 const
bool strict = true,
24558 const
bool allow_exceptions = true,
24561 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24567 const
bool strict = true,
24568 const
bool allow_exceptions = true,
24575 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24576 return res ? result :
basic_json(value_t::discarded);
24581 template<
typename InputType>
24584 const bool strict =
true,
24585 const bool allow_exceptions =
true)
24590 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).
sax_parse(input_format_t::msgpack, &sdp, strict);
24591 return res ? result :
basic_json(value_t::discarded);
24596 template<
typename IteratorType>
24599 const bool strict =
true,
24600 const bool allow_exceptions =
true)
24605 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).
sax_parse(input_format_t::msgpack, &sdp, strict);
24606 return res ? result :
basic_json(value_t::discarded);
24609 template<
typename T>
24613 const
bool strict = true,
24614 const
bool allow_exceptions = true)
24616 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24622 const
bool strict = true,
24623 const
bool allow_exceptions = true)
24629 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24630 return res ? result :
basic_json(value_t::discarded);
24635 template<
typename InputType>
24638 const bool strict =
true,
24639 const bool allow_exceptions =
true)
24644 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).
sax_parse(input_format_t::ubjson, &sdp, strict);
24645 return res ? result :
basic_json(value_t::discarded);
24650 template<
typename IteratorType>
24653 const bool strict =
true,
24654 const bool allow_exceptions =
true)
24659 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).
sax_parse(input_format_t::ubjson, &sdp, strict);
24660 return res ? result :
basic_json(value_t::discarded);
24663 template<
typename T>
24667 const
bool strict = true,
24668 const
bool allow_exceptions = true)
24670 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24676 const
bool strict = true,
24677 const
bool allow_exceptions = true)
24683 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24684 return res ? result :
basic_json(value_t::discarded);
24689 template<
typename InputType>
24692 const bool strict =
true,
24693 const bool allow_exceptions =
true)
24698 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).
sax_parse(input_format_t::bjdata, &sdp, strict);
24699 return res ? result :
basic_json(value_t::discarded);
24704 template<
typename IteratorType>
24707 const bool strict =
true,
24708 const bool allow_exceptions =
true)
24713 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).
sax_parse(input_format_t::bjdata, &sdp, strict);
24714 return res ? result :
basic_json(value_t::discarded);
24719 template<
typename InputType>
24722 const bool strict =
true,
24723 const bool allow_exceptions =
true)
24728 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).
sax_parse(input_format_t::bson, &sdp, strict);
24729 return res ? result :
basic_json(value_t::discarded);
24734 template<
typename IteratorType>
24737 const bool strict =
true,
24738 const bool allow_exceptions =
true)
24743 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).
sax_parse(input_format_t::bson, &sdp, strict);
24744 return res ? result :
basic_json(value_t::discarded);
24747 template<
typename T>
24751 const
bool strict = true,
24752 const
bool allow_exceptions = true)
24754 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24760 const
bool strict = true,
24761 const
bool allow_exceptions = true)
24767 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24768 return res ? result :
basic_json(value_t::discarded);
24783 return ptr.get_unchecked(
this);
24786 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24790 return ptr.get_unchecked(
this);
24797 return ptr.get_unchecked(
this);
24800 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24804 return ptr.get_unchecked(
this);
24811 return ptr.get_checked(
this);
24814 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24818 return ptr.get_checked(
this);
24825 return ptr.get_checked(
this);
24828 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24832 return ptr.get_checked(
this);
24840 json_pointer::flatten(
"", *
this, result);
24848 return json_pointer::unflatten(*
this);
24866 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24868 const auto get_op = [](
const string_t& op)
24872 return patch_operations::add;
24874 if (op ==
"remove")
24876 return patch_operations::remove;
24878 if (op ==
"replace")
24880 return patch_operations::replace;
24884 return patch_operations::move;
24888 return patch_operations::copy;
24892 return patch_operations::test;
24895 return patch_operations::invalid;
24910 if (top_pointer != ptr)
24912 result.
at(top_pointer);
24916 const auto last_path = ptr.
back();
24921 switch (parent.
m_data.m_type)
24923 case value_t::null:
24924 case value_t::object:
24927 parent[last_path] = val;
24931 case value_t::array:
24933 if (last_path ==
"-")
24940 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24944 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"), &parent));
24954 case value_t::string:
24955 case value_t::boolean:
24956 case value_t::number_integer:
24957 case value_t::number_unsigned:
24958 case value_t::number_float:
24959 case value_t::binary:
24960 case value_t::discarded:
24967 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24970 const auto last_path = ptr.
back();
24978 auto it = parent.
find(last_path);
24991 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24998 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
25002 for (
const auto& val : json_patch)
25005 const auto get_value = [&val](
const string_t& op,
25010 auto it = val.m_data.m_value.object->find(member);
25013 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
25026 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
25036 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
25040 const auto op = get_value(
"op",
"op",
true).template get<string_t>();
25041 const auto path = get_value(op,
"path",
true).template get<string_t>();
25044 switch (get_op(op))
25046 case patch_operations::add:
25048 operation_add(ptr, get_value(
"add",
"value",
false));
25052 case patch_operations::remove:
25054 operation_remove(ptr);
25058 case patch_operations::replace:
25061 result.
at(ptr) = get_value(
"replace",
"value",
false);
25065 case patch_operations::move:
25067 const auto from_path = get_value(
"move",
"from",
true).template get<string_t>();
25077 operation_remove(from_ptr);
25078 operation_add(ptr,
v);
25082 case patch_operations::copy:
25084 const auto from_path = get_value(
"copy",
"from",
true).template get<string_t>();
25093 operation_add(ptr,
v);
25097 case patch_operations::test:
25099 bool success =
false;
25104 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25120 case patch_operations::invalid:
25150 if (source == target)
25155 if (source.
type() != target.
type())
25160 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25165 switch (source.
type())
25167 case value_t::array:
25171 while (i < source.
size() && i < target.
size())
25175 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25184 while (i < source.
size())
25188 result.
insert(result.
begin() + end_index,
object(
25191 {
"path", detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i))}
25197 while (i < target.
size())
25203 {
"value", target[i]}
25211 case value_t::object:
25214 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25219 if (target.
find(it.key()) != target.
end())
25222 auto temp_diff = diff(it.value(), target[it.key()], path_key);
25223 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25230 {
"op",
"remove"}, {
"path", path_key}
25236 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25238 if (source.
find(it.key()) == source.
end())
25244 {
"op",
"add"}, {
"path", path_key},
25245 {
"value", it.value()}
25253 case value_t::null:
25254 case value_t::string:
25255 case value_t::boolean:
25256 case value_t::number_integer:
25257 case value_t::number_unsigned:
25258 case value_t::number_float:
25259 case value_t::binary:
25260 case value_t::discarded:
25266 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25293 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25295 if (it.value().is_null())
25301 operator[](it.key()).merge_patch(it.value());
25307 *
this = apply_patch;
25324inline namespace json_literals
25330#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25331 inline nlohmann::json
operator ""_json(
const char* s, std::size_t
n)
25333 inline nlohmann::json
operator "" _json(
const char* s, std::size_t
n)
25336 return nlohmann::json::parse(s, s +
n);
25342#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25343 inline nlohmann::json::json_pointer
operator ""_json_pointer(
const char* s, std::size_t
n)
25345 inline nlohmann::json::json_pointer
operator "" _json_pointer(
const char* s, std::size_t
n)
25348 return nlohmann::json::json_pointer(std::string(s,
n));
25367 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
25369 return nlohmann::detail::hash(j);
25375struct less< ::nlohmann::detail::value_t>
25382 ::nlohmann::detail::value_t rhs)
const noexcept
25384#if JSON_HAS_THREE_WAY_COMPARISON
25385 return std::is_lt(lhs <=> rhs);
25387 return ::nlohmann::detail::operator<(lhs, rhs);
25393#ifndef JSON_HAS_CPP_20
25398inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
25399 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
25400 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
25409#if JSON_USE_GLOBAL_UDLS
25410 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25411 using nlohmann::literals::json_literals::operator
""_json;
25412 using nlohmann::literals::json_literals::operator
""_json_pointer;
25414 using nlohmann::literals::json_literals::operator
"" _json;
25415 using nlohmann::literals::json_literals::operator
"" _json_pointer;
25431#if defined(__clang__)
25432 #pragma clang diagnostic pop
25437#undef JSON_INTERNAL_CATCH
25439#undef JSON_PRIVATE_UNLESS_TESTED
25440#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25441#undef NLOHMANN_BASIC_JSON_TPL
25442#undef JSON_EXPLICIT
25443#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
25444#undef JSON_INLINE_VARIABLE
25445#undef JSON_NO_UNIQUE_ADDRESS
25446#undef JSON_DISABLE_ENUM_SERIALIZATION
25447#undef JSON_USE_GLOBAL_UDLS
25449#ifndef JSON_TEST_KEEP_MACROS
25452 #undef JSON_HAS_CPP_11
25453 #undef JSON_HAS_CPP_14
25454 #undef JSON_HAS_CPP_17
25455 #undef JSON_HAS_CPP_20
25456 #undef JSON_HAS_CPP_23
25457 #undef JSON_HAS_CPP_26
25458 #undef JSON_HAS_FILESYSTEM
25459 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
25460 #undef JSON_HAS_THREE_WAY_COMPARISON
25461 #undef JSON_HAS_RANGES
25462 #undef JSON_HAS_STATIC_RTTI
25463 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
25477#undef JSON_HEDLEY_ALWAYS_INLINE
25478#undef JSON_HEDLEY_ARM_VERSION
25479#undef JSON_HEDLEY_ARM_VERSION_CHECK
25480#undef JSON_HEDLEY_ARRAY_PARAM
25481#undef JSON_HEDLEY_ASSUME
25482#undef JSON_HEDLEY_BEGIN_C_DECLS
25483#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25484#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25485#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25486#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25487#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25488#undef JSON_HEDLEY_CLANG_HAS_FEATURE
25489#undef JSON_HEDLEY_CLANG_HAS_WARNING
25490#undef JSON_HEDLEY_COMPCERT_VERSION
25491#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25492#undef JSON_HEDLEY_CONCAT
25493#undef JSON_HEDLEY_CONCAT3
25494#undef JSON_HEDLEY_CONCAT3_EX
25495#undef JSON_HEDLEY_CONCAT_EX
25496#undef JSON_HEDLEY_CONST
25497#undef JSON_HEDLEY_CONSTEXPR
25498#undef JSON_HEDLEY_CONST_CAST
25499#undef JSON_HEDLEY_CPP_CAST
25500#undef JSON_HEDLEY_CRAY_VERSION
25501#undef JSON_HEDLEY_CRAY_VERSION_CHECK
25502#undef JSON_HEDLEY_C_DECL
25503#undef JSON_HEDLEY_DEPRECATED
25504#undef JSON_HEDLEY_DEPRECATED_FOR
25505#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25506#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25507#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25508#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25509#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25510#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
25511#undef JSON_HEDLEY_DIAGNOSTIC_POP
25512#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25513#undef JSON_HEDLEY_DMC_VERSION
25514#undef JSON_HEDLEY_DMC_VERSION_CHECK
25515#undef JSON_HEDLEY_EMPTY_BASES
25516#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25517#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25518#undef JSON_HEDLEY_END_C_DECLS
25519#undef JSON_HEDLEY_FLAGS
25520#undef JSON_HEDLEY_FLAGS_CAST
25521#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25522#undef JSON_HEDLEY_GCC_HAS_BUILTIN
25523#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25524#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25525#undef JSON_HEDLEY_GCC_HAS_EXTENSION
25526#undef JSON_HEDLEY_GCC_HAS_FEATURE
25527#undef JSON_HEDLEY_GCC_HAS_WARNING
25528#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25529#undef JSON_HEDLEY_GCC_VERSION
25530#undef JSON_HEDLEY_GCC_VERSION_CHECK
25531#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25532#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25533#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25534#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25535#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25536#undef JSON_HEDLEY_GNUC_HAS_FEATURE
25537#undef JSON_HEDLEY_GNUC_HAS_WARNING
25538#undef JSON_HEDLEY_GNUC_VERSION
25539#undef JSON_HEDLEY_GNUC_VERSION_CHECK
25540#undef JSON_HEDLEY_HAS_ATTRIBUTE
25541#undef JSON_HEDLEY_HAS_BUILTIN
25542#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25543#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25544#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25545#undef JSON_HEDLEY_HAS_EXTENSION
25546#undef JSON_HEDLEY_HAS_FEATURE
25547#undef JSON_HEDLEY_HAS_WARNING
25548#undef JSON_HEDLEY_IAR_VERSION
25549#undef JSON_HEDLEY_IAR_VERSION_CHECK
25550#undef JSON_HEDLEY_IBM_VERSION
25551#undef JSON_HEDLEY_IBM_VERSION_CHECK
25552#undef JSON_HEDLEY_IMPORT
25553#undef JSON_HEDLEY_INLINE
25554#undef JSON_HEDLEY_INTEL_CL_VERSION
25555#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25556#undef JSON_HEDLEY_INTEL_VERSION
25557#undef JSON_HEDLEY_INTEL_VERSION_CHECK
25558#undef JSON_HEDLEY_IS_CONSTANT
25559#undef JSON_HEDLEY_IS_CONSTEXPR_
25560#undef JSON_HEDLEY_LIKELY
25561#undef JSON_HEDLEY_MALLOC
25562#undef JSON_HEDLEY_MCST_LCC_VERSION
25563#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
25564#undef JSON_HEDLEY_MESSAGE
25565#undef JSON_HEDLEY_MSVC_VERSION
25566#undef JSON_HEDLEY_MSVC_VERSION_CHECK
25567#undef JSON_HEDLEY_NEVER_INLINE
25568#undef JSON_HEDLEY_NON_NULL
25569#undef JSON_HEDLEY_NO_ESCAPE
25570#undef JSON_HEDLEY_NO_RETURN
25571#undef JSON_HEDLEY_NO_THROW
25572#undef JSON_HEDLEY_NULL
25573#undef JSON_HEDLEY_PELLES_VERSION
25574#undef JSON_HEDLEY_PELLES_VERSION_CHECK
25575#undef JSON_HEDLEY_PGI_VERSION
25576#undef JSON_HEDLEY_PGI_VERSION_CHECK
25577#undef JSON_HEDLEY_PREDICT
25578#undef JSON_HEDLEY_PRINTF_FORMAT
25579#undef JSON_HEDLEY_PRIVATE
25580#undef JSON_HEDLEY_PUBLIC
25581#undef JSON_HEDLEY_PURE
25582#undef JSON_HEDLEY_REINTERPRET_CAST
25583#undef JSON_HEDLEY_REQUIRE
25584#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25585#undef JSON_HEDLEY_REQUIRE_MSG
25586#undef JSON_HEDLEY_RESTRICT
25587#undef JSON_HEDLEY_RETURNS_NON_NULL
25588#undef JSON_HEDLEY_SENTINEL
25589#undef JSON_HEDLEY_STATIC_ASSERT
25590#undef JSON_HEDLEY_STATIC_CAST
25591#undef JSON_HEDLEY_STRINGIFY
25592#undef JSON_HEDLEY_STRINGIFY_EX
25593#undef JSON_HEDLEY_SUNPRO_VERSION
25594#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25595#undef JSON_HEDLEY_TINYC_VERSION
25596#undef JSON_HEDLEY_TINYC_VERSION_CHECK
25597#undef JSON_HEDLEY_TI_ARMCL_VERSION
25598#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25599#undef JSON_HEDLEY_TI_CL2000_VERSION
25600#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25601#undef JSON_HEDLEY_TI_CL430_VERSION
25602#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25603#undef JSON_HEDLEY_TI_CL6X_VERSION
25604#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25605#undef JSON_HEDLEY_TI_CL7X_VERSION
25606#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25607#undef JSON_HEDLEY_TI_CLPRU_VERSION
25608#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25609#undef JSON_HEDLEY_TI_VERSION
25610#undef JSON_HEDLEY_TI_VERSION_CHECK
25611#undef JSON_HEDLEY_UNAVAILABLE
25612#undef JSON_HEDLEY_UNLIKELY
25613#undef JSON_HEDLEY_UNPREDICTABLE
25614#undef JSON_HEDLEY_UNREACHABLE
25615#undef JSON_HEDLEY_UNREACHABLE_RETURN
25616#undef JSON_HEDLEY_VERSION
25617#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25618#undef JSON_HEDLEY_VERSION_DECODE_MINOR
25619#undef JSON_HEDLEY_VERSION_DECODE_REVISION
25620#undef JSON_HEDLEY_VERSION_ENCODE
25621#undef JSON_HEDLEY_WARNING
25622#undef JSON_HEDLEY_WARN_UNUSED_RESULT
25623#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25624#undef JSON_HEDLEY_FALL_THROUGH
a class to store JSON values
constexpr bool is_string() const noexcept
return whether value is a string
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
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
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)
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
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_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
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
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
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
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
std::size_t size_type
a type to represent container sizes
constexpr bool is_structured() const noexcept
return whether type is structured
const_reference operator[](KeyType &&key) const
access specified object element
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
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
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
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
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
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
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
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
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
const_iterator cend() const noexcept
returns an iterator to one past the last element
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
basic_json flatten() const
return flattened JSON value
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
size_type erase(KeyType &&key)
remove element from a JSON object given a key
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false, const bool ignore_trailing_commas=false)
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
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
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
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
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)
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
AllocatorType< basic_json > allocator_type
the allocator type
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
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)
reference at(size_type idx)
access specified array element with bounds checking
iterator find(KeyType &&key)
find an element in a JSON object
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
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
reference operator[](typename object_t::key_type key)
access specified object element
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
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
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
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
reference operator[](size_type idx)
access specified array element
basic_json(const JsonRef &ref)
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)))
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
constexpr bool is_binary() const noexcept
return whether value is a binary array
void swap(object_t &other)
exchanges the values
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
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
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
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
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
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
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
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
::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
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
binary_reader & operator=(const binary_reader &)=delete
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)
binary_reader & operator=(binary_reader &&)=default
serialization to CBOR and MessagePack values
void write_bson(const BasicJsonType &j)
static constexpr CharType to_char_type(std::uint8_t x) 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)
static CharType to_char_type(std::uint8_t x) noexcept
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static constexpr CharType to_char_type(InputCharType x) noexcept
void write_msgpack(const BasicJsonType &j)
void write_cbor(const BasicJsonType &j)
general exception of the basic_json class
const int id
the id of the exception
static std::string diagnostics(std::nullptr_t)
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 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)
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
pointer operator->() const
dereference the iterator
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
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
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 & 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–)
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
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
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
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
proxy class for the items() function
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(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
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
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)
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)
bool start_array(std::size_t len)
typename BasicJsonType::number_float_t number_float_t
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
bool skip_bom()
skip the UTF-8 byte order mark
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
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).
constexpr number_integer_t get_number_integer() const noexcept
return integer value
constexpr position_t get_position() const noexcept
return position of last read token
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
typename lexer_base< BasicJsonType >::token_type token_type
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
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
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
output adapter for byte vectors
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 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
void parse(const bool strict, BasicJsonType &result)
public parser interface
bool accept(const bool strict=true)
public accept interface
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
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
serializer & operator=(serializer &&)=delete
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.
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
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
bool empty() const noexcept
return whether pointer points to the root document
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 & 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
json_pointer parent_pointer() const
returns the parent of this JSON pointer
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
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
decltype( get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
@ C
C programming language.
#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)
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#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
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_VERSION_MAJOR
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#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
#define NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#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)
#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)
cached_power get_cached_power_for_binary_exponent(int e)
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
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)
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
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
make_integer_sequence< size_t, N > make_index_sequence
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
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
input_format_t
the supported input formats
typename detector< nonesuch, void, Op, Args... >::type detected_t
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
decltype(T::to_json(std::declval< Args >()...)) to_json_function
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
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
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
decltype(std::declval< T & >().end_object()) end_object_function_t
OutStringType concat(Args &&... args)
typename T::value_type value_type_t
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
is_detected< string_can_append, StringType, Arg > detect_string_can_append
typename std::enable_if< B, T >::type enable_if_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
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
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
typename T::pointer pointer_t
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
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
decltype(std::declval< T & >().null()) null_function_t
void int_to_string(StringType &target, std::size_t value)
T conditional_static_cast(U value)
typename T::difference_type difference_type_t
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
decltype(std::declval< T & >().number_float( std::declval< Float >(), std::declval< const String & >())) number_float_function_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 & >().start_array(std::declval< std::size_t >())) start_array_function_t
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
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
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
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
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
make_index_sequence< sizeof...(Ts)> index_sequence_for
void concat_into(OutStringType &)
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)
decltype(T::from_json(std::declval< Args >()...)) from_json_function
constexpr std::size_t unknown_size()
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)
std::size_t hash(const BasicJsonType &j)
hash a JSON value
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
typename make_void< Ts... >::type void_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
decltype(std::declval< T & >().parse_error( std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
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)
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
typename T::iterator_category iterator_category_t
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
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()
std::integral_constant< bool, Value > bool_constant
decltype(input_adapter(std::declval< std::string >())) string_input_adapter_type
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
typename T::key_compare detect_key_compare
void to_json(BasicJsonType &j, T b) noexcept
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
decltype(std::declval< T & >().end_array()) end_array_function_t
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
typename T::key_type key_type_t
typename T::reference reference_t
typename T::is_transparent detect_is_transparent
bjdata_version_t
how to encode BJData
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
typename T::mapped_type mapped_type_t
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
decltype(std::declval< T >().template get< U >()) get_template_function
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
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
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
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))
static constexpr bool value
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)
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
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())
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