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>;
346#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
347#if defined(JSON_HEDLEY_VERSION)
348 #undef JSON_HEDLEY_VERSION
350#define JSON_HEDLEY_VERSION 15
352#if defined(JSON_HEDLEY_STRINGIFY_EX)
353 #undef JSON_HEDLEY_STRINGIFY_EX
355#define JSON_HEDLEY_STRINGIFY_EX(x) #x
357#if defined(JSON_HEDLEY_STRINGIFY)
358 #undef JSON_HEDLEY_STRINGIFY
360#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
362#if defined(JSON_HEDLEY_CONCAT_EX)
363 #undef JSON_HEDLEY_CONCAT_EX
365#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
367#if defined(JSON_HEDLEY_CONCAT)
368 #undef JSON_HEDLEY_CONCAT
370#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
372#if defined(JSON_HEDLEY_CONCAT3_EX)
373 #undef JSON_HEDLEY_CONCAT3_EX
375#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
377#if defined(JSON_HEDLEY_CONCAT3)
378 #undef JSON_HEDLEY_CONCAT3
380#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
382#if defined(JSON_HEDLEY_VERSION_ENCODE)
383 #undef JSON_HEDLEY_VERSION_ENCODE
385#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
387#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
388 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
390#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
392#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
393 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
395#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
397#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
398 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
400#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
402#if defined(JSON_HEDLEY_GNUC_VERSION)
403 #undef JSON_HEDLEY_GNUC_VERSION
405#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
406 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
407#elif defined(__GNUC__)
408 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
411#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
412 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
414#if defined(JSON_HEDLEY_GNUC_VERSION)
415 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
417 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
420#if defined(JSON_HEDLEY_MSVC_VERSION)
421 #undef JSON_HEDLEY_MSVC_VERSION
423#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
424 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
425#elif defined(_MSC_FULL_VER) && !defined(__ICL)
426 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
427#elif defined(_MSC_VER) && !defined(__ICL)
428 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
431#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
432 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
434#if !defined(JSON_HEDLEY_MSVC_VERSION)
435 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
436#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
437 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
438#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
439 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
441 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
444#if defined(JSON_HEDLEY_INTEL_VERSION)
445 #undef JSON_HEDLEY_INTEL_VERSION
447#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
448 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
449#elif defined(__INTEL_COMPILER) && !defined(__ICL)
450 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
453#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
454 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
456#if defined(JSON_HEDLEY_INTEL_VERSION)
457 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
459 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
462#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
463 #undef JSON_HEDLEY_INTEL_CL_VERSION
465#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
466 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
469#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
470 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
472#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
473 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
475 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
478#if defined(JSON_HEDLEY_PGI_VERSION)
479 #undef JSON_HEDLEY_PGI_VERSION
481#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
482 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
485#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
486 #undef JSON_HEDLEY_PGI_VERSION_CHECK
488#if defined(JSON_HEDLEY_PGI_VERSION)
489 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
491 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
494#if defined(JSON_HEDLEY_SUNPRO_VERSION)
495 #undef JSON_HEDLEY_SUNPRO_VERSION
497#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
498 #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)
499#elif defined(__SUNPRO_C)
500 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
501#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
502 #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)
503#elif defined(__SUNPRO_CC)
504 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
507#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
508 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
510#if defined(JSON_HEDLEY_SUNPRO_VERSION)
511 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
513 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
516#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
517 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
519#if defined(__EMSCRIPTEN__)
520 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
523#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
524 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
526#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
527 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
529 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
532#if defined(JSON_HEDLEY_ARM_VERSION)
533 #undef JSON_HEDLEY_ARM_VERSION
535#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
536 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
537#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
538 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
541#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
542 #undef JSON_HEDLEY_ARM_VERSION_CHECK
544#if defined(JSON_HEDLEY_ARM_VERSION)
545 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
547 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
550#if defined(JSON_HEDLEY_IBM_VERSION)
551 #undef JSON_HEDLEY_IBM_VERSION
553#if defined(__ibmxl__)
554 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
555#elif defined(__xlC__) && defined(__xlC_ver__)
556 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
557#elif defined(__xlC__)
558 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
561#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
562 #undef JSON_HEDLEY_IBM_VERSION_CHECK
564#if defined(JSON_HEDLEY_IBM_VERSION)
565 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
567 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
570#if defined(JSON_HEDLEY_TI_VERSION)
571 #undef JSON_HEDLEY_TI_VERSION
574 defined(__TI_COMPILER_VERSION__) && \
576 defined(__TMS470__) || defined(__TI_ARM__) || \
577 defined(__MSP430__) || \
578 defined(__TMS320C2000__) \
580#if (__TI_COMPILER_VERSION__ >= 16000000)
581 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
585#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
586 #undef JSON_HEDLEY_TI_VERSION_CHECK
588#if defined(JSON_HEDLEY_TI_VERSION)
589 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
591 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
594#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
595 #undef JSON_HEDLEY_TI_CL2000_VERSION
597#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
598 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
601#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
602 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
604#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
605 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
607 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
610#if defined(JSON_HEDLEY_TI_CL430_VERSION)
611 #undef JSON_HEDLEY_TI_CL430_VERSION
613#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
614 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
617#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
618 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
620#if defined(JSON_HEDLEY_TI_CL430_VERSION)
621 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
623 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
626#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
627 #undef JSON_HEDLEY_TI_ARMCL_VERSION
629#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
630 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
633#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
634 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
636#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
637 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
639 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
642#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
643 #undef JSON_HEDLEY_TI_CL6X_VERSION
645#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
646 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
649#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
650 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
652#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
653 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
655 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
658#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
659 #undef JSON_HEDLEY_TI_CL7X_VERSION
661#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
662 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
665#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
666 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
668#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
669 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
671 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
674#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
675 #undef JSON_HEDLEY_TI_CLPRU_VERSION
677#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
678 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
681#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
682 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
684#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
685 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
687 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
690#if defined(JSON_HEDLEY_CRAY_VERSION)
691 #undef JSON_HEDLEY_CRAY_VERSION
694 #if defined(_RELEASE_PATCHLEVEL)
695 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
697 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
701#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
702 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
704#if defined(JSON_HEDLEY_CRAY_VERSION)
705 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
707 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
710#if defined(JSON_HEDLEY_IAR_VERSION)
711 #undef JSON_HEDLEY_IAR_VERSION
713#if defined(__IAR_SYSTEMS_ICC__)
715 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
717 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
721#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
722 #undef JSON_HEDLEY_IAR_VERSION_CHECK
724#if defined(JSON_HEDLEY_IAR_VERSION)
725 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
727 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
730#if defined(JSON_HEDLEY_TINYC_VERSION)
731 #undef JSON_HEDLEY_TINYC_VERSION
733#if defined(__TINYC__)
734 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
737#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
738 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
740#if defined(JSON_HEDLEY_TINYC_VERSION)
741 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
743 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
746#if defined(JSON_HEDLEY_DMC_VERSION)
747 #undef JSON_HEDLEY_DMC_VERSION
750 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
753#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
754 #undef JSON_HEDLEY_DMC_VERSION_CHECK
756#if defined(JSON_HEDLEY_DMC_VERSION)
757 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
759 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
762#if defined(JSON_HEDLEY_COMPCERT_VERSION)
763 #undef JSON_HEDLEY_COMPCERT_VERSION
765#if defined(__COMPCERT_VERSION__)
766 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
769#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
770 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
772#if defined(JSON_HEDLEY_COMPCERT_VERSION)
773 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
775 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
778#if defined(JSON_HEDLEY_PELLES_VERSION)
779 #undef JSON_HEDLEY_PELLES_VERSION
782 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
785#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
786 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
788#if defined(JSON_HEDLEY_PELLES_VERSION)
789 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
791 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
794#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
795 #undef JSON_HEDLEY_MCST_LCC_VERSION
797#if defined(__LCC__) && defined(__LCC_MINOR__)
798 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
801#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
802 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
804#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
805 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
807 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
810#if defined(JSON_HEDLEY_GCC_VERSION)
811 #undef JSON_HEDLEY_GCC_VERSION
814 defined(JSON_HEDLEY_GNUC_VERSION) && \
815 !defined(__clang__) && \
816 !defined(JSON_HEDLEY_INTEL_VERSION) && \
817 !defined(JSON_HEDLEY_PGI_VERSION) && \
818 !defined(JSON_HEDLEY_ARM_VERSION) && \
819 !defined(JSON_HEDLEY_CRAY_VERSION) && \
820 !defined(JSON_HEDLEY_TI_VERSION) && \
821 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
822 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
823 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
824 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
825 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
826 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
827 !defined(__COMPCERT__) && \
828 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
829 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
832#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
833 #undef JSON_HEDLEY_GCC_VERSION_CHECK
835#if defined(JSON_HEDLEY_GCC_VERSION)
836 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
838 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
841#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
842 #undef JSON_HEDLEY_HAS_ATTRIBUTE
845 defined(__has_attribute) && \
847 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
849# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
851# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
854#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
855 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
857#if defined(__has_attribute)
858 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
860 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
863#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
864 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
866#if defined(__has_attribute)
867 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
869 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
872#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
873 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
876 defined(__has_cpp_attribute) && \
877 defined(__cplusplus) && \
878 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
879 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
881 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
884#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
885 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
887#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
888 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
890 !defined(JSON_HEDLEY_PGI_VERSION) && \
891 !defined(JSON_HEDLEY_IAR_VERSION) && \
892 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
893 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
894 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
896 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
899#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
900 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
902#if defined(__has_cpp_attribute) && defined(__cplusplus)
903 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
905 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
908#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
909 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
911#if defined(__has_cpp_attribute) && defined(__cplusplus)
912 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
914 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
917#if defined(JSON_HEDLEY_HAS_BUILTIN)
918 #undef JSON_HEDLEY_HAS_BUILTIN
920#if defined(__has_builtin)
921 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
923 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
926#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
927 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
929#if defined(__has_builtin)
930 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
932 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
935#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
936 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
938#if defined(__has_builtin)
939 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
941 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
944#if defined(JSON_HEDLEY_HAS_FEATURE)
945 #undef JSON_HEDLEY_HAS_FEATURE
947#if defined(__has_feature)
948 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
950 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
953#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
954 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
956#if defined(__has_feature)
957 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
959 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
962#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
963 #undef JSON_HEDLEY_GCC_HAS_FEATURE
965#if defined(__has_feature)
966 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
968 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
971#if defined(JSON_HEDLEY_HAS_EXTENSION)
972 #undef JSON_HEDLEY_HAS_EXTENSION
974#if defined(__has_extension)
975 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
977 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
980#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
981 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
983#if defined(__has_extension)
984 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
986 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
989#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
990 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
992#if defined(__has_extension)
993 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
995 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
998#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
999 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1001#if defined(__has_declspec_attribute)
1002 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1004 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1007#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1008 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1010#if defined(__has_declspec_attribute)
1011 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1013 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1016#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1017 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1019#if defined(__has_declspec_attribute)
1020 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1022 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1025#if defined(JSON_HEDLEY_HAS_WARNING)
1026 #undef JSON_HEDLEY_HAS_WARNING
1028#if defined(__has_warning)
1029 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1031 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1034#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1035 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1037#if defined(__has_warning)
1038 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1040 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1043#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1044 #undef JSON_HEDLEY_GCC_HAS_WARNING
1046#if defined(__has_warning)
1047 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1049 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1053 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1054 defined(__clang__) || \
1055 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1056 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1057 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1058 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1059 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1060 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1061 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1062 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1063 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1064 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1065 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1066 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1067 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1068 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1069 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1070 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1071 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1072#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1073 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1075 #define JSON_HEDLEY_PRAGMA(value)
1078#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1079 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1081#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1082 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1084#if defined(__clang__)
1085 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1086 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1087#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1088 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1089 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1090#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1091 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1092 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1094 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1095 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1096 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1097 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1098#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1099 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1100 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1102 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1103 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1104 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1105 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1106 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1107 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1108 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1109 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1110#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1111 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1112 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1114 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1115 #define JSON_HEDLEY_DIAGNOSTIC_POP
1120#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1121 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1123#if defined(__cplusplus)
1124# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1125# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1126# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1127# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1128 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1129 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1130 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1131 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1133 JSON_HEDLEY_DIAGNOSTIC_POP
1135# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1136 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1137 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1138 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1140 JSON_HEDLEY_DIAGNOSTIC_POP
1143# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1144 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1145 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1147 JSON_HEDLEY_DIAGNOSTIC_POP
1151#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1155#if defined(JSON_HEDLEY_CONST_CAST)
1156 #undef JSON_HEDLEY_CONST_CAST
1158#if defined(__cplusplus)
1159# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1161 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1162 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1163 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1164# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1165 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1166 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1168 JSON_HEDLEY_DIAGNOSTIC_POP \
1171# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1174#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1175 #undef JSON_HEDLEY_REINTERPRET_CAST
1177#if defined(__cplusplus)
1178 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1180 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1183#if defined(JSON_HEDLEY_STATIC_CAST)
1184 #undef JSON_HEDLEY_STATIC_CAST
1186#if defined(__cplusplus)
1187 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1189 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1192#if defined(JSON_HEDLEY_CPP_CAST)
1193 #undef JSON_HEDLEY_CPP_CAST
1195#if defined(__cplusplus)
1196# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1197# define JSON_HEDLEY_CPP_CAST(T, expr) \
1198 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1199 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1201 JSON_HEDLEY_DIAGNOSTIC_POP
1202# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1203# define JSON_HEDLEY_CPP_CAST(T, expr) \
1204 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1205 _Pragma("diag_suppress=Pe137") \
1206 JSON_HEDLEY_DIAGNOSTIC_POP
1208# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1211# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1214#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1215 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1217#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1219#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1221#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1222 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1223#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1224 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1225#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1226 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1227#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1228 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1229#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1230 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1231#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1232 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1234 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1235 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1236 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1237 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1238 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1239 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1240 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1241 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1242 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1243 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1244 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1245 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1246#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1247 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1248#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1249 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1250#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1251 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1252#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1253 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1255 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1258#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1259 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1261#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1262 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1263#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1264 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1265#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1267#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1269#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1271#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1274 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1275 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1276 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1277 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1278 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1279#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1280 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1281#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1282 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1283#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1284 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1286 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1289#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1290 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1292#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1293 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1294#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1295 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1296#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1297 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1298#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1299 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1300#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1301 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1302#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1303 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1304#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1305 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1306#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1307 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1309 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1310 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1311 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1312 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1313#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1314 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1315#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1316 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1318 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1321#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1322 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1324#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1325 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1326#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1327 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1328#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1329 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1331 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1334#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1335 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1337#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1338 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1339#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1340 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1341#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1342 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1343#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1344 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1346 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1349#if defined(JSON_HEDLEY_DEPRECATED)
1350 #undef JSON_HEDLEY_DEPRECATED
1352#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1353 #undef JSON_HEDLEY_DEPRECATED_FOR
1356 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1357 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1358 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1359 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1361 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1362 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1363 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1364 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1365 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1366 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1367 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1368 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1369 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1370 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1371 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1372 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1373 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1374 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1375#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1376 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1377 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1379 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1380 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1381 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1382 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1383 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1384 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1385 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1386 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1387 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1388 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1389 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1390 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1391 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1392 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1393 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1394 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1395 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1396 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1398 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1399 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1400 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1401 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1402 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1403#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1404 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1405 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1407 #define JSON_HEDLEY_DEPRECATED(since)
1408 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1411#if defined(JSON_HEDLEY_UNAVAILABLE)
1412 #undef JSON_HEDLEY_UNAVAILABLE
1415 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1416 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1417 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1418 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1419 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1421 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1424#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1425 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1427#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1428 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1431 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1432 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1433 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1434 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1435 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1436 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1437 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1438 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1439 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1440 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1441 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1442 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1443 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1444 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1445 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1446 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1447 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1449 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1450#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1451 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1452 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1453#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1454 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1455 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1456#elif defined(_Check_return_)
1457 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1458 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1460 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1461 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1464#if defined(JSON_HEDLEY_SENTINEL)
1465 #undef JSON_HEDLEY_SENTINEL
1468 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1469 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1470 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1471 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1472 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1473 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1475 #define JSON_HEDLEY_SENTINEL(position)
1478#if defined(JSON_HEDLEY_NO_RETURN)
1479 #undef JSON_HEDLEY_NO_RETURN
1481#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1482 #define JSON_HEDLEY_NO_RETURN __noreturn
1484 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1485 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1486 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1487#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1488 #define JSON_HEDLEY_NO_RETURN _Noreturn
1489#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1490 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1492 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1493 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1494 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1495 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1496 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1497 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1498 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1499 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1500 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1501 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1502 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1503 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1504 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1505 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1506 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1507 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1508 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1509 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1510#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1511 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1513 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1514 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1515 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1516#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1517 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1518#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1519 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1520#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1521 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1523 #define JSON_HEDLEY_NO_RETURN
1526#if defined(JSON_HEDLEY_NO_ESCAPE)
1527 #undef JSON_HEDLEY_NO_ESCAPE
1529#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1530 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1532 #define JSON_HEDLEY_NO_ESCAPE
1535#if defined(JSON_HEDLEY_UNREACHABLE)
1536 #undef JSON_HEDLEY_UNREACHABLE
1538#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1539 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1541#if defined(JSON_HEDLEY_ASSUME)
1542 #undef JSON_HEDLEY_ASSUME
1545 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1546 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1547 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1548 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1549#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1550 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1552 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1553 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1554 #if defined(__cplusplus)
1555 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1557 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1561 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1562 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1563 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1564 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1565 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1566 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1567 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1568 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1569#elif defined(JSON_HEDLEY_ASSUME)
1570 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1572#if !defined(JSON_HEDLEY_ASSUME)
1573 #if defined(JSON_HEDLEY_UNREACHABLE)
1574 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1576 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1579#if defined(JSON_HEDLEY_UNREACHABLE)
1581 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1582 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1583 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1585 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1588 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1590#if !defined(JSON_HEDLEY_UNREACHABLE)
1591 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1595#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1596 #pragma clang diagnostic ignored "-Wpedantic"
1598#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1599 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1601#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1602 #if defined(__clang__)
1603 #pragma clang diagnostic ignored "-Wvariadic-macros"
1604 #elif defined(JSON_HEDLEY_GCC_VERSION)
1605 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1608#if defined(JSON_HEDLEY_NON_NULL)
1609 #undef JSON_HEDLEY_NON_NULL
1612 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1613 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1614 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1615 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1616 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1618 #define JSON_HEDLEY_NON_NULL(...)
1622#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1623 #undef JSON_HEDLEY_PRINTF_FORMAT
1625#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1626 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1627#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1628 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1630 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1631 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1632 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1633 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1634 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1635 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1636 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1637 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1638 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1639 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1640 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1641 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1642 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1643 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1644 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1645 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1646 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1647 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1648#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1649 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1651 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1654#if defined(JSON_HEDLEY_CONSTEXPR)
1655 #undef JSON_HEDLEY_CONSTEXPR
1657#if defined(__cplusplus)
1658 #if __cplusplus >= 201103L
1659 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1662#if !defined(JSON_HEDLEY_CONSTEXPR)
1663 #define JSON_HEDLEY_CONSTEXPR
1666#if defined(JSON_HEDLEY_PREDICT)
1667 #undef JSON_HEDLEY_PREDICT
1669#if defined(JSON_HEDLEY_LIKELY)
1670 #undef JSON_HEDLEY_LIKELY
1672#if defined(JSON_HEDLEY_UNLIKELY)
1673 #undef JSON_HEDLEY_UNLIKELY
1675#if defined(JSON_HEDLEY_UNPREDICTABLE)
1676 #undef JSON_HEDLEY_UNPREDICTABLE
1678#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1679 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1682 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1683 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1684 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1685# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1686# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1687# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1688# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1689# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1691 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1692 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1693 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1694 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1695 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1696 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1697 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1698 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1699 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1700 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1701 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1702 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1703 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1704 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1705 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1706 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1707# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1708 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1709# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1711 double hedley_probability_ = (probability); \
1712 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1714# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1716 double hedley_probability_ = (probability); \
1717 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1719# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1720# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1722# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1723# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1724# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1725# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1726# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1728#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1729 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1732#if defined(JSON_HEDLEY_MALLOC)
1733 #undef JSON_HEDLEY_MALLOC
1736 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1737 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1738 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1739 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1740 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1741 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1742 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1743 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1744 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1745 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1746 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1747 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1748 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1749 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1750 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1751 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1752 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1753 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1754 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1755#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1756 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1758 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1759 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1760 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1762 #define JSON_HEDLEY_MALLOC
1765#if defined(JSON_HEDLEY_PURE)
1766 #undef JSON_HEDLEY_PURE
1769 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1770 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1771 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1772 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1773 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1774 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1775 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1776 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1777 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1778 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1779 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1780 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1781 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1782 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1783 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1784 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1785 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1786 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1787 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1788# define JSON_HEDLEY_PURE __attribute__((__pure__))
1789#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1790# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1791#elif defined(__cplusplus) && \
1793 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1794 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1795 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1797# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1799# define JSON_HEDLEY_PURE
1802#if defined(JSON_HEDLEY_CONST)
1803 #undef JSON_HEDLEY_CONST
1806 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1807 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1808 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1809 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1810 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1811 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1812 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1813 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1814 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1815 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1816 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1817 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1818 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1819 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1820 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1821 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1822 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1823 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1824 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1825 #define JSON_HEDLEY_CONST __attribute__((__const__))
1827 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1828 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1830 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1833#if defined(JSON_HEDLEY_RESTRICT)
1834 #undef JSON_HEDLEY_RESTRICT
1836#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1837 #define JSON_HEDLEY_RESTRICT restrict
1839 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1840 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1841 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1842 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1843 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1844 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1845 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1846 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1847 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1848 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1849 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1850 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1851 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1852 defined(__clang__) || \
1853 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1854 #define JSON_HEDLEY_RESTRICT __restrict
1855#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1856 #define JSON_HEDLEY_RESTRICT _Restrict
1858 #define JSON_HEDLEY_RESTRICT
1861#if defined(JSON_HEDLEY_INLINE)
1862 #undef JSON_HEDLEY_INLINE
1865 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1866 (defined(__cplusplus) && (__cplusplus >= 199711L))
1867 #define JSON_HEDLEY_INLINE inline
1869 defined(JSON_HEDLEY_GCC_VERSION) || \
1870 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1871 #define JSON_HEDLEY_INLINE __inline__
1873 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1874 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1875 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1876 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1877 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1878 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1879 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1880 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1881 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1882 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1883 #define JSON_HEDLEY_INLINE __inline
1885 #define JSON_HEDLEY_INLINE
1888#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1889 #undef JSON_HEDLEY_ALWAYS_INLINE
1892 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1893 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1894 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1895 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1896 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1897 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1898 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1899 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1900 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1901 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1902 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1903 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1904 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1905 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1906 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1907 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1908 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1909 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1910 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1911# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1913 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1914 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1915# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1916#elif defined(__cplusplus) && \
1918 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1919 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1920 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1921 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1922 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1923 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1925# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1926#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1927# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1929# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1932#if defined(JSON_HEDLEY_NEVER_INLINE)
1933 #undef JSON_HEDLEY_NEVER_INLINE
1936 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1937 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1938 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1939 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1940 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1941 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1942 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1943 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1944 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1945 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1946 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1947 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1948 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1949 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1950 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1951 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1952 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1953 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1954 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1955 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1957 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1958 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1959 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1960#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1961 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1962#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1963 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1964#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1965 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1966#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1967 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1968#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1969 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1971 #define JSON_HEDLEY_NEVER_INLINE
1974#if defined(JSON_HEDLEY_PRIVATE)
1975 #undef JSON_HEDLEY_PRIVATE
1977#if defined(JSON_HEDLEY_PUBLIC)
1978 #undef JSON_HEDLEY_PUBLIC
1980#if defined(JSON_HEDLEY_IMPORT)
1981 #undef JSON_HEDLEY_IMPORT
1983#if defined(_WIN32) || defined(__CYGWIN__)
1984# define JSON_HEDLEY_PRIVATE
1985# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1986# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1989 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1990 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1991 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1992 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1993 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1994 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1996 defined(__TI_EABI__) && \
1998 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1999 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2002 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2003# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2004# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2006# define JSON_HEDLEY_PRIVATE
2007# define JSON_HEDLEY_PUBLIC
2009# define JSON_HEDLEY_IMPORT extern
2012#if defined(JSON_HEDLEY_NO_THROW)
2013 #undef JSON_HEDLEY_NO_THROW
2016 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2017 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2018 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2019 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2020 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2022 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2023 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2024 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2025 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2027 #define JSON_HEDLEY_NO_THROW
2030#if defined(JSON_HEDLEY_FALL_THROUGH)
2031 #undef JSON_HEDLEY_FALL_THROUGH
2034 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2035 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2036 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2037 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2038#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2039 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2040#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2041 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2042#elif defined(__fallthrough)
2043 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2045 #define JSON_HEDLEY_FALL_THROUGH
2048#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2049 #undef JSON_HEDLEY_RETURNS_NON_NULL
2052 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2053 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2054 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2055 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2056#elif defined(_Ret_notnull_)
2057 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2059 #define JSON_HEDLEY_RETURNS_NON_NULL
2062#if defined(JSON_HEDLEY_ARRAY_PARAM)
2063 #undef JSON_HEDLEY_ARRAY_PARAM
2066 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2067 !defined(__STDC_NO_VLA__) && \
2068 !defined(__cplusplus) && \
2069 !defined(JSON_HEDLEY_PGI_VERSION) && \
2070 !defined(JSON_HEDLEY_TINYC_VERSION)
2071 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2073 #define JSON_HEDLEY_ARRAY_PARAM(name)
2076#if defined(JSON_HEDLEY_IS_CONSTANT)
2077 #undef JSON_HEDLEY_IS_CONSTANT
2079#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2080 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2084#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2085 #undef JSON_HEDLEY_IS_CONSTEXPR_
2088 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2089 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2090 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2091 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2092 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2093 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2094 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2095 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2096 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2097 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2098 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2100#if !defined(__cplusplus)
2102 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2103 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2104 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2105 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2106 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2107 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2108 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2109#if defined(__INTPTR_TYPE__)
2110 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2113 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2117 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2118 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2119 !defined(JSON_HEDLEY_PGI_VERSION) && \
2120 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2121 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2122 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2123 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2124 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2125 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2126#if defined(__INTPTR_TYPE__)
2127 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2130 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2133 defined(JSON_HEDLEY_GCC_VERSION) || \
2134 defined(JSON_HEDLEY_INTEL_VERSION) || \
2135 defined(JSON_HEDLEY_TINYC_VERSION) || \
2136 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2137 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2138 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2139 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2140 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2141 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2143# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2147 ((void*) ((expr) * 0L) ) : \
2148((struct { char v[sizeof(void) * 2]; } *) 1) \
2154#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2155 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2156 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2158 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2160 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2161 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2163 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2166#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2167 #undef JSON_HEDLEY_BEGIN_C_DECLS
2169#if defined(JSON_HEDLEY_END_C_DECLS)
2170 #undef JSON_HEDLEY_END_C_DECLS
2172#if defined(JSON_HEDLEY_C_DECL)
2173 #undef JSON_HEDLEY_C_DECL
2175#if defined(__cplusplus)
2176 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2177 #define JSON_HEDLEY_END_C_DECLS }
2178 #define JSON_HEDLEY_C_DECL extern "C"
2180 #define JSON_HEDLEY_BEGIN_C_DECLS
2181 #define JSON_HEDLEY_END_C_DECLS
2182 #define JSON_HEDLEY_C_DECL
2185#if defined(JSON_HEDLEY_STATIC_ASSERT)
2186 #undef JSON_HEDLEY_STATIC_ASSERT
2189 !defined(__cplusplus) && ( \
2190 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2191 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2192 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2193 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2194 defined(_Static_assert) \
2196# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2198 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2199 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2200 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2201# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2203# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2206#if defined(JSON_HEDLEY_NULL)
2207 #undef JSON_HEDLEY_NULL
2209#if defined(__cplusplus)
2210 #if __cplusplus >= 201103L
2211 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2213 #define JSON_HEDLEY_NULL NULL
2215 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2218 #define JSON_HEDLEY_NULL NULL
2220 #define JSON_HEDLEY_NULL ((void*) 0)
2223#if defined(JSON_HEDLEY_MESSAGE)
2224 #undef JSON_HEDLEY_MESSAGE
2226#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2227# define JSON_HEDLEY_MESSAGE(msg) \
2228 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2229 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2230 JSON_HEDLEY_PRAGMA(message msg) \
2231 JSON_HEDLEY_DIAGNOSTIC_POP
2233 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2234 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2235# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2236#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2237# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2238#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2239# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2240#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2241# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2243# define JSON_HEDLEY_MESSAGE(msg)
2246#if defined(JSON_HEDLEY_WARNING)
2247 #undef JSON_HEDLEY_WARNING
2249#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2250# define JSON_HEDLEY_WARNING(msg) \
2251 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2252 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2253 JSON_HEDLEY_PRAGMA(clang warning msg) \
2254 JSON_HEDLEY_DIAGNOSTIC_POP
2256 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2257 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2258 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2259# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2261 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2262 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2263# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2265# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2268#if defined(JSON_HEDLEY_REQUIRE)
2269 #undef JSON_HEDLEY_REQUIRE
2271#if defined(JSON_HEDLEY_REQUIRE_MSG)
2272 #undef JSON_HEDLEY_REQUIRE_MSG
2274#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2275# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2276# define JSON_HEDLEY_REQUIRE(expr) \
2277 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2278 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2279 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2280 JSON_HEDLEY_DIAGNOSTIC_POP
2281# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2282 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2283 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2284 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2285 JSON_HEDLEY_DIAGNOSTIC_POP
2287# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2288# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2291# define JSON_HEDLEY_REQUIRE(expr)
2292# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2295#if defined(JSON_HEDLEY_FLAGS)
2296 #undef JSON_HEDLEY_FLAGS
2298#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2299 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2301 #define JSON_HEDLEY_FLAGS
2304#if defined(JSON_HEDLEY_FLAGS_CAST)
2305 #undef JSON_HEDLEY_FLAGS_CAST
2307#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2308# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2309 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2310 _Pragma("warning(disable:188)") \
2312 JSON_HEDLEY_DIAGNOSTIC_POP \
2315# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2318#if defined(JSON_HEDLEY_EMPTY_BASES)
2319 #undef JSON_HEDLEY_EMPTY_BASES
2322 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2323 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2324 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2326 #define JSON_HEDLEY_EMPTY_BASES
2331#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2332 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2334#if defined(__clang__)
2335 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2337 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2340#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2341 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2343#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2345#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2346 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2348#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2350#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2351 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2353#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2355#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2356 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2358#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2360#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2361 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2363#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2365#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2366 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2368#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2370#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2371 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2373#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2385#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2386 #if defined(__clang__)
2387 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2388 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2390 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2391 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2392 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2399#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)
2400 #if (defined(__cplusplus) && __cplusplus > 202302L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202302L)
2401 #define JSON_HAS_CPP_26
2402 #define JSON_HAS_CPP_23
2403 #define JSON_HAS_CPP_20
2404 #define JSON_HAS_CPP_17
2405 #define JSON_HAS_CPP_14
2406 #elif (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
2407 #define JSON_HAS_CPP_23
2408 #define JSON_HAS_CPP_20
2409 #define JSON_HAS_CPP_17
2410 #define JSON_HAS_CPP_14
2411 #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
2412 #define JSON_HAS_CPP_20
2413 #define JSON_HAS_CPP_17
2414 #define JSON_HAS_CPP_14
2415 #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2416 #define JSON_HAS_CPP_17
2417 #define JSON_HAS_CPP_14
2418 #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2419 #define JSON_HAS_CPP_14
2422 #define JSON_HAS_CPP_11
2426 #if __has_include(<version>)
2431#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2432 #ifdef JSON_HAS_CPP_17
2433 #if defined(__cpp_lib_filesystem)
2434 #define JSON_HAS_FILESYSTEM 1
2435 #elif defined(__cpp_lib_experimental_filesystem)
2436 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2437 #elif !defined(__has_include)
2438 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2439 #elif __has_include(<filesystem>)
2440 #define JSON_HAS_FILESYSTEM 1
2441 #elif __has_include(<experimental/filesystem>)
2442 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2446 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2447 #undef JSON_HAS_FILESYSTEM
2448 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2452 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2453 #undef JSON_HAS_FILESYSTEM
2454 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2458 #if defined(__clang_major__) && __clang_major__ < 7
2459 #undef JSON_HAS_FILESYSTEM
2460 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2464 #if defined(_MSC_VER) && _MSC_VER < 1914
2465 #undef JSON_HAS_FILESYSTEM
2466 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2470 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2471 #undef JSON_HAS_FILESYSTEM
2472 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2476 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2477 #undef JSON_HAS_FILESYSTEM
2478 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2483#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2484 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2487#ifndef JSON_HAS_FILESYSTEM
2488 #define JSON_HAS_FILESYSTEM 0
2491#ifndef JSON_HAS_THREE_WAY_COMPARISON
2492 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2493 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2494 #define JSON_HAS_THREE_WAY_COMPARISON 1
2496 #define JSON_HAS_THREE_WAY_COMPARISON 0
2500#ifndef JSON_HAS_RANGES
2502 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2503 #define JSON_HAS_RANGES 0
2504 #elif defined(__cpp_lib_ranges)
2505 #define JSON_HAS_RANGES 1
2507 #define JSON_HAS_RANGES 0
2511#ifndef JSON_HAS_STATIC_RTTI
2512 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2513 #define JSON_HAS_STATIC_RTTI 1
2515 #define JSON_HAS_STATIC_RTTI 0
2519#ifdef JSON_HAS_CPP_17
2520 #define JSON_INLINE_VARIABLE inline
2522 #define JSON_INLINE_VARIABLE
2525#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2526 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2528 #define JSON_NO_UNIQUE_ADDRESS
2532#if defined(__clang__)
2533 #pragma clang diagnostic push
2534 #pragma clang diagnostic ignored "-Wdocumentation"
2535 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2539#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2540 #define JSON_THROW(exception) throw exception
2541 #define JSON_TRY try
2542 #define JSON_CATCH(exception) catch(exception)
2543 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2546 #define JSON_THROW(exception) std::abort()
2547 #define JSON_TRY if(true)
2548 #define JSON_CATCH(exception) if(false)
2549 #define JSON_INTERNAL_CATCH(exception) if(false)
2553#if defined(JSON_THROW_USER)
2555 #define JSON_THROW JSON_THROW_USER
2557#if defined(JSON_TRY_USER)
2559 #define JSON_TRY JSON_TRY_USER
2561#if defined(JSON_CATCH_USER)
2563 #define JSON_CATCH JSON_CATCH_USER
2564 #undef JSON_INTERNAL_CATCH
2565 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2567#if defined(JSON_INTERNAL_CATCH_USER)
2568 #undef JSON_INTERNAL_CATCH
2569 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2573#if !defined(JSON_ASSERT)
2575 #define JSON_ASSERT(x) assert(x)
2579#if defined(JSON_TESTS_PRIVATE)
2580 #define JSON_PRIVATE_UNLESS_TESTED public
2582 #define JSON_PRIVATE_UNLESS_TESTED private
2590#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2591 template<typename BasicJsonType> \
2592 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2595 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2597 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2598 auto it = std::find_if(std::begin(m), std::end(m), \
2599 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2601 return ej_pair.first == e; \
2603 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2605 template<typename BasicJsonType> \
2606 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2609 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2611 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2612 auto it = std::find_if(std::begin(m), std::end(m), \
2613 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2615 return ej_pair.second == j; \
2617 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2623#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2624 template<template<typename, typename, typename...> class ObjectType, \
2625 template<typename, typename...> class ArrayType, \
2626 class StringType, class BooleanType, class NumberIntegerType, \
2627 class NumberUnsignedType, class NumberFloatType, \
2628 template<typename> class AllocatorType, \
2629 template<typename, typename = void> class JSONSerializer, \
2631 class CustomBaseClass>
2633#define NLOHMANN_BASIC_JSON_TPL \
2634 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2635 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2636 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2640#define NLOHMANN_JSON_EXPAND( x ) x
2641#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
2642#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2643 NLOHMANN_JSON_PASTE64, \
2644 NLOHMANN_JSON_PASTE63, \
2645 NLOHMANN_JSON_PASTE62, \
2646 NLOHMANN_JSON_PASTE61, \
2647 NLOHMANN_JSON_PASTE60, \
2648 NLOHMANN_JSON_PASTE59, \
2649 NLOHMANN_JSON_PASTE58, \
2650 NLOHMANN_JSON_PASTE57, \
2651 NLOHMANN_JSON_PASTE56, \
2652 NLOHMANN_JSON_PASTE55, \
2653 NLOHMANN_JSON_PASTE54, \
2654 NLOHMANN_JSON_PASTE53, \
2655 NLOHMANN_JSON_PASTE52, \
2656 NLOHMANN_JSON_PASTE51, \
2657 NLOHMANN_JSON_PASTE50, \
2658 NLOHMANN_JSON_PASTE49, \
2659 NLOHMANN_JSON_PASTE48, \
2660 NLOHMANN_JSON_PASTE47, \
2661 NLOHMANN_JSON_PASTE46, \
2662 NLOHMANN_JSON_PASTE45, \
2663 NLOHMANN_JSON_PASTE44, \
2664 NLOHMANN_JSON_PASTE43, \
2665 NLOHMANN_JSON_PASTE42, \
2666 NLOHMANN_JSON_PASTE41, \
2667 NLOHMANN_JSON_PASTE40, \
2668 NLOHMANN_JSON_PASTE39, \
2669 NLOHMANN_JSON_PASTE38, \
2670 NLOHMANN_JSON_PASTE37, \
2671 NLOHMANN_JSON_PASTE36, \
2672 NLOHMANN_JSON_PASTE35, \
2673 NLOHMANN_JSON_PASTE34, \
2674 NLOHMANN_JSON_PASTE33, \
2675 NLOHMANN_JSON_PASTE32, \
2676 NLOHMANN_JSON_PASTE31, \
2677 NLOHMANN_JSON_PASTE30, \
2678 NLOHMANN_JSON_PASTE29, \
2679 NLOHMANN_JSON_PASTE28, \
2680 NLOHMANN_JSON_PASTE27, \
2681 NLOHMANN_JSON_PASTE26, \
2682 NLOHMANN_JSON_PASTE25, \
2683 NLOHMANN_JSON_PASTE24, \
2684 NLOHMANN_JSON_PASTE23, \
2685 NLOHMANN_JSON_PASTE22, \
2686 NLOHMANN_JSON_PASTE21, \
2687 NLOHMANN_JSON_PASTE20, \
2688 NLOHMANN_JSON_PASTE19, \
2689 NLOHMANN_JSON_PASTE18, \
2690 NLOHMANN_JSON_PASTE17, \
2691 NLOHMANN_JSON_PASTE16, \
2692 NLOHMANN_JSON_PASTE15, \
2693 NLOHMANN_JSON_PASTE14, \
2694 NLOHMANN_JSON_PASTE13, \
2695 NLOHMANN_JSON_PASTE12, \
2696 NLOHMANN_JSON_PASTE11, \
2697 NLOHMANN_JSON_PASTE10, \
2698 NLOHMANN_JSON_PASTE9, \
2699 NLOHMANN_JSON_PASTE8, \
2700 NLOHMANN_JSON_PASTE7, \
2701 NLOHMANN_JSON_PASTE6, \
2702 NLOHMANN_JSON_PASTE5, \
2703 NLOHMANN_JSON_PASTE4, \
2704 NLOHMANN_JSON_PASTE3, \
2705 NLOHMANN_JSON_PASTE2, \
2706 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2707#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2708#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2709#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2710#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2711#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2712#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)
2713#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)
2714#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)
2715#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)
2716#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)
2717#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)
2718#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)
2719#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)
2720#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)
2721#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)
2722#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)
2723#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)
2724#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)
2725#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)
2726#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)
2727#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)
2728#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)
2729#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)
2730#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)
2731#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)
2732#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)
2733#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)
2734#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)
2735#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)
2736#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)
2737#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)
2738#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)
2739#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)
2740#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)
2741#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)
2742#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)
2743#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)
2744#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)
2745#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)
2746#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)
2747#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)
2748#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)
2749#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)
2750#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)
2751#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)
2752#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)
2753#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)
2754#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)
2755#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)
2756#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)
2757#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)
2758#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)
2759#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)
2760#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)
2761#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)
2762#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)
2763#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)
2764#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)
2765#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)
2766#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)
2767#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)
2768#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)
2769#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)
2771#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2772#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2773#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;
2781#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2782 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2783 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2784 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2785 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2793#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2794 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2795 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2796 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2797 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__)) }
2805#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2806 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2807 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2815#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2816 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2817 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2818 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2819 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2827#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2828 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2829 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2830 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2831 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__)) }
2839#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2840 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2841 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2849#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2850 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2851 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__)) } \
2852 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2853 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__)) }
2861#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2862 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2863 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__)) } \
2864 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2865 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__)) }
2873#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2874 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2875 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__)) }
2883#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2884 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2885 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__)) } \
2886 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2887 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__)) }
2895#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2896 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2897 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__)) } \
2898 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2899 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__)) }
2907#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2908 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2909 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__)) }
2917#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2918 namespace detail { \
2919 using std::std_name; \
2921 template<typename... T> \
2922 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2925 namespace detail2 { \
2926 struct std_name##_tag \
2930 template<typename... T> \
2931 std_name##_tag std_name(T&&...); \
2933 template<typename... T> \
2934 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2936 template<typename... T> \
2937 struct would_call_std_##std_name \
2939 static constexpr auto const value = ::nlohmann::detail:: \
2940 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2944 template<typename... T> \
2945 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2949#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2950 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2953#if JSON_USE_IMPLICIT_CONVERSIONS
2954 #define JSON_EXPLICIT
2956 #define JSON_EXPLICIT explicit
2959#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2960 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2963#ifndef JSON_USE_GLOBAL_UDLS
2964 #define JSON_USE_GLOBAL_UDLS 1
2967#if JSON_HAS_THREE_WAY_COMPARISON
3030#if JSON_HAS_THREE_WAY_COMPARISON
3031 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
3036 static constexpr std::array<std::uint8_t, 9> order = {{
3043 const auto l_index =
static_cast<std::size_t
>(lhs);
3044 const auto r_index =
static_cast<std::size_t
>(rhs);
3045#if JSON_HAS_THREE_WAY_COMPARISON
3046 if (l_index < order.size() && r_index < order.size())
3048 return order[l_index] <=> order[r_index];
3050 return std::partial_ordering::unordered;
3052 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3060#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
3063 return std::is_lt(lhs <=> rhs);
3101template<
typename StringType>
3103 const StringType& t)
3106 for (
auto pos = s.find(f);
3107 pos != StringType::npos;
3108 s.replace(pos, f.size(), t),
3109 pos = s.find(f, pos + t.size()))
3120template<
typename StringType>
3135template<
typename StringType>
3176 constexpr operator size_t()
const
3201#include <type_traits>
3212using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3214#ifdef JSON_HAS_CPP_14
3217using std::enable_if_t;
3218using std::index_sequence;
3219using std::make_index_sequence;
3220using std::index_sequence_for;
3225template<
bool B,
typename T =
void>
3252template <
typename T, T... Ints>
3256 static constexpr std::size_t
size() noexcept
3258 return sizeof...(Ints);
3267template <
size_t... Ints>
3270namespace utility_internal
3273template <
typename Seq,
size_t SeqSize,
size_t Rem>
3277template <
typename T, T... Ints,
size_t SeqSize>
3283template <
typename T, T... Ints,
size_t SeqSize>
3291template <
typename T,
size_t N>
3298template <
typename T>
3313template <
typename T, T N>
3329template <
typename... Ts>
3347#ifndef JSON_HAS_CPP_17
3348 template<
typename T>
3352template<
typename T,
typename... Args>
3353constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3355 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3375#include <type_traits>
3377#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3404template<
typename It,
typename =
void>
3407template<
typename It>
3411 typename It::reference, typename It::iterator_category >>
3422template<
typename T,
typename =
void>
3501#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3502 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3527 template<
typename T =
void,
typename SFINAE =
void>
3532 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3534 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3535 class StringType = std::string,
class BooleanType = bool,
3536 class NumberIntegerType = std::int64_t,
3537 class NumberUnsignedType = std::uint64_t,
3538 class NumberFloatType = double,
3539 template<
typename U>
class AllocatorType = std::allocator,
3540 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3542 class BinaryType = std::vector<std::uint8_t>,
3543 class CustomBaseClass =
void>
3548 template<
typename RefStringType>
3559 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3604template<
typename BasicJsonContext>
3606 std::integral_constant < bool,
3607 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3608 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3649template<
typename T,
typename... Args>
3652template<
typename T,
typename... Args>
3655template<
typename T,
typename U>
3659template<
typename BasicJsonType,
typename T,
typename =
void>
3666template <
typename BasicJsonType,
typename T>
3672template<
typename BasicJsonType,
typename T>
3675 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3679 const BasicJsonType&, T&>
::value;
3684template<
typename BasicJsonType,
typename T,
typename =
void>
3687template<
typename BasicJsonType,
typename T>
3690 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3699template<
typename BasicJsonType,
typename T,
typename =
void>
3702template<
typename BasicJsonType,
typename T>
3705 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3716struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3719template<
typename BasicJsonType>
3724 using type =
typename std::conditional < has_key_compare<object_t>::value,
3728template<
typename BasicJsonType>
3760 return static_cast<int_type>(std::char_traits<char>::eof());
3784 return static_cast<int_type>(std::char_traits<char>::eof());
3788#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3790struct char_traits<
std::byte> : std::char_traits<char>
3792 using char_type = std::byte;
3793 using int_type = uint64_t;
3795 static int_type to_int_type(char_type c)
noexcept
3797 return static_cast<int_type
>(std::to_integer<unsigned char>(c));
3800 static char_type to_char_type(int_type i)
noexcept
3802 return std::byte(
static_cast<unsigned char>(i));
3805 static constexpr int_type eof() noexcept
3807 return static_cast<int_type
>(std::char_traits<char>::eof());
3819template<
class B,
class... Bn>
3821: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3824template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3829template <
typename T>
3832template <
typename T1,
typename T2>
3834 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3836template <
typename T1,
typename T2>
3838 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3840template <
typename... Ts>
3842 :
conjunction<is_default_constructible<Ts>...> {};
3844template <
typename... Ts>
3846 :
conjunction<is_default_constructible<Ts>...> {};
3848template <
typename T,
typename... Args>
3851template <
typename T1,
typename T2>
3854template <
typename T1,
typename T2>
3857template <
typename... Ts>
3860template <
typename... Ts>
3863template<
typename T,
typename =
void>
3885 using t_ref =
typename std::add_lvalue_reference<T>::type;
3897 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3910template<
typename T,
typename =
void>
3916template<
typename BasicJsonType,
typename CompatibleObjectType,
3920template<
typename BasicJsonType,
typename CompatibleObjectType>
3922 BasicJsonType, CompatibleObjectType,
3931 typename CompatibleObjectType::key_type>
::value &&
3933 typename CompatibleObjectType::mapped_type>
::value;
3936template<
typename BasicJsonType,
typename CompatibleObjectType>
3940template<
typename BasicJsonType,
typename ConstructibleObjectType,
3944template<
typename BasicJsonType,
typename ConstructibleObjectType>
3946 BasicJsonType, ConstructibleObjectType,
3954 (std::is_move_assignable<ConstructibleObjectType>::value ||
3955 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3957 typename object_t::key_type>
::value &&
3959 typename object_t::mapped_type,
3960 typename ConstructibleObjectType::mapped_type >
::value)) ||
3962 typename ConstructibleObjectType::mapped_type>
::value ||
3965 typename ConstructibleObjectType::mapped_type >
::value);
3968template<
typename BasicJsonType,
typename ConstructibleObjectType>
3971 ConstructibleObjectType> {};
3973template<
typename BasicJsonType,
typename CompatibleStringType>
3980template<
typename BasicJsonType,
typename ConstructibleStringType>
3984#ifdef __INTEL_COMPILER
3985 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3997template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
4000template<
typename BasicJsonType,
typename CompatibleArrayType>
4002 BasicJsonType, CompatibleArrayType,
4008 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
4015template<
typename BasicJsonType,
typename CompatibleArrayType>
4019template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
4022template<
typename BasicJsonType,
typename ConstructibleArrayType>
4024 BasicJsonType, ConstructibleArrayType,
4026 typename BasicJsonType::value_type>
::value >>
4027 : std::true_type {};
4029template<
typename BasicJsonType,
typename ConstructibleArrayType>
4031 BasicJsonType, ConstructibleArrayType,
4033 typename BasicJsonType::value_type>
::value&&
4036(std::is_move_assignable<ConstructibleArrayType>::value ||
4037 std::is_copy_assignable<ConstructibleArrayType>::value)&&
4043!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
4045detected_t<range_value_t, ConstructibleArrayType >>
::value >>
4051 typename BasicJsonType::array_t::value_type>
::value ||
4059template<
typename BasicJsonType,
typename ConstructibleArrayType>
4063template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
4067template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4069 RealIntegerType, CompatibleNumberIntegerType,
4071 std::is_integral<CompatibleNumberIntegerType>
::value&&
4072 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
4080 CompatibleNumberIntegerType>
::value &&
4081 CompatibleLimits::is_integer &&
4082 RealLimits::is_signed == CompatibleLimits::is_signed;
4085template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4088 CompatibleNumberIntegerType> {};
4090template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
4093template<
typename BasicJsonType,
typename CompatibleType>
4095 BasicJsonType, CompatibleType,
4102template<
typename BasicJsonType,
typename CompatibleType>
4106template<
typename BasicJsonType,
typename CompatibleReferenceType>
4110 using CVType =
typename std::remove_reference<CompatibleReferenceType>::type;
4111 using Type =
typename std::remove_cv<CVType>::type;
4112 constexpr static bool value = std::is_reference<CompatibleReferenceType>::value &&
4113 (!std::is_const<typename std::remove_reference<BasicJsonType>::type>
::value || std::is_const<CVType>::value) &&
4114 (std::is_same<typename JsonType::boolean_t, Type>::value ||
4115 std::is_same<typename JsonType::number_float_t, Type>::value ||
4116 std::is_same<typename JsonType::number_integer_t, Type>::value ||
4117 std::is_same<typename JsonType::number_unsigned_t, Type>::value ||
4118 std::is_same<typename JsonType::string_t, Type>::value ||
4119 std::is_same<typename JsonType::binary_t, Type>::value ||
4120 std::is_same<typename JsonType::object_t, Type>::value ||
4121 std::is_same<typename JsonType::array_t, Type>::value);
4124template<
typename BasicJsonType,
typename CompatibleReferenceType>
4128template<
typename T1,
typename T2>
4131template<
typename T1,
typename... Args>
4134template<
typename BasicJsonType,
typename T>
4137template<
typename BasicJsonType>
4140template<
typename BasicJsonType>
4145template<
template <
typename...>
class Primary,
typename T>
4148template<
template <
typename...>
class Primary,
typename... Args>
4155template <
typename A,
typename B>
4158template <
typename A>
4161template <
typename A>
4165template<
typename Compare,
typename A,
typename B,
typename =
void>
4173template<
typename Compare,
typename A,
typename B>
4175&& std::is_constructible <decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>()))>
::value
4176&& std::is_constructible <decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))>
::value
4177>> : std::true_type {};
4184template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4188 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4190 && (!RequireTransparentComparator
4191 || is_detected <detect_is_transparent, Comparator>::value)
4194 std::false_type >::type;
4202template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4206 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4207 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4209#ifdef JSON_HAS_CPP_17
4210 || std::is_convertible<KeyType, std::string_view>::value
4213 std::false_type >::type;
4215template<
typename ObjectType,
typename KeyType>
4219template<
typename BasicJsonType,
typename KeyType>
4223 typename BasicJsonType::object_t, KeyType >
::value,
4225 std::false_type >::type;
4229template <
typename T>
4239 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4242 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
4246template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4249 return static_cast<T
>(
value);
4252template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4258template<
typename... Types>
4261template<
typename... Types>
4264template<
typename... Types>
4268template<
typename... Types>
4272template<
typename OfType,
typename T>
4274 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4277template<
typename OfType,
typename T,
4278 bool OfTypeSigned = std::is_signed<OfType>::value,
4279 bool TSigned = std::is_signed<T>::value>
4282template<
typename OfType,
typename T>
4287 using CommonType =
typename std::common_type<OfType, T>::type;
4288 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4292template<
typename OfType,
typename T>
4297 using CommonType =
typename std::common_type<OfType, T>::type;
4298 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4302template<
typename OfType,
typename T>
4307 using CommonType =
typename std::common_type<OfType, T>::type;
4308 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4312template<
typename OfType,
typename T>
4317 using CommonType =
typename std::common_type<OfType, T>::type;
4318 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4319 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4323template<
typename OfType,
typename T,
4324 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4328template<
typename OfType,
typename T>
4337template<
typename OfType,
typename T>
4346template<
typename OfType,
typename T>
4365 using TUnExt =
typename std::remove_extent<T>::type;
4366 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4367 using TUnPtr =
typename std::remove_pointer<T>::type;
4368 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4370 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4371 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4436template<
typename... Args>
4437inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4439template<
typename StringType,
typename... Args>
4440inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4442template<
typename... Args>
4448template<
typename... Args>
4455template<
typename StringType,
typename... Args>
4461template<
typename OutStringType>
4465template<
typename StringType,
typename Arg>
4468template<
typename StringType,
typename Arg>
4471template<
typename StringType,
typename Arg>
4474template<
typename StringType,
typename Arg>
4477template<
typename StringType,
typename Arg>
4478using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4480template<
typename StringType,
typename Arg>
4483template<
typename StringType,
typename Arg>
4484using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4486template<
typename StringType,
typename Arg>
4489template <
typename OutStringType,
typename Arg,
typename... Args,
4490 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4492inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4494template <
typename OutStringType,
typename Arg,
typename... Args,
4495 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4498inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4500template <
typename OutStringType,
typename Arg,
typename... Args,
4501 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4505inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4507template<
typename OutStringType,
typename Arg,
typename... Args,
4509inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4511 out.append(std::forward<Arg>(arg));
4515template <
typename OutStringType,
typename Arg,
typename... Args,
4516 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4517 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4518inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4520 out += std::forward<Arg>(arg);
4524template <
typename OutStringType,
typename Arg,
typename... Args,
4525 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4526 && !detect_string_can_append_op<OutStringType, Arg>::value
4527 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4528inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4530 out.append(arg.begin(), arg.end());
4534template <
typename OutStringType,
typename Arg,
typename... Args,
4535 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4536 && !detect_string_can_append_op<OutStringType, Arg>::value
4537 && !detect_string_can_append_iter<OutStringType, Arg>::value
4538 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4539inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4541 out.append(arg.data(), arg.size());
4545template<
typename OutStringType = std::string,
typename... Args>
4565#if defined(__clang__)
4566 #pragma clang diagnostic push
4567 #pragma clang diagnostic ignored "-Wweak-vtables"
4584 const char*
what() const noexcept
override
4594 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
4596 static std::string
name(
const std::string& ename,
int id_)
4598 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4606 template<
typename BasicJsonType>
4610 std::vector<std::string> tokens;
4611 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4613 switch (current->m_parent->type())
4617 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4619 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4621 tokens.emplace_back(std::to_string(i));
4630 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4632 if (&element.second == current)
4634 tokens.emplace_back(element.first.c_str());
4659 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4660 [](
const std::string & a,
const std::string & b)
4662 return concat(a,
'/', detail::escape(b));
4673 std::runtime_error
m;
4674#if JSON_DIAGNOSTIC_POSITIONS
4675 template<
typename BasicJsonType>
4678 if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
4680 return concat(
"(bytes ", std::to_string(leaf_element->start_pos()),
"-", std::to_string(leaf_element->end_pos()),
") ");
4685 template<
typename BasicJsonType>
4688 static_cast<void>(leaf_element);
4708 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4716 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4717 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4720 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4722 return {id_, byte_, w.c_str()};
4752 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4756 return {id_, w.c_str()};
4770 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4774 return {id_, w.c_str()};
4787 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4791 return {id_, w.c_str()};
4804 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4808 return {id_, w.c_str()};
4819#if defined(__clang__)
4820 #pragma clang diagnostic pop
4865#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4866#include <experimental/filesystem>
4870namespace std_fs = std::experimental::filesystem;
4873#elif JSON_HAS_FILESYSTEM
4874#include <filesystem>
4878namespace std_fs = std::filesystem;
4894#ifdef JSON_HAS_CPP_17
4896template<
bool... Booleans>
4897struct cxpr_or_impl : std::integral_constant < bool, (Booleans || ...) > {};
4899template<
bool... Booleans>
4900struct cxpr_and_impl : std::integral_constant < bool, (Booleans &&...) > {};
4904template<
bool... Booleans>
4907template<
bool... Booleans>
4910template<
bool... Booleans>
4913template<
bool... Booleans>
4916template<
bool... Booleans>
4919template<
bool... Booleans>
4924template<
class Boolean>
4925struct cxpr_not : std::integral_constant < bool, !Boolean::value > {};
4927template<
class... Booleans>
4930template<
bool... Booleans>
4933template<
class... Booleans>
4936template<
bool... Booleans>
4948#ifdef JSON_HAS_CPP_17
4952#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4953 #include <string_view>
4960template<
typename BasicJsonType>
4961inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4970#ifdef JSON_HAS_CPP_17
4971template <
typename BasicJsonType,
typename T,
4972 typename std::enable_if < !nlohmann::detail::is_basic_json<T>::value,
int >::type = 0 >
4973void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4981 opt.emplace(j.template get<T>());
4987template <
typename BasicJsonType,
typename ArithmeticType,
4988 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4989 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4993 switch (
static_cast<value_t>(j))
4997 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5002 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5007 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5023template<
typename BasicJsonType>
5024inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
5030 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
5033template<
typename BasicJsonType>
5034inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
5040 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5044 typename BasicJsonType,
typename StringType,
5046 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
5047 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
5048 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
5049 && !is_json_ref<StringType>::value,
int > = 0 >
5057 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5060template<
typename BasicJsonType>
5061inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
5066template<
typename BasicJsonType>
5067inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
5072template<
typename BasicJsonType>
5073inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
5078#if !JSON_DISABLE_ENUM_SERIALIZATION
5079template<
typename BasicJsonType,
typename EnumType,
5080 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5083 typename std::underlying_type<EnumType>::type val;
5085 e =
static_cast<EnumType
>(val);
5090template<
typename BasicJsonType,
typename T,
typename Allocator,
5091 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
5092inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
5099 std::transform(j.rbegin(), j.rend(),
5100 std::front_inserter(l), [](
const BasicJsonType & i)
5102 return i.template get<T>();
5107template<
typename BasicJsonType,
typename T,
5108 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
5109inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
5116 std::transform(j.begin(), j.end(), std::begin(l),
5117 [](
const BasicJsonType & elem)
5119 return elem.template get<T>();
5123template<
typename BasicJsonType,
typename T, std::
size_t N>
5125->
decltype(j.template get<T>(), void())
5127 for (std::size_t i = 0; i < N; ++i)
5129 arr[i] = j.at(i).template get<T>();
5133template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2>
5135->
decltype(j.template get<T>(), void())
5137 for (std::size_t i1 = 0; i1 < N1; ++i1)
5139 for (std::size_t i2 = 0; i2 < N2; ++i2)
5141 arr[i1][i2] = j.at(i1).at(i2).template get<T>();
5146template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3>
5148->
decltype(j.template get<T>(), void())
5150 for (std::size_t i1 = 0; i1 < N1; ++i1)
5152 for (std::size_t i2 = 0; i2 < N2; ++i2)
5154 for (std::size_t i3 = 0; i3 < N3; ++i3)
5156 arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template get<T>();
5162template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3, std::
size_t N4>
5163auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3][N4])
5164->
decltype(j.template get<T>(), void())
5166 for (std::size_t i1 = 0; i1 < N1; ++i1)
5168 for (std::size_t i2 = 0; i2 < N2; ++i2)
5170 for (std::size_t i3 = 0; i3 < N3; ++i3)
5172 for (std::size_t i4 = 0; i4 < N4; ++i4)
5174 arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template get<T>();
5181template<
typename BasicJsonType>
5184 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
5187template<
typename BasicJsonType,
typename T, std::
size_t N>
5190->
decltype(j.template get<T>(), void())
5192 for (std::size_t i = 0; i < N; ++i)
5194 arr[i] = j.at(i).template get<T>();
5198template<
typename BasicJsonType,
typename ConstructibleArrayType,
5200 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5204 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
5205 j.template get<typename ConstructibleArrayType::value_type>(),
5210 ConstructibleArrayType ret;
5211 ret.reserve(j.size());
5212 std::transform(j.begin(), j.end(),
5213 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
5217 return i.template get<typename ConstructibleArrayType::value_type>();
5219 arr = std::move(ret);
5222template<
typename BasicJsonType,
typename ConstructibleArrayType,
5224 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5231 ConstructibleArrayType ret;
5233 j.begin(), j.end(), std::inserter(ret, end(ret)),
5234 [](
const BasicJsonType & i)
5238 return i.template get<typename ConstructibleArrayType::value_type>();
5240 arr = std::move(ret);
5243template <
typename BasicJsonType,
typename ConstructibleArrayType,
5245 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
5246 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
5248 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
5249 !is_basic_json<ConstructibleArrayType>::value,
5251auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
5253j.template get<typename ConstructibleArrayType::value_type>(),
5264template <
typename BasicJsonType,
typename T, std::size_t... Idx >
5268 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
5271template <
typename BasicJsonType,
typename T, std::
size_t N >
5283template<
typename BasicJsonType>
5284inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
5291 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5294template<
typename BasicJsonType,
typename ConstructibleObjectType,
5295 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5296inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5303 ConstructibleObjectType ret;
5304 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5305 using value_type =
typename ConstructibleObjectType::value_type;
5307 inner_object->begin(), inner_object->end(),
5308 std::inserter(ret, ret.begin()),
5309 [](
typename BasicJsonType::object_t::value_type
const & p)
5311 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5313 obj = std::move(ret);
5320template <
typename BasicJsonType,
typename ArithmeticType,
5322 std::is_arithmetic<ArithmeticType>::value&&
5323 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5324 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5325 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5326 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5328inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5330 switch (
static_cast<value_t>(j))
5334 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5339 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5344 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5349 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5364template<
typename BasicJsonType,
typename Type>
5367 return std::forward<BasicJsonType>(j).template get<detail::uncvref_t<Type>>();
5370template<
typename BasicJsonType,
typename Type,
5374 return std::forward<BasicJsonType>(j).template get_ref<Type>();
5377template<
typename BasicJsonType,
typename Type,
5381 return std::forward<BasicJsonType>(j).template get<detail::uncvref_t<Type>>();
5384template<std::size_t PTagValue,
typename BasicJsonType,
typename... Types>
5387template<std::size_t PTagValue,
typename... Args,
typename BasicJsonType, std::size_t... Idx>
5393template<std::
size_t PTagValue,
typename BasicJsonType>
5399template <
typename BasicJsonType,
class A1,
class A2 >
5402 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
5403 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
5406template<
typename BasicJsonType,
typename A1,
typename A2>
5412template<
typename BasicJsonType,
typename... Args>
5416 "Can not return a tuple containing references to types not contained in a Json, try Json::get_to()");
5420template<
typename BasicJsonType,
typename... Args>
5426template<
typename BasicJsonType,
typename TupleRelated>
5435 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5438template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5440 typename BasicJsonType::string_t, Key >
::value >>
5441inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5448 for (
const auto& p : j)
5454 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5458template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5460 typename BasicJsonType::string_t, Key >
::value >>
5461inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5468 for (
const auto& p : j)
5474 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5478#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5479template<
typename BasicJsonType>
5480inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5486 const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5490#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
5491 p = std_fs::path(std::u8string_view(
reinterpret_cast<const char8_t*
>(s.data()), s.size()));
5493 p = std_fs::u8path(s);
5500 template<
typename BasicJsonType,
typename T>
5502 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5503 ->
decltype(
from_json(j, std::forward<T>(val)))
5505 return from_json(j, std::forward<T>(val));
5511#ifndef JSON_HAS_CPP_17
5520#ifndef JSON_HAS_CPP_17
5539#ifdef JSON_HAS_CPP_17
5548#include <type_traits>
5598template<
typename StringType>
5602 using std::to_string;
5606template<
typename StringType>
5632 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5649 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5659 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5662 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5706 switch (
anchor.m_object->type())
5738 typename IteratorType::reference
value()
const
5780template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5781auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5788template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5789auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5804#if defined(__clang__)
5806 #pragma clang diagnostic push
5807 #pragma clang diagnostic ignored "-Wmismatched-tags"
5809template<
typename IteratorType>
5810class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5811 :
public std::integral_constant<std::size_t, 2> {};
5813template<std::
size_t N,
typename IteratorType>
5814class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5818 get<N>(std::declval <
5819 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5821#if defined(__clang__)
5822 #pragma clang diagnostic pop
5828 template <
typename IteratorType>
5829 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5861 template<
typename BasicJsonType>
5862 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5864 j.m_data.m_value.destroy(j.m_data.m_type);
5866 j.m_data.m_value = b;
5867 j.assert_invariant();
5874 template<
typename BasicJsonType>
5875 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5877 j.m_data.m_value.destroy(j.m_data.m_type);
5879 j.m_data.m_value = s;
5880 j.assert_invariant();
5883 template<
typename BasicJsonType>
5884 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5886 j.m_data.m_value.destroy(j.m_data.m_type);
5888 j.m_data.m_value = std::move(s);
5889 j.assert_invariant();
5892 template <
typename BasicJsonType,
typename CompatibleStringType,
5893 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5895 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5897 j.m_data.m_value.destroy(j.m_data.m_type);
5899 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5900 j.assert_invariant();
5907 template<
typename BasicJsonType>
5908 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5910 j.m_data.m_value.destroy(j.m_data.m_type);
5912 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5913 j.assert_invariant();
5916 template<
typename BasicJsonType>
5917 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5919 j.m_data.m_value.destroy(j.m_data.m_type);
5921 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5922 j.assert_invariant();
5929 template<
typename BasicJsonType>
5930 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5932 j.m_data.m_value.destroy(j.m_data.m_type);
5934 j.m_data.m_value = val;
5935 j.assert_invariant();
5942 template<
typename BasicJsonType>
5943 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5945 j.m_data.m_value.destroy(j.m_data.m_type);
5947 j.m_data.m_value = val;
5948 j.assert_invariant();
5955 template<
typename BasicJsonType>
5956 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5958 j.m_data.m_value.destroy(j.m_data.m_type);
5960 j.m_data.m_value = val;
5961 j.assert_invariant();
5968 template<
typename BasicJsonType>
5969 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5971 j.m_data.m_value.destroy(j.m_data.m_type);
5973 j.m_data.m_value = arr;
5975 j.assert_invariant();
5978 template<
typename BasicJsonType>
5979 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5981 j.m_data.m_value.destroy(j.m_data.m_type);
5983 j.m_data.m_value = std::move(arr);
5985 j.assert_invariant();
5988 template <
typename BasicJsonType,
typename CompatibleArrayType,
5989 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5991 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5996 j.m_data.m_value.destroy(j.m_data.m_type);
5998 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
6000 j.assert_invariant();
6003 template<
typename BasicJsonType>
6004 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
6006 j.m_data.m_value.destroy(j.m_data.m_type);
6009 j.m_data.m_value.array->reserve(arr.size());
6010 for (
const bool x : arr)
6012 j.m_data.m_value.array->push_back(x);
6013 j.set_parent(j.m_data.m_value.array->back());
6015 j.assert_invariant();
6018 template<
typename BasicJsonType,
typename T,
6020 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
6022 j.m_data.m_value.destroy(j.m_data.m_type);
6025 j.m_data.m_value.array->resize(arr.size());
6028 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
6031 j.assert_invariant();
6038 template<
typename BasicJsonType>
6039 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
6041 j.m_data.m_value.destroy(j.m_data.m_type);
6043 j.m_data.m_value = obj;
6045 j.assert_invariant();
6048 template<
typename BasicJsonType>
6049 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6051 j.m_data.m_value.destroy(j.m_data.m_type);
6053 j.m_data.m_value = std::move(obj);
6055 j.assert_invariant();
6058 template <
typename BasicJsonType,
typename CompatibleObjectType,
6059 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
6060 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
6065 j.m_data.m_value.destroy(j.m_data.m_type);
6067 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
6069 j.assert_invariant();
6077#ifdef JSON_HAS_CPP_17
6078template<
typename BasicJsonType,
typename T,
6079 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
6080void to_json(BasicJsonType& j,
const std::optional<T>& opt)
noexcept
6082 if (opt.has_value())
6093template<
typename BasicJsonType,
typename T,
6094 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
6095inline void to_json(BasicJsonType& j, T b)
noexcept
6100template <
typename BasicJsonType,
typename BoolRef,
6102 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
6103 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
6104 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
6106 typename BasicJsonType::boolean_t >
::value))
6107 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
6108inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
6113template<
typename BasicJsonType,
typename CompatibleString,
6114 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
6115inline void to_json(BasicJsonType& j,
const CompatibleString& s)
6120template<
typename BasicJsonType>
6121inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
6126template<
typename BasicJsonType,
typename FloatType,
6127 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
6128inline void to_json(BasicJsonType& j, FloatType val)
noexcept
6133template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
6134 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
6135inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
6140template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
6141 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
6142inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
6147#if !JSON_DISABLE_ENUM_SERIALIZATION
6148template<
typename BasicJsonType,
typename EnumType,
6149 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
6150inline void to_json(BasicJsonType& j, EnumType e)
noexcept
6152 using underlying_type =
typename std::underlying_type<EnumType>::type;
6158template<
typename BasicJsonType>
6159inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
6164template <
typename BasicJsonType,
typename CompatibleArrayType,
6165 enable_if_t < is_compatible_array_type<BasicJsonType,
6167 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
6169 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
6170 !is_basic_json<CompatibleArrayType>::value,
6172inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
6177template<
typename BasicJsonType>
6178inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
6183template<
typename BasicJsonType,
typename T,
6184 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
6185inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
6190template<
typename BasicJsonType>
6191inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
6196template <
typename BasicJsonType,
typename CompatibleObjectType,
6197 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
6198inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
6203template<
typename BasicJsonType>
6204inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6210 typename BasicJsonType,
typename T, std::size_t N,
6211 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
6214inline void to_json(BasicJsonType& j,
const T(&arr)[N])
6219template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
6220inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
6222 j = { p.first, p.second };
6226template<
typename BasicJsonType,
typename T,
6227 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
6230 j = { {b.key(), b.value()} };
6233template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
6236 j = { std::get<Idx>(t)... };
6239template<
typename BasicJsonType,
typename Tuple>
6242 using array_t =
typename BasicJsonType::array_t;
6246template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
6247inline void to_json(BasicJsonType& j,
const T& t)
6252#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
6253#if defined(__cpp_lib_char8_t)
6254template<
typename BasicJsonType,
typename Tr,
typename Allocator>
6255inline void to_json(BasicJsonType& j,
const std::basic_string<char8_t, Tr, Allocator>& s)
6257 using OtherAllocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<char>;
6258 j = std::basic_string<char, std::char_traits<char>, OtherAllocator>(s.begin(), s.end(), s.get_allocator());
6262template<
typename BasicJsonType>
6263inline void to_json(BasicJsonType& j,
const std_fs::path& p)
6273 template<
typename BasicJsonType,
typename T>
6274 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
6275 ->
decltype(
to_json(j, std::forward<T>(val)), void())
6277 return to_json(j, std::forward<T>(val));
6282#ifndef JSON_HAS_CPP_17
6291#ifndef JSON_HAS_CPP_17
6303template<
typename ValueType,
typename>
6308 template<
typename BasicJsonType,
typename TargetType = ValueType>
6309 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
6310 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
6311 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
6313 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
6318 template<
typename BasicJsonType,
typename TargetType = ValueType>
6328 template<
typename BasicJsonType,
typename TargetType = ValueType>
6329 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
6330 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
6331 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
6333 ::nlohmann::to_json(j, std::forward<TargetType>(val));
6361template<
typename BinaryType>
6405 return !(rhs == *
this);
6464#include <functional>
6476inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6478 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6493template<
typename BasicJsonType>
6494std::size_t
hash(
const BasicJsonType& j)
6496 using string_t =
typename BasicJsonType::string_t;
6497 using number_integer_t =
typename BasicJsonType::number_integer_t;
6498 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6499 using number_float_t =
typename BasicJsonType::number_float_t;
6501 const auto type =
static_cast<std::size_t
>(j.type());
6504 case BasicJsonType::value_t::null:
6505 case BasicJsonType::value_t::discarded:
6510 case BasicJsonType::value_t::object:
6512 auto seed =
combine(type, j.size());
6513 for (
const auto& element : j.items())
6515 const auto h = std::hash<string_t> {}(element.key());
6522 case BasicJsonType::value_t::array:
6524 auto seed =
combine(type, j.size());
6525 for (
const auto& element : j)
6532 case BasicJsonType::value_t::string:
6534 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6538 case BasicJsonType::value_t::boolean:
6540 const auto h = std::hash<bool> {}(j.template get<bool>());
6544 case BasicJsonType::value_t::number_integer:
6546 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6550 case BasicJsonType::value_t::number_unsigned:
6552 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6556 case BasicJsonType::value_t::number_float:
6558 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6562 case BasicJsonType::value_t::binary:
6564 auto seed =
combine(type, j.get_binary().size());
6565 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6567 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6568 for (
const auto byte : j.get_binary())
6570 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6607#ifdef __cpp_lib_byteswap
6632#include <type_traits>
6686 return std::fgetc(
m_file);
6693 return fread(dest, 1,
sizeof(T) * count,
m_file);
6721 is->clear(
is->rdstate() & std::ios::eofbit);
6726 :
is(&i),
sb(i.rdbuf())
6735 :
is(rhs.is),
sb(rhs.sb)
6746 auto res =
sb->sbumpc();
6750 is->clear(
is->rdstate() | std::ios::eofbit);
6758 auto res =
static_cast<std::size_t
>(
sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(count *
sizeof(T))));
6761 is->clear(
is->rdstate() | std::ios::eofbit);
6768 std::istream*
is =
nullptr;
6769 std::streambuf*
sb =
nullptr;
6775template<
typename IteratorType>
6779 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6801 auto* ptr =
reinterpret_cast<char*
>(dest);
6802 for (std::size_t read_index = 0; read_index < count *
sizeof(T); ++read_index)
6806 ptr[read_index] =
static_cast<char>(*current);
6814 return count *
sizeof(T);
6821 template<
typename BaseInputAdapter,
size_t T>
6830template<
typename BaseInputAdapter,
size_t T>
6833template<
typename BaseInputAdapter>
6838 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6839 size_t& utf8_bytes_index,
6840 size_t& utf8_bytes_filled)
6842 utf8_bytes_index = 0;
6846 utf8_bytes[0] = std::char_traits<char>::eof();
6847 utf8_bytes_filled = 1;
6852 const auto wc = input.get_character();
6857 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6858 utf8_bytes_filled = 1;
6860 else if (wc <= 0x7FF)
6862 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6863 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6864 utf8_bytes_filled = 2;
6866 else if (wc <= 0xFFFF)
6868 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6869 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6870 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6871 utf8_bytes_filled = 3;
6873 else if (wc <= 0x10FFFF)
6875 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6876 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6877 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6878 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6879 utf8_bytes_filled = 4;
6884 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6885 utf8_bytes_filled = 1;
6891template<
typename BaseInputAdapter>
6896 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6897 size_t& utf8_bytes_index,
6898 size_t& utf8_bytes_filled)
6900 utf8_bytes_index = 0;
6904 utf8_bytes[0] = std::char_traits<char>::eof();
6905 utf8_bytes_filled = 1;
6910 const auto wc = input.get_character();
6915 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6916 utf8_bytes_filled = 1;
6918 else if (wc <= 0x7FF)
6920 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6921 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6922 utf8_bytes_filled = 2;
6924 else if (0xD800 > wc || wc >= 0xE000)
6926 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6927 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6928 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6929 utf8_bytes_filled = 3;
6935 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6936 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6937 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6938 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6939 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6940 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6941 utf8_bytes_filled = 4;
6945 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6946 utf8_bytes_filled = 1;
6954template<
typename BaseInputAdapter,
typename W
ideCharType>
6968 fill_buffer<sizeof(WideCharType)>();
6997 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
7005template<
typename IteratorType,
typename Enable =
void>
7009 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
7014 return adapter_type(std::move(first), std::move(last));
7028template<
typename IteratorType>
7032 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
7043template<
typename IteratorType>
7047 return factory_type::create(first, last);
7054namespace container_input_adapter_factory_impl
7060template<
typename ContainerType,
typename Enable =
void>
7063template<
typename ContainerType>
7065 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
7077template<
typename ContainerType>
7090 if (file ==
nullptr)
7092 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));
7111template <
typename CharT,
7112 typename std::enable_if <
7113 std::is_pointer<CharT>::value&&
7114 !std::is_array<CharT>::value&&
7115 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
7116 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
7122 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));
7124 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
7125 const auto* ptr =
reinterpret_cast<const char*
>(b);
7129template<
typename T, std::
size_t N>
7141 template <
typename CharT,
7142 typename std::enable_if <
7143 std::is_pointer<CharT>::value&&
7144 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
7145 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
7148 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
7150 template<
class IteratorType,
7151 typename std::enable_if<
7152 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
7159 return std::move(ia);
7182#include <type_traits>
7204#include <initializer_list>
7226template<
typename BasicJsonType>
7260 return "<uninitialized>";
7262 return "true literal";
7264 return "false literal";
7266 return "null literal";
7268 return "string literal";
7272 return "number literal";
7286 return "<parse error>";
7288 return "end of input";
7290 return "'[', '{', or a literal";
7293 return "unknown token";
7303template<
typename BasicJsonType,
typename InputAdapterType>
7316 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7317 :
ia(
std::move(adapter))
7338 const auto* loc = localeconv();
7340 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7368 const auto factors = { 12u, 8u, 4u, 0u };
7369 for (
const auto factor : factors)
7375 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
7379 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
7383 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
7391 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7412 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7415 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7464 return token_type::parse_error;
7470 return token_type::value_string;
7515 int codepoint = codepoint1;
7519 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7520 return token_type::parse_error;
7524 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7533 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7534 return token_type::parse_error;
7541 codepoint =
static_cast<int>(
7543 (
static_cast<unsigned int>(codepoint1) << 10u)
7545 +
static_cast<unsigned int>(codepoint2)
7553 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7554 return token_type::parse_error;
7559 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7560 return token_type::parse_error;
7567 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7568 return token_type::parse_error;
7573 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7576 if (codepoint < 0x80)
7581 else if (codepoint <= 0x7FF)
7584 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7585 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7587 else if (codepoint <= 0xFFFF)
7590 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7591 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7592 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7597 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7598 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7599 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7600 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7608 error_message =
"invalid string: forbidden character after backslash";
7609 return token_type::parse_error;
7618 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7619 return token_type::parse_error;
7624 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7625 return token_type::parse_error;
7630 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7631 return token_type::parse_error;
7636 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7637 return token_type::parse_error;
7642 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7643 return token_type::parse_error;
7648 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7649 return token_type::parse_error;
7654 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7655 return token_type::parse_error;
7660 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7661 return token_type::parse_error;
7666 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7667 return token_type::parse_error;
7672 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7673 return token_type::parse_error;
7678 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7679 return token_type::parse_error;
7684 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7685 return token_type::parse_error;
7690 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7691 return token_type::parse_error;
7696 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7697 return token_type::parse_error;
7702 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7703 return token_type::parse_error;
7708 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7709 return token_type::parse_error;
7714 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7715 return token_type::parse_error;
7720 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7721 return token_type::parse_error;
7726 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7727 return token_type::parse_error;
7732 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7733 return token_type::parse_error;
7738 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7739 return token_type::parse_error;
7744 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7745 return token_type::parse_error;
7750 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7751 return token_type::parse_error;
7756 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7757 return token_type::parse_error;
7762 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7763 return token_type::parse_error;
7768 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7769 return token_type::parse_error;
7774 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7775 return token_type::parse_error;
7780 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7781 return token_type::parse_error;
7786 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7787 return token_type::parse_error;
7792 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7793 return token_type::parse_error;
7798 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7799 return token_type::parse_error;
7804 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7805 return token_type::parse_error;
7942 return token_type::parse_error;
7952 return token_type::parse_error;
7976 return token_type::parse_error;
7986 return token_type::parse_error;
7996 return token_type::parse_error;
8008 return token_type::parse_error;
8018 return token_type::parse_error;
8027 return token_type::parse_error;
8102 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8109 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
8111 f = std::strtof(str, endptr);
8115 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
8117 f = std::strtod(str, endptr);
8121 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
8123 f = std::strtold(str, endptr);
8173 token_type number_type = token_type::value_unsigned;
8181 goto scan_number_minus;
8187 goto scan_number_zero;
8201 goto scan_number_any1;
8211 number_type = token_type::value_integer;
8217 goto scan_number_zero;
8231 goto scan_number_any1;
8237 return token_type::parse_error;
8249 goto scan_number_decimal1;
8256 goto scan_number_exponent;
8260 goto scan_number_done;
8279 goto scan_number_any1;
8286 goto scan_number_decimal1;
8293 goto scan_number_exponent;
8297 goto scan_number_done;
8300scan_number_decimal1:
8302 number_type = token_type::value_float;
8317 goto scan_number_decimal2;
8323 return token_type::parse_error;
8327scan_number_decimal2:
8343 goto scan_number_decimal2;
8350 goto scan_number_exponent;
8354 goto scan_number_done;
8357scan_number_exponent:
8359 number_type = token_type::value_float;
8366 goto scan_number_sign;
8381 goto scan_number_any2;
8387 "invalid number; expected '+', '-', or digit after exponent";
8388 return token_type::parse_error;
8408 goto scan_number_any2;
8413 error_message =
"invalid number; expected digit after exponent sign";
8414 return token_type::parse_error;
8434 goto scan_number_any2;
8438 goto scan_number_done;
8446 char* endptr =
nullptr;
8450 if (number_type == token_type::value_unsigned)
8452 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
8457 if (errno != ERANGE)
8462 return token_type::value_unsigned;
8466 else if (number_type == token_type::value_integer)
8468 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
8473 if (errno != ERANGE)
8478 return token_type::value_integer;
8490 return token_type::value_float;
8503 for (std::size_t i = 1; i < length; ++i)
8508 return token_type::parse_error;
8603 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8659 if (
static_cast<unsigned char>(c) <=
'\x1F')
8662 std::array<char, 9> cs{{}};
8663 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8664 result += cs.data();
8669 result.push_back(
static_cast<std::string::value_type
>(c));
8696 return get() == 0xBB &&
get() == 0xBF;
8719 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8720 return token_type::parse_error;
8731 return token_type::parse_error;
8742 return token_type::begin_array;
8744 return token_type::end_array;
8746 return token_type::begin_object;
8748 return token_type::end_object;
8750 return token_type::name_separator;
8752 return token_type::value_separator;
8758 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8763 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8768 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8793 return token_type::end_of_input;
8798 return token_type::parse_error;
8855template<
typename BasicJsonType>
8959 const std::string& last_token,
8974 return (std::numeric_limits<std::size_t>::max)();
8990template<
typename BasicJsonType,
typename InputAdapterType>
9007 : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9019 handle_value(
nullptr);
9055 handle_value(std::move(val));
9061 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
9063#if JSON_DIAGNOSTIC_POSITIONS
9070 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9076 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
9088 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
9097#if JSON_DIAGNOSTIC_POSITIONS
9101 ref_stack.back()->end_position = m_lexer_ref->get_position();
9105 ref_stack.back()->set_parents();
9106 ref_stack.pop_back();
9112 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
9114#if JSON_DIAGNOSTIC_POSITIONS
9119 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9125 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
9136#if JSON_DIAGNOSTIC_POSITIONS
9140 ref_stack.back()->end_position = m_lexer_ref->get_position();
9144 ref_stack.back()->set_parents();
9145 ref_stack.pop_back();
9149 template<
class Exception>
9151 const Exception& ex)
9154 static_cast<void>(ex);
9155 if (allow_exceptions)
9169#if JSON_DIAGNOSTIC_POSITIONS
9170 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9177 v.end_position = m_lexer_ref->get_position();
9181 case value_t::boolean:
9184 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9191 v.start_position = v.end_position - 4;
9195 case value_t::string:
9198 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9207 case value_t::discarded:
9209 v.end_position = std::string::npos;
9210 v.start_position = v.end_position;
9214 case value_t::binary:
9215 case value_t::number_integer:
9216 case value_t::number_unsigned:
9217 case value_t::number_float:
9219 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9222 case value_t::object:
9223 case value_t::array:
9243 template<
typename Value>
9247 if (ref_stack.empty())
9249 root = BasicJsonType(std::forward<Value>(v));
9251#if JSON_DIAGNOSTIC_POSITIONS
9252 handle_diagnostic_positions_for_json_value(root);
9258 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9260 if (ref_stack.back()->is_array())
9262 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
9264#if JSON_DIAGNOSTIC_POSITIONS
9265 handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
9268 return &(ref_stack.back()->m_data.m_value.array->back());
9273 *object_element = BasicJsonType(std::forward<Value>(v));
9275#if JSON_DIAGNOSTIC_POSITIONS
9276 handle_diagnostic_positions_for_json_value(*object_element);
9279 return object_element;
9285 std::vector<BasicJsonType*> ref_stack {};
9287 BasicJsonType* object_element =
nullptr;
9289 bool errored =
false;
9291 const bool allow_exceptions =
true;
9296template<
typename BasicJsonType,
typename InputAdapterType>
9311 const bool allow_exceptions_ =
true,
9313 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9315 keep_stack.push_back(
true);
9327 handle_value(
nullptr);
9363 handle_value(std::move(val));
9370 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
9371 keep_stack.push_back(keep);
9373 auto val = handle_value(BasicJsonType::value_t::object,
true);
9374 ref_stack.push_back(val.second);
9376 if (ref_stack.back())
9379#if JSON_DIAGNOSTIC_POSITIONS
9386 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9393 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
9401 BasicJsonType k = BasicJsonType(val);
9404 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
9405 key_keep_stack.push_back(keep);
9408 if (keep && ref_stack.back())
9410 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
9418 if (ref_stack.back())
9420 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
9425#if JSON_DIAGNOSTIC_POSITIONS
9427 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9433#if JSON_DIAGNOSTIC_POSITIONS
9437 ref_stack.back()->end_position = m_lexer_ref->get_position();
9441 ref_stack.back()->set_parents();
9447 ref_stack.pop_back();
9448 keep_stack.pop_back();
9450 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
9453 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
9455 if (it->is_discarded())
9457 ref_stack.back()->erase(it);
9468 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
9469 keep_stack.push_back(keep);
9471 auto val = handle_value(BasicJsonType::value_t::array,
true);
9472 ref_stack.push_back(val.second);
9474 if (ref_stack.back())
9477#if JSON_DIAGNOSTIC_POSITIONS
9484 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9491 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
9502 if (ref_stack.back())
9504 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
9508#if JSON_DIAGNOSTIC_POSITIONS
9512 ref_stack.back()->end_position = m_lexer_ref->get_position();
9516 ref_stack.back()->set_parents();
9523#if JSON_DIAGNOSTIC_POSITIONS
9525 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9532 ref_stack.pop_back();
9533 keep_stack.pop_back();
9536 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
9538 ref_stack.back()->m_data.m_value.array->pop_back();
9544 template<
class Exception>
9546 const Exception& ex)
9549 static_cast<void>(ex);
9550 if (allow_exceptions)
9564#if JSON_DIAGNOSTIC_POSITIONS
9565 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9572 v.end_position = m_lexer_ref->get_position();
9576 case value_t::boolean:
9579 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9586 v.start_position = v.end_position - 4;
9590 case value_t::string:
9593 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9597 case value_t::discarded:
9599 v.end_position = std::string::npos;
9600 v.start_position = v.end_position;
9604 case value_t::binary:
9605 case value_t::number_integer:
9606 case value_t::number_unsigned:
9607 case value_t::number_float:
9609 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9613 case value_t::object:
9614 case value_t::array:
9643 template<
typename Value>
9644 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
9650 if (!keep_stack.back())
9652 return {
false,
nullptr};
9656 auto value = BasicJsonType(std::forward<Value>(v));
9658#if JSON_DIAGNOSTIC_POSITIONS
9659 handle_diagnostic_positions_for_json_value(
value);
9663 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
9668 return {
false,
nullptr};
9671 if (ref_stack.empty())
9673 root = std::move(
value);
9674 return {
true, & root};
9679 if (!ref_stack.back())
9681 return {
false,
nullptr};
9685 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9688 if (ref_stack.back()->is_array())
9690 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(
value));
9691 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
9698 const bool store_element = key_keep_stack.back();
9699 key_keep_stack.pop_back();
9703 return {
false,
nullptr};
9707 *object_element = std::move(
value);
9708 return {
true, object_element};
9714 std::vector<BasicJsonType*> ref_stack {};
9716 std::vector<bool> keep_stack {};
9718 std::vector<bool> key_keep_stack {};
9720 BasicJsonType* object_element =
nullptr;
9722 bool errored =
false;
9726 const bool allow_exceptions =
true;
9728 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
9733template<
typename BasicJsonType>
9847 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9849template<
typename T,
typename Integer>
9851 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9853template<
typename T,
typename Un
signed>
9855 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9857template<
typename T,
typename Float,
typename String>
9859 std::declval<Float>(), std::declval<const String&>()));
9861template<
typename T,
typename String>
9863 decltype(std::declval<T&>().string(std::declval<String&>()));
9865template<
typename T,
typename Binary>
9867 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9871 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9873template<
typename T,
typename String>
9875 decltype(std::declval<T&>().key(std::declval<String&>()));
9882 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9887template<
typename T,
typename Exception>
9889 std::declval<std::size_t>(), std::declval<const std::string&>(),
9890 std::declval<const Exception&>()));
9892template<
typename SAX,
typename BasicJsonType>
9897 "BasicJsonType must be of type basic_json<...>");
9923template<
typename SAX,
typename BasicJsonType>
9928 "BasicJsonType must be of type basic_json<...>");
9939 "Missing/invalid function: bool null()");
9941 "Missing/invalid function: bool boolean(bool)");
9943 "Missing/invalid function: bool boolean(bool)");
9947 "Missing/invalid function: bool number_integer(number_integer_t)");
9951 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9954 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9957 "Missing/invalid function: bool string(string_t&)");
9960 "Missing/invalid function: bool binary(binary_t&)");
9962 "Missing/invalid function: bool start_object(std::size_t)");
9964 "Missing/invalid function: bool key(string_t&)");
9966 "Missing/invalid function: bool end_object()");
9968 "Missing/invalid function: bool start_array(std::size_t)");
9970 "Missing/invalid function: bool end_array()");
9973 "Missing/invalid function: bool parse_error(std::size_t, const "
9974 "std::string&, const exception&)");
10008 return *
reinterpret_cast<char*
>(&num) == 1;
10018template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
10036 explicit binary_reader(InputAdapterType&& adapter,
const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format)
10059 const
bool strict = true,
10063 bool result =
false;
10067 case input_format_t::bson:
10068 result = parse_bson_internal();
10071 case input_format_t::cbor:
10072 result = parse_cbor_internal(
true, tag_handler);
10075 case input_format_t::msgpack:
10076 result = parse_msgpack_internal();
10079 case input_format_t::ubjson:
10080 case input_format_t::bjdata:
10081 result = parse_ubjson_internal();
10084 case input_format_t::json:
10092 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
10103 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
10104 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
10122 std::int32_t document_size{};
10123 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10135 return sax->end_object();
10147 auto out = std::back_inserter(result);
10155 if (current == 0x00)
10159 *out++ =
static_cast<typename string_t::value_type
>(current);
10174 template<
typename NumberType>
10179 auto last_token = get_token_string();
10180 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10181 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
10196 template<
typename NumberType>
10201 auto last_token = get_token_string();
10202 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10203 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
10207 std::uint8_t subtype{};
10208 get_number<std::uint8_t>(input_format_t::bson, subtype);
10209 result.set_subtype(subtype);
10211 return get_binary(input_format_t::bson, len, result);
10225 const std::size_t element_type_parse_position)
10227 switch (element_type)
10232 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10237 std::int32_t len{};
10239 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len,
value) && sax->string(
value);
10244 return parse_bson_internal();
10249 return parse_bson_array();
10254 std::int32_t len{};
10256 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len,
value) && sax->binary(
value);
10261 return sax->boolean(
get() != 0);
10266 return sax->null();
10271 std::int32_t
value{};
10272 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
10277 std::int64_t
value{};
10278 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
10283 std::uint64_t
value{};
10284 return get_number<std::uint64_t, true>(input_format_t::bson,
value) && sax->number_unsigned(
value);
10289 std::array<char, 3> cr{{}};
10290 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
10291 const std::string cr_str{cr.data()};
10292 return sax->parse_error(element_type_parse_position, cr_str,
10293 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
10314 while (
auto element_type =
get())
10321 const std::size_t element_type_parse_position = chars_read;
10327 if (!is_array && !sax->key(
key))
10332 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
10350 std::int32_t document_size{};
10351 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10363 return sax->end_array();
10379 template<
typename NumberType>
10382 NumberType number{};
10387 const auto max_val =
static_cast<NumberType
>((std::numeric_limits<number_integer_t>::max)());
10388 if (number > max_val)
10390 return sax->parse_error(chars_read, get_token_string(),
10391 parse_error::create(112, chars_read,
10392 exception_message(input_format_t::cbor,
"negative integer overflow",
"value"),
nullptr));
10400 switch (get_char ?
get() : current)
10404 return unexpect_eof(input_format_t::cbor,
"value");
10435 std::uint8_t number{};
10436 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10441 std::uint16_t number{};
10442 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10447 std::uint32_t number{};
10448 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10453 std::uint64_t number{};
10454 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10482 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
10485 return get_cbor_negative_integer<std::uint8_t>();
10488 return get_cbor_negative_integer<std::uint16_t>();
10491 return get_cbor_negative_integer<std::uint32_t>();
10494 return get_cbor_negative_integer<std::uint64_t>();
10528 return get_cbor_binary(b) && sax->binary(b);
10563 return get_cbor_string(s) && sax->string(s);
10591 return get_cbor_array(
10592 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10596 std::uint8_t len{};
10597 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10602 std::uint16_t len{};
10603 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10608 std::uint32_t len{};
10609 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10614 std::uint64_t len{};
10615 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10646 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10650 std::uint8_t len{};
10651 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10656 std::uint16_t len{};
10657 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10662 std::uint32_t len{};
10663 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10668 std::uint64_t len{};
10669 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10695 switch (tag_handler)
10697 case cbor_tag_handler_t::error:
10699 auto last_token = get_token_string();
10700 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10701 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10704 case cbor_tag_handler_t::ignore:
10711 std::uint8_t subtype_to_ignore{};
10712 get_number(input_format_t::cbor, subtype_to_ignore);
10717 std::uint16_t subtype_to_ignore{};
10718 get_number(input_format_t::cbor, subtype_to_ignore);
10723 std::uint32_t subtype_to_ignore{};
10724 get_number(input_format_t::cbor, subtype_to_ignore);
10729 std::uint64_t subtype_to_ignore{};
10730 get_number(input_format_t::cbor, subtype_to_ignore);
10736 return parse_cbor_internal(
true, tag_handler);
10739 case cbor_tag_handler_t::store:
10747 std::uint8_t subtype{};
10748 get_number(input_format_t::cbor, subtype);
10749 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10754 std::uint16_t subtype{};
10755 get_number(input_format_t::cbor, subtype);
10756 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10761 std::uint32_t subtype{};
10762 get_number(input_format_t::cbor, subtype);
10763 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10768 std::uint64_t subtype{};
10769 get_number(input_format_t::cbor, subtype);
10770 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10774 return parse_cbor_internal(
true, tag_handler);
10777 return get_cbor_binary(b) && sax->binary(b);
10787 return sax->boolean(
false);
10790 return sax->boolean(
true);
10793 return sax->null();
10797 const auto byte1_raw =
get();
10802 const auto byte2_raw =
get();
10808 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10809 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10819 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10820 const double val = [&half]
10822 const int exp = (half >> 10u) & 0x1Fu;
10823 const unsigned int mant = half & 0x3FFu;
10829 return std::ldexp(mant, -24);
10832 ? std::numeric_limits<double>::infinity()
10833 : std::numeric_limits<double>::quiet_NaN();
10835 return std::ldexp(mant + 1024, exp - 25);
10838 return sax->number_float((half & 0x8000u) != 0
10846 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10852 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10857 auto last_token = get_token_string();
10858 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10859 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10910 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10915 std::uint8_t len{};
10916 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10921 std::uint16_t len{};
10922 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10927 std::uint32_t len{};
10928 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10933 std::uint64_t len{};
10934 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10939 while (
get() != 0xFF)
10942 if (!get_cbor_string(chunk))
10946 result.append(chunk);
10953 auto last_token = get_token_string();
10954 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10955 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
11006 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
11011 std::uint8_t len{};
11012 return get_number(input_format_t::cbor, len) &&
11013 get_binary(input_format_t::cbor, len, result);
11018 std::uint16_t len{};
11019 return get_number(input_format_t::cbor, len) &&
11020 get_binary(input_format_t::cbor, len, result);
11025 std::uint32_t len{};
11026 return get_number(input_format_t::cbor, len) &&
11027 get_binary(input_format_t::cbor, len, result);
11032 std::uint64_t len{};
11033 return get_number(input_format_t::cbor, len) &&
11034 get_binary(input_format_t::cbor, len, result);
11039 while (
get() != 0xFF)
11042 if (!get_cbor_binary(chunk))
11046 result.insert(result.end(), chunk.begin(), chunk.end());
11053 auto last_token = get_token_string();
11054 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11055 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));
11076 for (std::size_t i = 0; i < len; ++i)
11086 while (
get() != 0xFF)
11095 return sax->end_array();
11117 for (std::size_t i = 0; i < len; ++i)
11134 while (
get() != 0xFF)
11150 return sax->end_object();
11166 return unexpect_eof(input_format_t::msgpack,
"value");
11316 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11335 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11375 return get_msgpack_string(s) && sax->string(s);
11379 return sax->null();
11382 return sax->boolean(
false);
11385 return sax->boolean(
true);
11400 return get_msgpack_binary(b) && sax->binary(b);
11406 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11412 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11417 std::uint8_t number{};
11418 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11423 std::uint16_t number{};
11424 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11429 std::uint32_t number{};
11430 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11435 std::uint64_t number{};
11436 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11441 std::int8_t number{};
11442 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11447 std::int16_t number{};
11448 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11453 std::int32_t number{};
11454 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11459 std::int64_t number{};
11460 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11465 std::uint16_t len{};
11466 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
11471 std::uint32_t len{};
11472 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
11477 std::uint16_t len{};
11478 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
11483 std::uint32_t len{};
11484 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
11520 return sax->number_integer(
static_cast<std::int8_t
>(current));
11524 auto last_token = get_token_string();
11525 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11526 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
11584 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
11589 std::uint8_t len{};
11590 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11595 std::uint16_t len{};
11596 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11601 std::uint32_t len{};
11602 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11607 auto last_token = get_token_string();
11608 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11609 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
11627 auto assign_and_return_true = [&result](std::int8_t subtype)
11629 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
11637 std::uint8_t len{};
11638 return get_number(input_format_t::msgpack, len) &&
11639 get_binary(input_format_t::msgpack, len, result);
11644 std::uint16_t len{};
11645 return get_number(input_format_t::msgpack, len) &&
11646 get_binary(input_format_t::msgpack, len, result);
11651 std::uint32_t len{};
11652 return get_number(input_format_t::msgpack, len) &&
11653 get_binary(input_format_t::msgpack, len, result);
11658 std::uint8_t len{};
11659 std::int8_t subtype{};
11660 return get_number(input_format_t::msgpack, len) &&
11661 get_number(input_format_t::msgpack, subtype) &&
11662 get_binary(input_format_t::msgpack, len, result) &&
11663 assign_and_return_true(subtype);
11668 std::uint16_t len{};
11669 std::int8_t subtype{};
11670 return get_number(input_format_t::msgpack, len) &&
11671 get_number(input_format_t::msgpack, subtype) &&
11672 get_binary(input_format_t::msgpack, len, result) &&
11673 assign_and_return_true(subtype);
11678 std::uint32_t len{};
11679 std::int8_t subtype{};
11680 return get_number(input_format_t::msgpack, len) &&
11681 get_number(input_format_t::msgpack, subtype) &&
11682 get_binary(input_format_t::msgpack, len, result) &&
11683 assign_and_return_true(subtype);
11688 std::int8_t subtype{};
11689 return get_number(input_format_t::msgpack, subtype) &&
11690 get_binary(input_format_t::msgpack, 1, result) &&
11691 assign_and_return_true(subtype);
11696 std::int8_t subtype{};
11697 return get_number(input_format_t::msgpack, subtype) &&
11698 get_binary(input_format_t::msgpack, 2, result) &&
11699 assign_and_return_true(subtype);
11704 std::int8_t subtype{};
11705 return get_number(input_format_t::msgpack, subtype) &&
11706 get_binary(input_format_t::msgpack, 4, result) &&
11707 assign_and_return_true(subtype);
11712 std::int8_t subtype{};
11713 return get_number(input_format_t::msgpack, subtype) &&
11714 get_binary(input_format_t::msgpack, 8, result) &&
11715 assign_and_return_true(subtype);
11720 std::int8_t subtype{};
11721 return get_number(input_format_t::msgpack, subtype) &&
11722 get_binary(input_format_t::msgpack, 16, result) &&
11723 assign_and_return_true(subtype);
11742 for (std::size_t i = 0; i < len; ++i)
11750 return sax->end_array();
11765 for (std::size_t i = 0; i < len; ++i)
11780 return sax->end_object();
11796 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11829 std::uint8_t len{};
11830 return get_number(input_format, len) && get_string(input_format, len, result);
11836 return get_number(input_format, len) && get_string(input_format, len, result);
11841 std::int16_t len{};
11842 return get_number(input_format, len) && get_string(input_format, len, result);
11847 std::int32_t len{};
11848 return get_number(input_format, len) && get_string(input_format, len, result);
11853 std::int64_t len{};
11854 return get_number(input_format, len) && get_string(input_format, len, result);
11859 if (input_format != input_format_t::bjdata)
11863 std::uint16_t len{};
11864 return get_number(input_format, len) && get_string(input_format, len, result);
11869 if (input_format != input_format_t::bjdata)
11873 std::uint32_t len{};
11874 return get_number(input_format, len) && get_string(input_format, len, result);
11879 if (input_format != input_format_t::bjdata)
11883 std::uint64_t len{};
11884 return get_number(input_format, len) && get_string(input_format, len, result);
11890 auto last_token = get_token_string();
11891 std::string message;
11893 if (input_format != input_format_t::bjdata)
11895 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11899 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11901 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11910 std::pair<std::size_t, char_int_type> size_and_type;
11912 bool no_ndarray =
true;
11919 if (size_and_type.first != npos)
11921 if (size_and_type.second != 0)
11923 if (size_and_type.second !=
'N')
11925 for (std::size_t i = 0; i < size_and_type.first; ++i)
11931 dim.push_back(dimlen);
11937 for (std::size_t i = 0; i < size_and_type.first; ++i)
11943 dim.push_back(dimlen);
11949 while (current !=
']')
11955 dim.push_back(dimlen);
11977 prefix = get_ignore_noop();
11984 std::uint8_t number{};
11989 result =
static_cast<std::size_t
>(number);
11995 std::int8_t number{};
12002 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
12003 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
12005 result =
static_cast<std::size_t
>(number);
12011 std::int16_t number{};
12018 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
12019 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
12021 result =
static_cast<std::size_t
>(number);
12027 std::int32_t number{};
12034 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
12035 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
12037 result =
static_cast<std::size_t
>(number);
12043 std::int64_t number{};
12050 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
12051 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
12053 if (!value_in_range_of<std::size_t>(number))
12055 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
12056 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
12058 result =
static_cast<std::size_t
>(number);
12064 if (input_format != input_format_t::bjdata)
12068 std::uint16_t number{};
12073 result =
static_cast<std::size_t
>(number);
12079 if (input_format != input_format_t::bjdata)
12083 std::uint32_t number{};
12088 result = conditional_static_cast<std::size_t>(number);
12094 if (input_format != input_format_t::bjdata)
12098 std::uint64_t number{};
12103 if (!value_in_range_of<std::size_t>(number))
12105 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
12106 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
12108 result = detail::conditional_static_cast<std::size_t>(number);
12114 if (input_format != input_format_t::bjdata)
12120 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));
12122 std::vector<size_t> dim;
12127 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
12129 result = dim.at(dim.size() - 1);
12156 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));
12160 if (result == 0 || result == npos)
12162 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));
12170 return sax->end_array();
12179 auto last_token = get_token_string();
12180 std::string message;
12182 if (input_format != input_format_t::bjdata)
12184 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
12188 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
12190 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
12206 result.first = npos;
12208 bool is_ndarray =
false;
12212 if (current ==
'$')
12214 result.second =
get();
12215 if (input_format == input_format_t::bjdata
12216 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
12218 auto last_token = get_token_string();
12219 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12220 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
12235 auto last_token = get_token_string();
12236 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12237 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
12240 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12241 if (input_format == input_format_t::bjdata && is_ndarray)
12243 if (inside_ndarray)
12245 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12246 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
12248 result.second |= (1 << 8);
12253 if (current ==
'#')
12255 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12256 if (input_format == input_format_t::bjdata && is_ndarray)
12258 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12259 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
12276 return unexpect_eof(input_format,
"value");
12279 return sax->boolean(
true);
12281 return sax->boolean(
false);
12284 return sax->null();
12288 if (input_format != input_format_t::bjdata)
12292 std::uint8_t number{};
12293 return get_number(input_format, number) && sax->number_unsigned(number);
12298 std::uint8_t number{};
12299 return get_number(input_format, number) && sax->number_unsigned(number);
12304 std::int8_t number{};
12305 return get_number(input_format, number) && sax->number_integer(number);
12310 std::int16_t number{};
12311 return get_number(input_format, number) && sax->number_integer(number);
12316 std::int32_t number{};
12317 return get_number(input_format, number) && sax->number_integer(number);
12322 std::int64_t number{};
12323 return get_number(input_format, number) && sax->number_integer(number);
12328 if (input_format != input_format_t::bjdata)
12332 std::uint16_t number{};
12333 return get_number(input_format, number) && sax->number_unsigned(number);
12338 if (input_format != input_format_t::bjdata)
12342 std::uint32_t number{};
12343 return get_number(input_format, number) && sax->number_unsigned(number);
12348 if (input_format != input_format_t::bjdata)
12352 std::uint64_t number{};
12353 return get_number(input_format, number) && sax->number_unsigned(number);
12358 if (input_format != input_format_t::bjdata)
12362 const auto byte1_raw =
get();
12367 const auto byte2_raw =
get();
12373 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
12374 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
12384 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
12385 const double val = [&half]
12387 const int exp = (half >> 10u) & 0x1Fu;
12388 const unsigned int mant = half & 0x3FFu;
12394 return std::ldexp(mant, -24);
12397 ? std::numeric_limits<double>::infinity()
12398 : std::numeric_limits<double>::quiet_NaN();
12400 return std::ldexp(mant + 1024, exp - 25);
12403 return sax->number_float((half & 0x8000u) != 0
12411 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
12417 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
12422 return get_ubjson_high_precision_number();
12434 auto last_token = get_token_string();
12435 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
12436 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
12438 string_t s(1,
static_cast<typename string_t::value_type
>(current));
12439 return sax->string(s);
12445 return get_ubjson_string(s) && sax->string(s);
12449 return get_ubjson_array();
12452 return get_ubjson_object();
12457 auto last_token = get_token_string();
12458 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));
12466 std::pair<std::size_t, char_int_type> size_and_type;
12475 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12477 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
12478 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)
12480 return p.first < t;
12485 auto last_token = get_token_string();
12486 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12487 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
12496 if (size_and_type.second ==
'C' || size_and_type.second ==
'B')
12498 size_and_type.second =
'U';
12501 key =
"_ArrayData_";
12507 for (std::size_t i = 0; i < size_and_type.first; ++i)
12515 return (sax->end_array() && sax->end_object());
12519 if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second ==
'B')
12522 return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
12525 if (size_and_type.first != npos)
12532 if (size_and_type.second != 0)
12534 if (size_and_type.second !=
'N')
12536 for (std::size_t i = 0; i < size_and_type.first; ++i)
12547 for (std::size_t i = 0; i < size_and_type.first; ++i)
12563 while (current !=
']')
12573 return sax->end_array();
12581 std::pair<std::size_t, char_int_type> size_and_type;
12588 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12590 auto last_token = get_token_string();
12591 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12592 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
12596 if (size_and_type.first != npos)
12603 if (size_and_type.second != 0)
12605 for (std::size_t i = 0; i < size_and_type.first; ++i)
12620 for (std::size_t i = 0; i < size_and_type.first; ++i)
12641 while (current !=
'}')
12656 return sax->end_object();
12665 std::size_t size{};
12666 bool no_ndarray =
true;
12667 auto res = get_ubjson_size_value(size, no_ndarray);
12674 std::vector<char> number_vector;
12675 for (std::size_t i = 0; i < size; ++i)
12682 number_vector.push_back(
static_cast<char>(current));
12688 const auto result_number = number_lexer.scan();
12689 const auto number_string = number_lexer.get_token_string();
12690 const auto result_remainder = number_lexer.scan();
12696 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12697 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12700 switch (result_number)
12702 case token_type::value_integer:
12703 return sax->number_integer(number_lexer.get_number_integer());
12704 case token_type::value_unsigned:
12705 return sax->number_unsigned(number_lexer.get_number_unsigned());
12706 case token_type::value_float:
12707 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12708 case token_type::uninitialized:
12709 case token_type::literal_true:
12710 case token_type::literal_false:
12711 case token_type::literal_null:
12712 case token_type::value_string:
12713 case token_type::begin_array:
12714 case token_type::begin_object:
12715 case token_type::end_array:
12716 case token_type::end_object:
12717 case token_type::name_separator:
12718 case token_type::value_separator:
12719 case token_type::parse_error:
12720 case token_type::end_of_input:
12721 case token_type::literal_or_value:
12723 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12724 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12744 return current = ia.get_character();
12758 auto new_chars_read = ia.get_elements(&dest);
12759 chars_read += new_chars_read;
12764 sax->parse_error(chars_read,
"<end of file>", parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12779 while (current ==
'N');
12784 template<
class NumberType>
12787 constexpr std::size_t sz =
sizeof(number);
12788#ifdef __cpp_lib_byteswap
12789 if constexpr (sz == 1)
12793 else if constexpr(std::is_integral_v<NumberType>)
12795 number = std::byteswap(number);
12801 auto* ptr =
reinterpret_cast<std::uint8_t*
>(&number);
12802 for (std::size_t i = 0; i < sz / 2; ++i)
12806#ifdef __cpp_lib_byteswap
12826 template<
typename NumberType,
bool InputIsLittleEndian = false>
12835 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
12856 template<
typename NumberType>
12858 const NumberType len,
12861 bool success =
true;
12862 for (NumberType i = 0; i < len; i++)
12870 result.push_back(
static_cast<typename string_t::value_type
>(current));
12889 template<
typename NumberType>
12891 const NumberType len,
12894 bool success =
true;
12895 for (NumberType i = 0; i < len; i++)
12903 result.push_back(
static_cast<typename binary_t::value_type
>(current));
12918 return sax->parse_error(chars_read,
"<end of file>",
12919 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12929 std::array<char, 3> cr{{}};
12930 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12931 return std::string{cr.data()};
12941 const std::string&
detail,
12942 const std::string& context)
const
12944 std::string error_msg =
"syntax error while parsing ";
12948 case input_format_t::cbor:
12949 error_msg +=
"CBOR";
12952 case input_format_t::msgpack:
12953 error_msg +=
"MessagePack";
12956 case input_format_t::ubjson:
12957 error_msg +=
"UBJSON";
12960 case input_format_t::bson:
12961 error_msg +=
"BSON";
12964 case input_format_t::bjdata:
12965 error_msg +=
"BJData";
12968 case input_format_t::json:
12986 std::size_t chars_read = 0;
12998#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12999 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
13001#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
13002 make_array<bjd_type>( \
13003 bjd_type{'B', "byte"}, \
13004 bjd_type{'C', "char"}, \
13005 bjd_type{'D', "double"}, \
13006 bjd_type{'I', "int16"}, \
13007 bjd_type{'L', "int64"}, \
13008 bjd_type{'M', "uint64"}, \
13009 bjd_type{'U', "uint8"}, \
13010 bjd_type{'d', "single"}, \
13011 bjd_type{'i', "int8"}, \
13012 bjd_type{'l', "int32"}, \
13013 bjd_type{'m', "uint32"}, \
13014 bjd_type{'u', "uint16"})
13027#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
13028#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
13031#ifndef JSON_HAS_CPP_17
13032 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
13056#include <functional>
13101template<
typename BasicJsonType>
13103 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
13110template<
typename BasicJsonType,
typename InputAdapterType>
13124 const bool allow_exceptions_ =
true,
13125 const bool ignore_comments =
false,
13126 const bool ignore_trailing_commas_ =
false)
13127 : callback(
std::move(cb))
13128 , m_lexer(
std::move(adapter), ignore_comments)
13129 , allow_exceptions(allow_exceptions_)
13130 , ignore_trailing_commas(ignore_trailing_commas_)
13146 void parse(
const bool strict, BasicJsonType& result)
13151 sax_parse_internal(&sdp);
13154 if (
strict && (get_token() != token_type::end_of_input))
13157 m_lexer.get_token_string(),
13158 parse_error::create(101, m_lexer.get_position(),
13159 exception_message(token_type::end_of_input,
"value"),
nullptr));
13165 result = value_t::discarded;
13171 if (result.is_discarded())
13179 sax_parse_internal(&sdp);
13182 if (
strict && (get_token() != token_type::end_of_input))
13185 m_lexer.get_token_string(),
13186 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13192 result = value_t::discarded;
13197 result.assert_invariant();
13209 return sax_parse(&sax_acceptor,
strict);
13212 template<
typename SAX>
13214 bool sax_parse(SAX* sax, const
bool strict = true)
13217 const bool result = sax_parse_internal(sax);
13220 if (result &&
strict && (get_token() != token_type::end_of_input))
13222 return sax->parse_error(m_lexer.get_position(),
13223 m_lexer.get_token_string(),
13224 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13231 template<
typename SAX>
13233 bool sax_parse_internal(SAX* sax)
13237 std::vector<bool> states;
13239 bool skip_to_state_evaluation =
false;
13243 if (!skip_to_state_evaluation)
13246 switch (last_token)
13248 case token_type::begin_object:
13256 if (get_token() == token_type::end_object)
13268 return sax->parse_error(m_lexer.get_position(),
13269 m_lexer.get_token_string(),
13270 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13280 return sax->parse_error(m_lexer.get_position(),
13281 m_lexer.get_token_string(),
13282 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13286 states.push_back(
false);
13293 case token_type::begin_array:
13301 if (get_token() == token_type::end_array)
13311 states.push_back(
true);
13317 case token_type::value_float:
13319 const auto res = m_lexer.get_number_float();
13323 return sax->parse_error(m_lexer.get_position(),
13324 m_lexer.get_token_string(),
13325 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
13336 case token_type::literal_false:
13345 case token_type::literal_null:
13354 case token_type::literal_true:
13363 case token_type::value_integer:
13372 case token_type::value_string:
13381 case token_type::value_unsigned:
13390 case token_type::parse_error:
13393 return sax->parse_error(m_lexer.get_position(),
13394 m_lexer.get_token_string(),
13395 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
13397 case token_type::end_of_input:
13401 return sax->parse_error(m_lexer.get_position(),
13402 m_lexer.get_token_string(),
13403 parse_error::create(101, m_lexer.get_position(),
13404 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
13407 return sax->parse_error(m_lexer.get_position(),
13408 m_lexer.get_token_string(),
13409 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13411 case token_type::uninitialized:
13412 case token_type::end_array:
13413 case token_type::end_object:
13414 case token_type::name_separator:
13415 case token_type::value_separator:
13416 case token_type::literal_or_value:
13419 return sax->parse_error(m_lexer.get_position(),
13420 m_lexer.get_token_string(),
13421 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13427 skip_to_state_evaluation =
false;
13431 if (states.empty())
13441 if (get_token() == token_type::value_separator)
13447 if (!(ignore_trailing_commas && last_token == token_type::end_array))
13467 skip_to_state_evaluation =
true;
13471 return sax->parse_error(m_lexer.get_position(),
13472 m_lexer.get_token_string(),
13473 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
13480 if (get_token() == token_type::value_separator)
13485 if (!(ignore_trailing_commas && last_token == token_type::end_object))
13490 return sax->parse_error(m_lexer.get_position(),
13491 m_lexer.get_token_string(),
13492 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13503 return sax->parse_error(m_lexer.get_position(),
13504 m_lexer.get_token_string(),
13505 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13528 skip_to_state_evaluation =
true;
13532 return sax->parse_error(m_lexer.get_position(),
13533 m_lexer.get_token_string(),
13534 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
13541 return last_token = m_lexer.scan();
13546 std::string error_msg =
"syntax error ";
13548 if (!context.empty())
13550 error_msg +=
concat(
"while parsing ", context,
' ');
13555 if (last_token == token_type::parse_error)
13557 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
13558 m_lexer.get_token_string(),
'\'');
13562 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
13565 if (expected != token_type::uninitialized)
13567 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
13581 const bool allow_exceptions =
true;
13583 const bool ignore_trailing_commas =
false;
13652 m_it = begin_value;
13664 return m_it == begin_value;
13670 return m_it == end_value;
13675 return lhs.m_it == rhs.m_it;
13680 return lhs.m_it < rhs.m_it;
13685 auto result = *
this;
13692 return lhs.m_it - rhs.m_it;
13703 auto result = *
this;
13716 auto result = *
this;
13751 typename BasicJsonType::object_t::iterator object_iterator {};
13753 typename BasicJsonType::array_t::iterator array_iterator {};
13773#include <type_traits>
13795template<
typename IteratorType>
class iteration_proxy;
13796template<
typename IteratorType>
class iteration_proxy_value;
13814template<
typename BasicJsonType>
13829 "iter_impl only accepts (const) basic_json");
13831 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13832 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value,
13833 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13848 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13849 typename BasicJsonType::const_pointer,
13850 typename BasicJsonType::pointer>::type;
13853 typename std::conditional<std::is_const<BasicJsonType>::value,
13854 typename BasicJsonType::const_reference,
13855 typename BasicJsonType::reference>::type;
13872 switch (m_object->m_data.m_type)
13874 case value_t::object:
13876 m_it.object_iterator =
typename object_t::iterator();
13880 case value_t::array:
13882 m_it.array_iterator =
typename array_t::iterator();
13886 case value_t::null:
13887 case value_t::string:
13888 case value_t::boolean:
13889 case value_t::number_integer:
13890 case value_t::number_unsigned:
13891 case value_t::number_float:
13892 case value_t::binary:
13893 case value_t::discarded:
13919 : m_object(other.m_object), m_it(other.m_it)
13930 if (&other !=
this)
13932 m_object = other.m_object;
13944 : m_object(other.m_object), m_it(other.m_it)
13955 m_object = other.m_object;
13965 void set_begin() noexcept
13969 switch (m_object->m_data.m_type)
13971 case value_t::object:
13973 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13977 case value_t::array:
13979 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13983 case value_t::null:
13986 m_it.primitive_iterator.set_end();
13990 case value_t::string:
13991 case value_t::boolean:
13992 case value_t::number_integer:
13993 case value_t::number_unsigned:
13994 case value_t::number_float:
13995 case value_t::binary:
13996 case value_t::discarded:
13999 m_it.primitive_iterator.set_begin();
14013 switch (m_object->m_data.m_type)
14015 case value_t::object:
14017 m_it.object_iterator = m_object->m_data.m_value.object->end();
14021 case value_t::array:
14023 m_it.array_iterator = m_object->m_data.m_value.array->end();
14027 case value_t::null:
14028 case value_t::string:
14029 case value_t::boolean:
14030 case value_t::number_integer:
14031 case value_t::number_unsigned:
14032 case value_t::number_float:
14033 case value_t::binary:
14034 case value_t::discarded:
14037 m_it.primitive_iterator.set_end();
14052 switch (m_object->m_data.m_type)
14054 case value_t::object:
14056 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
14057 return m_it.object_iterator->second;
14060 case value_t::array:
14062 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
14063 return *m_it.array_iterator;
14066 case value_t::null:
14067 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14069 case value_t::string:
14070 case value_t::boolean:
14071 case value_t::number_integer:
14072 case value_t::number_unsigned:
14073 case value_t::number_float:
14074 case value_t::binary:
14075 case value_t::discarded:
14083 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14096 switch (m_object->m_data.m_type)
14098 case value_t::object:
14100 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
14101 return &(m_it.object_iterator->second);
14104 case value_t::array:
14106 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
14107 return &*m_it.array_iterator;
14110 case value_t::null:
14111 case value_t::string:
14112 case value_t::boolean:
14113 case value_t::number_integer:
14114 case value_t::number_unsigned:
14115 case value_t::number_float:
14116 case value_t::binary:
14117 case value_t::discarded:
14125 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14136 auto result = *
this;
14149 switch (m_object->m_data.m_type)
14151 case value_t::object:
14153 std::advance(m_it.object_iterator, 1);
14157 case value_t::array:
14159 std::advance(m_it.array_iterator, 1);
14163 case value_t::null:
14164 case value_t::string:
14165 case value_t::boolean:
14166 case value_t::number_integer:
14167 case value_t::number_unsigned:
14168 case value_t::number_float:
14169 case value_t::binary:
14170 case value_t::discarded:
14173 ++m_it.primitive_iterator;
14187 auto result = *
this;
14200 switch (m_object->m_data.m_type)
14202 case value_t::object:
14204 std::advance(m_it.object_iterator, -1);
14208 case value_t::array:
14210 std::advance(m_it.array_iterator, -1);
14214 case value_t::null:
14215 case value_t::string:
14216 case value_t::boolean:
14217 case value_t::number_integer:
14218 case value_t::number_unsigned:
14219 case value_t::number_float:
14220 case value_t::binary:
14221 case value_t::discarded:
14224 --m_it.primitive_iterator;
14236 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 >
14242 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14246 if (m_object ==
nullptr)
14251 switch (m_object->m_data.m_type)
14253 case value_t::object:
14254 return (m_it.object_iterator == other.m_it.object_iterator);
14256 case value_t::array:
14257 return (m_it.array_iterator == other.m_it.array_iterator);
14259 case value_t::null:
14260 case value_t::string:
14261 case value_t::boolean:
14262 case value_t::number_integer:
14263 case value_t::number_unsigned:
14264 case value_t::number_float:
14265 case value_t::binary:
14266 case value_t::discarded:
14268 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
14276 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 >
14291 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14295 if (m_object ==
nullptr)
14301 switch (m_object->m_data.m_type)
14303 case value_t::object:
14304 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
14306 case value_t::array:
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:
14328 return !other.operator < (*this);
14337 return !operator<=(other);
14357 switch (m_object->m_data.m_type)
14359 case value_t::object:
14360 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14362 case value_t::array:
14364 std::advance(m_it.array_iterator, i);
14368 case value_t::null:
14369 case value_t::string:
14370 case value_t::boolean:
14371 case value_t::number_integer:
14372 case value_t::number_unsigned:
14373 case value_t::number_float:
14374 case value_t::binary:
14375 case value_t::discarded:
14378 m_it.primitive_iterator += i;
14392 return operator+=(-i);
14401 auto result = *
this;
14423 auto result = *
this;
14436 switch (m_object->m_data.m_type)
14438 case value_t::object:
14439 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14441 case value_t::array:
14444 case value_t::null:
14445 case value_t::string:
14446 case value_t::boolean:
14447 case value_t::number_integer:
14448 case value_t::number_unsigned:
14449 case value_t::number_float:
14450 case value_t::binary:
14451 case value_t::discarded:
14465 switch (m_object->m_data.m_type)
14467 case value_t::object:
14468 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
14470 case value_t::array:
14471 return *std::next(m_it.array_iterator, n);
14473 case value_t::null:
14474 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14476 case value_t::string:
14477 case value_t::boolean:
14478 case value_t::number_integer:
14479 case value_t::number_unsigned:
14480 case value_t::number_float:
14481 case value_t::binary:
14482 case value_t::discarded:
14490 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14499 const typename object_t::key_type&
key()
const
14505 return m_it.object_iterator->first;
14508 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
14517 return operator*();
14576template<
typename Base>
14644 return *(this->operator+(n));
14648 auto key() const -> decltype(
std::declval<Base>().key())
14650 auto it = --this->base();
14657 auto it = --this->base();
14658 return it.operator * ();
14678#include <type_traits>
14701 std::is_same<T, void>::value,
14720#include <algorithm>
14748template<
typename RefStringType>
14758 template<
typename T>
14777 : reference_tokens(split(s))
14784 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14788 return detail::concat(a,
'/', detail::escape(b));
14814 reference_tokens.insert(reference_tokens.end(),
14824 push_back(std::move(token));
14832 return *
this /= std::to_string(array_idx);
14880 reference_tokens.pop_back();
14892 return reference_tokens.back();
14899 reference_tokens.push_back(token);
14906 reference_tokens.push_back(std::move(token));
14913 return reference_tokens.empty();
14927 template<
typename BasicJsonType>
14930 using size_type =
typename BasicJsonType::size_type;
14944 const char* p = s.c_str();
14945 char* p_end =
nullptr;
14947 const unsigned long long res = std::strtoull(p, &p_end, 10);
14957 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14962 return static_cast<size_type
>(res);
14987 template<
typename BasicJsonType>
14994 for (
const auto& reference_token : reference_tokens)
14996 switch (result->type())
15000 if (reference_token ==
"0")
15003 result = &result->operator[](0);
15008 result = &result->operator[](reference_token);
15016 result = &result->operator[](reference_token);
15023 result = &result->operator[](array_index<BasicJsonType>(reference_token));
15067 template<
typename BasicJsonType>
15070 for (
const auto& reference_token : reference_tokens)
15073 if (ptr->is_null())
15077 std::all_of(reference_token.begin(), reference_token.end(),
15078 [](
const unsigned char x)
15080 return std::isdigit(x);
15084 *ptr = (nums || reference_token ==
"-")
15089 switch (ptr->type())
15094 ptr = &ptr->operator[](reference_token);
15100 if (reference_token ==
"-")
15103 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
15108 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15135 template<
typename BasicJsonType>
15138 for (
const auto& reference_token : reference_tokens)
15140 switch (ptr->type())
15145 ptr = &ptr->at(reference_token);
15155 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15156 ") is out of range"), ptr));
15160 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15193 template<
typename BasicJsonType>
15196 for (
const auto& reference_token : reference_tokens)
15198 switch (ptr->type())
15203 ptr = &ptr->operator[](reference_token);
15216 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15242 template<
typename BasicJsonType>
15245 for (
const auto& reference_token : reference_tokens)
15247 switch (ptr->type())
15252 ptr = &ptr->at(reference_token);
15262 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15263 ") is out of range"), ptr));
15267 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15291 template<
typename BasicJsonType>
15294 for (
const auto& reference_token : reference_tokens)
15296 switch (ptr->type())
15300 if (!ptr->contains(reference_token))
15306 ptr = &ptr->operator[](reference_token);
15317 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
15329 for (std::size_t i = 1; i < reference_token.size(); i++)
15339 const auto idx = array_index<BasicJsonType>(reference_token);
15340 if (idx >= ptr->size())
15346 ptr = &ptr->operator[](idx);
15382 std::vector<string_t> result;
15385 if (reference_string.empty())
15401 std::size_t slash = reference_string.find_first_of(
'/', 1),
15408 start = (slash == string_t::npos) ? 0 : slash + 1,
15410 slash = reference_string.find_first_of(
'/', start))
15414 auto reference_token = reference_string.substr(start, slash - start);
15417 for (std::size_t pos = reference_token.find_first_of(
'~');
15418 pos != string_t::npos;
15419 pos = reference_token.find_first_of(
'~', pos + 1))
15425 (reference_token[pos + 1] !=
'0' &&
15426 reference_token[pos + 1] !=
'1')))
15434 result.push_back(reference_token);
15448 template<
typename BasicJsonType>
15450 const BasicJsonType& value,
15451 BasicJsonType& result)
15453 switch (value.type())
15457 if (value.m_data.m_value.array->empty())
15460 result[reference_string] =
nullptr;
15465 for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
15467 flatten(detail::concat<string_t>(reference_string,
'/', std::to_string(i)),
15468 value.m_data.m_value.array->operator[](i), result);
15476 if (value.m_data.m_value.object->empty())
15479 result[reference_string] =
nullptr;
15484 for (
const auto& element : *value.m_data.m_value.object)
15486 flatten(detail::concat<string_t>(reference_string,
'/',
detail::escape(element.first)), element.second, result);
15503 result[reference_string] = value;
15519 template<
typename BasicJsonType>
15520 static BasicJsonType
15528 BasicJsonType result;
15531 for (
const auto& element : *value.m_data.m_value.object)
15564#if JSON_HAS_THREE_WAY_COMPARISON
15567 template<
typename RefStringTypeRhs>
15582 template<
typename RefStringTypeRhs>
15585 return reference_tokens <=> rhs.reference_tokens;
15590 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15597 template<
typename RefStringTypeLhs,
typename StringType>
15600 const StringType& rhs);
15604 template<
typename RefStringTypeRhs,
typename StringType>
15606 friend bool operator==(
const StringType& lhs,
15611 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15618 template<
typename RefStringTypeLhs,
typename StringType>
15621 const StringType& rhs);
15625 template<
typename RefStringTypeRhs,
typename StringType>
15627 friend bool operator!=(
const StringType& lhs,
15631 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15642#if !JSON_HAS_THREE_WAY_COMPARISON
15644template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15648 return lhs.reference_tokens == rhs.reference_tokens;
15651template<
typename RefStringTypeLhs,
15655 const StringType& rhs)
15660template<
typename RefStringTypeRhs,
15663inline
bool operator==(const StringType& lhs,
15669template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15673 return !(lhs == rhs);
15676template<
typename RefStringTypeLhs,
15680 const StringType& rhs)
15682 return !(lhs == rhs);
15685template<
typename RefStringTypeRhs,
15688inline
bool operator!=(const StringType& lhs,
15691 return !(lhs == rhs);
15694template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15715#include <initializer_list>
15727template<
typename BasicJsonType>
15738 : value_ref(&
value)
15742 : owned_value(init)
15747 enable_if_t<std::is_constructible<value_type, Args...>::value,
int> = 0 >
15749 : owned_value(
std::forward<Args>(args)...)
15761 if (value_ref ==
nullptr)
15763 return std::move(owned_value);
15770 return value_ref ? *value_ref : owned_value;
15809#include <algorithm>
15835#include <algorithm>
15869template<typename CharType>
15873template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15887 void write_characters(const CharType* s,
std::
size_t length)
override
15889 v.insert(v.end(), s, s + length);
15893 std::vector<CharType, AllocatorType>&
v;
15898template<
typename CharType>
15912 void write_characters(const CharType* s,
std::
size_t length)
override
15914 stream.write(s,
static_cast<std::streamsize
>(length));
15923template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15937 void write_characters(const CharType* s,
std::
size_t length)
override
15939 str.append(s, length);
15946template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15950 template<
typename AllocatorType = std::allocator<CharType>>
15995template<
typename BasicJsonType,
typename CharType>
16021 case value_t::object:
16023 write_bson_object(*j.m_data.m_value.object);
16027 case value_t::null:
16028 case value_t::array:
16029 case value_t::string:
16030 case value_t::boolean:
16031 case value_t::number_integer:
16032 case value_t::number_unsigned:
16033 case value_t::number_float:
16034 case value_t::binary:
16035 case value_t::discarded:
16038 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
16050 case value_t::null:
16052 oa->write_character(to_char_type(0xF6));
16056 case value_t::boolean:
16058 oa->write_character(j.m_data.m_value.boolean
16059 ? to_char_type(0xF5)
16060 : to_char_type(0xF4));
16064 case value_t::number_integer:
16066 if (j.m_data.m_value.number_integer >= 0)
16071 if (j.m_data.m_value.number_integer <= 0x17)
16073 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16075 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16077 oa->write_character(to_char_type(0x18));
16078 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16080 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
16082 oa->write_character(to_char_type(0x19));
16083 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16085 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
16087 oa->write_character(to_char_type(0x1A));
16088 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16092 oa->write_character(to_char_type(0x1B));
16093 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16100 const auto positive_number = -1 - j.m_data.m_value.number_integer;
16101 if (j.m_data.m_value.number_integer >= -24)
16103 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
16105 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
16107 oa->write_character(to_char_type(0x38));
16108 write_number(
static_cast<std::uint8_t
>(positive_number));
16110 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
16112 oa->write_character(to_char_type(0x39));
16113 write_number(
static_cast<std::uint16_t
>(positive_number));
16115 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
16117 oa->write_character(to_char_type(0x3A));
16118 write_number(
static_cast<std::uint32_t
>(positive_number));
16122 oa->write_character(to_char_type(0x3B));
16123 write_number(
static_cast<std::uint64_t
>(positive_number));
16129 case value_t::number_unsigned:
16131 if (j.m_data.m_value.number_unsigned <= 0x17)
16133 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16135 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16137 oa->write_character(to_char_type(0x18));
16138 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
16140 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16142 oa->write_character(to_char_type(0x19));
16143 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
16145 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16147 oa->write_character(to_char_type(0x1A));
16148 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
16152 oa->write_character(to_char_type(0x1B));
16153 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
16158 case value_t::number_float:
16160 if (std::isnan(j.m_data.m_value.number_float))
16163 oa->write_character(to_char_type(0xF9));
16164 oa->write_character(to_char_type(0x7E));
16165 oa->write_character(to_char_type(0x00));
16167 else if (std::isinf(j.m_data.m_value.number_float))
16170 oa->write_character(to_char_type(0xf9));
16171 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
16172 oa->write_character(to_char_type(0x00));
16181 case value_t::string:
16184 const auto N = j.m_data.m_value.string->size();
16187 write_number(
static_cast<std::uint8_t
>(0x60 + N));
16189 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16191 oa->write_character(to_char_type(0x78));
16192 write_number(
static_cast<std::uint8_t
>(N));
16194 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16196 oa->write_character(to_char_type(0x79));
16197 write_number(
static_cast<std::uint16_t
>(N));
16199 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16201 oa->write_character(to_char_type(0x7A));
16202 write_number(
static_cast<std::uint32_t
>(N));
16205 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16207 oa->write_character(to_char_type(0x7B));
16208 write_number(
static_cast<std::uint64_t
>(N));
16213 oa->write_characters(
16214 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16215 j.m_data.m_value.string->size());
16219 case value_t::array:
16222 const auto N = j.m_data.m_value.array->size();
16225 write_number(
static_cast<std::uint8_t
>(0x80 + N));
16227 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16229 oa->write_character(to_char_type(0x98));
16230 write_number(
static_cast<std::uint8_t
>(N));
16232 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16234 oa->write_character(to_char_type(0x99));
16235 write_number(
static_cast<std::uint16_t
>(N));
16237 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16239 oa->write_character(to_char_type(0x9A));
16240 write_number(
static_cast<std::uint32_t
>(N));
16243 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16245 oa->write_character(to_char_type(0x9B));
16246 write_number(
static_cast<std::uint64_t
>(N));
16251 for (
const auto& el : *j.m_data.m_value.array)
16258 case value_t::binary:
16260 if (j.m_data.m_value.binary->has_subtype())
16262 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
16264 write_number(
static_cast<std::uint8_t
>(0xd8));
16265 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
16267 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
16269 write_number(
static_cast<std::uint8_t
>(0xd9));
16270 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
16272 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
16274 write_number(
static_cast<std::uint8_t
>(0xda));
16275 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
16277 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
16279 write_number(
static_cast<std::uint8_t
>(0xdb));
16280 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
16285 const auto N = j.m_data.m_value.binary->size();
16288 write_number(
static_cast<std::uint8_t
>(0x40 + N));
16290 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16292 oa->write_character(to_char_type(0x58));
16293 write_number(
static_cast<std::uint8_t
>(N));
16295 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16297 oa->write_character(to_char_type(0x59));
16298 write_number(
static_cast<std::uint16_t
>(N));
16300 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16302 oa->write_character(to_char_type(0x5A));
16303 write_number(
static_cast<std::uint32_t
>(N));
16306 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16308 oa->write_character(to_char_type(0x5B));
16309 write_number(
static_cast<std::uint64_t
>(N));
16314 oa->write_characters(
16315 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16321 case value_t::object:
16324 const auto N = j.m_data.m_value.object->size();
16327 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
16329 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16331 oa->write_character(to_char_type(0xB8));
16332 write_number(
static_cast<std::uint8_t
>(N));
16334 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16336 oa->write_character(to_char_type(0xB9));
16337 write_number(
static_cast<std::uint16_t
>(N));
16339 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16341 oa->write_character(to_char_type(0xBA));
16342 write_number(
static_cast<std::uint32_t
>(N));
16345 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16347 oa->write_character(to_char_type(0xBB));
16348 write_number(
static_cast<std::uint64_t
>(N));
16353 for (
const auto& el : *j.m_data.m_value.object)
16355 write_cbor(el.first);
16356 write_cbor(el.second);
16361 case value_t::discarded:
16374 case value_t::null:
16376 oa->write_character(to_char_type(0xC0));
16380 case value_t::boolean:
16382 oa->write_character(j.m_data.m_value.boolean
16383 ? to_char_type(0xC3)
16384 : to_char_type(0xC2));
16388 case value_t::number_integer:
16390 if (j.m_data.m_value.number_integer >= 0)
16395 if (j.m_data.m_value.number_unsigned < 128)
16398 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16400 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16403 oa->write_character(to_char_type(0xCC));
16404 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16406 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16409 oa->write_character(to_char_type(0xCD));
16410 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16412 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16415 oa->write_character(to_char_type(0xCE));
16416 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16418 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16421 oa->write_character(to_char_type(0xCF));
16422 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16427 if (j.m_data.m_value.number_integer >= -32)
16430 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16432 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
16433 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16436 oa->write_character(to_char_type(0xD0));
16437 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16439 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
16440 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16443 oa->write_character(to_char_type(0xD1));
16444 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
16446 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
16447 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16450 oa->write_character(to_char_type(0xD2));
16451 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
16453 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
16454 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16457 oa->write_character(to_char_type(0xD3));
16458 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
16464 case value_t::number_unsigned:
16466 if (j.m_data.m_value.number_unsigned < 128)
16469 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16471 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16474 oa->write_character(to_char_type(0xCC));
16475 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16477 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16480 oa->write_character(to_char_type(0xCD));
16481 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16483 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16486 oa->write_character(to_char_type(0xCE));
16487 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16489 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16492 oa->write_character(to_char_type(0xCF));
16493 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16498 case value_t::number_float:
16504 case value_t::string:
16507 const auto N = j.m_data.m_value.string->size();
16511 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
16513 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16516 oa->write_character(to_char_type(0xD9));
16517 write_number(
static_cast<std::uint8_t
>(N));
16519 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16522 oa->write_character(to_char_type(0xDA));
16523 write_number(
static_cast<std::uint16_t
>(N));
16525 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16528 oa->write_character(to_char_type(0xDB));
16529 write_number(
static_cast<std::uint32_t
>(N));
16533 oa->write_characters(
16534 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16535 j.m_data.m_value.string->size());
16539 case value_t::array:
16542 const auto N = j.m_data.m_value.array->size();
16546 write_number(
static_cast<std::uint8_t
>(0x90 | N));
16548 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16551 oa->write_character(to_char_type(0xDC));
16552 write_number(
static_cast<std::uint16_t
>(N));
16554 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16557 oa->write_character(to_char_type(0xDD));
16558 write_number(
static_cast<std::uint32_t
>(N));
16562 for (
const auto& el : *j.m_data.m_value.array)
16569 case value_t::binary:
16573 const bool use_ext = j.m_data.m_value.binary->has_subtype();
16576 const auto N = j.m_data.m_value.binary->size();
16577 if (N <= (std::numeric_limits<std::uint8_t>::max)())
16579 std::uint8_t output_type{};
16586 output_type = 0xD4;
16589 output_type = 0xD5;
16592 output_type = 0xD6;
16595 output_type = 0xD7;
16598 output_type = 0xD8;
16601 output_type = 0xC7;
16609 output_type = 0xC4;
16613 oa->write_character(to_char_type(output_type));
16616 write_number(
static_cast<std::uint8_t
>(N));
16619 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16621 const std::uint8_t output_type = use_ext
16625 oa->write_character(to_char_type(output_type));
16626 write_number(
static_cast<std::uint16_t
>(N));
16628 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16630 const std::uint8_t output_type = use_ext
16634 oa->write_character(to_char_type(output_type));
16635 write_number(
static_cast<std::uint32_t
>(N));
16641 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
16645 oa->write_characters(
16646 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16652 case value_t::object:
16655 const auto N = j.m_data.m_value.object->size();
16659 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
16661 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16664 oa->write_character(to_char_type(0xDE));
16665 write_number(
static_cast<std::uint16_t
>(N));
16667 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16670 oa->write_character(to_char_type(0xDF));
16671 write_number(
static_cast<std::uint32_t
>(N));
16675 for (
const auto& el : *j.m_data.m_value.object)
16677 write_msgpack(el.first);
16678 write_msgpack(el.second);
16683 case value_t::discarded:
16698 const bool use_type,
const bool add_prefix =
true,
16699 const bool use_bjdata =
false,
const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
16701 const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
16705 case value_t::null:
16709 oa->write_character(to_char_type(
'Z'));
16714 case value_t::boolean:
16718 oa->write_character(j.m_data.m_value.boolean
16719 ? to_char_type(
'T')
16720 : to_char_type(
'F'));
16725 case value_t::number_integer:
16727 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16731 case value_t::number_unsigned:
16733 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16737 case value_t::number_float:
16739 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16743 case value_t::string:
16747 oa->write_character(to_char_type(
'S'));
16749 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16750 oa->write_characters(
16751 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16752 j.m_data.m_value.string->size());
16756 case value_t::array:
16760 oa->write_character(to_char_type(
'['));
16763 bool prefix_required =
true;
16764 if (use_type && !j.m_data.m_value.array->empty())
16767 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16768 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16769 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16771 return ubjson_prefix(v, use_bjdata) == first_prefix;
16774 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16776 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16778 prefix_required =
false;
16779 oa->write_character(to_char_type(
'$'));
16780 oa->write_character(first_prefix);
16786 oa->write_character(to_char_type(
'#'));
16787 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16790 for (
const auto& el : *j.m_data.m_value.array)
16792 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16797 oa->write_character(to_char_type(
']'));
16803 case value_t::binary:
16807 oa->write_character(to_char_type(
'['));
16810 if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
16813 oa->write_character(to_char_type(
'$'));
16814 oa->write_character(bjdata_draft3 ?
'B' :
'U');
16819 oa->write_character(to_char_type(
'#'));
16820 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16825 oa->write_characters(
16826 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16827 j.m_data.m_value.binary->size());
16831 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16833 oa->write_character(to_char_type(bjdata_draft3 ?
'B' :
'U'));
16834 oa->write_character(j.m_data.m_value.binary->data()[i]);
16840 oa->write_character(to_char_type(
']'));
16846 case value_t::object:
16848 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())
16850 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version))
16858 oa->write_character(to_char_type(
'{'));
16861 bool prefix_required =
true;
16862 if (use_type && !j.m_data.m_value.object->empty())
16865 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16866 const bool same_prefix = std::all_of(j.begin(), j.end(),
16867 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16869 return ubjson_prefix(v, use_bjdata) == first_prefix;
16872 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16874 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16876 prefix_required =
false;
16877 oa->write_character(to_char_type(
'$'));
16878 oa->write_character(first_prefix);
16884 oa->write_character(to_char_type(
'#'));
16885 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16888 for (
const auto& el : *j.m_data.m_value.object)
16890 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16891 oa->write_characters(
16892 reinterpret_cast<const CharType*
>(el.first.c_str()),
16894 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16899 oa->write_character(to_char_type(
'}'));
16905 case value_t::discarded:
16922 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16925 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
16928 static_cast<void>(j);
16929 return 1ul + name.size() + 1u;
16936 const std::uint8_t element_type)
16938 oa->write_character(to_char_type(element_type));
16939 oa->write_characters(
16940 reinterpret_cast<const CharType*
>(name.c_str()),
16950 write_bson_entry_header(name, 0x08);
16951 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
16958 const double value)
16960 write_bson_entry_header(name, 0x01);
16961 write_number<double>(
value,
true);
16969 return sizeof(std::int32_t) +
value.size() + 1ul;
16978 write_bson_entry_header(name, 0x02);
16980 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16981 oa->write_characters(
16982 reinterpret_cast<const CharType*
>(
value.c_str()),
16991 write_bson_entry_header(name, 0x0A);
16999 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
17000 ?
sizeof(std::int32_t)
17001 :
sizeof(std::int64_t);
17008 const std::int64_t value)
17010 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
17012 write_bson_entry_header(name, 0x10);
17013 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
17017 write_bson_entry_header(name, 0x12);
17018 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
17027 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17028 ?
sizeof(std::int32_t)
17029 :
sizeof(std::int64_t);
17036 const BasicJsonType& j)
17038 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17040 write_bson_entry_header(name, 0x10 );
17041 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
17043 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17045 write_bson_entry_header(name, 0x12 );
17046 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
17050 write_bson_entry_header(name, 0x11 );
17051 write_number<std::uint64_t>(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned),
true);
17059 const typename BasicJsonType::object_t& value)
17061 write_bson_entry_header(name, 0x03);
17062 write_bson_object(
value);
17070 std::size_t array_index = 0ul;
17072 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)
17074 return result + calc_bson_element_size(std::to_string(array_index++), el);
17077 return sizeof(std::int32_t) + embedded_document_size + 1ul;
17085 return sizeof(std::int32_t) +
value.size() + 1ul;
17092 const typename BasicJsonType::array_t& value)
17094 write_bson_entry_header(name, 0x04);
17095 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
17097 std::size_t array_index = 0ul;
17099 for (
const auto& el :
value)
17101 write_bson_element(std::to_string(array_index++), el);
17104 oa->write_character(to_char_type(0x00));
17113 write_bson_entry_header(name, 0x05);
17115 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
17116 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
17118 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
17126 const BasicJsonType& j)
17128 const auto header_size = calc_bson_entry_header_size(name, j);
17131 case value_t::object:
17132 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
17134 case value_t::array:
17135 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
17137 case value_t::binary:
17138 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
17140 case value_t::boolean:
17141 return header_size + 1ul;
17143 case value_t::number_float:
17144 return header_size + 8ul;
17146 case value_t::number_integer:
17147 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
17149 case value_t::number_unsigned:
17150 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
17152 case value_t::string:
17153 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
17155 case value_t::null:
17156 return header_size + 0ul;
17159 case value_t::discarded:
17174 const BasicJsonType& j)
17178 case value_t::object:
17179 return write_bson_object_entry(name, *j.m_data.m_value.object);
17181 case value_t::array:
17182 return write_bson_array(name, *j.m_data.m_value.array);
17184 case value_t::binary:
17185 return write_bson_binary(name, *j.m_data.m_value.binary);
17187 case value_t::boolean:
17188 return write_bson_boolean(name, j.m_data.m_value.boolean);
17190 case value_t::number_float:
17191 return write_bson_double(name, j.m_data.m_value.number_float);
17193 case value_t::number_integer:
17194 return write_bson_integer(name, j.m_data.m_value.number_integer);
17196 case value_t::number_unsigned:
17197 return write_bson_unsigned(name, j);
17199 case value_t::string:
17200 return write_bson_string(name, *j.m_data.m_value.string);
17202 case value_t::null:
17203 return write_bson_null(name);
17206 case value_t::discarded:
17222 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
17223 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
17225 return result += calc_bson_element_size(el.first, el.second);
17228 return sizeof(std::int32_t) + document_size + 1ul;
17237 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
17239 for (
const auto& el :
value)
17241 write_bson_element(el.first, el.second);
17244 oa->write_character(to_char_type(0x00));
17253 return to_char_type(0xFA);
17258 return to_char_type(0xFB);
17267 return to_char_type(0xCA);
17272 return to_char_type(0xCB);
17280 template<
typename NumberType,
typename std::enable_if<
17281 std::is_floating_point<NumberType>::value,
int>::type = 0>
17283 const bool add_prefix,
17284 const bool use_bjdata)
17288 oa->write_character(get_ubjson_float_prefix(n));
17290 write_number(n, use_bjdata);
17294 template<
typename NumberType,
typename std::enable_if<
17295 std::is_unsigned<NumberType>::value,
int>::type = 0>
17297 const bool add_prefix,
17298 const bool use_bjdata)
17300 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17304 oa->write_character(to_char_type(
'i'));
17306 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17308 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
17312 oa->write_character(to_char_type(
'U'));
17314 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17316 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17320 oa->write_character(to_char_type(
'I'));
17322 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17324 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
17328 oa->write_character(to_char_type(
'u'));
17330 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
17332 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17336 oa->write_character(to_char_type(
'l'));
17338 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17340 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
17344 oa->write_character(to_char_type(
'm'));
17346 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
17348 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17352 oa->write_character(to_char_type(
'L'));
17354 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17356 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
17360 oa->write_character(to_char_type(
'M'));
17362 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
17368 oa->write_character(to_char_type(
'H'));
17371 const auto number = BasicJsonType(n).dump();
17372 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17373 for (std::size_t i = 0; i < number.size(); ++i)
17375 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17381 template <
typename NumberType,
typename std::enable_if <
17382 std::is_signed<NumberType>::value&&
17383 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
17385 const bool add_prefix,
17386 const bool use_bjdata)
17388 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
17392 oa->write_character(to_char_type(
'i'));
17394 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
17396 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)()))
17400 oa->write_character(to_char_type(
'U'));
17402 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17404 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
17408 oa->write_character(to_char_type(
'I'));
17410 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17412 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)())))
17416 oa->write_character(to_char_type(
'u'));
17418 write_number(
static_cast<uint16_t
>(n), use_bjdata);
17420 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
17424 oa->write_character(to_char_type(
'l'));
17426 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17428 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)())))
17432 oa->write_character(to_char_type(
'm'));
17434 write_number(
static_cast<uint32_t
>(n), use_bjdata);
17436 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
17440 oa->write_character(to_char_type(
'L'));
17442 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17449 oa->write_character(to_char_type(
'H'));
17452 const auto number = BasicJsonType(n).dump();
17453 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17454 for (std::size_t i = 0; i < number.size(); ++i)
17456 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17465 CharType
ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
17469 case value_t::null:
17472 case value_t::boolean:
17473 return j.m_data.m_value.boolean ?
'T' :
'F';
17475 case value_t::number_integer:
17477 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)())
17481 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)())
17485 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)())
17489 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)()))
17493 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)())
17497 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)()))
17501 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)())
17509 case value_t::number_unsigned:
17511 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17515 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17519 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17523 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
17527 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17531 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
17535 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17539 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
17547 case value_t::number_float:
17548 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
17550 case value_t::string:
17553 case value_t::array:
17554 case value_t::binary:
17557 case value_t::object:
17560 case value_t::discarded:
17581 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
17582 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'},
17583 {
"char",
'C'}, {
"byte",
'B'}
17588 if (it == bjdtype.end())
17592 CharType dtype = it->second;
17594 key =
"_ArraySize_";
17595 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
17596 for (
const auto& el :
value.at(
key))
17598 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
17601 key =
"_ArrayData_";
17607 oa->write_character(
'[');
17608 oa->write_character(
'$');
17609 oa->write_character(dtype);
17610 oa->write_character(
'#');
17612 key =
"_ArraySize_";
17613 write_ubjson(
value.at(
key), use_count, use_type,
true,
true, bjdata_version);
17615 key =
"_ArrayData_";
17616 if (dtype ==
'U' || dtype ==
'C' || dtype ==
'B')
17618 for (
const auto& el :
value.at(
key))
17620 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
17623 else if (dtype ==
'i')
17625 for (
const auto& el :
value.at(
key))
17627 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
17630 else if (dtype ==
'u')
17632 for (
const auto& el :
value.at(
key))
17634 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
17637 else if (dtype ==
'I')
17639 for (
const auto& el :
value.at(
key))
17641 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
17644 else if (dtype ==
'm')
17646 for (
const auto& el :
value.at(
key))
17648 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
17651 else if (dtype ==
'l')
17653 for (
const auto& el :
value.at(
key))
17655 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
17658 else if (dtype ==
'M')
17660 for (
const auto& el :
value.at(
key))
17662 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
17665 else if (dtype ==
'L')
17667 for (
const auto& el :
value.at(
key))
17669 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
17672 else if (dtype ==
'd')
17674 for (
const auto& el :
value.at(
key))
17676 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
17679 else if (dtype ==
'D')
17681 for (
const auto& el :
value.at(
key))
17683 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
17706 template<
typename NumberType>
17710 std::array<CharType,
sizeof(NumberType)> vec{};
17711 std::memcpy(vec.data(), &n,
sizeof(NumberType));
17714 if (is_little_endian != OutputIsLittleEndian)
17717 std::reverse(vec.begin(), vec.end());
17720 oa->write_characters(vec.data(),
sizeof(NumberType));
17726#pragma GCC diagnostic push
17727#pragma GCC diagnostic ignored "-Wfloat-equal"
17729 if (!std::isfinite(n) || ((
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17730 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17731 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))))
17734 ? get_cbor_float_prefix(
static_cast<float>(n))
17735 : get_msgpack_float_prefix(
static_cast<float>(n)));
17736 write_number(
static_cast<float>(n));
17741 ? get_cbor_float_prefix(n)
17742 : get_msgpack_float_prefix(n));
17746#pragma GCC diagnostic pop
17755 template <
typename C = CharType,
17756 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
17759 return *
reinterpret_cast<char*
>(&x);
17762 template <
typename C = CharType,
17763 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
17773#ifdef JSON_HAS_CPP_26
17774 static_assert(std::is_trivially_copyable<CharType>::value,
"CharType must be trivially copyable");
17775 static_assert(std::is_trivially_default_constructible<CharType>::value,
"CharType must be trivially default constructible");
17777 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
17780 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17782 std::memcpy(&result, &x,
sizeof(x));
17786 template<
typename C = CharType,
17793 template <
typename InputCharType,
typename C = CharType,
17795 std::is_signed<C>::value &&
17796 std::is_signed<char>::value &&
17797 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
17829#include <algorithm>
17839#include <type_traits>
17859#include <type_traits>
17890template<
typename Target,
typename Source>
17893 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17896 std::memcpy(&target, &source,
sizeof(Source));
17902 static constexpr int kPrecision = 64;
17904 std::uint64_t f = 0;
17907 constexpr diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
17918 return {x.f - y.f, x.e};
17927 static_assert(kPrecision == 64,
"internal error");
17952 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
17953 const std::uint64_t u_hi = x.f >> 32u;
17954 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17955 const std::uint64_t v_hi = y.f >> 32u;
17957 const std::uint64_t p0 = u_lo * v_lo;
17958 const std::uint64_t p1 = u_lo * v_hi;
17959 const std::uint64_t p2 = u_hi * v_lo;
17960 const std::uint64_t p3 = u_hi * v_hi;
17962 const std::uint64_t p0_hi = p0 >> 32u;
17963 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17964 const std::uint64_t p1_hi = p1 >> 32u;
17965 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17966 const std::uint64_t p2_hi = p2 >> 32u;
17968 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17979 Q += std::uint64_t{1} << (64u - 32u - 1u);
17981 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17983 return {h, x.e + y.e + 64};
17994 while ((x.f >> 63u) == 0)
18009 const int delta = x.
e - target_exponent;
18014 return {x.f << delta, target_exponent};
18031template<
typename FloatType>
18044 static_assert(std::numeric_limits<FloatType>::is_iec559,
18045 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
18047 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
18048 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
18049 constexpr int kMinExp = 1 - kBias;
18050 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
18052 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
18054 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
18055 const std::uint64_t E = bits >> (kPrecision - 1);
18056 const std::uint64_t F = bits & (kHiddenBit - 1);
18058 const bool is_denormal = E == 0;
18059 const diyfp v = is_denormal
18060 ?
diyfp(F, kMinExp)
18061 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
18084 const bool lower_boundary_is_closer = F == 0 && E > 1;
18086 const diyfp m_minus = lower_boundary_is_closer
18087 ?
diyfp((4 * v.
f) - 1, v.
e - 2)
18088 :
diyfp((2 * v.
f) - 1, v.
e - 1);
18091 const diyfp w_plus = diyfp::normalize(m_plus);
18094 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
18096 return {diyfp::normalize(v), w_minus, w_plus};
18223 constexpr int kCachedPowersMinDecExp = -300;
18224 constexpr int kCachedPowersDecStep = 8;
18226 static constexpr std::array<cached_power, 79> kCachedPowers =
18229 { 0xAB70FE17C79AC6CA, -1060, -300 },
18230 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
18231 { 0xBE5691EF416BD60C, -1007, -284 },
18232 { 0x8DD01FAD907FFC3C, -980, -276 },
18233 { 0xD3515C2831559A83, -954, -268 },
18234 { 0x9D71AC8FADA6C9B5, -927, -260 },
18235 { 0xEA9C227723EE8BCB, -901, -252 },
18236 { 0xAECC49914078536D, -874, -244 },
18237 { 0x823C12795DB6CE57, -847, -236 },
18238 { 0xC21094364DFB5637, -821, -228 },
18239 { 0x9096EA6F3848984F, -794, -220 },
18240 { 0xD77485CB25823AC7, -768, -212 },
18241 { 0xA086CFCD97BF97F4, -741, -204 },
18242 { 0xEF340A98172AACE5, -715, -196 },
18243 { 0xB23867FB2A35B28E, -688, -188 },
18244 { 0x84C8D4DFD2C63F3B, -661, -180 },
18245 { 0xC5DD44271AD3CDBA, -635, -172 },
18246 { 0x936B9FCEBB25C996, -608, -164 },
18247 { 0xDBAC6C247D62A584, -582, -156 },
18248 { 0xA3AB66580D5FDAF6, -555, -148 },
18249 { 0xF3E2F893DEC3F126, -529, -140 },
18250 { 0xB5B5ADA8AAFF80B8, -502, -132 },
18251 { 0x87625F056C7C4A8B, -475, -124 },
18252 { 0xC9BCFF6034C13053, -449, -116 },
18253 { 0x964E858C91BA2655, -422, -108 },
18254 { 0xDFF9772470297EBD, -396, -100 },
18255 { 0xA6DFBD9FB8E5B88F, -369, -92 },
18256 { 0xF8A95FCF88747D94, -343, -84 },
18257 { 0xB94470938FA89BCF, -316, -76 },
18258 { 0x8A08F0F8BF0F156B, -289, -68 },
18259 { 0xCDB02555653131B6, -263, -60 },
18260 { 0x993FE2C6D07B7FAC, -236, -52 },
18261 { 0xE45C10C42A2B3B06, -210, -44 },
18262 { 0xAA242499697392D3, -183, -36 },
18263 { 0xFD87B5F28300CA0E, -157, -28 },
18264 { 0xBCE5086492111AEB, -130, -20 },
18265 { 0x8CBCCC096F5088CC, -103, -12 },
18266 { 0xD1B71758E219652C, -77, -4 },
18267 { 0x9C40000000000000, -50, 4 },
18268 { 0xE8D4A51000000000, -24, 12 },
18269 { 0xAD78EBC5AC620000, 3, 20 },
18270 { 0x813F3978F8940984, 30, 28 },
18271 { 0xC097CE7BC90715B3, 56, 36 },
18272 { 0x8F7E32CE7BEA5C70, 83, 44 },
18273 { 0xD5D238A4ABE98068, 109, 52 },
18274 { 0x9F4F2726179A2245, 136, 60 },
18275 { 0xED63A231D4C4FB27, 162, 68 },
18276 { 0xB0DE65388CC8ADA8, 189, 76 },
18277 { 0x83C7088E1AAB65DB, 216, 84 },
18278 { 0xC45D1DF942711D9A, 242, 92 },
18279 { 0x924D692CA61BE758, 269, 100 },
18280 { 0xDA01EE641A708DEA, 295, 108 },
18281 { 0xA26DA3999AEF774A, 322, 116 },
18282 { 0xF209787BB47D6B85, 348, 124 },
18283 { 0xB454E4A179DD1877, 375, 132 },
18284 { 0x865B86925B9BC5C2, 402, 140 },
18285 { 0xC83553C5C8965D3D, 428, 148 },
18286 { 0x952AB45CFA97A0B3, 455, 156 },
18287 { 0xDE469FBD99A05FE3, 481, 164 },
18288 { 0xA59BC234DB398C25, 508, 172 },
18289 { 0xF6C69A72A3989F5C, 534, 180 },
18290 { 0xB7DCBF5354E9BECE, 561, 188 },
18291 { 0x88FCF317F22241E2, 588, 196 },
18292 { 0xCC20CE9BD35C78A5, 614, 204 },
18293 { 0x98165AF37B2153DF, 641, 212 },
18294 { 0xE2A0B5DC971F303A, 667, 220 },
18295 { 0xA8D9D1535CE3B396, 694, 228 },
18296 { 0xFB9B7CD9A4A7443C, 720, 236 },
18297 { 0xBB764C4CA7A44410, 747, 244 },
18298 { 0x8BAB8EEFB6409C1A, 774, 252 },
18299 { 0xD01FEF10A657842C, 800, 260 },
18300 { 0x9B10A4E5E9913129, 827, 268 },
18301 { 0xE7109BFBA19C0C9D, 853, 276 },
18302 { 0xAC2820D9623BF429, 880, 284 },
18303 { 0x80444B5E7AA7CF85, 907, 292 },
18304 { 0xBF21E44003ACDD2D, 933, 300 },
18305 { 0x8E679C2F5E44FF8F, 960, 308 },
18306 { 0xD433179D9C8CB841, 986, 316 },
18307 { 0x9E19DB92B4E31BA9, 1013, 324 },
18317 const int f =
kAlpha - e - 1;
18318 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
18320 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
18322 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
18324 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
18338 if (n >= 1000000000)
18340 pow10 = 1000000000;
18344 if (n >= 100000000)
18389inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
18390 std::uint64_t rest, std::uint64_t ten_k)
18417 && delta - rest >= ten_k
18418 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
18433 static_assert(
kAlpha >= -60,
"internal error");
18434 static_assert(
kGamma <= -32,
"internal error");
18451 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
18452 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
18461 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
18463 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
18464 std::uint64_t p2 = M_plus.
f & (one.f - 1);
18472 std::uint32_t pow10{};
18500 const std::uint32_t d = p1 / pow10;
18501 const std::uint32_t r = p1 % pow10;
18507 buffer[length++] =
static_cast<char>(
'0' + d);
18526 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
18531 decimal_exponent += n;
18542 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
18543 grisu2_round(buffer, length, dist, delta, rest, ten_n);
18604 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
18606 const std::uint64_t d = p2 >> -one.e;
18607 const std::uint64_t r = p2 & (one.f - 1);
18614 buffer[length++] =
static_cast<char>(
'0' + d);
18639 decimal_exponent -= m;
18647 const std::uint64_t ten_m = one.f;
18671inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
18688 const diyfp c_minus_k(cached.
f, cached.
e);
18691 const diyfp w = diyfp::mul(v, c_minus_k);
18692 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
18693 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
18716 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
18717 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
18719 decimal_exponent = -cached.
k;
18729template<
typename FloatType>
18731void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
18733 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
18734 "internal error: not enough precision");
18771inline
char* append_exponent(
char* buf,
int e)
18786 auto k =
static_cast<std::uint32_t
>(e);
18792 *buf++ =
static_cast<char>(
'0' + k);
18796 *buf++ =
static_cast<char>(
'0' + (k / 10));
18798 *buf++ =
static_cast<char>(
'0' + k);
18802 *buf++ =
static_cast<char>(
'0' + (k / 100));
18804 *buf++ =
static_cast<char>(
'0' + (k / 10));
18806 *buf++ =
static_cast<char>(
'0' + k);
18823inline
char* format_buffer(
char* buf,
int len,
int decimal_exponent,
18824 int min_exp,
int max_exp)
18830 const int n = len + decimal_exponent;
18836 if (k <= n && n <= max_exp)
18841 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18845 return buf + (
static_cast<size_t>(n) + 2);
18848 if (0 < n && n <= max_exp)
18855 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18857 return buf + (
static_cast<size_t>(k) + 1U);
18860 if (min_exp < n && n <= 0)
18865 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18868 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18869 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18884 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18886 buf += 1 +
static_cast<size_t>(k);
18905template<
typename FloatType>
18908char* to_chars(
char* first, const
char* last, FloatType value)
18910 static_cast<void>(last);
18914 if (std::signbit(
value))
18921#pragma GCC diagnostic push
18922#pragma GCC diagnostic ignored "-Wfloat-equal"
18933#pragma GCC diagnostic pop
18936 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18943 int decimal_exponent = 0;
18944 dtoa_impl::grisu2(first, len, decimal_exponent,
value);
18946 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18949 constexpr int kMinExp = -4;
18951 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18954 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18955 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18957 return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
18994template<
typename BasicJsonType>
19002 static constexpr std::uint8_t UTF8_ACCEPT = 0;
19003 static constexpr std::uint8_t UTF8_REJECT = 1;
19014 , loc(
std::localeconv())
19015 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->thousands_sep)))
19016 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->decimal_point)))
19017 , indent_char(ichar)
19018 , indent_string(512, indent_char)
19019 , error_handler(error_handler_)
19052 const bool pretty_print,
19053 const bool ensure_ascii,
19054 const unsigned int indent_step,
19055 const unsigned int current_indent = 0)
19057 switch (val.m_data.m_type)
19059 case value_t::object:
19061 if (val.m_data.m_value.object->empty())
19063 o->write_characters(
"{}", 2);
19069 o->write_characters(
"{\n", 2);
19072 const auto new_indent = current_indent + indent_step;
19075 indent_string.resize(indent_string.size() * 2,
' ');
19079 auto i = val.m_data.m_value.object->cbegin();
19080 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
19082 o->write_characters(indent_string.c_str(), new_indent);
19083 o->write_character(
'\"');
19084 dump_escaped(i->first, ensure_ascii);
19085 o->write_characters(
"\": ", 3);
19086 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
19087 o->write_characters(
",\n", 2);
19091 JSON_ASSERT(i != val.m_data.m_value.object->cend());
19092 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
19093 o->write_characters(indent_string.c_str(), new_indent);
19094 o->write_character(
'\"');
19095 dump_escaped(i->first, ensure_ascii);
19096 o->write_characters(
"\": ", 3);
19097 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
19099 o->write_character(
'\n');
19100 o->write_characters(indent_string.c_str(), current_indent);
19101 o->write_character(
'}');
19105 o->write_character(
'{');
19108 auto i = val.m_data.m_value.object->cbegin();
19109 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
19111 o->write_character(
'\"');
19112 dump_escaped(i->first, ensure_ascii);
19113 o->write_characters(
"\":", 2);
19114 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
19115 o->write_character(
',');
19119 JSON_ASSERT(i != val.m_data.m_value.object->cend());
19120 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
19121 o->write_character(
'\"');
19122 dump_escaped(i->first, ensure_ascii);
19123 o->write_characters(
"\":", 2);
19124 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
19126 o->write_character(
'}');
19132 case value_t::array:
19134 if (val.m_data.m_value.array->empty())
19136 o->write_characters(
"[]", 2);
19142 o->write_characters(
"[\n", 2);
19145 const auto new_indent = current_indent + indent_step;
19148 indent_string.resize(indent_string.size() * 2,
' ');
19152 for (
auto i = val.m_data.m_value.array->cbegin();
19153 i != val.m_data.m_value.array->cend() - 1; ++i)
19155 o->write_characters(indent_string.c_str(), new_indent);
19156 dump(*i,
true, ensure_ascii, indent_step, new_indent);
19157 o->write_characters(
",\n", 2);
19162 o->write_characters(indent_string.c_str(), new_indent);
19163 dump(val.m_data.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
19165 o->write_character(
'\n');
19166 o->write_characters(indent_string.c_str(), current_indent);
19167 o->write_character(
']');
19171 o->write_character(
'[');
19174 for (
auto i = val.m_data.m_value.array->cbegin();
19175 i != val.m_data.m_value.array->cend() - 1; ++i)
19177 dump(*i,
false, ensure_ascii, indent_step, current_indent);
19178 o->write_character(
',');
19183 dump(val.m_data.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
19185 o->write_character(
']');
19191 case value_t::string:
19193 o->write_character(
'\"');
19194 dump_escaped(*val.m_data.m_value.string, ensure_ascii);
19195 o->write_character(
'\"');
19199 case value_t::binary:
19203 o->write_characters(
"{\n", 2);
19206 const auto new_indent = current_indent + indent_step;
19209 indent_string.resize(indent_string.size() * 2,
' ');
19212 o->write_characters(indent_string.c_str(), new_indent);
19214 o->write_characters(
"\"bytes\": [", 10);
19216 if (!val.m_data.m_value.binary->empty())
19218 for (
auto i = val.m_data.m_value.binary->cbegin();
19219 i != val.m_data.m_value.binary->cend() - 1; ++i)
19222 o->write_characters(
", ", 2);
19224 dump_integer(val.m_data.m_value.binary->back());
19227 o->write_characters(
"],\n", 3);
19228 o->write_characters(indent_string.c_str(), new_indent);
19230 o->write_characters(
"\"subtype\": ", 11);
19231 if (val.m_data.m_value.binary->has_subtype())
19233 dump_integer(val.m_data.m_value.binary->subtype());
19237 o->write_characters(
"null", 4);
19239 o->write_character(
'\n');
19240 o->write_characters(indent_string.c_str(), current_indent);
19241 o->write_character(
'}');
19245 o->write_characters(
"{\"bytes\":[", 10);
19247 if (!val.m_data.m_value.binary->empty())
19249 for (
auto i = val.m_data.m_value.binary->cbegin();
19250 i != val.m_data.m_value.binary->cend() - 1; ++i)
19253 o->write_character(
',');
19255 dump_integer(val.m_data.m_value.binary->back());
19258 o->write_characters(
"],\"subtype\":", 12);
19259 if (val.m_data.m_value.binary->has_subtype())
19261 dump_integer(val.m_data.m_value.binary->subtype());
19262 o->write_character(
'}');
19266 o->write_characters(
"null}", 5);
19272 case value_t::boolean:
19274 if (val.m_data.m_value.boolean)
19276 o->write_characters(
"true", 4);
19280 o->write_characters(
"false", 5);
19285 case value_t::number_integer:
19287 dump_integer(val.m_data.m_value.number_integer);
19291 case value_t::number_unsigned:
19293 dump_integer(val.m_data.m_value.number_unsigned);
19297 case value_t::number_float:
19299 dump_float(val.m_data.m_value.number_float);
19303 case value_t::discarded:
19305 o->write_characters(
"<discarded>", 11);
19309 case value_t::null:
19311 o->write_characters(
"null", 4);
19335 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
19337 std::uint32_t codepoint{};
19338 std::uint8_t state = UTF8_ACCEPT;
19339 std::size_t bytes = 0;
19342 std::size_t bytes_after_last_accept = 0;
19343 std::size_t undumped_chars = 0;
19345 for (std::size_t i = 0; i < s.size(); ++i)
19347 const auto byte =
static_cast<std::uint8_t
>(s[i]);
19349 switch (decode(state, codepoint,
byte))
19357 string_buffer[bytes++] =
'\\';
19358 string_buffer[bytes++] =
'b';
19364 string_buffer[bytes++] =
'\\';
19365 string_buffer[bytes++] =
't';
19371 string_buffer[bytes++] =
'\\';
19372 string_buffer[bytes++] =
'n';
19378 string_buffer[bytes++] =
'\\';
19379 string_buffer[bytes++] =
'f';
19385 string_buffer[bytes++] =
'\\';
19386 string_buffer[bytes++] =
'r';
19392 string_buffer[bytes++] =
'\\';
19393 string_buffer[bytes++] =
'\"';
19399 string_buffer[bytes++] =
'\\';
19400 string_buffer[bytes++] =
'\\';
19408 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
19410 if (codepoint <= 0xFFFF)
19413 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
19414 static_cast<std::uint16_t
>(codepoint)));
19420 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
19421 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
19422 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
19430 string_buffer[bytes++] = s[i];
19439 if (string_buffer.size() - bytes < 13)
19441 o->write_characters(string_buffer.data(), bytes);
19446 bytes_after_last_accept = bytes;
19447 undumped_chars = 0;
19453 switch (error_handler)
19455 case error_handler_t::strict:
19457 JSON_THROW(type_error::create(316,
concat(
"invalid UTF-8 byte at index ", std::to_string(i),
": 0x", hex_bytes(
byte | 0)),
nullptr));
19460 case error_handler_t::ignore:
19461 case error_handler_t::replace:
19467 if (undumped_chars > 0)
19474 bytes = bytes_after_last_accept;
19476 if (error_handler == error_handler_t::replace)
19481 string_buffer[bytes++] =
'\\';
19482 string_buffer[bytes++] =
'u';
19483 string_buffer[bytes++] =
'f';
19484 string_buffer[bytes++] =
'f';
19485 string_buffer[bytes++] =
'f';
19486 string_buffer[bytes++] =
'd';
19498 if (string_buffer.size() - bytes < 13)
19500 o->write_characters(string_buffer.data(), bytes);
19504 bytes_after_last_accept = bytes;
19507 undumped_chars = 0;
19510 state = UTF8_ACCEPT;
19525 string_buffer[bytes++] = s[i];
19539 o->write_characters(string_buffer.data(), bytes);
19545 switch (error_handler)
19547 case error_handler_t::strict:
19549 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));
19552 case error_handler_t::ignore:
19555 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19559 case error_handler_t::replace:
19562 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19566 o->write_characters(
"\\ufffd", 6);
19570 o->write_characters(
"\xEF\xBF\xBD", 3);
19590 unsigned int count_digits(number_unsigned_t x)
noexcept
19592 unsigned int n_digits = 1;
19601 return n_digits + 1;
19605 return n_digits + 2;
19609 return n_digits + 3;
19621 static std::string hex_bytes(std::uint8_t
byte)
19623 std::string result =
"FF";
19624 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
19625 result[0] = nibble_to_hex[
byte / 16];
19626 result[1] = nibble_to_hex[
byte % 16];
19631 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
19632 bool is_negative_number(NumberType x)
19637 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
19638 bool is_negative_number(NumberType )
19653 std::is_integral<NumberType>::value ||
19654 std::is_same<NumberType, number_unsigned_t>::value ||
19655 std::is_same<NumberType, number_integer_t>::value ||
19656 std::is_same<NumberType, binary_char_t>::value,
19658 void dump_integer(NumberType x)
19660 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
19663 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
19664 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
19665 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
19666 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
19667 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
19668 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
19669 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
19670 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
19671 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
19672 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
19679 o->write_character(
'0');
19684 auto buffer_ptr = number_buffer.begin();
19686 number_unsigned_t abs_value;
19688 unsigned int n_chars{};
19690 if (is_negative_number(x))
19693 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
19696 n_chars = 1 + count_digits(abs_value);
19700 abs_value =
static_cast<number_unsigned_t
>(x);
19701 n_chars = count_digits(abs_value);
19709 buffer_ptr +=
static_cast<typename decltype(number_buffer)::difference_type
>(n_chars);
19713 while (abs_value >= 100)
19715 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
19717 *(--buffer_ptr) = digits_to_99[digits_index][1];
19718 *(--buffer_ptr) = digits_to_99[digits_index][0];
19721 if (abs_value >= 10)
19723 const auto digits_index =
static_cast<unsigned>(abs_value);
19724 *(--buffer_ptr) = digits_to_99[digits_index][1];
19725 *(--buffer_ptr) = digits_to_99[digits_index][0];
19729 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19732 o->write_characters(number_buffer.data(), n_chars);
19743 void dump_float(number_float_t x)
19746 if (!std::isfinite(x))
19748 o->write_characters(
"null", 4);
19757 static constexpr bool is_ieee_single_or_double
19758 = (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) ||
19759 (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);
19761 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
19764 void dump_float(number_float_t x, std::true_type )
19766 auto* begin = number_buffer.data();
19767 auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
19769 o->write_characters(begin,
static_cast<size_t>(end - begin));
19772 void dump_float(number_float_t x, std::false_type )
19775 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
19779 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
19784 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
19787 if (thousands_sep !=
'\0')
19790 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
19791 std::fill(end, number_buffer.end(),
'\0');
19792 JSON_ASSERT((end - number_buffer.begin()) <= len);
19793 len = (end - number_buffer.begin());
19797 if (decimal_point !=
'\0' && decimal_point !=
'.')
19800 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
19801 if (dec_pos != number_buffer.end())
19807 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
19810 const bool value_is_int_like =
19811 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
19814 return c ==
'.' || c ==
'e';
19817 if (value_is_int_like)
19819 o->write_characters(
".0", 2);
19844 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19846 static const std::array<std::uint8_t, 400> utf8d =
19849 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,
19850 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,
19851 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,
19852 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,
19853 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,
19854 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,
19855 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,
19856 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19857 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19858 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19859 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,
19860 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,
19861 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,
19862 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
19866 JSON_ASSERT(
static_cast<std::size_t
>(
byte) < utf8d.size());
19867 const std::uint8_t type = utf8d[byte];
19869 codep = (state != UTF8_ACCEPT)
19870 ? (
byte & 0x3fu) | (codep << 6u)
19871 : (0xFFu >> type) & (byte);
19873 const std::size_t index = 256u + (
static_cast<size_t>(state) * 16u) +
static_cast<size_t>(type);
19875 state = utf8d[index];
19884 number_unsigned_t remove_sign(number_unsigned_t x)
19899 number_unsigned_t remove_sign(number_integer_t x)
noexcept
19901 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19902 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
19907 output_adapter_t<char> o =
nullptr;
19910 std::array<char, 64> number_buffer{{}};
19913 const std::lconv* loc =
nullptr;
19915 const char thousands_sep =
'\0';
19917 const char decimal_point =
'\0';
19920 std::array<char, 512> string_buffer{{}};
19949#include <functional>
19950#include <initializer_list>
19953#include <stdexcept>
19954#include <type_traits>
19967template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19968 class Allocator = std::allocator<std::pair<const Key, T>>>
19973 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19978#ifdef JSON_HAS_CPP_14
19988 template <
class It>
19991 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19996 for (
auto it = this->begin(); it != this->end(); ++it)
19998 if (m_compare(it->first, key))
20000 return {it,
false};
20003 Container::emplace_back(key, std::forward<T>(t));
20004 return {std::prev(this->end()),
true};
20009 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
20011 for (
auto it = this->begin(); it != this->end(); ++it)
20013 if (m_compare(it->first, key))
20015 return {it,
false};
20018 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
20019 return {std::prev(this->end()),
true};
20024 return emplace(key, T{}).first->second;
20031 return emplace(std::forward<KeyType>(key), T{}).first->second;
20043 return at(std::forward<KeyType>(key));
20048 for (
auto it = this->begin(); it != this->end(); ++it)
20050 if (m_compare(it->first, key))
20056 JSON_THROW(std::out_of_range(
"key not found"));
20063 for (
auto it = this->begin(); it != this->end(); ++it)
20065 if (m_compare(it->first, key))
20071 JSON_THROW(std::out_of_range(
"key not found"));
20076 for (
auto it = this->begin(); it != this->end(); ++it)
20078 if (m_compare(it->first, key))
20084 JSON_THROW(std::out_of_range(
"key not found"));
20089 const T &
at(KeyType && key)
const
20091 for (
auto it = this->begin(); it != this->end(); ++it)
20093 if (m_compare(it->first, key))
20099 JSON_THROW(std::out_of_range(
"key not found"));
20104 for (
auto it = this->begin(); it != this->end(); ++it)
20106 if (m_compare(it->first, key))
20109 for (
auto next = it; ++next != this->end(); ++it)
20114 Container::pop_back();
20125 for (
auto it = this->begin(); it != this->end(); ++it)
20127 if (m_compare(it->first, key))
20130 for (
auto next = it; ++next != this->end(); ++it)
20135 Container::pop_back();
20144 return erase(pos, std::next(pos));
20154 const auto elements_affected = std::distance(first, last);
20155 const auto offset = std::distance(Container::begin(), first);
20177 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
20180 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
20188 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
20197 return Container::begin() + offset;
20202 for (
auto it = this->begin(); it != this->end(); ++it)
20204 if (m_compare(it->first, key))
20216 for (
auto it = this->begin(); it != this->end(); ++it)
20218 if (m_compare(it->first, key))
20228 for (
auto it = this->begin(); it != this->end(); ++it)
20230 if (m_compare(it->first, key))
20235 return Container::end();
20242 for (
auto it = this->begin(); it != this->end(); ++it)
20244 if (m_compare(it->first, key))
20249 return Container::end();
20254 for (
auto it = this->begin(); it != this->end(); ++it)
20256 if (m_compare(it->first, key))
20261 return Container::end();
20266 return emplace(value.first, std::move(value.second));
20271 for (
auto it = this->begin(); it != this->end(); ++it)
20273 if (m_compare(it->first, value.first))
20275 return {it,
false};
20278 Container::push_back(value);
20279 return {--this->end(),
true};
20282 template<
typename InputIt>
20283 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20284 std::input_iterator_tag>::value>::type;
20286 template<
typename InputIt,
typename = require_input_iter<InputIt>>
20289 for (
auto it = first; it != last; ++it)
20302#if defined(JSON_HAS_CPP_17)
20303 #if JSON_HAS_STATIC_RTTI
20306 #include <string_view>
20336 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
20342 friend class ::nlohmann::json_pointer;
20346 template<
typename BasicJsonType,
typename InputType>
20347 friend class ::nlohmann::detail::parser;
20348 friend ::nlohmann::detail::serializer<basic_json>;
20349 template<
typename BasicJsonType>
20350 friend class ::nlohmann::detail::iter_impl;
20351 template<
typename BasicJsonType,
typename CharType>
20352 friend class ::nlohmann::detail::binary_writer;
20353 template<
typename BasicJsonType,
typename InputType,
typename SAX>
20354 friend class ::nlohmann::detail::binary_reader;
20355 template<
typename BasicJsonType,
typename InputAdapterType>
20356 friend class ::nlohmann::detail::json_sax_dom_parser;
20357 template<
typename BasicJsonType,
typename InputAdapterType>
20358 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
20359 friend class ::nlohmann::detail::exception;
20367 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
20369 template<
typename InputAdapterType>
20370 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
20371 InputAdapterType adapter,
20373 const bool allow_exceptions =
true,
20374 const bool ignore_comments =
false,
20375 const bool ignore_trailing_commas =
false
20378 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20379 std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
20384 template<
typename BasicJsonType>
20386 template<
typename BasicJsonType>
20388 template<
typename Iterator>
20392 template<
typename CharType>
20395 template<
typename InputType>
20397 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
20400 using serializer = ::nlohmann::detail::serializer<basic_json>;
20406 template<
typename T,
typename SFINAE>
20464 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
20466 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
20493 result[
"copyright"] =
"(C) 2013-2026 Niels Lohmann";
20494 result[
"name"] =
"JSON for Modern C++";
20495 result[
"url"] =
"https://github.com/nlohmann/json";
20496 result[
"version"][
"string"] =
20505 result[
"platform"] =
"win32";
20506#elif defined __linux__
20507 result[
"platform"] =
"linux";
20508#elif defined __APPLE__
20509 result[
"platform"] =
"apple";
20510#elif defined __unix__
20511 result[
"platform"] =
"unix";
20513 result[
"platform"] =
"unknown";
20516#if defined(__ICC) || defined(__INTEL_COMPILER)
20517 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
20518#elif defined(__clang__)
20519 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
20520#elif defined(__GNUC__) || defined(__GNUG__)
20521 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
20522 std::to_string(__GNUC__),
'.',
20523 std::to_string(__GNUC_MINOR__),
'.',
20524 std::to_string(__GNUC_PATCHLEVEL__))
20527#elif defined(__HP_cc) || defined(__HP_aCC)
20528 result[
"compiler"] =
"hp"
20529#elif defined(__IBMCPP__)
20530 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
20531#elif defined(_MSC_VER)
20532 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
20533#elif defined(__PGI)
20534 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
20535#elif defined(__SUNPRO_CC)
20536 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
20538 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
20541#if defined(_MSVC_LANG)
20542 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
20543#elif defined(__cplusplus)
20544 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
20546 result[
"compiler"][
"c++"] =
"unknown";
20564#if defined(JSON_HAS_CPP_14)
20567 using default_object_comparator_t = std::less<>;
20577 AllocatorType<std::pair<
const StringType,
20582 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
20606 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
20617 template<
typename T,
typename... Args>
20621 AllocatorType<T> alloc;
20622 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
20624 auto deleter = [&](T * obj)
20626 AllocatorTraits::deallocate(alloc, obj, 1);
20628 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
20629 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
20631 return obj.release();
20698 case value_t::object:
20700 object = create<object_t>();
20704 case value_t::array:
20706 array = create<array_t>();
20710 case value_t::string:
20712 string = create<string_t>(
"");
20716 case value_t::binary:
20718 binary = create<binary_t>();
20722 case value_t::boolean:
20724 boolean =
static_cast<boolean_t>(
false);
20728 case value_t::number_integer:
20734 case value_t::number_unsigned:
20740 case value_t::number_float:
20746 case value_t::null:
20752 case value_t::discarded:
20758 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0",
nullptr));
20798 (t == value_t::object &&
object ==
nullptr) ||
20799 (t == value_t::array && array ==
nullptr) ||
20800 (t == value_t::string &&
string ==
nullptr) ||
20801 (t == value_t::binary && binary ==
nullptr)
20807 if (t == value_t::array || t == value_t::object)
20810 std::vector<basic_json> stack;
20813 if (t == value_t::array)
20815 stack.reserve(array->size());
20816 std::move(array->begin(), array->end(), std::back_inserter(stack));
20820 stack.reserve(object->size());
20821 for (
auto&& it : *object)
20823 stack.push_back(std::move(it.second));
20827 while (!stack.empty())
20830 basic_json current_item(std::move(stack.back()));
20837 std::move(current_item.
m_data.m_value.array->begin(), current_item.
m_data.m_value.array->end(), std::back_inserter(stack));
20839 current_item.
m_data.m_value.array->clear();
20843 for (
auto&& it : *current_item.
m_data.m_value.object)
20845 stack.push_back(std::move(it.second));
20848 current_item.
m_data.m_value.object->clear();
20858 case value_t::object:
20860 AllocatorType<object_t> alloc;
20861 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20862 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20866 case value_t::array:
20868 AllocatorType<array_t> alloc;
20869 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20870 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20874 case value_t::string:
20876 AllocatorType<string_t> alloc;
20877 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20878 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20882 case value_t::binary:
20884 AllocatorType<binary_t> alloc;
20885 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20886 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20890 case value_t::null:
20891 case value_t::boolean:
20892 case value_t::number_integer:
20893 case value_t::number_unsigned:
20894 case value_t::number_float:
20895 case value_t::discarded:
20925 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
20926 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
20927 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
20928 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
20930#if JSON_DIAGNOSTICS
20934 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
20936 return j.m_parent ==
this;
20941 static_cast<void>(check_parents);
20946#if JSON_DIAGNOSTICS
20947 switch (m_data.m_type)
20949 case value_t::array:
20951 for (
auto& element : *m_data.m_value.array)
20953 element.m_parent =
this;
20958 case value_t::object:
20960 for (
auto& element : *m_data.m_value.object)
20962 element.second.m_parent =
this;
20967 case value_t::null:
20968 case value_t::string:
20969 case value_t::boolean:
20970 case value_t::number_integer:
20971 case value_t::number_unsigned:
20972 case value_t::number_float:
20973 case value_t::binary:
20974 case value_t::discarded:
20983#if JSON_DIAGNOSTICS
20984 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20986 (it + i)->m_parent =
this;
20989 static_cast<void>(count_set_parents);
20996#if JSON_DIAGNOSTICS
21011#ifdef JSON_HEDLEY_MSVC_VERSION
21012#pragma warning(push )
21013#pragma warning(disable : 4127)
21020#ifdef JSON_HEDLEY_MSVC_VERSION
21021#pragma warning( pop )
21026 static_cast<void>(j);
21027 static_cast<void>(old_capacity);
21059 assert_invariant();
21067 assert_invariant();
21072 template <
typename CompatibleType,
21077 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
21078 std::forward<CompatibleType>(val))))
21080 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
21082 assert_invariant();
21087 template <
typename BasicJsonType,
21091#if JSON_DIAGNOSTIC_POSITIONS
21092 : start_position(val.start_pos()),
21093 end_position(val.end_pos())
21096 using other_boolean_t =
typename BasicJsonType::boolean_t;
21097 using other_number_float_t =
typename BasicJsonType::number_float_t;
21098 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
21099 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
21100 using other_string_t =
typename BasicJsonType::string_t;
21101 using other_object_t =
typename BasicJsonType::object_t;
21102 using other_array_t =
typename BasicJsonType::array_t;
21103 using other_binary_t =
typename BasicJsonType::binary_t;
21105 switch (val.type())
21107 case value_t::boolean:
21108 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
21110 case value_t::number_float:
21111 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
21113 case value_t::number_integer:
21114 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
21116 case value_t::number_unsigned:
21117 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
21119 case value_t::string:
21120 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
21122 case value_t::object:
21123 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
21125 case value_t::array:
21126 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
21128 case value_t::binary:
21129 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
21131 case value_t::null:
21134 case value_t::discarded:
21135 m_data.m_type = value_t::discarded;
21143 assert_invariant();
21149 bool type_deduction =
true,
21150 value_t manual_type = value_t::array)
21154 bool is_an_object = std::all_of(init.begin(), init.end(),
21160 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
21164 if (!type_deduction)
21167 if (manual_type == value_t::array)
21169 is_an_object =
false;
21175 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
21182 m_data.m_type = value_t::object;
21183 m_data.m_value = value_t::object;
21185 for (
auto& element_ref : init)
21188 m_data.m_value.object->emplace(
21189 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
21190 std::move((*element.m_data.m_value.array)[1]));
21196 m_data.m_type = value_t::array;
21197 m_data.m_value.array = create<array_t>(init.begin(), init.end());
21201 assert_invariant();
21210 res.m_data.m_type = value_t::binary;
21211 res.m_data.m_value = init;
21218 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
21221 res.m_data.m_type = value_t::binary;
21222 res.m_data.m_value =
binary_t(init, subtype);
21232 res.m_data.m_type = value_t::binary;
21233 res.m_data.m_value = std::move(init);
21240 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
21243 res.m_data.m_type = value_t::binary;
21244 res.m_data.m_value =
binary_t(std::move(init), subtype);
21253 return basic_json(init,
false, value_t::array);
21261 return basic_json(init,
false, value_t::object);
21270 assert_invariant();
21275 template <
class InputIT,
typename std::enable_if <
21276 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
21277 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
21286 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
21290 m_data.m_type = first.m_object->m_data.m_type;
21293 switch (m_data.m_type)
21295 case value_t::boolean:
21296 case value_t::number_float:
21297 case value_t::number_integer:
21298 case value_t::number_unsigned:
21299 case value_t::string:
21302 || !last.m_it.primitive_iterator.is_end()))
21304 JSON_THROW(invalid_iterator::create(204,
"iterators out of range", first.m_object));
21309 case value_t::null:
21310 case value_t::object:
21311 case value_t::array:
21312 case value_t::binary:
21313 case value_t::discarded:
21318 switch (m_data.m_type)
21320 case value_t::number_integer:
21322 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
21326 case value_t::number_unsigned:
21328 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
21332 case value_t::number_float:
21334 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
21338 case value_t::boolean:
21340 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
21344 case value_t::string:
21346 m_data.m_value = *first.m_object->m_data.m_value.string;
21350 case value_t::object:
21352 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
21353 last.m_it.object_iterator);
21357 case value_t::array:
21359 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
21360 last.m_it.array_iterator);
21364 case value_t::binary:
21366 m_data.m_value = *first.m_object->m_data.m_value.binary;
21370 case value_t::null:
21371 case value_t::discarded:
21373 JSON_THROW(invalid_iterator::create(206,
detail::concat(
"cannot construct with iterators from ", first.m_object->type_name()), first.m_object));
21377 assert_invariant();
21384 template<
typename JsonRef,
21386 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
21394 , start_position(other.start_position)
21395 , end_position(other.end_position)
21398 m_data.m_type = other.
m_data.m_type;
21402 switch (m_data.m_type)
21404 case value_t::object:
21406 m_data.m_value = *other.
m_data.m_value.object;
21410 case value_t::array:
21412 m_data.m_value = *other.
m_data.m_value.array;
21416 case value_t::string:
21418 m_data.m_value = *other.
m_data.m_value.string;
21422 case value_t::boolean:
21424 m_data.m_value = other.
m_data.m_value.boolean;
21428 case value_t::number_integer:
21430 m_data.m_value = other.
m_data.m_value.number_integer;
21434 case value_t::number_unsigned:
21436 m_data.m_value = other.
m_data.m_value.number_unsigned;
21440 case value_t::number_float:
21442 m_data.m_value = other.
m_data.m_value.number_float;
21446 case value_t::binary:
21448 m_data.m_value = *other.
m_data.m_value.binary;
21452 case value_t::null:
21453 case value_t::discarded:
21459 assert_invariant();
21466 m_data(std::move(other.m_data))
21467#if JSON_DIAGNOSTIC_POSITIONS
21468 , start_position(other.start_position)
21469 , end_position(other.end_position)
21473 other.assert_invariant(
false);
21476 other.m_data.m_type = value_t::null;
21477 other.m_data.m_value = {};
21479#if JSON_DIAGNOSTIC_POSITIONS
21480 other.start_position = std::string::npos;
21481 other.end_position = std::string::npos;
21485 assert_invariant();
21491 std::is_nothrow_move_constructible<value_t>::value&&
21492 std::is_nothrow_move_assignable<value_t>::value&&
21493 std::is_nothrow_move_constructible<json_value>::value&&
21494 std::is_nothrow_move_assignable<json_value>::value&&
21495 std::is_nothrow_move_assignable<json_base_class_t>::value
21502 swap(m_data.m_type, other.m_data.m_type);
21503 swap(m_data.m_value, other.m_data.m_value);
21505#if JSON_DIAGNOSTIC_POSITIONS
21506 swap(start_position, other.start_position);
21507 swap(end_position, other.end_position);
21510 json_base_class_t::operator=(std::move(other));
21513 assert_invariant();
21521 assert_invariant(
false);
21538 const char indent_char =
' ',
21539 const bool ensure_ascii =
false,
21547 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
21551 s.dump(*
this,
false, ensure_ascii, 0);
21561 return m_data.m_type;
21568 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
21575 return is_array() || is_object();
21582 return m_data.m_type == value_t::null;
21589 return m_data.m_type == value_t::boolean;
21596 return is_number_integer() || is_number_float();
21603 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
21610 return m_data.m_type == value_t::number_unsigned;
21617 return m_data.m_type == value_t::number_float;
21624 return m_data.m_type == value_t::object;
21631 return m_data.m_type == value_t::array;
21638 return m_data.m_type == value_t::string;
21645 return m_data.m_type == value_t::binary;
21652 return m_data.m_type == value_t::discarded;
21659 return m_data.m_type;
21674 return m_data.m_value.boolean;
21683 return is_object() ? m_data.m_value.object :
nullptr;
21689 return is_object() ? m_data.m_value.object :
nullptr;
21695 return is_array() ? m_data.m_value.array :
nullptr;
21701 return is_array() ? m_data.m_value.array :
nullptr;
21707 return is_string() ? m_data.m_value.string :
nullptr;
21713 return is_string() ? m_data.m_value.string :
nullptr;
21719 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21725 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21731 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21737 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21743 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21749 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21755 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21761 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21767 return is_binary() ? m_data.m_value.binary :
nullptr;
21773 return is_binary() ? m_data.m_value.binary :
nullptr;
21787 template<
typename ReferenceType,
typename ThisType>
21791 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
21798 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
21808 template<
typename PointerType,
typename std::enable_if<
21809 std::is_pointer<PointerType>::value,
int>::type = 0>
21813 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21818 template <
typename PointerType,
typename std::enable_if <
21819 std::is_pointer<PointerType>::value&&
21820 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
21824 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21866 template <
typename ValueType,
21872 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21874 auto ret = ValueType();
21875 JSONSerializer<ValueType>::from_json(*
this, ret);
21909 template <
typename ValueType,
21914 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21916 return JSONSerializer<ValueType>::from_json(*
this);
21934 template <
typename BasicJsonType,
21957 template<
typename BasicJsonType,
21959 std::is_same<BasicJsonType, basic_json_t>::value,
21970 template<
typename PointerType,
21972 std::is_pointer<PointerType>::value,
21975 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21978 return get_ptr<PointerType>();
22005 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
22006#if defined(JSON_HAS_CPP_14)
22010 noexcept(
std::declval<const
basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
22016 static_assert(!std::is_reference<ValueTypeCV>::value,
22017 "get() cannot be used with reference types, you might want to use get_ref()");
22048 template<
typename PointerType,
typename std::enable_if<
22049 std::is_pointer<PointerType>::value,
int>::type = 0>
22053 return get_ptr<PointerType>();
22058 template <
typename ValueType,
22063 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
22064 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
22066 JSONSerializer<ValueType>::from_json(*
this, v);
22072 template<
typename ValueType,
22083 typename T, std::size_t N,
22084 typename Array = T (&)[N],
22088 noexcept(
noexcept(JSONSerializer<Array>::from_json(
22089 std::declval<const basic_json_t&>(), v)))
22091 JSONSerializer<Array>::from_json(*
this, v);
22097 template<
typename ReferenceType,
typename std::enable_if<
22098 std::is_reference<ReferenceType>::value,
int>::type = 0>
22102 return get_ref_impl<ReferenceType>(*
this);
22107 template <
typename ReferenceType,
typename std::enable_if <
22108 std::is_reference<ReferenceType>::value&&
22109 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
22113 return get_ref_impl<ReferenceType>(*
this);
22145 template <
typename ValueType,
typename std::enable_if <
22153#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
22156#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
22160 >::value,
int >::type = 0 >
22164 return get<ValueType>();
22176 return *get_ptr<binary_t*>();
22188 return *get_ptr<const binary_t*>();
22210 return set_parent(m_data.m_value.array->at(idx));
22215 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22233 return m_data.
m_value.array->at(idx);
22238 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22257 auto it = m_data.m_value.object->find(key);
22258 if (it == m_data.m_value.object->end())
22262 return set_parent(it->second);
22277 auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
22278 if (it == m_data.m_value.object->end())
22282 return set_parent(it->second);
22295 auto it = m_data.m_value.object->find(key);
22296 if (it == m_data.m_value.object->end())
22315 auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
22316 if (it == m_data.m_value.object->end())
22330 m_data.m_type = value_t::array;
22331 m_data.
m_value.array = create<array_t>();
22332 assert_invariant();
22339 if (idx >= m_data.m_value.array->size())
22341#if JSON_DIAGNOSTICS
22343 const auto old_size = m_data.m_value.array->size();
22344 const auto old_capacity = m_data.m_value.array->capacity();
22346 m_data.m_value.array->resize(idx + 1);
22348#if JSON_DIAGNOSTICS
22357 set_parents(begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
22360 assert_invariant();
22363 return m_data.m_value.array->operator[](idx);
22366 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22376 return m_data.
m_value.array->operator[](idx);
22379 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22389 m_data.m_type = value_t::object;
22390 m_data.
m_value.object = create<object_t>();
22391 assert_invariant();
22397 auto result = m_data.m_value.object->emplace(std::move(key),
nullptr);
22398 return set_parent(result.first->second);
22401 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22411 auto it = m_data.
m_value.object->find(key);
22416 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22421 template<
typename T>
22424 return operator[](
typename object_t::key_type(key));
22427 template<
typename T>
22430 return operator[](
typename object_t::key_type(key));
22442 m_data.m_type = value_t::object;
22443 m_data.
m_value.object = create<object_t>();
22444 assert_invariant();
22450 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
22451 return set_parent(result.first->second);
22454 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22466 auto it = m_data.
m_value.object->find(std::forward<KeyType>(key));
22471 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22475 template<
typename KeyType>
22479 template<
typename ValueType>
22482 string_t,
typename std::decay<ValueType>::type >;
22490 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22491 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
22497 const auto it = find(key);
22500 return it->template get<ValueType>();
22503 return default_value;
22511 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22515 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22516 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
22522 const auto it = find(key);
22525 return it->template get<ReturnType>();
22528 return std::forward<ValueType>(default_value);
22539 && is_comparable_with_object_key<KeyType>::value
22541 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22542 ValueType
value(KeyType && key,
const ValueType& default_value)
const
22548 const auto it = find(std::forward<KeyType>(key));
22551 return it->template get<ValueType>();
22554 return default_value;
22562 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
22566 && is_comparable_with_object_key<KeyType>::value
22568 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22569 ReturnType
value(KeyType && key, ValueType && default_value)
const
22575 const auto it = find(std::forward<KeyType>(key));
22578 return it->template get<ReturnType>();
22581 return std::forward<ValueType>(default_value);
22591 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22601 return ptr.
get_checked(
this).template get<ValueType>();
22605 return default_value;
22614 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22617 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22627 return ptr.
get_checked(
this).template get<ReturnType>();
22631 return std::forward<ValueType>(default_value);
22641 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22643 ValueType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
22645 return value(ptr.convert(), default_value);
22648 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
22652 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22654 ReturnType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const
22656 return value(ptr.convert(), std::forward<ValueType>(default_value));
22694 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22695 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22701 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22704 IteratorType result = end();
22706 switch (m_data.m_type)
22708 case value_t::boolean:
22709 case value_t::number_float:
22710 case value_t::number_integer:
22711 case value_t::number_unsigned:
22712 case value_t::string:
22713 case value_t::binary:
22717 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
22722 AllocatorType<string_t> alloc;
22723 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22724 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22725 m_data.m_value.string =
nullptr;
22727 else if (is_binary())
22729 AllocatorType<binary_t> alloc;
22730 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22731 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22732 m_data.m_value.binary =
nullptr;
22735 m_data.m_type = value_t::null;
22736 assert_invariant();
22740 case value_t::object:
22742 result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator);
22746 case value_t::array:
22748 result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator);
22752 case value_t::null:
22753 case value_t::discarded:
22764 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22765 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22766 IteratorType
erase(IteratorType first, IteratorType last)
22771 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
22774 IteratorType result = end();
22776 switch (m_data.m_type)
22778 case value_t::boolean:
22779 case value_t::number_float:
22780 case value_t::number_integer:
22781 case value_t::number_unsigned:
22782 case value_t::string:
22783 case value_t::binary:
22786 || !last.m_it.primitive_iterator.is_end()))
22788 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
22793 AllocatorType<string_t> alloc;
22794 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22795 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22796 m_data.m_value.string =
nullptr;
22798 else if (is_binary())
22800 AllocatorType<binary_t> alloc;
22801 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22802 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22803 m_data.m_value.binary =
nullptr;
22806 m_data.m_type = value_t::null;
22807 assert_invariant();
22811 case value_t::object:
22813 result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator,
22814 last.m_it.object_iterator);
22818 case value_t::array:
22820 result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator,
22821 last.m_it.array_iterator);
22825 case value_t::null:
22826 case value_t::discarded:
22845 return m_data.m_value.object->erase(std::forward<KeyType>(key));
22858 const auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
22859 if (it != m_data.m_value.object->end())
22861 m_data.m_value.object->erase(it);
22875 return erase_internal(key);
22884 return erase_internal(std::forward<KeyType>(key));
22896 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
22899 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
22920 auto result = end();
22924 result.m_it.object_iterator = m_data.m_value.object->find(key);
22934 auto result = cend();
22938 result.m_it.object_iterator = m_data.m_value.object->find(key);
22950 auto result = end();
22954 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
22966 auto result = cend();
22970 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
22981 return is_object() ? m_data.m_value.object->count(key) : 0;
22991 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(key)) : 0;
22996 bool contains(
const typename object_t::key_type& key)
const
22998 return is_object() && m_data.m_value.object->find(key) != m_data.m_value.object->end();
23007 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(key)) != m_data.m_value.object->end();
23017 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23019 bool contains(const typename ::nlohmann::
json_pointer<BasicJsonType>& ptr)
const
23021 return ptr.contains(
this);
23038 result.set_begin();
23054 result.set_begin();
23134 return ref.items();
23145 return ref.items();
23175 switch (m_data.m_type)
23177 case value_t::null:
23183 case value_t::array:
23186 return m_data.m_value.array->empty();
23189 case value_t::object:
23192 return m_data.m_value.object->empty();
23195 case value_t::string:
23196 case value_t::boolean:
23197 case value_t::number_integer:
23198 case value_t::number_unsigned:
23199 case value_t::number_float:
23200 case value_t::binary:
23201 case value_t::discarded:
23214 switch (m_data.m_type)
23216 case value_t::null:
23222 case value_t::array:
23225 return m_data.m_value.array->size();
23228 case value_t::object:
23231 return m_data.m_value.object->size();
23234 case value_t::string:
23235 case value_t::boolean:
23236 case value_t::number_integer:
23237 case value_t::number_unsigned:
23238 case value_t::number_float:
23239 case value_t::binary:
23240 case value_t::discarded:
23253 switch (m_data.m_type)
23255 case value_t::array:
23258 return m_data.m_value.array->max_size();
23261 case value_t::object:
23264 return m_data.m_value.object->max_size();
23267 case value_t::null:
23268 case value_t::string:
23269 case value_t::boolean:
23270 case value_t::number_integer:
23271 case value_t::number_unsigned:
23272 case value_t::number_float:
23273 case value_t::binary:
23274 case value_t::discarded:
23296 switch (m_data.m_type)
23298 case value_t::number_integer:
23300 m_data.m_value.number_integer = 0;
23304 case value_t::number_unsigned:
23306 m_data.m_value.number_unsigned = 0;
23310 case value_t::number_float:
23312 m_data.m_value.number_float = 0.0;
23316 case value_t::boolean:
23318 m_data.m_value.boolean =
false;
23322 case value_t::string:
23324 m_data.m_value.string->clear();
23328 case value_t::binary:
23330 m_data.m_value.binary->clear();
23334 case value_t::array:
23336 m_data.m_value.array->clear();
23340 case value_t::object:
23342 m_data.m_value.object->clear();
23346 case value_t::null:
23347 case value_t::discarded:
23366 m_data.m_type = value_t::array;
23367 m_data.m_value = value_t::array;
23368 assert_invariant();
23372 const auto old_capacity = m_data.m_value.array->capacity();
23373 m_data.m_value.array->push_back(std::move(val));
23374 set_parent(m_data.m_value.array->back(), old_capacity);
23382 push_back(std::move(val));
23399 m_data.m_type = value_t::array;
23400 m_data.m_value = value_t::array;
23401 assert_invariant();
23405 const auto old_capacity = m_data.m_value.array->capacity();
23406 m_data.m_value.array->push_back(val);
23407 set_parent(m_data.m_value.array->back(), old_capacity);
23431 m_data.m_type = value_t::object;
23432 m_data.m_value = value_t::object;
23433 assert_invariant();
23437 auto res = m_data.m_value.object->insert(val);
23438 set_parent(res.first->second);
23453 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
23455 basic_json&& key = init.begin()->moved_or_copied();
23456 push_back(
typename object_t::value_type(
23457 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23475 template<
class... Args>
23487 m_data.m_type = value_t::array;
23488 m_data.m_value = value_t::array;
23489 assert_invariant();
23493 const auto old_capacity = m_data.m_value.array->capacity();
23494 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
23495 return set_parent(m_data.m_value.array->back(), old_capacity);
23500 template<
class... Args>
23512 m_data.m_type = value_t::object;
23513 m_data.m_value = value_t::object;
23514 assert_invariant();
23518 auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
23519 set_parent(res.first->second);
23523 it.m_it.object_iterator = res.first;
23526 return {it, res.second};
23532 template<
typename... Args>
23538 auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator);
23539 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
23540 result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos;
23560 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23564 return insert_iterator(pos, val);
23574 return insert(pos, val);
23587 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23591 return insert_iterator(pos, cnt, val);
23610 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23616 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23621 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
23625 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
23641 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23645 return insert_iterator(pos, ilist.begin(), ilist.end());
23661 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23667 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
23670 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
23678 update(j.
begin(), j.
end(), merge_objects);
23688 m_data.m_type = value_t::object;
23689 m_data.m_value.object = create<object_t>();
23690 assert_invariant();
23701 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23707 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
23710 for (
auto it = first; it != last; ++it)
23712 if (merge_objects && it.value().is_object())
23714 auto it2 = m_data.m_value.object->find(it.key());
23715 if (it2 != m_data.m_value.object->end())
23717 it2->second.update(it.value(),
true);
23721 m_data.m_value.object->operator[](it.key()) = it.value();
23722#if JSON_DIAGNOSTICS
23723 m_data.m_value.object->operator[](it.key()).m_parent =
this;
23731 std::is_nothrow_move_constructible<value_t>::value&&
23732 std::is_nothrow_move_assignable<value_t>::value&&
23733 std::is_nothrow_move_constructible<json_value>::value&&
23734 std::is_nothrow_move_assignable<json_value>::value
23737 std::swap(m_data.m_type, other.m_data.m_type);
23738 std::swap(m_data.m_value, other.m_data.m_value);
23741 other.set_parents();
23742 assert_invariant();
23748 std::is_nothrow_move_constructible<value_t>::value&&
23749 std::is_nothrow_move_assignable<value_t>::value&&
23750 std::is_nothrow_move_constructible<json_value>::value&&
23751 std::is_nothrow_move_assignable<json_value>::value
23765 swap(*(m_data.m_value.array), other);
23781 swap(*(m_data.m_value.object), other);
23797 swap(*(m_data.m_value.string), other);
23813 swap(*(m_data.m_value.binary), other);
23823 void swap(
typename binary_t::container_type& other)
23829 swap(*(m_data.m_value.binary), other);
23833 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
23848#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23849 const auto lhs_type = lhs.type(); \
23850 const auto rhs_type = rhs.type(); \
23852 if (lhs_type == rhs_type) \
23854 switch (lhs_type) \
23856 case value_t::array: \
23857 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23859 case value_t::object: \
23860 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23862 case value_t::null: \
23863 return (null_result); \
23865 case value_t::string: \
23866 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23868 case value_t::boolean: \
23869 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23871 case value_t::number_integer: \
23872 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23874 case value_t::number_unsigned: \
23875 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23877 case value_t::number_float: \
23878 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23880 case value_t::binary: \
23881 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23883 case value_t::discarded: \
23885 return (unordered_result); \
23888 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23890 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23892 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23894 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23896 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23898 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23900 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23902 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23904 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23906 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23908 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23910 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23912 else if(compares_unordered(lhs, rhs))\
23914 return (unordered_result);\
23917 return (default_result);
23932#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23935 static_cast<void>(inverse);
23941 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
23943 return compares_unordered(*
this, rhs, inverse);
23947#if JSON_HAS_THREE_WAY_COMPARISON
23950 bool operator==(const_reference rhs)
const noexcept
23953#pragma GCC diagnostic push
23954#pragma GCC diagnostic ignored "-Wfloat-equal"
23956 const_reference lhs = *
this;
23959#pragma GCC diagnostic pop
23965 template<
typename ScalarType>
23966 requires std::is_scalar_v<ScalarType>
23967 bool operator==(ScalarType rhs)
const noexcept
23974 bool operator!=(const_reference rhs)
const noexcept
23976 if (compares_unordered(rhs,
true))
23985 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23987 const_reference lhs = *
this;
23991 std::partial_ordering::equivalent,
23992 std::partial_ordering::unordered,
23993 lhs_type <=> rhs_type)
23998 template<
typename ScalarType>
23999 requires std::is_scalar_v<ScalarType>
24000 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
24005#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24012 bool operator<=(const_reference rhs)
const noexcept
24014 if (compares_unordered(rhs,
true))
24018 return !(rhs < *
this);
24023 template<
typename ScalarType>
24024 requires std::is_scalar_v<ScalarType>
24025 bool operator<=(ScalarType rhs)
const noexcept
24033 bool operator>=(const_reference rhs)
const noexcept
24035 if (compares_unordered(rhs,
true))
24039 return !(*
this < rhs);
24044 template<
typename ScalarType>
24045 requires std::is_scalar_v<ScalarType>
24046 bool operator>=(ScalarType rhs)
const noexcept
24054 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
24057#pragma GCC diagnostic push
24058#pragma GCC diagnostic ignored "-Wfloat-equal"
24062#pragma GCC diagnostic pop
24068 template<
typename ScalarType,
typename std::enable_if<
24069 std::is_scalar<ScalarType>::value,
int>::type = 0>
24070 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
24077 template<
typename ScalarType,
typename std::enable_if<
24078 std::is_scalar<ScalarType>::value,
int>::type = 0>
24079 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
24086 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
24088 if (compares_unordered(lhs, rhs,
true))
24092 return !(lhs == rhs);
24097 template<
typename ScalarType,
typename std::enable_if<
24098 std::is_scalar<ScalarType>::value,
int>::type = 0>
24099 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
24106 template<
typename ScalarType,
typename std::enable_if<
24107 std::is_scalar<ScalarType>::value,
int>::type = 0>
24108 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
24115 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
24125 template<
typename ScalarType,
typename std::enable_if<
24126 std::is_scalar<ScalarType>::value,
int>::type = 0>
24127 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
24134 template<
typename ScalarType,
typename std::enable_if<
24135 std::is_scalar<ScalarType>::value,
int>::type = 0>
24136 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
24143 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
24145 if (compares_unordered(lhs, rhs,
true))
24149 return !(rhs < lhs);
24154 template<
typename ScalarType,
typename std::enable_if<
24155 std::is_scalar<ScalarType>::value,
int>::type = 0>
24156 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
24163 template<
typename ScalarType,
typename std::enable_if<
24164 std::is_scalar<ScalarType>::value,
int>::type = 0>
24165 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
24172 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
24175 if (compares_unordered(lhs, rhs))
24179 return !(lhs <= rhs);
24184 template<
typename ScalarType,
typename std::enable_if<
24185 std::is_scalar<ScalarType>::value,
int>::type = 0>
24186 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
24193 template<
typename ScalarType,
typename std::enable_if<
24194 std::is_scalar<ScalarType>::value,
int>::type = 0>
24195 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
24202 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
24204 if (compares_unordered(lhs, rhs,
true))
24208 return !(lhs < rhs);
24213 template<
typename ScalarType,
typename std::enable_if<
24214 std::is_scalar<ScalarType>::value,
int>::type = 0>
24215 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
24222 template<
typename ScalarType,
typename std::enable_if<
24223 std::is_scalar<ScalarType>::value,
int>::type = 0>
24224 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
24230#undef JSON_IMPLEMENT_OPERATOR
24246 const bool pretty_print = o.width() > 0;
24247 const auto indentation = pretty_print ? o.width() : 0;
24254 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24265 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
24281 template<
typename InputType>
24284 parser_callback_t cb =
nullptr,
24285 const bool allow_exceptions =
true,
24286 const bool ignore_comments =
false,
24287 const bool ignore_trailing_commas =
false)
24290 parser(
detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24296 template<
typename IteratorType>
24300 parser_callback_t cb =
nullptr,
24301 const bool allow_exceptions =
true,
24302 const bool ignore_comments =
false,
24303 const bool ignore_trailing_commas =
false)
24306 parser(
detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24313 parser_callback_t cb =
nullptr,
24314 const bool allow_exceptions =
true,
24315 const bool ignore_comments =
false,
24316 const bool ignore_trailing_commas =
false)
24319 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24325 template<
typename InputType>
24326 static bool accept(InputType&& i,
24327 const bool ignore_comments =
false,
24328 const bool ignore_trailing_commas =
false)
24330 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24335 template<
typename IteratorType>
24336 static bool accept(IteratorType first, IteratorType last,
24337 const bool ignore_comments =
false,
24338 const bool ignore_trailing_commas =
false)
24340 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24346 const bool ignore_comments =
false,
24347 const bool ignore_trailing_commas =
false)
24349 return parser(i.get(),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24354 template <
typename InputType,
typename SAX>
24356 static
bool sax_parse(InputType&& i, SAX* sax,
24358 const
bool strict = true,
24359 const
bool ignore_comments = false,
24360 const
bool ignore_trailing_commas = false)
24362#if defined(__clang__)
24363#pragma clang diagnostic push
24364#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
24365#elif defined(__GNUC__)
24366#pragma GCC diagnostic push
24367#pragma GCC diagnostic ignored "-Wnonnull-compare"
24369 if (sax ==
nullptr)
24371 JSON_THROW(other_error::create(502,
"SAX handler must not be null",
nullptr));
24373#if defined(__clang__)
24374#pragma clang diagnostic pop
24375#elif defined(__GNUC__)
24376#pragma GCC diagnostic pop
24379 return format == input_format_t::json
24380 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24386 template<
class IteratorType,
class SAX>
24388 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24390 const
bool strict = true,
24391 const
bool ignore_comments = false,
24392 const
bool ignore_trailing_commas = false)
24394#if defined(__clang__)
24395#pragma clang diagnostic push
24396#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
24397#elif defined(__GNUC__)
24398#pragma GCC diagnostic push
24399#pragma GCC diagnostic ignored "-Wnonnull-compare"
24401 if (sax ==
nullptr)
24403 JSON_THROW(other_error::create(502,
"SAX handler must not be null",
nullptr));
24405#if defined(__clang__)
24406#pragma clang diagnostic pop
24407#elif defined(__GNUC__)
24408#pragma GCC diagnostic pop
24411 return format == input_format_t::json
24412 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24421 template <
typename SAX>
24424 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
24426 const
bool strict = true,
24427 const
bool ignore_comments = false,
24428 const
bool ignore_trailing_commas = false)
24430#if defined(__clang__)
24431#pragma clang diagnostic push
24432#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
24433#elif defined(__GNUC__)
24434#pragma GCC diagnostic push
24435#pragma GCC diagnostic ignored "-Wnonnull-compare"
24437 if (sax ==
nullptr)
24439 JSON_THROW(other_error::create(502,
"SAX handler must not be null",
nullptr));
24441#if defined(__clang__)
24442#pragma clang diagnostic pop
24443#elif defined(__GNUC__)
24444#pragma GCC diagnostic pop
24447 return format == input_format_t::json
24449 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24463 return operator>>(i, j);
24485 switch (m_data.m_type)
24487 case value_t::null:
24489 case value_t::object:
24491 case value_t::array:
24493 case value_t::string:
24495 case value_t::boolean:
24497 case value_t::binary:
24499 case value_t::discarded:
24500 return "discarded";
24501 case value_t::number_integer:
24502 case value_t::number_unsigned:
24503 case value_t::number_float:
24518 value_t m_type = value_t::null;
24521 json_value m_value = {};
24524 : m_type(v), m_value(v)
24531 m_value.array = create<array_t>(cnt, val);
24535 data(data&&) noexcept = default;
24536 data(const data&) noexcept = delete;
24537 data& operator=(data&&) noexcept = delete;
24538 data& operator=(const data&) noexcept = delete;
24542 m_value.destroy(m_type);
24548#if JSON_DIAGNOSTICS
24553#if JSON_DIAGNOSTIC_POSITIONS
24555 std::size_t start_position = std::string::npos;
24557 std::size_t end_position = std::string::npos;
24559 constexpr std::size_t start_pos() const noexcept
24561 return start_position;
24564 constexpr std::size_t end_pos() const noexcept
24566 return end_position;
24582 std::vector<std::uint8_t> result;
24583 to_cbor(j, result);
24605 std::vector<std::uint8_t> result;
24606 to_msgpack(j, result);
24627 const bool use_size =
false,
24628 const bool use_type =
false)
24630 std::vector<std::uint8_t> result;
24631 to_ubjson(j, result, use_size, use_type);
24638 const bool use_size =
false,
const bool use_type =
false)
24646 const bool use_size =
false,
const bool use_type =
false)
24654 const bool use_size =
false,
24655 const bool use_type =
false,
24658 std::vector<std::uint8_t> result;
24659 to_bjdata(j, result, use_size, use_type, version);
24666 const bool use_size =
false,
const bool use_type =
false,
24675 const bool use_size =
false,
const bool use_type =
false,
24685 std::vector<std::uint8_t> result;
24686 to_bson(j, result);
24706 template<
typename InputType>
24709 const bool strict =
true,
24710 const bool allow_exceptions =
true,
24717 return res ? result :
basic_json(value_t::discarded);
24722 template<
typename IteratorType>
24725 const bool strict =
true,
24726 const bool allow_exceptions =
true,
24733 return res ? result :
basic_json(value_t::discarded);
24736 template<
typename T>
24740 const
bool strict = true,
24741 const
bool allow_exceptions = true,
24744 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24750 const
bool strict = true,
24751 const
bool allow_exceptions = true,
24759 return res ? result :
basic_json(value_t::discarded);
24764 template<
typename InputType>
24767 const bool strict =
true,
24768 const bool allow_exceptions =
true)
24774 return res ? result :
basic_json(value_t::discarded);
24779 template<
typename IteratorType>
24782 const bool strict =
true,
24783 const bool allow_exceptions =
true)
24789 return res ? result :
basic_json(value_t::discarded);
24792 template<
typename T>
24796 const
bool strict = true,
24797 const
bool allow_exceptions = true)
24799 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24805 const
bool strict = true,
24806 const
bool allow_exceptions = true)
24813 return res ? result :
basic_json(value_t::discarded);
24818 template<
typename InputType>
24821 const bool strict =
true,
24822 const bool allow_exceptions =
true)
24828 return res ? result :
basic_json(value_t::discarded);
24833 template<
typename IteratorType>
24836 const bool strict =
true,
24837 const bool allow_exceptions =
true)
24843 return res ? result :
basic_json(value_t::discarded);
24846 template<
typename T>
24850 const
bool strict = true,
24851 const
bool allow_exceptions = true)
24853 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24859 const
bool strict = true,
24860 const
bool allow_exceptions = true)
24867 return res ? result :
basic_json(value_t::discarded);
24872 template<
typename InputType>
24875 const bool strict =
true,
24876 const bool allow_exceptions =
true)
24882 return res ? result :
basic_json(value_t::discarded);
24887 template<
typename IteratorType>
24890 const bool strict =
true,
24891 const bool allow_exceptions =
true)
24897 return res ? result :
basic_json(value_t::discarded);
24902 template<
typename InputType>
24905 const bool strict =
true,
24906 const bool allow_exceptions =
true)
24912 return res ? result :
basic_json(value_t::discarded);
24917 template<
typename IteratorType>
24920 const bool strict =
true,
24921 const bool allow_exceptions =
true)
24927 return res ? result :
basic_json(value_t::discarded);
24930 template<
typename T>
24934 const
bool strict = true,
24935 const
bool allow_exceptions = true)
24937 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24943 const
bool strict = true,
24944 const
bool allow_exceptions = true)
24951 return res ? result :
basic_json(value_t::discarded);
24969 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24973 return ptr.get_unchecked(
this);
24983 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24987 return ptr.get_unchecked(
this);
24997 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
25001 return ptr.get_checked(
this);
25011 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
25015 return ptr.get_checked(
this);
25049 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
25051 const auto get_op = [](
const string_t& op)
25055 return patch_operations::add;
25057 if (op ==
"remove")
25059 return patch_operations::remove;
25061 if (op ==
"replace")
25063 return patch_operations::replace;
25067 return patch_operations::move;
25071 return patch_operations::copy;
25075 return patch_operations::test;
25078 return patch_operations::invalid;
25093 if (top_pointer != ptr)
25095 result.
at(top_pointer);
25099 const auto last_path = ptr.
back();
25104 switch (parent.
m_data.m_type)
25106 case value_t::null:
25107 case value_t::object:
25110 parent[last_path] = val;
25114 case value_t::array:
25116 if (last_path ==
"-")
25123 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
25127 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"), &parent));
25137 case value_t::string:
25138 case value_t::boolean:
25139 case value_t::number_integer:
25140 case value_t::number_unsigned:
25141 case value_t::number_float:
25142 case value_t::binary:
25143 case value_t::discarded:
25150 const auto operation_remove = [
this, & result](
json_pointer & ptr)
25153 const auto last_path = ptr.
back();
25161 auto it = parent.
find(last_path);
25174 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
25181 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
25185 for (
const auto& val : json_patch)
25188 const auto get_value = [&val](
const string_t& op,
25193 auto it = val.
m_data.m_value.object->find(member);
25196 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
25209 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
25219 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
25223 const auto op = get_value(
"op",
"op",
true).template get<string_t>();
25224 const auto path = get_value(op,
"path",
true).template get<string_t>();
25227 switch (get_op(op))
25229 case patch_operations::add:
25231 operation_add(ptr, get_value(
"add",
"value",
false));
25235 case patch_operations::remove:
25237 operation_remove(ptr);
25241 case patch_operations::replace:
25244 result.
at(ptr) = get_value(
"replace",
"value",
false);
25248 case patch_operations::move:
25250 const auto from_path = get_value(
"move",
"from",
true).template get<string_t>();
25260 operation_remove(from_ptr);
25261 operation_add(ptr, v);
25265 case patch_operations::copy:
25267 const auto from_path = get_value(
"copy",
"from",
true).template get<string_t>();
25276 operation_add(ptr, v);
25280 case patch_operations::test:
25282 bool success =
false;
25287 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25303 case patch_operations::invalid:
25333 if (source == target)
25338 if (source.
type() != target.
type())
25343 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25348 switch (source.
type())
25350 case value_t::array:
25354 while (i < source.
size() && i < target.
size())
25357 auto temp_diff = diff(source[i], target[i], detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i)));
25358 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25367 while (i < source.
size())
25371 result.
insert(result.
begin() + end_index, object(
25374 {
"path", detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i))}
25380 while (i < target.
size())
25385 {
"path", detail::concat<string_t>(path,
"/-")},
25386 {
"value", target[i]}
25394 case value_t::object:
25397 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25400 const auto path_key = detail::concat<string_t>(path,
'/',
detail::escape(it.key()));
25402 if (target.
find(it.key()) != target.
end())
25405 auto temp_diff = diff(it.value(), target[it.key()], path_key);
25406 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25413 {
"op",
"remove"}, {
"path", path_key}
25419 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25421 if (source.
find(it.key()) == source.
end())
25424 const auto path_key = detail::concat<string_t>(path,
'/',
detail::escape(it.key()));
25427 {
"op",
"add"}, {
"path", path_key},
25428 {
"value", it.value()}
25436 case value_t::null:
25437 case value_t::string:
25438 case value_t::boolean:
25439 case value_t::number_integer:
25440 case value_t::number_unsigned:
25441 case value_t::number_float:
25442 case value_t::binary:
25443 case value_t::discarded:
25449 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25476 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25478 if (it.value().is_null())
25484 operator[](it.key()).merge_patch(it.value());
25490 *
this = apply_patch;
25507inline namespace json_literals
25513#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25514 inline nlohmann::json
operator""_json(
const char* s, std::size_t n)
25517 inline nlohmann::json
operator"" _json(
const char* s, std::size_t n)
25520 return nlohmann::json::parse(s, s + n);
25523#if defined(__cpp_char8_t)
25525inline nlohmann::
json operator""_json(const
char8_t* s,
std::
size_t n)
25527 return nlohmann::json::parse(
reinterpret_cast<const char*
>(s),
25528 reinterpret_cast<const char*
>(s) + n);
25535#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25545#if defined(__cpp_char8_t)
25568 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
25570 return nlohmann::detail::hash(j);
25576struct less< ::nlohmann::detail::value_t>
25583 ::nlohmann::detail::value_t rhs)
const noexcept
25585#if JSON_HAS_THREE_WAY_COMPARISON
25586 return std::is_lt(lhs <=> rhs);
25588 return ::nlohmann::detail::operator<(lhs, rhs);
25594#ifndef JSON_HAS_CPP_20
25599inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
25600 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
25601 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
25610#if JSON_USE_GLOBAL_UDLS
25611 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25612 using nlohmann::literals::json_literals::operator
""_json;
25613 using nlohmann::literals::json_literals::operator
""_json_pointer;
25616 using nlohmann::literals::json_literals::operator
"" _json;
25617 using nlohmann::literals::json_literals::operator
"" _json_pointer;
25633#if defined(__clang__)
25634 #pragma clang diagnostic pop
25639#undef JSON_INTERNAL_CATCH
25641#undef JSON_PRIVATE_UNLESS_TESTED
25642#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25643#undef NLOHMANN_BASIC_JSON_TPL
25644#undef JSON_EXPLICIT
25645#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
25646#undef JSON_INLINE_VARIABLE
25647#undef JSON_NO_UNIQUE_ADDRESS
25648#undef JSON_DISABLE_ENUM_SERIALIZATION
25649#undef JSON_USE_GLOBAL_UDLS
25651#ifndef JSON_TEST_KEEP_MACROS
25654 #undef JSON_HAS_CPP_11
25655 #undef JSON_HAS_CPP_14
25656 #undef JSON_HAS_CPP_17
25657 #undef JSON_HAS_CPP_20
25658 #undef JSON_HAS_CPP_23
25659 #undef JSON_HAS_CPP_26
25660 #undef JSON_HAS_FILESYSTEM
25661 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
25662 #undef JSON_HAS_THREE_WAY_COMPARISON
25663 #undef JSON_HAS_RANGES
25664 #undef JSON_HAS_STATIC_RTTI
25665 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
25679#undef JSON_HEDLEY_ALWAYS_INLINE
25680#undef JSON_HEDLEY_ARM_VERSION
25681#undef JSON_HEDLEY_ARM_VERSION_CHECK
25682#undef JSON_HEDLEY_ARRAY_PARAM
25683#undef JSON_HEDLEY_ASSUME
25684#undef JSON_HEDLEY_BEGIN_C_DECLS
25685#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25686#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25687#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25688#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25689#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25690#undef JSON_HEDLEY_CLANG_HAS_FEATURE
25691#undef JSON_HEDLEY_CLANG_HAS_WARNING
25692#undef JSON_HEDLEY_COMPCERT_VERSION
25693#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25694#undef JSON_HEDLEY_CONCAT
25695#undef JSON_HEDLEY_CONCAT3
25696#undef JSON_HEDLEY_CONCAT3_EX
25697#undef JSON_HEDLEY_CONCAT_EX
25698#undef JSON_HEDLEY_CONST
25699#undef JSON_HEDLEY_CONSTEXPR
25700#undef JSON_HEDLEY_CONST_CAST
25701#undef JSON_HEDLEY_CPP_CAST
25702#undef JSON_HEDLEY_CRAY_VERSION
25703#undef JSON_HEDLEY_CRAY_VERSION_CHECK
25704#undef JSON_HEDLEY_C_DECL
25705#undef JSON_HEDLEY_DEPRECATED
25706#undef JSON_HEDLEY_DEPRECATED_FOR
25707#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25708#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25709#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25710#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25711#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25712#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
25713#undef JSON_HEDLEY_DIAGNOSTIC_POP
25714#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25715#undef JSON_HEDLEY_DMC_VERSION
25716#undef JSON_HEDLEY_DMC_VERSION_CHECK
25717#undef JSON_HEDLEY_EMPTY_BASES
25718#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25719#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25720#undef JSON_HEDLEY_END_C_DECLS
25721#undef JSON_HEDLEY_FLAGS
25722#undef JSON_HEDLEY_FLAGS_CAST
25723#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25724#undef JSON_HEDLEY_GCC_HAS_BUILTIN
25725#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25726#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25727#undef JSON_HEDLEY_GCC_HAS_EXTENSION
25728#undef JSON_HEDLEY_GCC_HAS_FEATURE
25729#undef JSON_HEDLEY_GCC_HAS_WARNING
25730#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25731#undef JSON_HEDLEY_GCC_VERSION
25732#undef JSON_HEDLEY_GCC_VERSION_CHECK
25733#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25734#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25735#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25736#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25737#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25738#undef JSON_HEDLEY_GNUC_HAS_FEATURE
25739#undef JSON_HEDLEY_GNUC_HAS_WARNING
25740#undef JSON_HEDLEY_GNUC_VERSION
25741#undef JSON_HEDLEY_GNUC_VERSION_CHECK
25742#undef JSON_HEDLEY_HAS_ATTRIBUTE
25743#undef JSON_HEDLEY_HAS_BUILTIN
25744#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25745#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25746#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25747#undef JSON_HEDLEY_HAS_EXTENSION
25748#undef JSON_HEDLEY_HAS_FEATURE
25749#undef JSON_HEDLEY_HAS_WARNING
25750#undef JSON_HEDLEY_IAR_VERSION
25751#undef JSON_HEDLEY_IAR_VERSION_CHECK
25752#undef JSON_HEDLEY_IBM_VERSION
25753#undef JSON_HEDLEY_IBM_VERSION_CHECK
25754#undef JSON_HEDLEY_IMPORT
25755#undef JSON_HEDLEY_INLINE
25756#undef JSON_HEDLEY_INTEL_CL_VERSION
25757#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25758#undef JSON_HEDLEY_INTEL_VERSION
25759#undef JSON_HEDLEY_INTEL_VERSION_CHECK
25760#undef JSON_HEDLEY_IS_CONSTANT
25761#undef JSON_HEDLEY_IS_CONSTEXPR_
25762#undef JSON_HEDLEY_LIKELY
25763#undef JSON_HEDLEY_MALLOC
25764#undef JSON_HEDLEY_MCST_LCC_VERSION
25765#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
25766#undef JSON_HEDLEY_MESSAGE
25767#undef JSON_HEDLEY_MSVC_VERSION
25768#undef JSON_HEDLEY_MSVC_VERSION_CHECK
25769#undef JSON_HEDLEY_NEVER_INLINE
25770#undef JSON_HEDLEY_NON_NULL
25771#undef JSON_HEDLEY_NO_ESCAPE
25772#undef JSON_HEDLEY_NO_RETURN
25773#undef JSON_HEDLEY_NO_THROW
25774#undef JSON_HEDLEY_NULL
25775#undef JSON_HEDLEY_PELLES_VERSION
25776#undef JSON_HEDLEY_PELLES_VERSION_CHECK
25777#undef JSON_HEDLEY_PGI_VERSION
25778#undef JSON_HEDLEY_PGI_VERSION_CHECK
25779#undef JSON_HEDLEY_PREDICT
25780#undef JSON_HEDLEY_PRINTF_FORMAT
25781#undef JSON_HEDLEY_PRIVATE
25782#undef JSON_HEDLEY_PUBLIC
25783#undef JSON_HEDLEY_PURE
25784#undef JSON_HEDLEY_REINTERPRET_CAST
25785#undef JSON_HEDLEY_REQUIRE
25786#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25787#undef JSON_HEDLEY_REQUIRE_MSG
25788#undef JSON_HEDLEY_RESTRICT
25789#undef JSON_HEDLEY_RETURNS_NON_NULL
25790#undef JSON_HEDLEY_SENTINEL
25791#undef JSON_HEDLEY_STATIC_ASSERT
25792#undef JSON_HEDLEY_STATIC_CAST
25793#undef JSON_HEDLEY_STRINGIFY
25794#undef JSON_HEDLEY_STRINGIFY_EX
25795#undef JSON_HEDLEY_SUNPRO_VERSION
25796#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25797#undef JSON_HEDLEY_TINYC_VERSION
25798#undef JSON_HEDLEY_TINYC_VERSION_CHECK
25799#undef JSON_HEDLEY_TI_ARMCL_VERSION
25800#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25801#undef JSON_HEDLEY_TI_CL2000_VERSION
25802#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25803#undef JSON_HEDLEY_TI_CL430_VERSION
25804#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25805#undef JSON_HEDLEY_TI_CL6X_VERSION
25806#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25807#undef JSON_HEDLEY_TI_CL7X_VERSION
25808#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25809#undef JSON_HEDLEY_TI_CLPRU_VERSION
25810#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25811#undef JSON_HEDLEY_TI_VERSION
25812#undef JSON_HEDLEY_TI_VERSION_CHECK
25813#undef JSON_HEDLEY_UNAVAILABLE
25814#undef JSON_HEDLEY_UNLIKELY
25815#undef JSON_HEDLEY_UNPREDICTABLE
25816#undef JSON_HEDLEY_UNREACHABLE
25817#undef JSON_HEDLEY_UNREACHABLE_RETURN
25818#undef JSON_HEDLEY_VERSION
25819#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25820#undef JSON_HEDLEY_VERSION_DECODE_MINOR
25821#undef JSON_HEDLEY_VERSION_DECODE_REVISION
25822#undef JSON_HEDLEY_VERSION_ENCODE
25823#undef JSON_HEDLEY_WARNING
25824#undef JSON_HEDLEY_WARN_UNUSED_RESULT
25825#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25826#undef JSON_HEDLEY_FALL_THROUGH
std::ostream & operator<<(std::ostream &out, smf::MidiFile &aMidiFile)
Definition MidiFile.cpp:3501
namespace for Niels Lohmann
Definition json.hpp:20337
constexpr bool is_string() const noexcept
return whether value is a string
Definition json.hpp:21636
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
Definition json.hpp:21729
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition json.hpp:22871
reference operator[](KeyType &&key)
access specified object element
Definition json.hpp:22437
json_value(object_t &&value)
constructor for rvalue objects
Definition json.hpp:20775
size_type size() const noexcept
returns the number of elements
Definition json.hpp:23212
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
Definition json.hpp:24724
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
Definition json.hpp:20787
number_unsigned_t number_unsigned
number (unsigned integer)
Definition json.hpp:20679
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)
Definition json.hpp:22009
::nlohmann::detail::iteration_proxy< Iterator > iteration_proxy
Definition json.hpp:20389
const_iterator end() const noexcept
returns an iterator to one past the last element
Definition json.hpp:23069
reference back()
access the last element
Definition json.hpp:22675
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
Definition json.hpp:21076
number_float_t number_float
number (floating-point)
Definition json.hpp:20681
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:23085
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition json.hpp:25316
json_value(const array_t &value)
constructor for arrays
Definition json.hpp:20778
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
Definition json.hpp:21693
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition json.hpp:24483
const_reference front() const
access the first element
Definition json.hpp:22668
constexpr bool is_array() const noexcept
return whether value is an array
Definition json.hpp:21629
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
Definition json.hpp:21753
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
Definition json.hpp:23730
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22618
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22988
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
Definition json.hpp:21735
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
Definition json.hpp:20471
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition json.hpp:20415
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition json.hpp:21601
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition json.hpp:20475
data(size_type cnt, const basic_json &val)
Definition json.hpp:24528
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
Definition json.hpp:24919
::nlohmann::detail::json_base_class< CustomBaseClass > json_base_class_t
Definition json.hpp:20363
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
Definition json.hpp:21961
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24964
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition json.hpp:20466
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
Definition json.hpp:20619
std::size_t size_type
a type to represent container sizes
Definition json.hpp:20458
constexpr bool is_structured() const noexcept
return whether type is structured
Definition json.hpp:21573
json_value(boolean_t v) noexcept
constructor for booleans
Definition json.hpp:20686
const_reference operator[](KeyType &&key) const
access specified object element
Definition json.hpp:22461
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
Definition json.hpp:21670
void swap(binary_t &other)
exchanges the values
Definition json.hpp:23807
ReferenceType get_ref()
get a reference value (implicit)
Definition json.hpp:22099
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition json.hpp:23251
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:23676
::nlohmann::detail::iter_impl< BasicJsonType > iter_impl
Definition json.hpp:20387
ReferenceType get_ref() const
get a reference value (implicit)
Definition json.hpp:22110
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition json.hpp:21650
reference operator+=(initializer_list_t init)
add an object to an object
Definition json.hpp:23467
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
Definition json.hpp:20393
void push_back(basic_json &&val)
add an object to an array
Definition json.hpp:23355
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition json.hpp:22406
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:23157
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
Definition json.hpp:20688
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
Definition json.hpp:21788
::nlohmann::detail::json_reverse_iterator< Base > json_reverse_iterator
Definition json.hpp:20390
basic_json & operator=(basic_json other) noexcept(//NOLINT(cppcoreguidelines-c-copy-assignment-signature, misc-unconventional-assign-operator)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
Definition json.hpp:21490
const_reference back() const
access the last element
Definition json.hpp:22684
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition json.hpp:22766
reference operator+=(const basic_json &val)
add an object to an array
Definition json.hpp:23412
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
Definition json.hpp:23747
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
Definition json.hpp:24820
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
Definition json.hpp:21711
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)
Definition json.hpp:21218
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition json.hpp:23579
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
Definition json.hpp:21681
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false, const bool ignore_trailing_commas=false)
Definition json.hpp:20370
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
Definition json.hpp:24904
static allocator_type get_allocator()
returns the allocator associated with the container
Definition json.hpp:20481
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition json.hpp:20606
reference at(KeyType &&key)
access specified object element with bounds checking
Definition json.hpp:22269
iterator end() noexcept
returns an iterator to one past the last element
Definition json.hpp:23060
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition json.hpp:21608
json_value(array_t &&value)
constructor for rvalue arrays
Definition json.hpp:20781
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:23683
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition json.hpp:24683
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:23092
data m_data
Definition json.hpp:24546
void push_back(initializer_list_t init)
add an object to an object
Definition json.hpp:23451
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition json.hpp:21043
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition json.hpp:21259
ValueType & get_to(ValueType &v) const
Definition json.hpp:22076
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24619
iterator begin() noexcept
returns an iterator to the first element
Definition json.hpp:23035
array_t * array
array (stored with pointer to save storage)
Definition json.hpp:20669
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition json.hpp:20923
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition json.hpp:22516
void destroy(value_t t)
Definition json.hpp:20795
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
Definition json.hpp:21871
json_value(string_t &&value)
constructor for rvalue strings
Definition json.hpp:20769
const_iterator cend() const noexcept
returns an iterator to one past the last element
Definition json.hpp:23076
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
Definition json.hpp:21771
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
Definition json.hpp:24874
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:25006
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition json.hpp:21229
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition json.hpp:21064
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
Definition json.hpp:24708
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
Definition json.hpp:21747
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
Definition json.hpp:21723
basic_json flatten() const
return flattened JSON value
Definition json.hpp:25020
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
Definition json.hpp:21699
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
Definition json.hpp:24835
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
Definition json.hpp:20690
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition json.hpp:22882
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)
Definition json.hpp:24356
::nlohmann::detail::primitive_iterator_t primitive_iterator_t
Definition json.hpp:20383
json_value(const string_t &value)
constructor for strings
Definition json.hpp:20766
const binary_t & get_binary() const
get a binary value
Definition json.hpp:22181
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition json.hpp:23599
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
Definition json.hpp:25045
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22569
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:24978
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
Definition json.hpp:20692
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition json.hpp:20582
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition json.hpp:23005
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:24589
::nlohmann::detail::binary_reader< basic_json, InputType > binary_reader
Definition json.hpp:20396
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition json.hpp:24699
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition json.hpp:22918
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition json.hpp:21207
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
Definition json.hpp:21938
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
Definition json.hpp:24653
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition json.hpp:22307
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition json.hpp:20489
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition json.hpp:21266
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition json.hpp:22932
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition json.hpp:24580
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition json.hpp:22696
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition json.hpp:23552
NumberFloatType number_float_t
a type for a number (floating-point)
Definition json.hpp:20602
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:22491
string_t * string
string (stored with pointer to save storage)
Definition json.hpp:20671
AllocatorType< basic_json > allocator_type
the allocator type
Definition json.hpp:20461
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition json.hpp:20464
reference set_parent(reference j, std::size_t old_capacity=detail::unknown_size())
Definition json.hpp:20994
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
Definition json.hpp:21537
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition json.hpp:25468
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition json.hpp:22063
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
Definition json.hpp:24665
reference operator[](T *key)
Definition json.hpp:22422
reference at(size_type idx)
access specified array element with bounds checking
Definition json.hpp:22203
iterator find(KeyType &&key)
find an element in a JSON object
Definition json.hpp:22948
binary_t * binary
binary (stored with pointer to save storage)
Definition json.hpp:20673
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition json.hpp:21615
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition json.hpp:23099
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
Definition json.hpp:24626
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24992
BooleanType boolean_t
a type for a boolean
Definition json.hpp:20590
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
Definition json.hpp:25326
::nlohmann::detail::internal_iterator< BasicJsonType > internal_iterator
Definition json.hpp:20385
void set_parents()
Definition json.hpp:20944
std::conditional< detail::is_c_string_uncvref< ValueType >::value, string_t, typename std::decay< ValueType >::type > value_return_type
Definition json.hpp:22482
size_type erase_internal(KeyType &&key)
Definition json.hpp:22837
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition json.hpp:20569
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:23443
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition json.hpp:23051
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
Definition json.hpp:21759
reference operator[](typename object_t::key_type key)
access specified object element
Definition json.hpp:22384
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
Definition json.hpp:21705
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21821
~basic_json() noexcept
destructor
Definition json.hpp:21519
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
Definition json.hpp:20793
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition json.hpp:23120
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
Definition json.hpp:21148
json_value(const object_t &value)
constructor for objects
Definition json.hpp:20772
void swap(typename binary_t::container_type &other)
exchanges the values
Definition json.hpp:23823
binary_t & get_binary()
get a binary value
Definition json.hpp:22169
const_iterator begin() const noexcept
returns an iterator to the first element
Definition json.hpp:23044
constexpr bool is_number() const noexcept
return whether value is a number
Definition json.hpp:21594
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
Definition json.hpp:21741
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition json.hpp:23650
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
Definition json.hpp:24766
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition json.hpp:22050
const_reference operator[](T *key) const
Definition json.hpp:22428
data(const value_t v)
Definition json.hpp:24523
reference operator[](size_type idx)
access specified array element
Definition json.hpp:22325
basic_json(const JsonRef &ref)
Definition json.hpp:21387
JSONSerializer< T, SFINAE > json_serializer
Definition json.hpp:20407
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
Definition json.hpp:24645
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition json.hpp:22087
NumberIntegerType number_integer_t
a type for a number (integer)
Definition json.hpp:20594
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21810
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition json.hpp:22287
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
Definition json.hpp:21765
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition json.hpp:21643
void swap(object_t &other)
exchanges the values
Definition json.hpp:23775
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
Definition json.hpp:20981
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition json.hpp:21974
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition json.hpp:25029
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition json.hpp:23630
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
Definition json.hpp:24674
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)
Definition json.hpp:21240
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:23150
bool empty() const noexcept
checks whether the container is empty.
Definition json.hpp:23173
void swap(array_t &other)
exchanges the values
Definition json.hpp:23759
void erase(const size_type idx)
remove element from a JSON array given an index
Definition json.hpp:22889
reference operator+=(basic_json &&val)
add an object to an array
Definition json.hpp:23380
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition json.hpp:23012
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
Definition json.hpp:21913
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition json.hpp:21559
reference emplace_back(Args &&... args)
add an object to an array
Definition json.hpp:23476
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22592
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition json.hpp:21251
StringType string_t
a type for a string
Definition json.hpp:20586
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition json.hpp:20578
void push_back(const basic_json &val)
add an object to an array
Definition json.hpp:23388
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:22542
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition json.hpp:22249
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
Definition json.hpp:24889
json_value m_value
the value of the current element
Definition json.hpp:24521
number_integer_t number_integer
number (integer)
Definition json.hpp:20677
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition json.hpp:23113
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition json.hpp:21587
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22978
reference front()
access the first element
Definition json.hpp:22661
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition json.hpp:21566
constexpr bool is_null() const noexcept
return whether value is null
Definition json.hpp:21580
void clear() noexcept
clears the contents
Definition json.hpp:23294
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
Definition json.hpp:21687
json_value(value_t t)
constructor for empty values of a given type
Definition json.hpp:20694
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
Definition json.hpp:24637
json_value()=default
default constructor (for null values)
basic_json(basic_json &&other) noexcept
move constructor
Definition json.hpp:21464
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition json.hpp:20469
basic_json(const value_t v)
create an empty value with a given type
Definition json.hpp:21056
const_reference operator[](size_type idx) const
access specified array element
Definition json.hpp:22371
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition json.hpp:20456
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition json.hpp:23572
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
Definition json.hpp:23106
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition json.hpp:20598
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition json.hpp:24468
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24603
void swap(string_t &other)
exchanges the values
Definition json.hpp:23791
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition json.hpp:21090
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
Definition json.hpp:20362
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
Definition json.hpp:21717
::nlohmann::detail::binary_writer< basic_json, CharType > binary_writer
Definition json.hpp:20397
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition json.hpp:20473
json_value(const binary_t &value)
constructor for binary arrays (internal type)
Definition json.hpp:20790
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition json.hpp:22226
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition json.hpp:20610
basic_json(const basic_json &other)
copy constructor
Definition json.hpp:21391
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:23420
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition json.hpp:23501
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:24596
constexpr bool is_object() const noexcept
return whether value is an object
Definition json.hpp:21622
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24612
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
Definition json.hpp:24781
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition json.hpp:23533
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition json.hpp:21278
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition json.hpp:22996
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition json.hpp:24692
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition json.hpp:22964
boolean_t boolean
boolean
Definition json.hpp:20675
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
Definition json.hpp:20784
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition json.hpp:20405
an internal type for a backed binary type
Definition json.hpp:6363
bool operator!=(const byte_container_with_subtype &rhs) const
Definition json.hpp:6403
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition json.hpp:6369
std::uint64_t subtype_type
Definition json.hpp:6366
bool operator==(const byte_container_with_subtype &rhs) const
Definition json.hpp:6397
BinaryType container_type
Definition json.hpp:6365
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:6391
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:6379
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition json.hpp:6418
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition json.hpp:6384
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition json.hpp:6425
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition json.hpp:6374
subtype_type m_subtype
Definition json.hpp:6439
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition json.hpp:6410
bool m_has_subtype
Definition json.hpp:6440
void clear_subtype() noexcept
clears the binary subtype
Definition json.hpp:6432
deserialization of CBOR, MessagePack, and UBJSON values
Definition json.hpp:10020
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition json.hpp:12857
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result, bool inside_ndarray=false)
determine the type and size for a container
Definition json.hpp:12204
binary_reader(const binary_reader &)=delete
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
Definition json.hpp:10348
typename BasicJsonType::string_t string_t
Definition json.hpp:10024
bool get_cbor_negative_integer()
Definition json.hpp:10380
std::pair< char_int_type, string_t > bjd_type
Definition json.hpp:13022
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
Definition json.hpp:10310
typename InputAdapterType::char_type char_type
Definition json.hpp:10027
bool parse_msgpack_internal()
Definition json.hpp:11160
std::string get_token_string() const
Definition json.hpp:12927
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:10022
bool get_msgpack_string(string_t &result)
reads a MessagePack string
Definition json.hpp:11541
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition json.hpp:12940
InputAdapterType ia
input adapter
Definition json.hpp:12980
bool get_ubjson_high_precision_number()
Definition json.hpp:12662
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
Definition json.hpp:12890
binary_reader(binary_reader &&)=default
static void byte_swap(NumberType &number)
Definition json.hpp:12785
char_int_type get_ignore_noop()
Definition json.hpp:12773
bool get_ubjson_value(const char_int_type prefix)
Definition json.hpp:12271
bool get_ubjson_ndarray_size(std::vector< size_t > &dim)
Definition json.hpp:11908
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
Definition json.hpp:10224
bool get_msgpack_object(const std::size_t len)
Definition json.hpp:11757
typename char_traits< char_type >::int_type char_int_type
Definition json.hpp:10028
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition json.hpp:10036
typename BasicJsonType::binary_t binary_t
Definition json.hpp:10025
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
Definition json.hpp:10120
binary_reader & operator=(const binary_reader &)=delete
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition json.hpp:11104
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
Definition json.hpp:10971
bool get_number(const input_format_t format, NumberType &result)
Definition json.hpp:12827
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:10021
bool get_ubjson_array()
Definition json.hpp:12464
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
Definition json.hpp:10145
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)
Definition json.hpp:10057
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition json.hpp:11066
bool get_msgpack_array(const std::size_t len)
Definition json.hpp:11735
char_int_type get()
get next character from the input
Definition json.hpp:12741
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:10023
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
Definition json.hpp:11624
bool parse_ubjson_internal(const bool get_char=true)
Definition json.hpp:11794
SAX json_sax_t
Definition json.hpp:10026
bool get_ubjson_size_value(std::size_t &result, bool &is_ndarray, char_int_type prefix=0)
Definition json.hpp:11973
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
Definition json.hpp:10397
bool get_ubjson_object()
Definition json.hpp:12579
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
Definition json.hpp:10175
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
Definition json.hpp:11813
bool get_to(T &dest, const input_format_t format, const char *context)
get_to read into a primitive type
Definition json.hpp:12756
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition json.hpp:10875
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
Definition json.hpp:10197
binary_reader & operator=(binary_reader &&)=default
serialization to CBOR and MessagePack values
Definition json.hpp:15997
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
Definition json.hpp:17110
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
Definition json.hpp:16947
void write_bson(const BasicJsonType &j)
Definition json.hpp:16017
typename BasicJsonType::binary_t binary_t
Definition json.hpp:15999
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
Definition json.hpp:17007
typename BasicJsonType::string_t string_t
Definition json.hpp:15998
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition json.hpp:17757
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
Definition json.hpp:17025
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)
Definition json.hpp:16697
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
Definition json.hpp:17091
static CharType to_char_type(std::uint8_t x) noexcept
Definition json.hpp:17764
static constexpr CharType get_cbor_float_prefix(double)
Definition json.hpp:17256
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
Definition json.hpp:16975
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition json.hpp:16008
static constexpr CharType get_ubjson_float_prefix(double)
Definition json.hpp:17571
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
Definition json.hpp:17282
static constexpr CharType get_msgpack_float_prefix(double)
Definition json.hpp:17270
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
Definition json.hpp:17173
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition json.hpp:17799
void write_bson_object(const typename BasicJsonType::object_t &value)
Definition json.hpp:17235
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
Definition json.hpp:16957
static std::size_t calc_bson_string_size(const string_t &value)
Definition json.hpp:16967
void write_number(const NumberType n, const bool OutputIsLittleEndian=false)
Definition json.hpp:17707
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
Definition json.hpp:16920
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
Definition json.hpp:16989
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:16000
CharType ubjson_prefix(const BasicJsonType &j, const bool use_bjdata) const noexcept
determine the type prefix of container values
Definition json.hpp:17465
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
Definition json.hpp:17035
static constexpr CharType get_ubjson_float_prefix(float)
Definition json.hpp:17566
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
Definition json.hpp:17083
bool write_bjdata_ndarray(const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type, const bjdata_version_t bjdata_version)
Definition json.hpp:17579
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
Definition json.hpp:17125
void write_msgpack(const BasicJsonType &j)
Definition json.hpp:16370
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
Definition json.hpp:17220
void write_compact_float(const number_float_t n, detail::input_format_t format)
Definition json.hpp:17723
void write_cbor(const BasicJsonType &j)
Definition json.hpp:16046
static constexpr CharType get_cbor_float_prefix(float)
Definition json.hpp:17251
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
Definition json.hpp:16935
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
Definition json.hpp:17058
static constexpr CharType get_msgpack_float_prefix(float)
Definition json.hpp:17265
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
Definition json.hpp:17068
static std::size_t calc_bson_integer_size(const std::int64_t value)
Definition json.hpp:16997
general exception of the basic_json class
Definition json.hpp:4581
static std::string get_byte_positions(const BasicJsonType *leaf_element)
Definition json.hpp:4686
const int id
the id of the exception
Definition json.hpp:4590
static std::string diagnostics(std::nullptr_t)
Definition json.hpp:4601
std::runtime_error m
an exception object as storage for error messages
Definition json.hpp:4673
static std::string name(const std::string &ename, int id_)
Definition json.hpp:4596
const char * what() const noexcept override
returns the explanatory string
Definition json.hpp:4584
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition json.hpp:4607
exception indicating errors with iterators
Definition json.hpp:4750
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4753
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition json.hpp:13816
iter_impl operator+(difference_type i) const
add to iterator
Definition json.hpp:14399
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition json.hpp:13953
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition json.hpp:14344
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition json.hpp:13943
bool operator<(const iter_impl &other) const
comparison: smaller
Definition json.hpp:14286
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition json.hpp:14326
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition json.hpp:14390
iter_impl & operator--()
pre-decrement (–it)
Definition json.hpp:14196
const object_t::key_type & key() const
return the key of an object iterator
Definition json.hpp:14499
bool operator==(const IterImpl &other) const
comparison: equal
Definition json.hpp:14237
iter_impl operator++(int) &
post-increment (it++)
Definition json.hpp:14134
iter_impl & operator+=(difference_type i)
add to iterator
Definition json.hpp:14353
reference operator[](difference_type n) const
access to successor
Definition json.hpp:14461
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition json.hpp:13846
pointer operator->() const
dereference the iterator
Definition json.hpp:14092
friend other_iter_impl
allow basic_json to access private members
Definition json.hpp:13820
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition json.hpp:14524
difference_type operator-(const iter_impl &other) const
return difference
Definition json.hpp:14432
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
Definition json.hpp:13841
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition json.hpp:14410
reference value() const
return the value of an iterator
Definition json.hpp:14515
bool operator>(const iter_impl &other) const
comparison: greater than
Definition json.hpp:14335
typename BasicJsonType::array_t array_t
Definition json.hpp:13826
typename BasicJsonType::object_t object_t
Definition json.hpp:13825
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)
Definition json.hpp:13850
iter_impl & operator++()
pre-increment (++it)
Definition json.hpp:14145
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition json.hpp:13844
reference operator*() const
return a reference to the value pointed to by the iterator
Definition json.hpp:14048
iter_impl operator-(difference_type i) const
subtract from iterator
Definition json.hpp:14421
friend BasicJsonType
Definition json.hpp:13821
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition json.hpp:13928
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition json.hpp:14277
iter_impl operator--(int) &
post-decrement (it–)
Definition json.hpp:14185
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)
Definition json.hpp:13855
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition json.hpp:13918
void set_end() noexcept
set the iterator past the last value
Definition json.hpp:14009
iteration_proxy_value operator++(int) &
Definition json.hpp:5681
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition json.hpp:5690
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition json.hpp:5696
std::ptrdiff_t difference_type
Definition json.hpp:5627
string_type empty_str
an empty string (to return a reference for primitive values)
Definition json.hpp:5644
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)
Definition json.hpp:5648
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition json.hpp:5673
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
Definition json.hpp:5631
std::size_t array_index_last
last stringified array index
Definition json.hpp:5640
std::size_t array_index
an index for arrays (used to create key names)
Definition json.hpp:5638
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
Definition json.hpp:5738
const string_type & key() const
return key of the iterator
Definition json.hpp:5702
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
string_type array_index_str
a string representation of the array index
Definition json.hpp:5642
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition json.hpp:5632
IteratorType anchor
the iterator
Definition json.hpp:5636
proxy class for the items() function
Definition json.hpp:5746
IteratorType::pointer container
the container to iterate
Definition json.hpp:5749
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition json.hpp:5771
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition json.hpp:5765
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition json.hpp:5755
iteration_proxy & operator=(iteration_proxy const &)=default
Definition json.hpp:15729
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
Definition json.hpp:15737
json_ref(value_type &&value)
Definition json.hpp:15733
value_type const & operator*() const
Definition json.hpp:15768
value_type const * operator->() const
Definition json.hpp:15773
json_ref(std::initializer_list< json_ref > init)
Definition json.hpp:15741
json_ref(Args &&... args)
Definition json.hpp:15748
value_type moved_or_copied() const
Definition json.hpp:15759
BasicJsonType value_type
Definition json.hpp:15731
a template for a reverse iterator class
Definition json.hpp:14578
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition json.hpp:14594
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition json.hpp:14606
json_reverse_iterator & operator++()
pre-increment (++it)
Definition json.hpp:14600
std::ptrdiff_t difference_type
Definition json.hpp:14580
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition json.hpp:14618
reference operator[](difference_type n) const
access to successor
Definition json.hpp:14642
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition json.hpp:14648
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition json.hpp:14636
typename Base::reference reference
the reference type for the pointed-to element
Definition json.hpp:14584
reference value() const
return the value of an iterator
Definition json.hpp:14655
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition json.hpp:14591
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition json.hpp:14612
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition json.hpp:14582
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition json.hpp:14630
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition json.hpp:14587
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition json.hpp:14624
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9738
bool end_object()
Definition json.hpp:9788
bool binary(binary_t &)
Definition json.hpp:9773
bool number_integer(number_integer_t)
Definition json.hpp:9753
bool start_array(std::size_t=detail::unknown_size())
Definition json.hpp:9793
bool boolean(bool)
Definition json.hpp:9748
bool null()
Definition json.hpp:9743
bool end_array()
Definition json.hpp:9798
bool number_unsigned(number_unsigned_t)
Definition json.hpp:9758
bool start_object(std::size_t=detail::unknown_size())
Definition json.hpp:9778
bool string(string_t &)
Definition json.hpp:9768
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9741
bool number_float(number_float_t, const string_t &)
Definition json.hpp:9763
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition json.hpp:9803
bool key(string_t &)
Definition json.hpp:9783
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9737
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9739
typename BasicJsonType::string_t string_t
Definition json.hpp:9740
bool start_array(std::size_t len)
Definition json.hpp:9466
typename BasicJsonType::parser_callback_t parser_callback_t
Definition json.hpp:9305
bool null()
Definition json.hpp:9325
typename BasicJsonType::parse_event_t parse_event_t
Definition json.hpp:9306
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool number_integer(number_integer_t val)
Definition json.hpp:9337
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:9545
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9302
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool end_object()
Definition json.hpp:9416
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:9343
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:9349
constexpr bool is_errored() const
Definition json.hpp:9557
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition json.hpp:9309
bool binary(binary_t &val)
Definition json.hpp:9361
typename BasicJsonType::string_t string_t
Definition json.hpp:9303
bool boolean(bool val)
Definition json.hpp:9331
bool key(string_t &val)
Definition json.hpp:9399
bool string(string_t &val)
Definition json.hpp:9355
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
BasicJsonType & root
the parsed JSON value
Definition json.hpp:9712
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9301
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9300
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9304
~json_sax_dom_callback_parser()=default
bool end_array()
Definition json.hpp:9498
bool start_object(std::size_t len)
Definition json.hpp:9367
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
Definition json.hpp:9644
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
SAX implementation to create a JSON value from SAX events.
Definition json.hpp:8992
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:9041
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:9035
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)
Definition json.hpp:9053
typename BasicJsonType::binary_t binary_t
Definition json.hpp:8998
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition json.hpp:9006
bool start_object(std::size_t len)
Definition json.hpp:9059
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:8994
bool key(string_t &val)
Definition json.hpp:9082
bool end_object()
Definition json.hpp:9092
typename BasicJsonType::string_t string_t
Definition json.hpp:8997
~json_sax_dom_parser()=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:8995
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:9150
bool boolean(bool val)
Definition json.hpp:9023
bool start_array(std::size_t len)
Definition json.hpp:9110
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:8996
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
Definition json.hpp:9245
BasicJsonType & root
the parsed JSON value
Definition json.hpp:9283
bool end_array()
Definition json.hpp:9131
json_sax_dom_parser(json_sax_dom_parser &&)=default
constexpr bool is_errored() const
Definition json.hpp:9162
bool null()
Definition json.hpp:9017
bool string(string_t &val)
Definition json.hpp:9047
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_integer(number_integer_t val)
Definition json.hpp:9029
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)
Definition json.hpp:7255
token_type
token types for the parser
Definition json.hpp:7232
@ 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
lexical analysis
Definition json.hpp:7305
void reset() noexcept
reset token_buffer; current character is beginning of token
Definition json.hpp:8519
bool skip_bom()
skip the UTF-8 byte order mark
Definition json.hpp:8691
string_t token_buffer
buffer for variable-length tokens (numbers, strings)
Definition json.hpp:8822
int get_codepoint()
get codepoint from 4 hex characters following \u
Definition json.hpp:7362
token_type scan_string()
scan a string literal
Definition json.hpp:7447
number_integer_t value_integer
Definition json.hpp:8828
void skip_whitespace()
Definition json.hpp:8705
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
Definition json.hpp:8807
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition json.hpp:7316
char_int_type current
the current character
Definition json.hpp:8810
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition json.hpp:8678
std::string get_token_string() const
Definition json.hpp:8653
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:7308
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition json.hpp:8612
typename BasicJsonType::string_t string_t
Definition json.hpp:7309
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:7307
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
Definition json.hpp:7410
char_int_type get()
Definition json.hpp:8537
constexpr position_t get_position() const noexcept
return position of last read token
Definition json.hpp:8645
static void strtof(float &f, const char *str, char **endptr) noexcept
Definition json.hpp:8109
const char_int_type decimal_point_char
the decimal point
Definition json.hpp:8833
number_unsigned_t value_unsigned
Definition json.hpp:8829
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:7306
token_type scan()
Definition json.hpp:8714
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition json.hpp:8618
typename char_traits< char_type >::int_type char_int_type
Definition json.hpp:7311
bool scan_comment()
scan a comment
Definition json.hpp:8037
typename lexer_base< BasicJsonType >::token_type token_type
Definition json.hpp:7314
const char * error_message
a description of occurred lexer errors
Definition json.hpp:8825
lexer & operator=(lexer &&)=default
bool next_unget
whether the next get() call should just return current
Definition json.hpp:8813
lexer(const lexer &)=delete
std::size_t decimal_point_position
the position of the decimal point in the input
Definition json.hpp:8835
typename InputAdapterType::char_type char_type
Definition json.hpp:7310
InputAdapterType ia
input adapter
Definition json.hpp:8804
lexer & operator=(lexer &)=delete
token_type scan_number()
scan a number literal
Definition json.hpp:8166
number_float_t value_float
Definition json.hpp:8830
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition json.hpp:8630
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
Definition json.hpp:8499
std::vector< char_type > token_string
raw input token string (for error messages)
Definition json.hpp:8819
void add(char_int_type c)
add a character to token_buffer
Definition json.hpp:8601
position_t position
the start position of the current token
Definition json.hpp:8816
void unget()
unget current character (read it again on next get)
Definition json.hpp:8574
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition json.hpp:8624
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
Definition json.hpp:7336
exception indicating other library errors
Definition json.hpp:4802
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4805
exception indicating access out of the defined range
Definition json.hpp:4785
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4788
Definition json.hpp:15948
output_adapter(StringType &s)
Definition json.hpp:15959
output_adapter(std::basic_ostream< CharType > &s)
Definition json.hpp:15955
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition json.hpp:15951
output adapter for output streams
Definition json.hpp:15900
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition json.hpp:15902
void write_character(CharType c) override
Definition json.hpp:15906
std::basic_ostream< CharType > & stream
Definition json.hpp:15918
output adapter for basic_string
Definition json.hpp:15925
void write_character(CharType c) override
Definition json.hpp:15931
output_string_adapter(StringType &s) noexcept
Definition json.hpp:15927
StringType & str
Definition json.hpp:15943
output adapter for byte vectors
Definition json.hpp:15875
std::vector< CharType, AllocatorType > & v
Definition json.hpp:15893
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition json.hpp:15877
void write_character(CharType c) override
Definition json.hpp:15881
exception indicating a parse error
Definition json.hpp:4697
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition json.hpp:4709
static std::string position_string(const position_t &pos)
Definition json.hpp:4740
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4717
const std::size_t byte
byte index of the parse error
Definition json.hpp:4734
parse_error(int id_, std::size_t byte_, const char *what_arg)
Definition json.hpp:4737
syntax analysis
Definition json.hpp:13112
std::string exception_message(const token_type expected, const std::string &context)
Definition json.hpp:13544
typename lexer_t::token_type token_type
Definition json.hpp:13118
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition json.hpp:13146
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:13114
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:13113
typename BasicJsonType::string_t string_t
Definition json.hpp:13116
lexer_t m_lexer
the lexer
Definition json.hpp:13579
bool accept(const bool strict=true)
public accept interface
Definition json.hpp:13206
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:13115
token_type get_token()
get next token from lexer
Definition json.hpp:13539
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
Definition json.hpp:13122
Definition json.hpp:13633
primitive_iterator_t & operator++() noexcept
Definition json.hpp:13695
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition json.hpp:13727
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition json.hpp:13662
primitive_iterator_t & operator--() noexcept
Definition json.hpp:13708
void set_end() noexcept
set iterator to a defined past the end
Definition json.hpp:13656
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13678
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition json.hpp:13668
primitive_iterator_t operator++(int) &noexcept
Definition json.hpp:13701
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition json.hpp:13721
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13673
constexpr difference_type get_value() const noexcept
Definition json.hpp:13644
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13690
primitive_iterator_t operator+(difference_type n) noexcept
Definition json.hpp:13683
void set_begin() noexcept
set iterator to a defined beginning
Definition json.hpp:13650
primitive_iterator_t operator--(int) &noexcept
Definition json.hpp:13714
std::ptrdiff_t difference_type
Definition json.hpp:13635
Definition json.hpp:18996
typename BasicJsonType::binary_t::value_type binary_char_t
Definition json.hpp:19001
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:19000
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition json.hpp:19011
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition json.hpp:19928
string_t indent_string
the indentation string
Definition json.hpp:19925
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:18999
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:18998
serializer & operator=(serializer &&)=delete
typename BasicJsonType::string_t string_t
Definition json.hpp:18997
const char indent_char
the indentation character
Definition json.hpp:19923
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
Definition json.hpp:19051
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
Definition json.hpp:4768
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4771
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition json.hpp:14750
BasicJsonType & get_checked(BasicJsonType *ptr) const
Definition json.hpp:15136
json_pointer< string_t > convert() const &
Definition json.hpp:15549
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
Definition json.hpp:14845
static BasicJsonType::size_type array_index(const string_t &s)
Definition json.hpp:14928
typename string_t_helper< RefStringType >::type string_t
Definition json.hpp:14772
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
Definition json.hpp:14852
result reference_tokens
Definition json.hpp:14974
json_pointer(const string_t &s="")
create JSON pointer
Definition json.hpp:14776
static std::vector< string_t > split(const string_t &reference_string)
split the string input to reference tokens
Definition json.hpp:15380
bool empty() const noexcept
return whether pointer points to the root document
Definition json.hpp:14911
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
Definition json.hpp:14988
void pop_back()
remove last reference token
Definition json.hpp:14873
string_t to_string() const
return a string representation of the JSON pointer
Definition json.hpp:14782
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition json.hpp:14830
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14904
json_pointer< string_t > convert() &&
Definition json.hpp:15556
std::vector< string_t > reference_tokens
the reference tokens
Definition json.hpp:15639
return result
Definition json.hpp:14975
static void flatten(const string_t &reference_string, const BasicJsonType &value, BasicJsonType &result)
Definition json.hpp:15449
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition json.hpp:14812
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
Definition json.hpp:14837
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
Definition json.hpp:15068
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition json.hpp:14859
static BasicJsonType unflatten(const BasicJsonType &value)
Definition json.hpp:15521
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition json.hpp:14822
const string_t & back() const
return last reference token
Definition json.hpp:14885
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
Definition json.hpp:14803
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
Definition json.hpp:15194
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14897
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
Definition json.hpp:15243
bool contains(const BasicJsonType *ptr) const
Definition json.hpp:15292
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition json.hpp:5819
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition json.hpp:2623
#define JSON_HEDLEY_CONST
Definition json.hpp:1830
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition json.hpp:1114
#define JSON_INLINE_VARIABLE
Definition json.hpp:2522
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition json.hpp:1460
#define JSON_PRIVATE_UNLESS_TESTED
Definition json.hpp:2582
#define JSON_HEDLEY_UNREACHABLE()
Definition json.hpp:1591
#define NLOHMANN_JSON_VERSION_PATCH
Definition json.hpp:70
#define JSON_HEDLEY_LIKELY(expr)
Definition json.hpp:1725
#define JSON_HEDLEY_NON_NULL(...)
Definition json.hpp:1618
#define JSON_INTERNAL_CATCH(exception)
Definition json.hpp:2549
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition json.hpp:25500
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition json.hpp:2059
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15645
#define JSON_CATCH(exception)
Definition json.hpp:2548
#define JSON_ASSERT(x)
Definition json.hpp:2575
#define JSON_THROW(exception)
Definition json.hpp:2546
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition json.hpp:81
#define NLOHMANN_JSON_VERSION_MAJOR
Definition json.hpp:68
#define NLOHMANN_BASIC_JSON_TPL
Definition json.hpp:2633
#define JSON_HEDLEY_UNLIKELY(expr)
Definition json.hpp:1726
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
Definition json.hpp:13001
#define JSON_TRY
Definition json.hpp:2547
#define NLOHMANN_JSON_NAMESPACE_END
Definition json.hpp:155
#define JSON_NO_UNIQUE_ADDRESS
Definition json.hpp:2528
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15670
#define NLOHMANN_JSON_VERSION_MINOR
Definition json.hpp:69
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition json.hpp:2917
#define NLOHMANN_JSON_NAMESPACE_BEGIN
Definition json.hpp:145
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
Definition json.hpp:12998
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition json.hpp:1115
#define JSON_EXPLICIT
Definition json.hpp:2954
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition json.hpp:1408
#define JSON_HEDLEY_PURE
Definition json.hpp:1799
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15695
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition json.hpp:23848
#define JSON_DIAGNOSTIC_POSITIONS
Definition json.hpp:77
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition json.hpp:18335
cached_power get_cached_power_for_binary_exponent(int e)
Definition json.hpp:18171
Target reinterpret_bits(const Source source)
Definition json.hpp:17891
boundaries compute_boundaries(FloatType value)
Definition json.hpp:18032
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition json.hpp:18389
constexpr int kAlpha
Definition json.hpp:18154
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition json.hpp:18671
constexpr int kGamma
Definition json.hpp:18155
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition json.hpp:18430
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition json.hpp:18771
constexpr bool is_transparent()
Definition json.hpp:4391
constexpr bool is_c_string()
Definition json.hpp:4363
detail namespace with internal helper functions
Definition json.hpp:260
std::tuple< decltype(from_json_tuple_get_impl(std::declval< BasicJsonType >(), detail::identity_tag< Types > {}, detail::priority_tag< PTagValue > {}))... > tuple_type
Definition json.hpp:5385
input_format_t
the supported input formats
Definition json.hpp:6654
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition json.hpp:6234
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition json.hpp:320
typename make_void< Ts... >::type void_t
Definition json.hpp:266
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition json.hpp:9882
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition json.hpp:15870
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition json.hpp:4472
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition json.hpp:9890
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition json.hpp:13103
OutStringType concat(Args &&... args)
Definition json.hpp:4546
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition json.hpp:4481
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition json.hpp:3650
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
Definition json.hpp:3353
decltype(std::declval< T >().template get< U >()) get_template_function
Definition json.hpp:3656
typename T::pointer pointer_t
Definition json.hpp:3641
parse_event_t
Definition json.hpp:13086
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition json.hpp:4475
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition json.hpp:5400
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition json.hpp:5182
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition json.hpp:3314
typename T::value_type value_type_t
Definition json.hpp:3635
tuple_type< PTagValue, BasicJsonType, Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition json.hpp:5388
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition json.hpp:324
void int_to_string(StringType &target, std::size_t value)
Definition json.hpp:5599
T conditional_static_cast(U value)
Definition json.hpp:4247
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition json.hpp:4487
typename std::enable_if< B, T >::type enable_if_t
Definition json.hpp:3226
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition json.hpp:9851
typename T::mapped_type mapped_type_t
Definition json.hpp:3629
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition json.hpp:3102
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition json.hpp:9859
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition json.hpp:3901
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition json.hpp:5781
bool little_endianness(int num=1) noexcept
determine system byte order
Definition json.hpp:10006
cbor_tag_handler_t
how to treat CBOR tags
Definition json.hpp:9993
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition json.hpp:317
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition json.hpp:3653
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition json.hpp:7108
make_integer_sequence< size_t, N > make_index_sequence
Definition json.hpp:3322
std::integral_constant< bool, Value > bool_constant
Definition json.hpp:4353
void concat_into(OutStringType &)
Definition json.hpp:4462
typename T::key_type key_type_t
Definition json.hpp:3632
constexpr bool value_in_range_of(T val)
Definition json.hpp:4347
value_t
the JSON type enumeration
Definition json.hpp:3004
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition json.hpp:4270
constexpr std::size_t unknown_size()
Definition json.hpp:8972
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition json.hpp:9867
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition json.hpp:5265
StringType to_string(std::size_t value)
Definition json.hpp:5607
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition json.hpp:311
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
Definition json.hpp:4194
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition json.hpp:6494
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition json.hpp:4478
typename T::iterator_category iterator_category_t
Definition json.hpp:3647
void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:3136
decltype(input_adapter(std::declval< std::string >())) string_input_adapter_type
Definition json.hpp:7084
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition json.hpp:6476
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition json.hpp:3033
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
Definition json.hpp:4213
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition json.hpp:7044
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition json.hpp:9885
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
Definition json.hpp:4225
error_handler_t
how to treat decoding errors
Definition json.hpp:18988
@ 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()
Definition json.hpp:4431
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition json.hpp:3904
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition json.hpp:4961
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition json.hpp:3729
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition json.hpp:4466
void to_json(BasicJsonType &j, T b) noexcept
Definition json.hpp:6095
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition json.hpp:4991
decltype(std::declval< T & >().null()) null_function_t
Definition json.hpp:9843
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition json.hpp:3330
typename T::difference_type difference_type_t
Definition json.hpp:3638
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition json.hpp:3212
typename T::is_transparent detect_is_transparent
Definition json.hpp:4180
detail::uncvref_t< Type > from_json_tuple_get_impl(BasicJsonType &&j, detail::identity_tag< Type >, detail::priority_tag< 0 >)
Definition json.hpp:5365
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition json.hpp:9863
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
Definition json.hpp:14704
typename T::reference reference_t
Definition json.hpp:3644
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition json.hpp:9847
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition json.hpp:9878
bjdata_version_t
how to encode BJData
Definition json.hpp:15983
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition json.hpp:4216
typename T::key_compare detect_key_compare
Definition json.hpp:3713
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition json.hpp:9871
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition json.hpp:4484
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition json.hpp:9855
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition json.hpp:305
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:3121
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
Definition json.hpp:4275
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition json.hpp:4469
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition json.hpp:9875
Definition json.hpp:25506
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
Definition json.hpp:25599
namespace for Niels Lohmann
Definition json.hpp:6305
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
Definition json.hpp:6329
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
Definition json.hpp:6319
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
Definition json.hpp:6309
typename BasicJsonType::object_t object_t
Definition json.hpp:3722
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition json.hpp:3723
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition json.hpp:3725
signed char char_type
Definition json.hpp:3768
static constexpr int_type eof() noexcept
Definition json.hpp:3782
uint64_t int_type
Definition json.hpp:3769
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3777
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3772
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3753
static constexpr int_type eof() noexcept
Definition json.hpp:3758
unsigned char char_type
Definition json.hpp:3744
uint64_t int_type
Definition json.hpp:3745
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3748
std::true_type value_t
Definition json.hpp:300
Op< Args... > type
Definition json.hpp:301
std::false_type value_t
Definition json.hpp:293
Default type
Definition json.hpp:294
Definition json.hpp:18019
diyfp w
Definition json.hpp:18020
diyfp minus
Definition json.hpp:18021
diyfp plus
Definition json.hpp:18022
Definition json.hpp:18158
std::uint64_t f
Definition json.hpp:18159
int e
Definition json.hpp:18160
int k
Definition json.hpp:18161
Definition json.hpp:17901
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition json.hpp:17925
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition json.hpp:18007
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition json.hpp:17990
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition json.hpp:17913
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition json.hpp:17907
std::uint64_t f
Definition json.hpp:17904
int e
Definition json.hpp:17905
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition json.hpp:6004
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition json.hpp:5979
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition json.hpp:5969
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition json.hpp:5991
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition json.hpp:6020
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition json.hpp:5908
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition json.hpp:5917
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition json.hpp:5862
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition json.hpp:5930
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition json.hpp:5956
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition json.hpp:5943
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition json.hpp:6039
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition json.hpp:6060
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition json.hpp:6049
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition json.hpp:5884
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition json.hpp:5895
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition json.hpp:5875
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)))
Definition json.hpp:5501
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3675
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3690
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3705
T value_type
Definition json.hpp:3255
static constexpr std::size_t size() noexcept
Definition json.hpp:3256
an iterator value
Definition json.hpp:13749
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition json.hpp:13753
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition json.hpp:13755
std::numeric_limits< RealIntegerType > RealLimits
Definition json.hpp:4075
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition json.hpp:4076
typename BasicJsonType::object_t object_t
Definition json.hpp:3926
typename std::remove_reference< CompatibleReferenceType >::type CVType
Definition json.hpp:4110
typename std::remove_cv< CVType >::type Type
Definition json.hpp:4111
uncvref_t< BasicJsonType > JsonType
Definition json.hpp:4109
static constexpr bool value
Definition json.hpp:4112
static constexpr auto value
Definition json.hpp:3976
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
Definition json.hpp:4047
typename BasicJsonType::object_t object_t
Definition json.hpp:3950
ConstructibleStringType laundered_type
Definition json.hpp:3987
static constexpr auto value
Definition json.hpp:3990
static constexpr bool value
Definition json.hpp:3669
typename std::iterator_traits< T >::value_type value_type
Definition json.hpp:7021
char x[2]
Definition json.hpp:4236
static one test(decltype(&C::capacity))
@ value
Definition json.hpp:4242
char one
Definition json.hpp:4232
detected_t< result_of_end, t_ref > sentinel
Definition json.hpp:3888
detected_t< result_of_begin, t_ref > iterator
Definition json.hpp:3887
typename std::add_lvalue_reference< T >::type t_ref
Definition json.hpp:3885
static constexpr bool value
Definition json.hpp:3897
static constexpr auto is_iterator_begin
Definition json.hpp:3893
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9930
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9931
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9934
typename BasicJsonType::exception exception_t
Definition json.hpp:9935
typename BasicJsonType::string_t string_t
Definition json.hpp:9933
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9932
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9903
typename BasicJsonType::exception exception_t
Definition json.hpp:9904
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9901
typename BasicJsonType::string_t string_t
Definition json.hpp:9902
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9900
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9899
T value_type
Definition json.hpp:3437
T * pointer
Definition json.hpp:3439
ptrdiff_t difference_type
Definition json.hpp:3438
T & reference
Definition json.hpp:3440
std::random_access_iterator_tag iterator_category
Definition json.hpp:3436
typename It::iterator_category iterator_category
Definition json.hpp:3417
typename It::difference_type difference_type
Definition json.hpp:3413
typename It::value_type value_type
Definition json.hpp:3414
typename It::reference reference
Definition json.hpp:3416
typename It::pointer pointer
Definition json.hpp:3415
Default base class of the basic_json class.
Definition json.hpp:14697
void type
Definition json.hpp:264
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
Definition json.hpp:15856
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
Definition json.hpp:3167
std::size_t chars_read_current_line
the number of characters read in the current line
Definition json.hpp:3171
std::size_t lines_read
the number of lines read
Definition json.hpp:3173
std::size_t chars_read_total
the total number of characters read
Definition json.hpp:3169
static JSON_INLINE_VARIABLE constexpr T value
Definition json.hpp:3344
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())
Definition json.hpp:6274
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition json.hpp:3295
static constexpr bool test(T val)
Definition json.hpp:4331
static constexpr bool test(T)
Definition json.hpp:4340
static constexpr bool test(T val)
Definition json.hpp:4285
static constexpr bool test(T val)
Definition json.hpp:4305
static constexpr bool test(T val)
Definition json.hpp:4295
static constexpr bool test(T val)
Definition json.hpp:4315
StringType type
Definition json.hpp:14767
Definition json.hpp:14760
T type
Definition json.hpp:14761
SAX interface.
Definition json.hpp:8857
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
Definition json.hpp:8858
typename BasicJsonType::string_t string_t
Definition json.hpp:8861
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
Definition json.hpp:8860
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:8859
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
Definition json.hpp:8862
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
Definition json.hpp:19970
std::vector< std::pair< const Key, T >, Allocator > Container
Definition json.hpp:19973
std::pair< iterator, bool > insert(value_type &&value)
Definition json.hpp:20264
typename Container::value_type value_type
Definition json.hpp:19977
std::equal_to< Key > key_compare
Definition json.hpp:19981
iterator erase(iterator pos)
Definition json.hpp:20142
T mapped_type
Definition json.hpp:19972
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition json.hpp:19987
T & operator[](KeyType &&key)
Definition json.hpp:20029
typename Container::iterator iterator
Definition json.hpp:19974
const T & at(KeyType &&key) const
Definition json.hpp:20089
T & at(KeyType &&key)
Definition json.hpp:20061
const T & operator[](KeyType &&key) const
Definition json.hpp:20041
iterator find(const key_type &key)
Definition json.hpp:20226
iterator erase(iterator first, iterator last)
Definition json.hpp:20147
const T & at(const key_type &key) const
Definition json.hpp:20074
const_iterator find(const key_type &key) const
Definition json.hpp:20252
T & operator[](const key_type &key)
Definition json.hpp:20022
size_type erase(KeyType &&key)
Definition json.hpp:20123
typename Container::size_type size_type
Definition json.hpp:19976
ordered_map() noexcept(noexcept(Container()))
Definition json.hpp:19986
void insert(InputIt first, InputIt last)
Definition json.hpp:20287
size_type count(const key_type &key) const
Definition json.hpp:20200
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
Definition json.hpp:20009
size_type erase(const key_type &key)
Definition json.hpp:20102
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition json.hpp:19991
std::pair< iterator, bool > insert(const value_type &value)
Definition json.hpp:20269
size_type count(KeyType &&key) const
Definition json.hpp:20214
Key key_type
Definition json.hpp:19971
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition json.hpp:19989
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition json.hpp:20284
const T & operator[](const key_type &key) const
Definition json.hpp:20034
iterator find(KeyType &&key)
Definition json.hpp:20240
T & at(const key_type &key)
Definition json.hpp:20046
typename Container::const_iterator const_iterator
Definition json.hpp:19975
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition json.hpp:19994
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition json.hpp:25568
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition json.hpp:25582