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 != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
63 #warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 11
70#define NLOHMANN_JSON_VERSION_PATCH 3
72#ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
77 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
81 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
83 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
86#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
87 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
89 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
92#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
93 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
97#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
98#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
99 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
101#define NLOHMANN_JSON_ABI_TAGS \
102 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
103 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
104 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
107#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
108 _v ## major ## _ ## minor ## _ ## patch
109#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
110 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
112#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
113#define NLOHMANN_JSON_NAMESPACE_VERSION
115#define NLOHMANN_JSON_NAMESPACE_VERSION \
116 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
117 NLOHMANN_JSON_VERSION_MINOR, \
118 NLOHMANN_JSON_VERSION_PATCH)
122#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
123#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
124 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
126#ifndef NLOHMANN_JSON_NAMESPACE
127#define NLOHMANN_JSON_NAMESPACE \
128 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
129 NLOHMANN_JSON_ABI_TAGS, \
130 NLOHMANN_JSON_NAMESPACE_VERSION)
133#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
134#define NLOHMANN_JSON_NAMESPACE_BEGIN \
137 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
138 NLOHMANN_JSON_ABI_TAGS, \
139 NLOHMANN_JSON_NAMESPACE_VERSION) \
143#ifndef NLOHMANN_JSON_NAMESPACE_END
144#define NLOHMANN_JSON_NAMESPACE_END \
162#include <forward_list>
165#ifdef JSON_HAS_CPP_17
170#include <type_traits>
171#include <unordered_map>
235#include <type_traits>
280template<
class Default,
282 template<
class...>
class Op,
290template<
class Default,
template<
class...>
class Op,
class... Args>
297template<
template<
class...>
class Op,
class... Args>
300template<
template<
class...>
class Op,
class... Args>
303template<
template<
class...>
class Op,
class... Args>
306template<
class Default,
template<
class...>
class Op,
class... Args>
309template<
class Default,
template<
class...>
class Op,
class... Args>
312template<
class Expected,
template<
class...>
class Op,
class... Args>
315template<
class To,
template<
class...>
class Op,
class... Args>
317 std::is_convertible<
detected_t<Op, Args...>, To>;
338#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
339#if defined(JSON_HEDLEY_VERSION)
340 #undef JSON_HEDLEY_VERSION
342#define JSON_HEDLEY_VERSION 15
344#if defined(JSON_HEDLEY_STRINGIFY_EX)
345 #undef JSON_HEDLEY_STRINGIFY_EX
347#define JSON_HEDLEY_STRINGIFY_EX(x) #x
349#if defined(JSON_HEDLEY_STRINGIFY)
350 #undef JSON_HEDLEY_STRINGIFY
352#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
354#if defined(JSON_HEDLEY_CONCAT_EX)
355 #undef JSON_HEDLEY_CONCAT_EX
357#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
359#if defined(JSON_HEDLEY_CONCAT)
360 #undef JSON_HEDLEY_CONCAT
362#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
364#if defined(JSON_HEDLEY_CONCAT3_EX)
365 #undef JSON_HEDLEY_CONCAT3_EX
367#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
369#if defined(JSON_HEDLEY_CONCAT3)
370 #undef JSON_HEDLEY_CONCAT3
372#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
374#if defined(JSON_HEDLEY_VERSION_ENCODE)
375 #undef JSON_HEDLEY_VERSION_ENCODE
377#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
379#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
380 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
382#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
384#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
385 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
387#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
389#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
390 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
392#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
394#if defined(JSON_HEDLEY_GNUC_VERSION)
395 #undef JSON_HEDLEY_GNUC_VERSION
397#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
398 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
399#elif defined(__GNUC__)
400 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
403#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
404 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
406#if defined(JSON_HEDLEY_GNUC_VERSION)
407 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
409 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
412#if defined(JSON_HEDLEY_MSVC_VERSION)
413 #undef JSON_HEDLEY_MSVC_VERSION
415#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
416 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
417#elif defined(_MSC_FULL_VER) && !defined(__ICL)
418 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
419#elif defined(_MSC_VER) && !defined(__ICL)
420 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
423#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
424 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
426#if !defined(JSON_HEDLEY_MSVC_VERSION)
427 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
428#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
429 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
430#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
431 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
433 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
436#if defined(JSON_HEDLEY_INTEL_VERSION)
437 #undef JSON_HEDLEY_INTEL_VERSION
439#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
440 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
441#elif defined(__INTEL_COMPILER) && !defined(__ICL)
442 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
445#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
446 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
448#if defined(JSON_HEDLEY_INTEL_VERSION)
449 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
451 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
454#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
455 #undef JSON_HEDLEY_INTEL_CL_VERSION
457#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
458 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
461#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
462 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
464#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
465 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
467 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
470#if defined(JSON_HEDLEY_PGI_VERSION)
471 #undef JSON_HEDLEY_PGI_VERSION
473#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
474 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
477#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
478 #undef JSON_HEDLEY_PGI_VERSION_CHECK
480#if defined(JSON_HEDLEY_PGI_VERSION)
481 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
483 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
486#if defined(JSON_HEDLEY_SUNPRO_VERSION)
487 #undef JSON_HEDLEY_SUNPRO_VERSION
489#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
490 #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)
491#elif defined(__SUNPRO_C)
492 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
493#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
494 #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)
495#elif defined(__SUNPRO_CC)
496 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
499#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
500 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
502#if defined(JSON_HEDLEY_SUNPRO_VERSION)
503 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
505 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
508#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
509 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
511#if defined(__EMSCRIPTEN__)
512 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
515#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
516 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
518#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
519 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
521 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
524#if defined(JSON_HEDLEY_ARM_VERSION)
525 #undef JSON_HEDLEY_ARM_VERSION
527#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
528 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
529#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
530 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
533#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
534 #undef JSON_HEDLEY_ARM_VERSION_CHECK
536#if defined(JSON_HEDLEY_ARM_VERSION)
537 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
539 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
542#if defined(JSON_HEDLEY_IBM_VERSION)
543 #undef JSON_HEDLEY_IBM_VERSION
545#if defined(__ibmxl__)
546 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
547#elif defined(__xlC__) && defined(__xlC_ver__)
548 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
549#elif defined(__xlC__)
550 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
553#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
554 #undef JSON_HEDLEY_IBM_VERSION_CHECK
556#if defined(JSON_HEDLEY_IBM_VERSION)
557 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
559 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
562#if defined(JSON_HEDLEY_TI_VERSION)
563 #undef JSON_HEDLEY_TI_VERSION
566 defined(__TI_COMPILER_VERSION__) && \
568 defined(__TMS470__) || defined(__TI_ARM__) || \
569 defined(__MSP430__) || \
570 defined(__TMS320C2000__) \
572#if (__TI_COMPILER_VERSION__ >= 16000000)
573 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
577#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
578 #undef JSON_HEDLEY_TI_VERSION_CHECK
580#if defined(JSON_HEDLEY_TI_VERSION)
581 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
583 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
586#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
587 #undef JSON_HEDLEY_TI_CL2000_VERSION
589#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
590 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
593#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
594 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
596#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
597 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
599 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
602#if defined(JSON_HEDLEY_TI_CL430_VERSION)
603 #undef JSON_HEDLEY_TI_CL430_VERSION
605#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
606 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
609#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
610 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
612#if defined(JSON_HEDLEY_TI_CL430_VERSION)
613 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
615 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
618#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
619 #undef JSON_HEDLEY_TI_ARMCL_VERSION
621#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
622 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
625#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
626 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
628#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
629 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
631 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
634#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
635 #undef JSON_HEDLEY_TI_CL6X_VERSION
637#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
638 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
641#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
642 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
644#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
645 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
647 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
650#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
651 #undef JSON_HEDLEY_TI_CL7X_VERSION
653#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
654 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
657#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
658 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
660#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
661 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
663 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
666#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
667 #undef JSON_HEDLEY_TI_CLPRU_VERSION
669#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
670 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
673#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
674 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
676#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
677 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
679 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
682#if defined(JSON_HEDLEY_CRAY_VERSION)
683 #undef JSON_HEDLEY_CRAY_VERSION
686 #if defined(_RELEASE_PATCHLEVEL)
687 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
689 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
693#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
694 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
696#if defined(JSON_HEDLEY_CRAY_VERSION)
697 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
699 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
702#if defined(JSON_HEDLEY_IAR_VERSION)
703 #undef JSON_HEDLEY_IAR_VERSION
705#if defined(__IAR_SYSTEMS_ICC__)
707 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
709 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
713#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
714 #undef JSON_HEDLEY_IAR_VERSION_CHECK
716#if defined(JSON_HEDLEY_IAR_VERSION)
717 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
719 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
722#if defined(JSON_HEDLEY_TINYC_VERSION)
723 #undef JSON_HEDLEY_TINYC_VERSION
725#if defined(__TINYC__)
726 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
729#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
730 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
732#if defined(JSON_HEDLEY_TINYC_VERSION)
733 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
735 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
738#if defined(JSON_HEDLEY_DMC_VERSION)
739 #undef JSON_HEDLEY_DMC_VERSION
742 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
745#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
746 #undef JSON_HEDLEY_DMC_VERSION_CHECK
748#if defined(JSON_HEDLEY_DMC_VERSION)
749 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
751 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
754#if defined(JSON_HEDLEY_COMPCERT_VERSION)
755 #undef JSON_HEDLEY_COMPCERT_VERSION
757#if defined(__COMPCERT_VERSION__)
758 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
761#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
762 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
764#if defined(JSON_HEDLEY_COMPCERT_VERSION)
765 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
767 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
770#if defined(JSON_HEDLEY_PELLES_VERSION)
771 #undef JSON_HEDLEY_PELLES_VERSION
774 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
777#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
778 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
780#if defined(JSON_HEDLEY_PELLES_VERSION)
781 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
783 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
786#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
787 #undef JSON_HEDLEY_MCST_LCC_VERSION
789#if defined(__LCC__) && defined(__LCC_MINOR__)
790 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
793#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
794 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
796#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
797 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
799 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
802#if defined(JSON_HEDLEY_GCC_VERSION)
803 #undef JSON_HEDLEY_GCC_VERSION
806 defined(JSON_HEDLEY_GNUC_VERSION) && \
807 !defined(__clang__) && \
808 !defined(JSON_HEDLEY_INTEL_VERSION) && \
809 !defined(JSON_HEDLEY_PGI_VERSION) && \
810 !defined(JSON_HEDLEY_ARM_VERSION) && \
811 !defined(JSON_HEDLEY_CRAY_VERSION) && \
812 !defined(JSON_HEDLEY_TI_VERSION) && \
813 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
814 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
815 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
816 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
817 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
818 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
819 !defined(__COMPCERT__) && \
820 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
821 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
824#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
825 #undef JSON_HEDLEY_GCC_VERSION_CHECK
827#if defined(JSON_HEDLEY_GCC_VERSION)
828 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
830 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
833#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
834 #undef JSON_HEDLEY_HAS_ATTRIBUTE
837 defined(__has_attribute) && \
839 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
841# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
843# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
846#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
847 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
849#if defined(__has_attribute)
850 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
852 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
855#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
856 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
858#if defined(__has_attribute)
859 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
861 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
864#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
865 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
868 defined(__has_cpp_attribute) && \
869 defined(__cplusplus) && \
870 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
871 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
873 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
876#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
877 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
879#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
882 !defined(JSON_HEDLEY_PGI_VERSION) && \
883 !defined(JSON_HEDLEY_IAR_VERSION) && \
884 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
885 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
886 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
888 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
891#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
892 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
894#if defined(__has_cpp_attribute) && defined(__cplusplus)
895 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
897 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
900#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
901 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
903#if defined(__has_cpp_attribute) && defined(__cplusplus)
904 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
906 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
909#if defined(JSON_HEDLEY_HAS_BUILTIN)
910 #undef JSON_HEDLEY_HAS_BUILTIN
912#if defined(__has_builtin)
913 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
915 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
918#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
919 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
921#if defined(__has_builtin)
922 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
924 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
927#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
928 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
930#if defined(__has_builtin)
931 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
933 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
936#if defined(JSON_HEDLEY_HAS_FEATURE)
937 #undef JSON_HEDLEY_HAS_FEATURE
939#if defined(__has_feature)
940 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
942 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
945#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
946 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
948#if defined(__has_feature)
949 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
951 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
954#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
955 #undef JSON_HEDLEY_GCC_HAS_FEATURE
957#if defined(__has_feature)
958 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
960 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
963#if defined(JSON_HEDLEY_HAS_EXTENSION)
964 #undef JSON_HEDLEY_HAS_EXTENSION
966#if defined(__has_extension)
967 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
969 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
972#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
973 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
975#if defined(__has_extension)
976 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
978 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
981#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
982 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
984#if defined(__has_extension)
985 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
987 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
990#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
991 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
993#if defined(__has_declspec_attribute)
994 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
996 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
999#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1000 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1002#if defined(__has_declspec_attribute)
1003 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1005 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1008#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1009 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1011#if defined(__has_declspec_attribute)
1012 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1014 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1017#if defined(JSON_HEDLEY_HAS_WARNING)
1018 #undef JSON_HEDLEY_HAS_WARNING
1020#if defined(__has_warning)
1021 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1023 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1026#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1027 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1029#if defined(__has_warning)
1030 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1032 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1035#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1036 #undef JSON_HEDLEY_GCC_HAS_WARNING
1038#if defined(__has_warning)
1039 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1041 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1045 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1046 defined(__clang__) || \
1047 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1048 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1049 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1050 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1051 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1052 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1053 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1054 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1055 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1056 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1057 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1058 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1059 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1060 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1061 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1062 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1063 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1064#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1065 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1067 #define JSON_HEDLEY_PRAGMA(value)
1070#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1071 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1073#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1074 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1076#if defined(__clang__)
1077 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1078 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1079#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1080 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1081 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1082#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1083 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1084 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1086 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1087 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1088 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1089 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1090#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1091 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1092 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1094 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1095 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1096 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1097 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1098 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1099 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1100 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1101 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1102#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1103 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1104 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1106 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1107 #define JSON_HEDLEY_DIAGNOSTIC_POP
1112#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1113 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1115#if defined(__cplusplus)
1116# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1117# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1118# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1119# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1120 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1121 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1122 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1123 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1125 JSON_HEDLEY_DIAGNOSTIC_POP
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\"") \
1132 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\"") \
1139 JSON_HEDLEY_DIAGNOSTIC_POP
1143#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1144 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1147#if defined(JSON_HEDLEY_CONST_CAST)
1148 #undef JSON_HEDLEY_CONST_CAST
1150#if defined(__cplusplus)
1151# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1153 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1154 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1155 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1156# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1157 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1158 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1160 JSON_HEDLEY_DIAGNOSTIC_POP \
1163# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1166#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1167 #undef JSON_HEDLEY_REINTERPRET_CAST
1169#if defined(__cplusplus)
1170 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1172 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1175#if defined(JSON_HEDLEY_STATIC_CAST)
1176 #undef JSON_HEDLEY_STATIC_CAST
1178#if defined(__cplusplus)
1179 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1181 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1184#if defined(JSON_HEDLEY_CPP_CAST)
1185 #undef JSON_HEDLEY_CPP_CAST
1187#if defined(__cplusplus)
1188# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1189# define JSON_HEDLEY_CPP_CAST(T, expr) \
1190 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1191 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1193 JSON_HEDLEY_DIAGNOSTIC_POP
1194# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1195# define JSON_HEDLEY_CPP_CAST(T, expr) \
1196 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1197 _Pragma("diag_suppress=Pe137") \
1198 JSON_HEDLEY_DIAGNOSTIC_POP
1200# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1203# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1206#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1207 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1209#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1211#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1213#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1215#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1217#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1219#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1221#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1222 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1223#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1224 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1226 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1227 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1229 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1231 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1232 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1233 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1234 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1235 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1236 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1238#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1239 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1240#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1241 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1242#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1243 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1244#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1245 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1247 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1250#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1251 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1253#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1255#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1256 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1257#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1259#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1260 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1261#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1262 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1263#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1264 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1266 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1267 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1268 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1269 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1271#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1273#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1274 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1275#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1276 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1278 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1281#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1282 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1284#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1286#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1287 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1288#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1289 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1290#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1291 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1292#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1293 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1294#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1295 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1296#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1297 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1298#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1299 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1301 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1302 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1303 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1305#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1307#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1308 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1310 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1313#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1314 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1316#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1318#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1319 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1320#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1321 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1323 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1326#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1327 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1329#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1331#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1332 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1333#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1334 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1335#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1336 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1338 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1341#if defined(JSON_HEDLEY_DEPRECATED)
1342 #undef JSON_HEDLEY_DEPRECATED
1344#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1345 #undef JSON_HEDLEY_DEPRECATED_FOR
1348 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1349 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1350 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1351 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1353 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1354 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1355 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1356 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1357 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1358 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1359 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1360 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1361 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1362 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1363 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1364 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1365 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1366 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1367#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1368 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1369 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1371 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1372 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1373 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1374 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1375 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1376 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1377 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1378 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1379 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1380 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1381 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1382 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1383 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1384 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1385 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1386 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1387 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1388 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1390 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1391 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1392 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1393 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1394 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1395#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1396 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1397 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1399 #define JSON_HEDLEY_DEPRECATED(since)
1400 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1403#if defined(JSON_HEDLEY_UNAVAILABLE)
1404 #undef JSON_HEDLEY_UNAVAILABLE
1407 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1408 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1409 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1410 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1411 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1413 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1416#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1417 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1419#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1420 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1423 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1424 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1425 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1426 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1427 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1428 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1429 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1430 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1431 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1432 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1433 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1434 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1435 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1436 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1437 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1438 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1439 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1440 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1441 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1442#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1443 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1444 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1445#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1446 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1447 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1448#elif defined(_Check_return_)
1449 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1452 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1456#if defined(JSON_HEDLEY_SENTINEL)
1457 #undef JSON_HEDLEY_SENTINEL
1460 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1461 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1462 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1463 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1464 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1465 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1467 #define JSON_HEDLEY_SENTINEL(position)
1470#if defined(JSON_HEDLEY_NO_RETURN)
1471 #undef JSON_HEDLEY_NO_RETURN
1473#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1474 #define JSON_HEDLEY_NO_RETURN __noreturn
1476 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1477 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1478 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1479#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1480 #define JSON_HEDLEY_NO_RETURN _Noreturn
1481#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1482 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1484 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1485 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1486 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1487 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1488 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1489 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1490 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1491 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1492 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1493 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1494 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1495 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1496 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1497 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1498 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1499 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1500 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1501 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1502#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1503 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1505 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1506 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1507 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1508#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1509 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1510#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1511 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1512#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1513 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1515 #define JSON_HEDLEY_NO_RETURN
1518#if defined(JSON_HEDLEY_NO_ESCAPE)
1519 #undef JSON_HEDLEY_NO_ESCAPE
1521#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1522 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1524 #define JSON_HEDLEY_NO_ESCAPE
1527#if defined(JSON_HEDLEY_UNREACHABLE)
1528 #undef JSON_HEDLEY_UNREACHABLE
1530#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1531 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1533#if defined(JSON_HEDLEY_ASSUME)
1534 #undef JSON_HEDLEY_ASSUME
1537 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1538 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1539 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1540 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1541#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1542 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1544 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1545 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1546 #if defined(__cplusplus)
1547 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1549 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1553 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1554 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1555 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1556 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1557 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1558 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1559 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1560 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1561#elif defined(JSON_HEDLEY_ASSUME)
1562 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1564#if !defined(JSON_HEDLEY_ASSUME)
1565 #if defined(JSON_HEDLEY_UNREACHABLE)
1566 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1568 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1571#if defined(JSON_HEDLEY_UNREACHABLE)
1573 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1574 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1575 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1577 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1580 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1582#if !defined(JSON_HEDLEY_UNREACHABLE)
1583 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1587#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1588 #pragma clang diagnostic ignored "-Wpedantic"
1590#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1591 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1593#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1594 #if defined(__clang__)
1595 #pragma clang diagnostic ignored "-Wvariadic-macros"
1596 #elif defined(JSON_HEDLEY_GCC_VERSION)
1597 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1600#if defined(JSON_HEDLEY_NON_NULL)
1601 #undef JSON_HEDLEY_NON_NULL
1604 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1605 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1606 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1607 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1608 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1610 #define JSON_HEDLEY_NON_NULL(...)
1614#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1615 #undef JSON_HEDLEY_PRINTF_FORMAT
1617#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1618 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1619#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1620 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1622 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1623 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1624 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1625 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1626 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1627 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1628 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1629 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1630 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1631 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1632 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1633 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1634 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1635 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1636 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1637 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1638 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1639 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1640#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1641 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1643 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1646#if defined(JSON_HEDLEY_CONSTEXPR)
1647 #undef JSON_HEDLEY_CONSTEXPR
1649#if defined(__cplusplus)
1650 #if __cplusplus >= 201103L
1651 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1654#if !defined(JSON_HEDLEY_CONSTEXPR)
1655 #define JSON_HEDLEY_CONSTEXPR
1658#if defined(JSON_HEDLEY_PREDICT)
1659 #undef JSON_HEDLEY_PREDICT
1661#if defined(JSON_HEDLEY_LIKELY)
1662 #undef JSON_HEDLEY_LIKELY
1664#if defined(JSON_HEDLEY_UNLIKELY)
1665 #undef JSON_HEDLEY_UNLIKELY
1667#if defined(JSON_HEDLEY_UNPREDICTABLE)
1668 #undef JSON_HEDLEY_UNPREDICTABLE
1670#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1671 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1674 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1675 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1676 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1677# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1678# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1679# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1680# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1681# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1683 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1684 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1685 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1686 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1687 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1688 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1689 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1690 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1691 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1692 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1693 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1694 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1695 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1696 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1697 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1698 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1699# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1700 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1701# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1703 double hedley_probability_ = (probability); \
1704 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1706# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1708 double hedley_probability_ = (probability); \
1709 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1711# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1712# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1714# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1715# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1716# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1717# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1718# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1720#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1721 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1724#if defined(JSON_HEDLEY_MALLOC)
1725 #undef JSON_HEDLEY_MALLOC
1728 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1729 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1730 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1731 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1732 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1733 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1734 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1735 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1736 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1737 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1738 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1739 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1740 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1741 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1742 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1743 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1744 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1745 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1746 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1747#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1748 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1750 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1751 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1752 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1754 #define JSON_HEDLEY_MALLOC
1757#if defined(JSON_HEDLEY_PURE)
1758 #undef JSON_HEDLEY_PURE
1761 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1762 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1763 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1764 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1765 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1766 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1767 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1768 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1769 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1770 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1771 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1772 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1773 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1774 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1775 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1776 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1777 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1778 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1779 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1780# define JSON_HEDLEY_PURE __attribute__((__pure__))
1781#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1782# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1783#elif defined(__cplusplus) && \
1785 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1786 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1787 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1789# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1791# define JSON_HEDLEY_PURE
1794#if defined(JSON_HEDLEY_CONST)
1795 #undef JSON_HEDLEY_CONST
1798 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1799 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1800 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1801 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1802 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1803 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1804 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1805 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1806 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1807 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1808 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1809 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1810 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1811 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1812 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1813 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1814 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1815 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1816 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1817 #define JSON_HEDLEY_CONST __attribute__((__const__))
1819 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1820 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1822 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1825#if defined(JSON_HEDLEY_RESTRICT)
1826 #undef JSON_HEDLEY_RESTRICT
1828#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1829 #define JSON_HEDLEY_RESTRICT restrict
1831 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1832 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1833 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1834 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1835 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1836 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1837 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1838 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1839 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1840 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1841 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1842 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1843 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1844 defined(__clang__) || \
1845 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1846 #define JSON_HEDLEY_RESTRICT __restrict
1847#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1848 #define JSON_HEDLEY_RESTRICT _Restrict
1850 #define JSON_HEDLEY_RESTRICT
1853#if defined(JSON_HEDLEY_INLINE)
1854 #undef JSON_HEDLEY_INLINE
1857 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1858 (defined(__cplusplus) && (__cplusplus >= 199711L))
1859 #define JSON_HEDLEY_INLINE inline
1861 defined(JSON_HEDLEY_GCC_VERSION) || \
1862 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1863 #define JSON_HEDLEY_INLINE __inline__
1865 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1866 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1867 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1868 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1869 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1870 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1871 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1872 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1873 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1874 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1875 #define JSON_HEDLEY_INLINE __inline
1877 #define JSON_HEDLEY_INLINE
1880#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1881 #undef JSON_HEDLEY_ALWAYS_INLINE
1884 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1885 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1886 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1887 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1888 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1889 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1890 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1891 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1892 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1893 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1894 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1895 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1896 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1897 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1898 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1899 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1900 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1901 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1902 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1903# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1905 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1906 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1907# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1908#elif defined(__cplusplus) && \
1910 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1911 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1912 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1913 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1914 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1915 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1917# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1918#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1919# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1921# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1924#if defined(JSON_HEDLEY_NEVER_INLINE)
1925 #undef JSON_HEDLEY_NEVER_INLINE
1928 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1929 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1930 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1931 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1932 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1933 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1934 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1935 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1936 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1937 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1938 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1939 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1940 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1941 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1942 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1943 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1944 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1945 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1946 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1947 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1949 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1950 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1951 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1952#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1953 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1954#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1955 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1956#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1957 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1958#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1959 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1960#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1961 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1963 #define JSON_HEDLEY_NEVER_INLINE
1966#if defined(JSON_HEDLEY_PRIVATE)
1967 #undef JSON_HEDLEY_PRIVATE
1969#if defined(JSON_HEDLEY_PUBLIC)
1970 #undef JSON_HEDLEY_PUBLIC
1972#if defined(JSON_HEDLEY_IMPORT)
1973 #undef JSON_HEDLEY_IMPORT
1975#if defined(_WIN32) || defined(__CYGWIN__)
1976# define JSON_HEDLEY_PRIVATE
1977# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1978# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1981 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1982 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1983 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1984 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1985 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1986 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1988 defined(__TI_EABI__) && \
1990 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1991 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1994 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1995# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1996# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1998# define JSON_HEDLEY_PRIVATE
1999# define JSON_HEDLEY_PUBLIC
2001# define JSON_HEDLEY_IMPORT extern
2004#if defined(JSON_HEDLEY_NO_THROW)
2005 #undef JSON_HEDLEY_NO_THROW
2008 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2009 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2010 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2011 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2012 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2014 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2015 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2016 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2017 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2019 #define JSON_HEDLEY_NO_THROW
2022#if defined(JSON_HEDLEY_FALL_THROUGH)
2023 #undef JSON_HEDLEY_FALL_THROUGH
2026 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2027 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2028 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2029 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2030#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2031 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2032#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2033 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2034#elif defined(__fallthrough)
2035 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2037 #define JSON_HEDLEY_FALL_THROUGH
2040#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2041 #undef JSON_HEDLEY_RETURNS_NON_NULL
2044 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2045 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2046 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2047 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2048#elif defined(_Ret_notnull_)
2049 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2051 #define JSON_HEDLEY_RETURNS_NON_NULL
2054#if defined(JSON_HEDLEY_ARRAY_PARAM)
2055 #undef JSON_HEDLEY_ARRAY_PARAM
2058 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2059 !defined(__STDC_NO_VLA__) && \
2060 !defined(__cplusplus) && \
2061 !defined(JSON_HEDLEY_PGI_VERSION) && \
2062 !defined(JSON_HEDLEY_TINYC_VERSION)
2063 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2065 #define JSON_HEDLEY_ARRAY_PARAM(name)
2068#if defined(JSON_HEDLEY_IS_CONSTANT)
2069 #undef JSON_HEDLEY_IS_CONSTANT
2071#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2072 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2076#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2077 #undef JSON_HEDLEY_IS_CONSTEXPR_
2080 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2081 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2082 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2083 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2084 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2085 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2086 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2087 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2088 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2089 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2090 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2092#if !defined(__cplusplus)
2094 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2095 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2096 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2097 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2098 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2099 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2100 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2101#if defined(__INTPTR_TYPE__)
2102 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2105 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2109 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2110 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2111 !defined(JSON_HEDLEY_PGI_VERSION) && \
2112 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2113 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2114 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2115 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2116 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2117 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2118#if defined(__INTPTR_TYPE__)
2119 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2122 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2125 defined(JSON_HEDLEY_GCC_VERSION) || \
2126 defined(JSON_HEDLEY_INTEL_VERSION) || \
2127 defined(JSON_HEDLEY_TINYC_VERSION) || \
2128 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2129 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2130 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2131 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2132 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2133 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2135# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2139 ((void*) ((expr) * 0L) ) : \
2140((struct { char v[sizeof(void) * 2]; } *) 1) \
2146#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2147 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2148 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2150 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2152 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2153 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2155 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2158#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2159 #undef JSON_HEDLEY_BEGIN_C_DECLS
2161#if defined(JSON_HEDLEY_END_C_DECLS)
2162 #undef JSON_HEDLEY_END_C_DECLS
2164#if defined(JSON_HEDLEY_C_DECL)
2165 #undef JSON_HEDLEY_C_DECL
2167#if defined(__cplusplus)
2168 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2169 #define JSON_HEDLEY_END_C_DECLS }
2170 #define JSON_HEDLEY_C_DECL extern "C"
2172 #define JSON_HEDLEY_BEGIN_C_DECLS
2173 #define JSON_HEDLEY_END_C_DECLS
2174 #define JSON_HEDLEY_C_DECL
2177#if defined(JSON_HEDLEY_STATIC_ASSERT)
2178 #undef JSON_HEDLEY_STATIC_ASSERT
2181 !defined(__cplusplus) && ( \
2182 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2183 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2184 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2185 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2186 defined(_Static_assert) \
2188# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2190 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2191 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2192 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2193# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2195# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2198#if defined(JSON_HEDLEY_NULL)
2199 #undef JSON_HEDLEY_NULL
2201#if defined(__cplusplus)
2202 #if __cplusplus >= 201103L
2203 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2205 #define JSON_HEDLEY_NULL NULL
2207 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2210 #define JSON_HEDLEY_NULL NULL
2212 #define JSON_HEDLEY_NULL ((void*) 0)
2215#if defined(JSON_HEDLEY_MESSAGE)
2216 #undef JSON_HEDLEY_MESSAGE
2218#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2219# define JSON_HEDLEY_MESSAGE(msg) \
2220 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2221 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2222 JSON_HEDLEY_PRAGMA(message msg) \
2223 JSON_HEDLEY_DIAGNOSTIC_POP
2225 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2226 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2227# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2228#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2229# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2230#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2231# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2232#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2233# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2235# define JSON_HEDLEY_MESSAGE(msg)
2238#if defined(JSON_HEDLEY_WARNING)
2239 #undef JSON_HEDLEY_WARNING
2241#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2242# define JSON_HEDLEY_WARNING(msg) \
2243 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2244 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2245 JSON_HEDLEY_PRAGMA(clang warning msg) \
2246 JSON_HEDLEY_DIAGNOSTIC_POP
2248 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2249 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2250 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2251# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2253 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2254 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2255# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2257# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2260#if defined(JSON_HEDLEY_REQUIRE)
2261 #undef JSON_HEDLEY_REQUIRE
2263#if defined(JSON_HEDLEY_REQUIRE_MSG)
2264 #undef JSON_HEDLEY_REQUIRE_MSG
2266#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2267# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2268# define JSON_HEDLEY_REQUIRE(expr) \
2269 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2270 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2271 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2272 JSON_HEDLEY_DIAGNOSTIC_POP
2273# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2274 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2275 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2276 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2277 JSON_HEDLEY_DIAGNOSTIC_POP
2279# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2280# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2283# define JSON_HEDLEY_REQUIRE(expr)
2284# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2287#if defined(JSON_HEDLEY_FLAGS)
2288 #undef JSON_HEDLEY_FLAGS
2290#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2291 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2293 #define JSON_HEDLEY_FLAGS
2296#if defined(JSON_HEDLEY_FLAGS_CAST)
2297 #undef JSON_HEDLEY_FLAGS_CAST
2299#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2300# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2301 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2302 _Pragma("warning(disable:188)") \
2304 JSON_HEDLEY_DIAGNOSTIC_POP \
2307# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2310#if defined(JSON_HEDLEY_EMPTY_BASES)
2311 #undef JSON_HEDLEY_EMPTY_BASES
2314 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2315 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2316 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2318 #define JSON_HEDLEY_EMPTY_BASES
2323#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2324 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2326#if defined(__clang__)
2327 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2329 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2332#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2333 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2335#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2337#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2338 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2340#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2342#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2343 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2345#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2347#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2348 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2350#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2352#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2353 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2355#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2357#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2358 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2360#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2362#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2363 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2365#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2377#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2378 #if defined(__clang__)
2379 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2380 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2382 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2383 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2384 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2391#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2392 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2393 #define JSON_HAS_CPP_20
2394 #define JSON_HAS_CPP_17
2395 #define JSON_HAS_CPP_14
2396 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2397 #define JSON_HAS_CPP_17
2398 #define JSON_HAS_CPP_14
2399 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2400 #define JSON_HAS_CPP_14
2403 #define JSON_HAS_CPP_11
2407 #if __has_include(<version>)
2412#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2413 #ifdef JSON_HAS_CPP_17
2414 #if defined(__cpp_lib_filesystem)
2415 #define JSON_HAS_FILESYSTEM 1
2416 #elif defined(__cpp_lib_experimental_filesystem)
2417 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2418 #elif !defined(__has_include)
2419 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2420 #elif __has_include(<filesystem>)
2421 #define JSON_HAS_FILESYSTEM 1
2422 #elif __has_include(<experimental/filesystem>)
2423 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2427 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2428 #undef JSON_HAS_FILESYSTEM
2429 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2433 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2434 #undef JSON_HAS_FILESYSTEM
2435 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2439 #if defined(__clang_major__) && __clang_major__ < 7
2440 #undef JSON_HAS_FILESYSTEM
2441 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2445 #if defined(_MSC_VER) && _MSC_VER < 1914
2446 #undef JSON_HAS_FILESYSTEM
2447 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2451 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2452 #undef JSON_HAS_FILESYSTEM
2453 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2457 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2458 #undef JSON_HAS_FILESYSTEM
2459 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2464#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2465 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2468#ifndef JSON_HAS_FILESYSTEM
2469 #define JSON_HAS_FILESYSTEM 0
2472#ifndef JSON_HAS_THREE_WAY_COMPARISON
2473 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2474 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2475 #define JSON_HAS_THREE_WAY_COMPARISON 1
2477 #define JSON_HAS_THREE_WAY_COMPARISON 0
2481#ifndef JSON_HAS_RANGES
2483 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2484 #define JSON_HAS_RANGES 0
2485 #elif defined(__cpp_lib_ranges)
2486 #define JSON_HAS_RANGES 1
2488 #define JSON_HAS_RANGES 0
2492#ifndef JSON_HAS_STATIC_RTTI
2493 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2494 #define JSON_HAS_STATIC_RTTI 1
2496 #define JSON_HAS_STATIC_RTTI 0
2500#ifdef JSON_HAS_CPP_17
2501 #define JSON_INLINE_VARIABLE inline
2503 #define JSON_INLINE_VARIABLE
2506#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2507 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2509 #define JSON_NO_UNIQUE_ADDRESS
2513#if defined(__clang__)
2514 #pragma clang diagnostic push
2515 #pragma clang diagnostic ignored "-Wdocumentation"
2516 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2520#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2521 #define JSON_THROW(exception) throw exception
2522 #define JSON_TRY try
2523 #define JSON_CATCH(exception) catch(exception)
2524 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2527 #define JSON_THROW(exception) std::abort()
2528 #define JSON_TRY if(true)
2529 #define JSON_CATCH(exception) if(false)
2530 #define JSON_INTERNAL_CATCH(exception) if(false)
2534#if defined(JSON_THROW_USER)
2536 #define JSON_THROW JSON_THROW_USER
2538#if defined(JSON_TRY_USER)
2540 #define JSON_TRY JSON_TRY_USER
2542#if defined(JSON_CATCH_USER)
2544 #define JSON_CATCH JSON_CATCH_USER
2545 #undef JSON_INTERNAL_CATCH
2546 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2548#if defined(JSON_INTERNAL_CATCH_USER)
2549 #undef JSON_INTERNAL_CATCH
2550 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2554#if !defined(JSON_ASSERT)
2556 #define JSON_ASSERT(x) assert(x)
2560#if defined(JSON_TESTS_PRIVATE)
2561 #define JSON_PRIVATE_UNLESS_TESTED public
2563 #define JSON_PRIVATE_UNLESS_TESTED private
2571#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2572 template<typename BasicJsonType> \
2573 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2576 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2578 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2579 auto it = std::find_if(std::begin(m), std::end(m), \
2580 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2582 return ej_pair.first == e; \
2584 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2586 template<typename BasicJsonType> \
2587 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2590 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2592 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2593 auto it = std::find_if(std::begin(m), std::end(m), \
2594 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2596 return ej_pair.second == j; \
2598 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2604#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2605 template<template<typename, typename, typename...> class ObjectType, \
2606 template<typename, typename...> class ArrayType, \
2607 class StringType, class BooleanType, class NumberIntegerType, \
2608 class NumberUnsignedType, class NumberFloatType, \
2609 template<typename> class AllocatorType, \
2610 template<typename, typename = void> class JSONSerializer, \
2612 class CustomBaseClass>
2614#define NLOHMANN_BASIC_JSON_TPL \
2615 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2616 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2617 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2621#define NLOHMANN_JSON_EXPAND( x ) x
2622#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
2623#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2624 NLOHMANN_JSON_PASTE64, \
2625 NLOHMANN_JSON_PASTE63, \
2626 NLOHMANN_JSON_PASTE62, \
2627 NLOHMANN_JSON_PASTE61, \
2628 NLOHMANN_JSON_PASTE60, \
2629 NLOHMANN_JSON_PASTE59, \
2630 NLOHMANN_JSON_PASTE58, \
2631 NLOHMANN_JSON_PASTE57, \
2632 NLOHMANN_JSON_PASTE56, \
2633 NLOHMANN_JSON_PASTE55, \
2634 NLOHMANN_JSON_PASTE54, \
2635 NLOHMANN_JSON_PASTE53, \
2636 NLOHMANN_JSON_PASTE52, \
2637 NLOHMANN_JSON_PASTE51, \
2638 NLOHMANN_JSON_PASTE50, \
2639 NLOHMANN_JSON_PASTE49, \
2640 NLOHMANN_JSON_PASTE48, \
2641 NLOHMANN_JSON_PASTE47, \
2642 NLOHMANN_JSON_PASTE46, \
2643 NLOHMANN_JSON_PASTE45, \
2644 NLOHMANN_JSON_PASTE44, \
2645 NLOHMANN_JSON_PASTE43, \
2646 NLOHMANN_JSON_PASTE42, \
2647 NLOHMANN_JSON_PASTE41, \
2648 NLOHMANN_JSON_PASTE40, \
2649 NLOHMANN_JSON_PASTE39, \
2650 NLOHMANN_JSON_PASTE38, \
2651 NLOHMANN_JSON_PASTE37, \
2652 NLOHMANN_JSON_PASTE36, \
2653 NLOHMANN_JSON_PASTE35, \
2654 NLOHMANN_JSON_PASTE34, \
2655 NLOHMANN_JSON_PASTE33, \
2656 NLOHMANN_JSON_PASTE32, \
2657 NLOHMANN_JSON_PASTE31, \
2658 NLOHMANN_JSON_PASTE30, \
2659 NLOHMANN_JSON_PASTE29, \
2660 NLOHMANN_JSON_PASTE28, \
2661 NLOHMANN_JSON_PASTE27, \
2662 NLOHMANN_JSON_PASTE26, \
2663 NLOHMANN_JSON_PASTE25, \
2664 NLOHMANN_JSON_PASTE24, \
2665 NLOHMANN_JSON_PASTE23, \
2666 NLOHMANN_JSON_PASTE22, \
2667 NLOHMANN_JSON_PASTE21, \
2668 NLOHMANN_JSON_PASTE20, \
2669 NLOHMANN_JSON_PASTE19, \
2670 NLOHMANN_JSON_PASTE18, \
2671 NLOHMANN_JSON_PASTE17, \
2672 NLOHMANN_JSON_PASTE16, \
2673 NLOHMANN_JSON_PASTE15, \
2674 NLOHMANN_JSON_PASTE14, \
2675 NLOHMANN_JSON_PASTE13, \
2676 NLOHMANN_JSON_PASTE12, \
2677 NLOHMANN_JSON_PASTE11, \
2678 NLOHMANN_JSON_PASTE10, \
2679 NLOHMANN_JSON_PASTE9, \
2680 NLOHMANN_JSON_PASTE8, \
2681 NLOHMANN_JSON_PASTE7, \
2682 NLOHMANN_JSON_PASTE6, \
2683 NLOHMANN_JSON_PASTE5, \
2684 NLOHMANN_JSON_PASTE4, \
2685 NLOHMANN_JSON_PASTE3, \
2686 NLOHMANN_JSON_PASTE2, \
2687 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2688#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2689#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2690#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2691#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2692#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2693#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)
2694#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)
2695#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)
2696#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)
2697#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)
2698#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)
2699#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)
2700#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)
2701#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)
2702#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)
2703#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)
2704#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)
2705#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)
2706#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)
2707#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)
2708#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)
2709#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)
2710#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)
2711#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)
2712#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)
2713#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)
2714#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)
2715#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)
2716#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)
2717#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)
2718#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)
2719#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)
2720#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)
2721#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)
2722#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)
2723#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)
2724#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)
2725#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)
2726#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)
2727#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)
2728#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)
2729#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)
2730#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)
2731#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)
2732#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)
2733#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)
2734#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)
2735#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)
2736#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)
2737#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)
2738#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)
2739#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)
2740#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)
2741#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)
2742#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)
2743#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)
2744#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)
2745#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)
2746#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)
2747#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)
2748#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)
2749#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)
2750#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)
2752#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2753#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2754#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2761#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2762 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2763 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2765#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2766 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2767 friend void from_json(const nlohmann::json& 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__)) }
2769#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2770 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2777#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2778 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2779 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2781#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2782 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2784#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2785 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2786 inline void from_json(const nlohmann::json& 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__)) }
2793#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2794 friend void to_json(nlohmann::json& 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__)) } \
2795 friend void from_json(const nlohmann::json& 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__)) }
2797#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2798 friend void to_json(nlohmann::json& 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__)) } \
2799 friend void from_json(const nlohmann::json& 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__)) }
2806#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2807 inline void to_json(nlohmann::json& 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__)) } \
2808 inline void from_json(const nlohmann::json& 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__)) }
2810#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2811 inline void to_json(nlohmann::json& 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__)) } \
2812 inline void from_json(const nlohmann::json& 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__)) }
2820#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2821 namespace detail { \
2822 using std::std_name; \
2824 template<typename... T> \
2825 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2828 namespace detail2 { \
2829 struct std_name##_tag \
2833 template<typename... T> \
2834 std_name##_tag std_name(T&&...); \
2836 template<typename... T> \
2837 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2839 template<typename... T> \
2840 struct would_call_std_##std_name \
2842 static constexpr auto const value = ::nlohmann::detail:: \
2843 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2847 template<typename... T> \
2848 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2852#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2853 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2856#if JSON_USE_IMPLICIT_CONVERSIONS
2857 #define JSON_EXPLICIT
2859 #define JSON_EXPLICIT explicit
2862#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2863 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2866#ifndef JSON_USE_GLOBAL_UDLS
2867 #define JSON_USE_GLOBAL_UDLS 1
2870#if JSON_HAS_THREE_WAY_COMPARISON
2933#if JSON_HAS_THREE_WAY_COMPARISON
2934 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2939 static constexpr std::array<std::uint8_t, 9> order = {{
2946 const auto l_index =
static_cast<std::size_t
>(lhs);
2947 const auto r_index =
static_cast<std::size_t
>(rhs);
2948#if JSON_HAS_THREE_WAY_COMPARISON
2949 if (l_index < order.size() && r_index < order.size())
2951 return order[l_index] <=> order[r_index];
2953 return std::partial_ordering::unordered;
2955 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2963#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2966 return std::is_lt(lhs <=> rhs);
3004template<
typename StringType>
3006 const StringType& t)
3009 for (
auto pos = s.find(f);
3010 pos != StringType::npos;
3011 s.replace(pos, f.size(), t),
3012 pos = s.find(f, pos + t.size()))
3023template<
typename StringType>
3038template<
typename StringType>
3039static void unescape(StringType& s)
3079 constexpr operator size_t()
const
3104#include <type_traits>
3115using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3117#ifdef JSON_HAS_CPP_14
3120using std::enable_if_t;
3121using std::index_sequence;
3122using std::make_index_sequence;
3123using std::index_sequence_for;
3128template<
bool B,
typename T =
void>
3155template <
typename T, T... Ints>
3159 static constexpr std::size_t
size() noexcept
3161 return sizeof...(Ints);
3170template <
size_t... Ints>
3173namespace utility_internal
3176template <
typename Seq,
size_t SeqSize,
size_t Rem>
3180template <
typename T, T... Ints,
size_t SeqSize>
3186template <
typename T, T... Ints,
size_t SeqSize>
3194template <
typename T,
size_t N>
3201template <
typename T>
3216template <
typename T, T N>
3232template <
typename... Ts>
3250#ifndef JSON_HAS_CPP_17
3251 template<
typename T>
3255template<
typename T,
typename... Args>
3256constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3258 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3276#include <type_traits>
3305template<
typename It,
typename =
void>
3308template<
typename It>
3312 typename It::reference, typename It::iterator_category >>
3323template<
typename T,
typename =
void>
3402#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3403 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3428 template<
typename T =
void,
typename SFINAE =
void>
3433 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3435 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3436 class StringType = std::string,
class BooleanType = bool,
3437 class NumberIntegerType = std::int64_t,
3438 class NumberUnsignedType = std::uint64_t,
3439 class NumberFloatType = double,
3440 template<
typename U>
class AllocatorType = std::allocator,
3441 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3443 class BinaryType = std::vector<std::uint8_t>,
3444 class CustomBaseClass =
void>
3449 template<
typename RefStringType>
3460 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3505template<
typename BasicJsonContext>
3507 std::integral_constant < bool,
3508 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3509 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3550template<
typename T,
typename... Args>
3553template<
typename T,
typename... Args>
3556template<
typename T,
typename U>
3560template<
typename BasicJsonType,
typename T,
typename =
void>
3567template <
typename BasicJsonType,
typename T>
3573template<
typename BasicJsonType,
typename T>
3576 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3580 const BasicJsonType&, T&>
::value;
3585template<
typename BasicJsonType,
typename T,
typename =
void>
3588template<
typename BasicJsonType,
typename T>
3591 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3600template<
typename BasicJsonType,
typename T,
typename =
void>
3603template<
typename BasicJsonType,
typename T>
3606 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3617struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3620template<
typename BasicJsonType>
3625 using type =
typename std::conditional < has_key_compare<object_t>::value,
3629template<
typename BasicJsonType>
3696template<
class B,
class... Bn>
3698: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3701template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3706template <
typename T>
3709template <
typename T1,
typename T2>
3711 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3713template <
typename T1,
typename T2>
3715 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3717template <
typename... Ts>
3719 :
conjunction<is_default_constructible<Ts>...> {};
3721template <
typename... Ts>
3723 :
conjunction<is_default_constructible<Ts>...> {};
3725template <
typename T,
typename... Args>
3728template <
typename T1,
typename T2>
3731template <
typename T1,
typename T2>
3734template <
typename... Ts>
3737template <
typename... Ts>
3740template<
typename T,
typename =
void>
3762 using t_ref =
typename std::add_lvalue_reference<T>::type;
3770 static constexpr auto is_iterator_begin =
3774 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3787template<
typename T,
typename =
void>
3793template<
typename BasicJsonType,
typename CompatibleObjectType,
3797template<
typename BasicJsonType,
typename CompatibleObjectType>
3799 BasicJsonType, CompatibleObjectType,
3808 typename CompatibleObjectType::key_type>
::value &&
3810 typename CompatibleObjectType::mapped_type>
::value;
3813template<
typename BasicJsonType,
typename CompatibleObjectType>
3817template<
typename BasicJsonType,
typename ConstructibleObjectType,
3821template<
typename BasicJsonType,
typename ConstructibleObjectType>
3823 BasicJsonType, ConstructibleObjectType,
3831 (std::is_move_assignable<ConstructibleObjectType>::value ||
3832 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3834 typename object_t::key_type>
::value &&
3836 typename object_t::mapped_type,
3837 typename ConstructibleObjectType::mapped_type >
::value)) ||
3839 typename ConstructibleObjectType::mapped_type>
::value ||
3842 typename ConstructibleObjectType::mapped_type >
::value);
3845template<
typename BasicJsonType,
typename ConstructibleObjectType>
3848 ConstructibleObjectType> {};
3850template<
typename BasicJsonType,
typename CompatibleStringType>
3857template<
typename BasicJsonType,
typename ConstructibleStringType>
3861#ifdef __INTEL_COMPILER
3862 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3874template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3877template<
typename BasicJsonType,
typename CompatibleArrayType>
3879 BasicJsonType, CompatibleArrayType,
3885 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3892template<
typename BasicJsonType,
typename CompatibleArrayType>
3896template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3899template<
typename BasicJsonType,
typename ConstructibleArrayType>
3901 BasicJsonType, ConstructibleArrayType,
3903 typename BasicJsonType::value_type>
::value >>
3904 : std::true_type {};
3906template<
typename BasicJsonType,
typename ConstructibleArrayType>
3908 BasicJsonType, ConstructibleArrayType,
3910 typename BasicJsonType::value_type>
::value&&
3913(std::is_move_assignable<ConstructibleArrayType>::value ||
3914 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3920!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3922 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3928 typename BasicJsonType::array_t::value_type>
::value ||
3936template<
typename BasicJsonType,
typename ConstructibleArrayType>
3940template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3944template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3946 RealIntegerType, CompatibleNumberIntegerType,
3948 std::is_integral<CompatibleNumberIntegerType>
::value&&
3949 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3957 CompatibleNumberIntegerType>
::value &&
3958 CompatibleLimits::is_integer &&
3959 RealLimits::is_signed == CompatibleLimits::is_signed;
3962template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3965 CompatibleNumberIntegerType> {};
3967template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3970template<
typename BasicJsonType,
typename CompatibleType>
3972 BasicJsonType, CompatibleType,
3979template<
typename BasicJsonType,
typename CompatibleType>
3983template<
typename T1,
typename T2>
3986template<
typename T1,
typename... Args>
3989template<
typename BasicJsonType,
typename T>
3992template<
typename BasicJsonType>
3995template<
typename BasicJsonType>
4000template<
template <
typename...>
class Primary,
typename T>
4003template<
template <
typename...>
class Primary,
typename... Args>
4010template<
typename Compare,
typename A,
typename B,
typename =
void>
4013template<
typename Compare,
typename A,
typename B>
4015decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4016decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4017>> : std::true_type {};
4024template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4028 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4030 && (!RequireTransparentComparator
4031 || is_detected <detect_is_transparent, Comparator>::value)
4034 std::false_type >::type;
4042template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4046 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4047 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4050 std::false_type >::type;
4052template<
typename ObjectType,
typename KeyType>
4056template<
typename BasicJsonType,
typename KeyType>
4060 typename BasicJsonType::object_t, KeyType >
::value,
4062 std::false_type >::type;
4066template <
typename T>
4076 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4079 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
4083template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4086 return static_cast<T
>(
value);
4089template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4095template<
typename... Types>
4098template<
typename... Types>
4101template<
typename... Types>
4105template<
typename... Types>
4109template<
typename OfType,
typename T>
4111 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4114template<
typename OfType,
typename T,
4115 bool OfTypeSigned = std::is_signed<OfType>::value,
4116 bool TSigned = std::is_signed<T>::value>
4119template<
typename OfType,
typename T>
4124 using CommonType =
typename std::common_type<OfType, T>::type;
4125 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4129template<
typename OfType,
typename T>
4134 using CommonType =
typename std::common_type<OfType, T>::type;
4135 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4139template<
typename OfType,
typename T>
4144 using CommonType =
typename std::common_type<OfType, T>::type;
4145 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4149template<
typename OfType,
typename T>
4154 using CommonType =
typename std::common_type<OfType, T>::type;
4155 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4156 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4160template<
typename OfType,
typename T,
4161 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4165template<
typename OfType,
typename T>
4174template<
typename OfType,
typename T>
4183template<
typename OfType,
typename T>
4202 using TUnExt =
typename std::remove_extent<T>::type;
4203 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4204 using TUnPtr =
typename std::remove_pointer<T>::type;
4205 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4207 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4208 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4273template<
typename... Args>
4274inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4276template<
typename StringType,
typename... Args>
4277inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4279template<
typename... Args>
4285template<
typename... Args>
4292template<
typename StringType,
typename... Args>
4298template<
typename OutStringType>
4302template<
typename StringType,
typename Arg>
4305template<
typename StringType,
typename Arg>
4308template<
typename StringType,
typename Arg>
4311template<
typename StringType,
typename Arg>
4314template<
typename StringType,
typename Arg>
4315using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4317template<
typename StringType,
typename Arg>
4320template<
typename StringType,
typename Arg>
4321using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4323template<
typename StringType,
typename Arg>
4326template <
typename OutStringType,
typename Arg,
typename... Args,
4327 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4329inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4331template <
typename OutStringType,
typename Arg,
typename... Args,
4332 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4335inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4337template <
typename OutStringType,
typename Arg,
typename... Args,
4338 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4342inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4344template<
typename OutStringType,
typename Arg,
typename... Args,
4346inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4348 out.append(std::forward<Arg>(arg));
4352template <
typename OutStringType,
typename Arg,
typename... Args,
4353 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4354 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4355inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4357 out += std::forward<Arg>(arg);
4361template <
typename OutStringType,
typename Arg,
typename... Args,
4362 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4363 && !detect_string_can_append_op<OutStringType, Arg>::value
4364 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4365inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4367 out.append(arg.begin(), arg.end());
4371template <
typename OutStringType,
typename Arg,
typename... Args,
4372 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4373 && !detect_string_can_append_op<OutStringType, Arg>::value
4374 && !detect_string_can_append_iter<OutStringType, Arg>::value
4375 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4376inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4378 out.append(arg.data(), arg.size());
4382template<
typename OutStringType = std::string,
typename... Args>
4402#if defined(__clang__)
4403 #pragma clang diagnostic push
4404 #pragma clang diagnostic ignored "-Wweak-vtables"
4421 const char*
what() const noexcept
override
4431 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4433 static std::string
name(
const std::string& ename,
int id_)
4435 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4443 template<
typename BasicJsonType>
4447 std::vector<std::string> tokens;
4448 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4450 switch (current->m_parent->type())
4454 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4456 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4458 tokens.emplace_back(std::to_string(i));
4467 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4469 if (&element.second == current)
4471 tokens.emplace_back(element.first.c_str());
4496 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4497 [](
const std::string & a,
const std::string & b)
4499 return concat(a,
'/', detail::escape(b));
4501 return concat(
'(', str,
") ");
4503 static_cast<void>(leaf_element);
4510 std::runtime_error m;
4527 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4535 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4536 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4539 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4541 return {id_, byte_, w.c_str()};
4556 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4559 static std::string position_string(
const position_t& pos)
4571 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4575 return {id_, w.c_str()};
4589 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4593 return {id_, w.c_str()};
4606 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4610 return {id_, w.c_str()};
4623 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4627 return {id_, w.c_str()};
4638#if defined(__clang__)
4639 #pragma clang diagnostic pop
4684#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4685#include <experimental/filesystem>
4689namespace std_fs = std::experimental::filesystem;
4692#elif JSON_HAS_FILESYSTEM
4693#include <filesystem>
4697namespace std_fs = std::filesystem;
4713template<
typename BasicJsonType>
4714inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4723#ifdef JSON_HAS_CPP_17
4724#ifndef JSON_USE_IMPLICIT_CONVERSIONS
4725template<
typename BasicJsonType,
typename T>
4726void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4734 opt.emplace(j.template get<T>());
4742template <
typename BasicJsonType,
typename ArithmeticType,
4743 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4744 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4748 switch (
static_cast<value_t>(j))
4752 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4757 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4762 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4778template<
typename BasicJsonType>
4779inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4785 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4788template<
typename BasicJsonType>
4789inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4795 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4799 typename BasicJsonType,
typename StringType,
4801 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4802 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4803 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4804 && !is_json_ref<StringType>::value,
int > = 0 >
4812 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4815template<
typename BasicJsonType>
4816inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4821template<
typename BasicJsonType>
4822inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4827template<
typename BasicJsonType>
4828inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4833#if !JSON_DISABLE_ENUM_SERIALIZATION
4834template<
typename BasicJsonType,
typename EnumType,
4835 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4838 typename std::underlying_type<EnumType>::type val;
4840 e =
static_cast<EnumType
>(val);
4845template<
typename BasicJsonType,
typename T,
typename Allocator,
4846 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4847inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4854 std::transform(j.rbegin(), j.rend(),
4855 std::front_inserter(l), [](
const BasicJsonType & i)
4857 return i.template get<T>();
4862template<
typename BasicJsonType,
typename T,
4863 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4864inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4871 std::transform(j.begin(), j.end(), std::begin(l),
4872 [](
const BasicJsonType & elem)
4874 return elem.template get<T>();
4878template<
typename BasicJsonType,
typename T, std::
size_t N>
4880->
decltype(j.template get<T>(), void())
4882 for (std::size_t i = 0; i < N; ++i)
4884 arr[i] = j.at(i).template get<T>();
4888template<
typename BasicJsonType>
4891 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4894template<
typename BasicJsonType,
typename T, std::
size_t N>
4897->
decltype(j.template get<T>(), void())
4899 for (std::size_t i = 0; i < N; ++i)
4901 arr[i] = j.at(i).template get<T>();
4905template<
typename BasicJsonType,
typename ConstructibleArrayType,
4907 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4911 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4912 j.template get<typename ConstructibleArrayType::value_type>(),
4917 ConstructibleArrayType ret;
4918 ret.reserve(j.size());
4919 std::transform(j.begin(), j.end(),
4920 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4924 return i.template get<typename ConstructibleArrayType::value_type>();
4926 arr = std::move(ret);
4929template<
typename BasicJsonType,
typename ConstructibleArrayType,
4931 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4938 ConstructibleArrayType ret;
4940 j.begin(), j.end(), std::inserter(ret, end(ret)),
4941 [](
const BasicJsonType & i)
4945 return i.template get<typename ConstructibleArrayType::value_type>();
4947 arr = std::move(ret);
4950template <
typename BasicJsonType,
typename ConstructibleArrayType,
4952 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4953 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4955 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4956 !is_basic_json<ConstructibleArrayType>::value,
4958auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4960j.template get<typename ConstructibleArrayType::value_type>(),
4971template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4975 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4978template <
typename BasicJsonType,
typename T, std::
size_t N >
4990template<
typename BasicJsonType>
4991inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4998 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5001template<
typename BasicJsonType,
typename ConstructibleObjectType,
5002 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5003inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5010 ConstructibleObjectType ret;
5011 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5012 using value_type =
typename ConstructibleObjectType::value_type;
5014 inner_object->begin(), inner_object->end(),
5015 std::inserter(ret, ret.begin()),
5016 [](
typename BasicJsonType::object_t::value_type
const & p)
5018 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5020 obj = std::move(ret);
5027template <
typename BasicJsonType,
typename ArithmeticType,
5029 std::is_arithmetic<ArithmeticType>::value&&
5030 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5031 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5032 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5033 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5035inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5037 switch (
static_cast<value_t>(j))
5041 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5046 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5051 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5056 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5071template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5074 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5077template <
typename BasicJsonType,
class A1,
class A2 >
5080 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
5081 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
5084template<
typename BasicJsonType,
typename A1,
typename A2>
5090template<
typename BasicJsonType,
typename... Args>
5096template<
typename BasicJsonType,
typename... Args>
5102template<
typename BasicJsonType,
typename TupleRelated>
5111 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5114template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5116 typename BasicJsonType::string_t, Key >
::value >>
5117inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5124 for (
const auto& p : j)
5130 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5134template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5136 typename BasicJsonType::string_t, Key >
::value >>
5137inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5144 for (
const auto& p : j)
5150 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5154#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5155template<
typename BasicJsonType>
5156inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5162 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5168 template<
typename BasicJsonType,
typename T>
5170 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5171 ->
decltype(
from_json(j, std::forward<T>(val)))
5173 return from_json(j, std::forward<T>(val));
5179#ifndef JSON_HAS_CPP_17
5188#ifndef JSON_HAS_CPP_17
5207#ifdef JSON_HAS_CPP_17
5212#include <type_traits>
5249template<
typename string_type>
5253 using std::to_string;
5264 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5268 IteratorType anchor{};
5270 std::size_t array_index = 0;
5272 mutable std::size_t array_index_last = 0;
5281 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5283 : anchor(
std::move(it))
5284 , array_index(array_index_)
5291 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5294 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5324 return anchor == o.anchor;
5330 return anchor != o.anchor;
5338 switch (anchor.m_object->type())
5343 if (array_index != array_index_last)
5346 array_index_last = array_index;
5348 return array_index_str;
5353 return anchor.key();
5370 typename IteratorType::reference
value()
const
5372 return anchor.value();
5381 typename IteratorType::pointer container =
nullptr;
5388 : container(&cont) {}
5412template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5413auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5420template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5421auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5436#if defined(__clang__)
5438 #pragma clang diagnostic push
5439 #pragma clang diagnostic ignored "-Wmismatched-tags"
5441template<
typename IteratorType>
5442class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5443 :
public std::integral_constant<std::size_t, 2> {};
5445template<std::
size_t N,
typename IteratorType>
5446class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5450 get<N>(std::declval <
5451 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5453#if defined(__clang__)
5454 #pragma clang diagnostic pop
5460 template <
typename IteratorType>
5461 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5495 template<
typename BasicJsonType>
5496 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5498 j.m_data.m_value.destroy(j.m_data.m_type);
5500 j.m_data.m_value = b;
5501 j.assert_invariant();
5508 template<
typename BasicJsonType>
5509 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5511 j.m_data.m_value.destroy(j.m_data.m_type);
5513 j.m_data.m_value = s;
5514 j.assert_invariant();
5517 template<
typename BasicJsonType>
5518 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5520 j.m_data.m_value.destroy(j.m_data.m_type);
5522 j.m_data.m_value = std::move(s);
5523 j.assert_invariant();
5526 template <
typename BasicJsonType,
typename CompatibleStringType,
5527 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5529 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5531 j.m_data.m_value.destroy(j.m_data.m_type);
5533 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5534 j.assert_invariant();
5541 template<
typename BasicJsonType>
5542 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5544 j.m_data.m_value.destroy(j.m_data.m_type);
5546 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5547 j.assert_invariant();
5550 template<
typename BasicJsonType>
5551 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5553 j.m_data.m_value.destroy(j.m_data.m_type);
5555 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5556 j.assert_invariant();
5563 template<
typename BasicJsonType>
5564 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5566 j.m_data.m_value.destroy(j.m_data.m_type);
5568 j.m_data.m_value = val;
5569 j.assert_invariant();
5576 template<
typename BasicJsonType>
5577 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5579 j.m_data.m_value.destroy(j.m_data.m_type);
5581 j.m_data.m_value = val;
5582 j.assert_invariant();
5589 template<
typename BasicJsonType>
5590 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5592 j.m_data.m_value.destroy(j.m_data.m_type);
5594 j.m_data.m_value = val;
5595 j.assert_invariant();
5602 template<
typename BasicJsonType>
5603 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5605 j.m_data.m_value.destroy(j.m_data.m_type);
5607 j.m_data.m_value = arr;
5609 j.assert_invariant();
5612 template<
typename BasicJsonType>
5613 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5615 j.m_data.m_value.destroy(j.m_data.m_type);
5617 j.m_data.m_value = std::move(arr);
5619 j.assert_invariant();
5622 template <
typename BasicJsonType,
typename CompatibleArrayType,
5623 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5625 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5630 j.m_data.m_value.destroy(j.m_data.m_type);
5632 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5634 j.assert_invariant();
5637 template<
typename BasicJsonType>
5638 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5640 j.m_data.m_value.destroy(j.m_data.m_type);
5643 j.m_data.m_value.array->reserve(arr.size());
5644 for (
const bool x : arr)
5646 j.m_data.m_value.array->push_back(x);
5647 j.set_parent(j.m_data.m_value.array->back());
5649 j.assert_invariant();
5652 template<
typename BasicJsonType,
typename T,
5654 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5656 j.m_data.m_value.destroy(j.m_data.m_type);
5659 j.m_data.m_value.array->resize(arr.size());
5662 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5665 j.assert_invariant();
5672 template<
typename BasicJsonType>
5673 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5675 j.m_data.m_value.destroy(j.m_data.m_type);
5677 j.m_data.m_value = obj;
5679 j.assert_invariant();
5682 template<
typename BasicJsonType>
5683 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5685 j.m_data.m_value.destroy(j.m_data.m_type);
5687 j.m_data.m_value = std::move(obj);
5689 j.assert_invariant();
5692 template <
typename BasicJsonType,
typename CompatibleObjectType,
5693 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5694 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5699 j.m_data.m_value.destroy(j.m_data.m_type);
5701 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5703 j.assert_invariant();
5711#ifdef JSON_HAS_CPP_17
5712template<
typename BasicJsonType,
typename T,
5713 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
5714void to_json(BasicJsonType& j,
const std::optional<T>& opt)
5716 if (opt.has_value())
5727template<
typename BasicJsonType,
typename T,
5728 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5729inline void to_json(BasicJsonType& j, T b)
noexcept
5734template <
typename BasicJsonType,
typename BoolRef,
5736 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5737 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5738 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5740 typename BasicJsonType::boolean_t >
::value))
5741 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5742inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5747template<
typename BasicJsonType,
typename CompatibleString,
5748 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5749inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5754template<
typename BasicJsonType>
5755inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5760template<
typename BasicJsonType,
typename FloatType,
5761 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5762inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5767template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5768 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5769inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5774template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5775 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5776inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5781#if !JSON_DISABLE_ENUM_SERIALIZATION
5782template<
typename BasicJsonType,
typename EnumType,
5783 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5784inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5786 using underlying_type =
typename std::underlying_type<EnumType>::type;
5792template<
typename BasicJsonType>
5793inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5798template <
typename BasicJsonType,
typename CompatibleArrayType,
5799 enable_if_t < is_compatible_array_type<BasicJsonType,
5801 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5803 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5804 !is_basic_json<CompatibleArrayType>::value,
5806inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5811template<
typename BasicJsonType>
5812inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5817template<
typename BasicJsonType,
typename T,
5818 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5819inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5824template<
typename BasicJsonType>
5825inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5830template <
typename BasicJsonType,
typename CompatibleObjectType,
5831 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5832inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5837template<
typename BasicJsonType>
5838inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5844 typename BasicJsonType,
typename T, std::size_t N,
5845 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5848inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5853template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5854inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5856 j = { p.first, p.second };
5860template<
typename BasicJsonType,
typename T,
5861 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
5864 j = { {b.key(), b.value()} };
5867template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5870 j = { std::get<Idx>(t)... };
5873template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5874inline void to_json(BasicJsonType& j,
const T& t)
5879#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5880template<
typename BasicJsonType>
5881inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5889 template<
typename BasicJsonType,
typename T>
5890 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5891 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5893 return to_json(j, std::forward<T>(val));
5898#ifndef JSON_HAS_CPP_17
5907#ifndef JSON_HAS_CPP_17
5919template<
typename ValueType,
typename>
5924 template<
typename BasicJsonType,
typename TargetType = ValueType>
5925 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5926 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5927 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
5929 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5934 template<
typename BasicJsonType,
typename TargetType = ValueType>
5944 template<
typename BasicJsonType,
typename TargetType = ValueType>
5945 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5946 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5947 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
5949 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5977template<
typename BinaryType>
6002 , m_subtype(subtype_)
6003 , m_has_subtype(
true)
6009 , m_subtype(subtype_)
6010 , m_has_subtype(
true)
6015 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
6016 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
6021 return !(rhs == *
this);
6028 m_subtype = subtype_;
6029 m_has_subtype =
true;
6036 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
6043 return m_has_subtype;
6051 m_has_subtype =
false;
6056 bool m_has_subtype =
false;
6080#include <functional>
6092inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6094 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6109template<
typename BasicJsonType>
6110std::size_t
hash(
const BasicJsonType& j)
6112 using string_t =
typename BasicJsonType::string_t;
6113 using number_integer_t =
typename BasicJsonType::number_integer_t;
6114 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6115 using number_float_t =
typename BasicJsonType::number_float_t;
6117 const auto type =
static_cast<std::size_t
>(j.type());
6120 case BasicJsonType::value_t::null:
6121 case BasicJsonType::value_t::discarded:
6126 case BasicJsonType::value_t::object:
6128 auto seed =
combine(type, j.size());
6129 for (
const auto& element : j.items())
6131 const auto h = std::hash<string_t> {}(element.key());
6138 case BasicJsonType::value_t::array:
6140 auto seed =
combine(type, j.size());
6141 for (
const auto& element : j)
6148 case BasicJsonType::value_t::string:
6150 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6154 case BasicJsonType::value_t::boolean:
6156 const auto h = std::hash<bool> {}(j.template get<bool>());
6160 case BasicJsonType::value_t::number_integer:
6162 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6166 case BasicJsonType::value_t::number_unsigned:
6168 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6172 case BasicJsonType::value_t::number_float:
6174 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6178 case BasicJsonType::value_t::binary:
6180 auto seed =
combine(type, j.get_binary().size());
6181 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6183 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6184 for (
const auto byte : j.get_binary())
6186 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6244#include <type_traits>
6298 return std::fgetc(m_file);
6326 is->clear(is->rdstate() & std::ios::eofbit);
6331 : is(&i), sb(i.rdbuf())
6340 : is(rhs.is), sb(rhs.sb)
6351 auto res = sb->sbumpc();
6355 is->clear(is->rdstate() | std::ios::eofbit);
6362 std::istream* is =
nullptr;
6363 std::streambuf* sb =
nullptr;
6369template<
typename IteratorType>
6373 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6376 : current(
std::move(first)), end(
std::move(last))
6384 std::advance(current, 1);
6392 IteratorType current;
6395 template<
typename BaseInputAdapter,
size_t T>
6400 return current == end;
6404template<
typename BaseInputAdapter,
size_t T>
6407template<
typename BaseInputAdapter>
6412 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6413 size_t& utf8_bytes_index,
6414 size_t& utf8_bytes_filled)
6416 utf8_bytes_index = 0;
6420 utf8_bytes[0] = std::char_traits<char>::eof();
6421 utf8_bytes_filled = 1;
6426 const auto wc = input.get_character();
6431 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6432 utf8_bytes_filled = 1;
6434 else if (wc <= 0x7FF)
6436 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6437 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6438 utf8_bytes_filled = 2;
6440 else if (wc <= 0xFFFF)
6442 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6443 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6444 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6445 utf8_bytes_filled = 3;
6447 else if (wc <= 0x10FFFF)
6449 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6450 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6451 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6452 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6453 utf8_bytes_filled = 4;
6458 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6459 utf8_bytes_filled = 1;
6465template<
typename BaseInputAdapter>
6470 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6471 size_t& utf8_bytes_index,
6472 size_t& utf8_bytes_filled)
6474 utf8_bytes_index = 0;
6478 utf8_bytes[0] = std::char_traits<char>::eof();
6479 utf8_bytes_filled = 1;
6484 const auto wc = input.get_character();
6489 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6490 utf8_bytes_filled = 1;
6492 else if (wc <= 0x7FF)
6494 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6495 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6496 utf8_bytes_filled = 2;
6498 else if (0xD800 > wc || wc >= 0xE000)
6500 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6501 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6502 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6503 utf8_bytes_filled = 3;
6509 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6510 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6511 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6512 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6513 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6514 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6515 utf8_bytes_filled = 4;
6519 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6520 utf8_bytes_filled = 1;
6528template<
typename BaseInputAdapter,
typename W
ideCharType>
6535 : base_adapter(base) {}
6540 if (utf8_bytes_index == utf8_bytes_filled)
6542 fill_buffer<sizeof(WideCharType)>();
6550 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6551 return utf8_bytes[utf8_bytes_index++];
6555 BaseInputAdapter base_adapter;
6564 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6567 std::size_t utf8_bytes_index = 0;
6569 std::size_t utf8_bytes_filled = 0;
6572template<
typename IteratorType,
typename Enable =
void>
6576 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6581 return adapter_type(std::move(first), std::move(last));
6595template<
typename IteratorType>
6599 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6610template<
typename IteratorType>
6614 return factory_type::create(first, last);
6621namespace container_input_adapter_factory_impl
6627template<
typename ContainerType,
typename Enable =
void>
6630template<
typename ContainerType>
6632 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6644template<
typename ContainerType>
6654 if (file ==
nullptr)
6656 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));
6675template <
typename CharT,
6676 typename std::enable_if <
6677 std::is_pointer<CharT>::value&&
6678 !std::is_array<CharT>::value&&
6679 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6680 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6686 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));
6688 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6689 const auto* ptr =
reinterpret_cast<const char*
>(b);
6693template<
typename T, std::
size_t N>
6705 template <
typename CharT,
6706 typename std::enable_if <
6707 std::is_pointer<CharT>::value&&
6708 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6709 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6712 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6714 template<
class IteratorType,
6715 typename std::enable_if<
6716 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
6723 return std::move(ia);
6766template<
typename BasicJsonType>
6870 const std::string& last_token,
6896template<
typename BasicJsonType>
6912 : root(r), allow_exceptions(allow_exceptions_)
6924 handle_value(
nullptr);
6960 handle_value(std::move(val));
6966 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6968 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6970 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
6982 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
6991 ref_stack.back()->set_parents();
6992 ref_stack.pop_back();
6998 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
7000 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7002 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7013 ref_stack.back()->set_parents();
7014 ref_stack.pop_back();
7018 template<
class Exception>
7020 const Exception& ex)
7023 static_cast<void>(ex);
7024 if (allow_exceptions)
7043 template<
typename Value>
7045 BasicJsonType* handle_value(Value&& v)
7047 if (ref_stack.empty())
7049 root = BasicJsonType(std::forward<Value>(v));
7053 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7055 if (ref_stack.back()->is_array())
7057 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
7058 return &(ref_stack.back()->m_data.m_value.array->back());
7063 *object_element = BasicJsonType(std::forward<Value>(v));
7064 return object_element;
7068 BasicJsonType& root;
7070 std::vector<BasicJsonType*> ref_stack {};
7072 BasicJsonType* object_element =
nullptr;
7074 bool errored =
false;
7076 const bool allow_exceptions =
true;
7079template<
typename BasicJsonType>
7093 const bool allow_exceptions_ =
true)
7094 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_)
7096 keep_stack.push_back(
true);
7108 handle_value(
nullptr);
7144 handle_value(std::move(val));
7151 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
7152 keep_stack.push_back(keep);
7154 auto val = handle_value(BasicJsonType::value_t::object,
true);
7155 ref_stack.push_back(val.second);
7158 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7160 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
7168 BasicJsonType k = BasicJsonType(val);
7171 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
7172 key_keep_stack.push_back(keep);
7175 if (keep && ref_stack.back())
7177 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
7185 if (ref_stack.back())
7187 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7194 ref_stack.back()->set_parents();
7200 ref_stack.pop_back();
7201 keep_stack.pop_back();
7203 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7206 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7208 if (it->is_discarded())
7210 ref_stack.back()->erase(it);
7221 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7222 keep_stack.push_back(keep);
7224 auto val = handle_value(BasicJsonType::value_t::array,
true);
7225 ref_stack.push_back(val.second);
7228 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7230 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7240 if (ref_stack.back())
7242 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7245 ref_stack.back()->set_parents();
7256 ref_stack.pop_back();
7257 keep_stack.pop_back();
7260 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7262 ref_stack.back()->m_data.m_value.array->pop_back();
7268 template<
class Exception>
7270 const Exception& ex)
7273 static_cast<void>(ex);
7274 if (allow_exceptions)
7302 template<
typename Value>
7303 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
7309 if (!keep_stack.back())
7311 return {
false,
nullptr};
7315 auto value = BasicJsonType(std::forward<Value>(v));
7318 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
7323 return {
false,
nullptr};
7326 if (ref_stack.empty())
7328 root = std::move(value);
7329 return {
true, & root};
7334 if (!ref_stack.back())
7336 return {
false,
nullptr};
7340 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7343 if (ref_stack.back()->is_array())
7345 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
7346 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
7353 const bool store_element = key_keep_stack.back();
7354 key_keep_stack.pop_back();
7358 return {
false,
nullptr};
7362 *object_element = std::move(value);
7363 return {
true, object_element};
7367 BasicJsonType& root;
7369 std::vector<BasicJsonType*> ref_stack {};
7371 std::vector<bool> keep_stack {};
7373 std::vector<bool> key_keep_stack {};
7375 BasicJsonType* object_element =
nullptr;
7377 bool errored =
false;
7381 const bool allow_exceptions =
true;
7383 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7386template<
typename BasicJsonType>
7481#include <initializer_list>
7503template<
typename BasicJsonType>
7536 case token_type::uninitialized:
7537 return "<uninitialized>";
7538 case token_type::literal_true:
7539 return "true literal";
7540 case token_type::literal_false:
7541 return "false literal";
7542 case token_type::literal_null:
7543 return "null literal";
7544 case token_type::value_string:
7545 return "string literal";
7546 case token_type::value_unsigned:
7547 case token_type::value_integer:
7548 case token_type::value_float:
7549 return "number literal";
7550 case token_type::begin_array:
7552 case token_type::begin_object:
7554 case token_type::end_array:
7556 case token_type::end_object:
7558 case token_type::name_separator:
7560 case token_type::value_separator:
7562 case token_type::parse_error:
7563 return "<parse error>";
7564 case token_type::end_of_input:
7565 return "end of input";
7566 case token_type::literal_or_value:
7567 return "'[', '{', or a literal";
7570 return "unknown token";
7580template<
typename BasicJsonType,
typename InputAdapterType>
7583 using number_integer_t =
typename BasicJsonType::number_integer_t;
7584 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7585 using number_float_t =
typename BasicJsonType::number_float_t;
7586 using string_t =
typename BasicJsonType::string_t;
7587 using char_type =
typename InputAdapterType::char_type;
7593 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7594 : ia(
std::move(adapter))
7595 , ignore_comments(ignore_comments_)
7596 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7613 static char get_decimal_point() noexcept
7615 const auto* loc = localeconv();
7617 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7645 const auto factors = { 12u, 8u, 4u, 0u };
7646 for (
const auto factor : factors)
7650 if (current >=
'0' && current <=
'9')
7652 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7654 else if (current >=
'A' && current <=
'F')
7656 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
7658 else if (current >=
'a' && current <=
'f')
7660 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
7668 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7687 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7689 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7692 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7701 error_message =
"invalid string: ill-formed UTF-8 byte";
7738 case char_traits<char_type>::eof():
7740 error_message =
"invalid string: missing closing quote";
7741 return token_type::parse_error;
7747 return token_type::value_string;
7791 const int codepoint1 = get_codepoint();
7792 int codepoint = codepoint1;
7796 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7797 return token_type::parse_error;
7801 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7806 const int codepoint2 = get_codepoint();
7810 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7811 return token_type::parse_error;
7818 codepoint =
static_cast<int>(
7820 (
static_cast<unsigned int>(codepoint1) << 10u)
7822 +
static_cast<unsigned int>(codepoint2)
7830 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7831 return token_type::parse_error;
7836 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7837 return token_type::parse_error;
7844 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7845 return token_type::parse_error;
7850 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7853 if (codepoint < 0x80)
7856 add(
static_cast<char_int_type
>(codepoint));
7858 else if (codepoint <= 0x7FF)
7861 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7862 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7864 else if (codepoint <= 0xFFFF)
7867 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7868 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7869 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7874 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7875 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7876 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7877 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7885 error_message =
"invalid string: forbidden character after backslash";
7886 return token_type::parse_error;
7895 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7896 return token_type::parse_error;
7901 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7902 return token_type::parse_error;
7907 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7908 return token_type::parse_error;
7913 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7914 return token_type::parse_error;
7919 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7920 return token_type::parse_error;
7925 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7926 return token_type::parse_error;
7931 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7932 return token_type::parse_error;
7937 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7938 return token_type::parse_error;
7943 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7944 return token_type::parse_error;
7949 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7950 return token_type::parse_error;
7955 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7956 return token_type::parse_error;
7961 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7962 return token_type::parse_error;
7967 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7968 return token_type::parse_error;
7973 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7974 return token_type::parse_error;
7979 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7980 return token_type::parse_error;
7985 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7986 return token_type::parse_error;
7991 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7992 return token_type::parse_error;
7997 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7998 return token_type::parse_error;
8003 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
8004 return token_type::parse_error;
8009 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
8010 return token_type::parse_error;
8015 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
8016 return token_type::parse_error;
8021 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
8022 return token_type::parse_error;
8027 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
8028 return token_type::parse_error;
8033 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
8034 return token_type::parse_error;
8039 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
8040 return token_type::parse_error;
8045 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
8046 return token_type::parse_error;
8051 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
8052 return token_type::parse_error;
8057 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
8058 return token_type::parse_error;
8063 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
8064 return token_type::parse_error;
8069 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
8070 return token_type::parse_error;
8075 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
8076 return token_type::parse_error;
8081 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
8082 return token_type::parse_error;
8219 return token_type::parse_error;
8229 return token_type::parse_error;
8253 return token_type::parse_error;
8263 return token_type::parse_error;
8273 return token_type::parse_error;
8285 return token_type::parse_error;
8295 return token_type::parse_error;
8303 error_message =
"invalid string: ill-formed UTF-8 byte";
8304 return token_type::parse_error;
8327 case char_traits<char_type>::eof():
8344 case char_traits<char_type>::eof():
8347 error_message =
"invalid comment; missing closing '*/'";
8375 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8382 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
8384 f = std::strtof(str, endptr);
8388 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
8390 f = std::strtod(str, endptr);
8394 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
8396 f = std::strtold(str, endptr);
8446 token_type number_type = token_type::value_unsigned;
8454 goto scan_number_minus;
8460 goto scan_number_zero;
8474 goto scan_number_any1;
8484 number_type = token_type::value_integer;
8490 goto scan_number_zero;
8504 goto scan_number_any1;
8509 error_message =
"invalid number; expected digit after '-'";
8510 return token_type::parse_error;
8520 add(decimal_point_char);
8521 goto scan_number_decimal1;
8528 goto scan_number_exponent;
8532 goto scan_number_done;
8551 goto scan_number_any1;
8556 add(decimal_point_char);
8557 goto scan_number_decimal1;
8564 goto scan_number_exponent;
8568 goto scan_number_done;
8571scan_number_decimal1:
8573 number_type = token_type::value_float;
8588 goto scan_number_decimal2;
8593 error_message =
"invalid number; expected digit after '.'";
8594 return token_type::parse_error;
8598scan_number_decimal2:
8614 goto scan_number_decimal2;
8621 goto scan_number_exponent;
8625 goto scan_number_done;
8628scan_number_exponent:
8630 number_type = token_type::value_float;
8637 goto scan_number_sign;
8652 goto scan_number_any2;
8658 "invalid number; expected '+', '-', or digit after exponent";
8659 return token_type::parse_error;
8679 goto scan_number_any2;
8684 error_message =
"invalid number; expected digit after exponent sign";
8685 return token_type::parse_error;
8705 goto scan_number_any2;
8709 goto scan_number_done;
8717 char* endptr =
nullptr;
8721 if (number_type == token_type::value_unsigned)
8723 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8726 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8730 value_unsigned =
static_cast<number_unsigned_t
>(
x);
8731 if (value_unsigned == x)
8733 return token_type::value_unsigned;
8737 else if (number_type == token_type::value_integer)
8739 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8742 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8746 value_integer =
static_cast<number_integer_t
>(
x);
8747 if (value_integer == x)
8749 return token_type::value_integer;
8756 strtof(value_float, token_buffer.data(), &endptr);
8759 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8761 return token_type::value_float;
8770 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8773 JSON_ASSERT(char_traits<char_type>::to_char_type(current) == literal_text[0]);
8774 for (std::size_t i = 1; i < length; ++i)
8778 error_message =
"invalid literal";
8779 return token_type::parse_error;
8790 void reset() noexcept
8792 token_buffer.clear();
8793 token_string.clear();
8794 token_string.push_back(char_traits<char_type>::to_char_type(current));
8810 ++
position.chars_read_current_line;
8824 token_string.push_back(char_traits<char_type>::to_char_type(current));
8827 if (current ==
'\n')
8830 position.chars_read_current_line = 0;
8851 if (
position.chars_read_current_line == 0)
8860 --
position.chars_read_current_line;
8866 token_string.pop_back();
8871 void add(char_int_type c)
8873 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8884 return value_integer;
8890 return value_unsigned;
8902 return token_buffer;
8922 for (
const auto c : token_string)
8924 if (
static_cast<unsigned char>(c) <=
'\x1F')
8927 std::array<char, 9> cs{{}};
8928 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8929 result += cs.data();
8934 result.push_back(
static_cast<std::string::value_type
>(c));
8945 return error_message;
8961 return get() == 0xBB &&
get() == 0xBF;
8976 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8982 if (position.chars_read_total == 0 && !skip_bom())
8984 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8985 return token_type::parse_error;
8992 while (ignore_comments && current ==
'/')
8994 if (!scan_comment())
8996 return token_type::parse_error;
9007 return token_type::begin_array;
9009 return token_type::end_array;
9011 return token_type::begin_object;
9013 return token_type::end_object;
9015 return token_type::name_separator;
9017 return token_type::value_separator;
9022 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
9023 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
9027 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
9028 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
9032 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
9033 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
9038 return scan_string();
9052 return scan_number();
9058 return token_type::end_of_input;
9062 error_message =
"invalid literal";
9063 return token_type::parse_error;
9069 InputAdapterType ia;
9072 const bool ignore_comments =
false;
9078 bool next_unget =
false;
9084 std::vector<char_type> token_string {};
9087 string_t token_buffer {};
9090 const char* error_message =
"";
9093 number_integer_t value_integer = 0;
9094 number_unsigned_t value_unsigned = 0;
9095 number_float_t value_float = 0;
9098 const char_int_type decimal_point_char =
'.';
9137 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9139template<
typename T,
typename Integer>
9141 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9143template<
typename T,
typename Un
signed>
9145 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9147template<
typename T,
typename Float,
typename String>
9149 std::declval<Float>(), std::declval<const String&>()));
9151template<
typename T,
typename String>
9153 decltype(std::declval<T&>().string(std::declval<String&>()));
9155template<
typename T,
typename Binary>
9157 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9161 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9163template<
typename T,
typename String>
9165 decltype(std::declval<T&>().key(std::declval<String&>()));
9172 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9177template<
typename T,
typename Exception>
9179 std::declval<std::size_t>(), std::declval<const std::string&>(),
9180 std::declval<const Exception&>()));
9182template<
typename SAX,
typename BasicJsonType>
9187 "BasicJsonType must be of type basic_json<...>");
9189 using number_integer_t =
typename BasicJsonType::number_integer_t;
9190 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9191 using number_float_t =
typename BasicJsonType::number_float_t;
9192 using string_t =
typename BasicJsonType::string_t;
9193 using binary_t =
typename BasicJsonType::binary_t;
9194 using exception_t =
typename BasicJsonType::exception;
9213template<
typename SAX,
typename BasicJsonType>
9218 "BasicJsonType must be of type basic_json<...>");
9220 using number_integer_t =
typename BasicJsonType::number_integer_t;
9221 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9222 using number_float_t =
typename BasicJsonType::number_float_t;
9223 using string_t =
typename BasicJsonType::string_t;
9224 using binary_t =
typename BasicJsonType::binary_t;
9225 using exception_t =
typename BasicJsonType::exception;
9229 "Missing/invalid function: bool null()");
9231 "Missing/invalid function: bool boolean(bool)");
9233 "Missing/invalid function: bool boolean(bool)");
9237 "Missing/invalid function: bool number_integer(number_integer_t)");
9241 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9243 number_float_t, string_t>
::value,
9244 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9247 "Missing/invalid function: bool string(string_t&)");
9250 "Missing/invalid function: bool binary(binary_t&)");
9252 "Missing/invalid function: bool start_object(std::size_t)");
9254 "Missing/invalid function: bool key(string_t&)");
9256 "Missing/invalid function: bool end_object()");
9258 "Missing/invalid function: bool start_array(std::size_t)");
9260 "Missing/invalid function: bool end_array()");
9263 "Missing/invalid function: bool parse_error(std::size_t, const "
9264 "std::string&, const exception&)");
9296static inline bool little_endianness(
int num = 1) noexcept
9298 return *
reinterpret_cast<char*
>(&num) == 1;
9308template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9311 using number_integer_t =
typename BasicJsonType::number_integer_t;
9312 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9313 using number_float_t =
typename BasicJsonType::number_float_t;
9314 using string_t =
typename BasicJsonType::string_t;
9315 using binary_t =
typename BasicJsonType::binary_t;
9316 using json_sax_t = SAX;
9317 using char_type =
typename InputAdapterType::char_type;
9349 const
bool strict = true,
9353 bool result =
false;
9358 result = parse_bson_internal();
9362 result = parse_cbor_internal(
true, tag_handler);
9366 result = parse_msgpack_internal();
9371 result = parse_ubjson_internal();
9393 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9394 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9410 bool parse_bson_internal()
9412 std::int32_t document_size{};
9425 return sax->end_object();
9435 bool get_bson_cstr(string_t& result)
9437 auto out = std::back_inserter(result);
9445 if (current == 0x00)
9449 *out++ =
static_cast<typename string_t::value_type
>(current);
9464 template<
typename NumberType>
9465 bool get_bson_string(
const NumberType len, string_t& result)
9469 auto last_token = get_token_string();
9471 exception_message(
input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
9474 return get_string(
input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != char_traits<char_type>::eof();
9486 template<
typename NumberType>
9487 bool get_bson_binary(
const NumberType len, binary_t& result)
9491 auto last_token = get_token_string();
9493 exception_message(
input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
9497 std::uint8_t subtype{};
9499 result.set_subtype(subtype);
9514 bool parse_bson_element_internal(
const char_int_type element_type,
9515 const std::size_t element_type_parse_position)
9517 switch (element_type)
9522 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9534 return parse_bson_internal();
9539 return parse_bson_array();
9551 return sax->boolean(get() != 0);
9561 std::int32_t
value{};
9567 std::int64_t
value{};
9573 std::array<char, 3> cr{{}};
9574 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(
element_type)));
9575 const std::string cr_str{cr.data()};
9576 return sax->parse_error(element_type_parse_position, cr_str,
9594 bool parse_bson_element_list(
const bool is_array)
9598 while (
auto element_type = get())
9605 const std::size_t element_type_parse_position = chars_read;
9611 if (!is_array && !sax->key(
key))
9616 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9632 bool parse_bson_array()
9634 std::int32_t document_size{};
9647 return sax->end_array();
9662 bool parse_cbor_internal(
const bool get_char,
9665 switch (get_char ? get() : current)
9668 case char_traits<char_type>::eof():
9696 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9747 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9752 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9758 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9764 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9770 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
9771 -
static_cast<number_integer_t
>(number));
9806 return get_cbor_binary(b) && sax->binary(b);
9841 return get_cbor_string(s) && sax->string(s);
9869 return get_cbor_array(
9870 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9875 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9880 std::uint16_t len{};
9881 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9886 std::uint32_t len{};
9887 return get_number(
input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9892 std::uint64_t len{};
9893 return get_number(
input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9897 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9924 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9929 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9934 std::uint16_t len{};
9935 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9940 std::uint32_t len{};
9941 return get_number(
input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9946 std::uint64_t len{};
9947 return get_number(
input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9951 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9973 switch (tag_handler)
9977 auto last_token = get_token_string();
9989 std::uint8_t subtype_to_ignore{};
9995 std::uint16_t subtype_to_ignore{};
10001 std::uint32_t subtype_to_ignore{};
10007 std::uint64_t subtype_to_ignore{};
10014 return parse_cbor_internal(
true, tag_handler);
10025 std::uint8_t subtype{};
10027 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10032 std::uint16_t subtype{};
10034 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10039 std::uint32_t subtype{};
10041 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10046 std::uint64_t subtype{};
10048 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10052 return parse_cbor_internal(
true, tag_handler);
10055 return get_cbor_binary(b) && sax->binary(b);
10065 return sax->boolean(
false);
10068 return sax->boolean(
true);
10071 return sax->null();
10075 const auto byte1_raw = get();
10080 const auto byte2_raw = get();
10086 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10087 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10097 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10098 const double val = [&half]
10100 const int exp = (half >> 10u) & 0x1Fu;
10101 const unsigned int mant = half & 0x3FFu;
10107 return std::ldexp(mant, -24);
10110 ? std::numeric_limits<double>::infinity()
10111 :
std::numeric_limits<double>::quiet_NaN();
10113 return std::ldexp(mant + 1024, exp - 25);
10116 return sax->number_float((half & 0x8000u) != 0
10117 ?
static_cast<number_float_t
>(-
val)
10118 :
static_cast<number_float_t
>(val),
"");
10124 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10130 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10135 auto last_token = get_token_string();
10153 bool get_cbor_string(string_t& result)
10193 std::uint8_t len{};
10199 std::uint16_t len{};
10205 std::uint32_t len{};
10211 std::uint64_t len{};
10217 while (get() != 0xFF)
10220 if (!get_cbor_string(chunk))
10231 auto last_token = get_token_string();
10233 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10249 bool get_cbor_binary(binary_t& result)
10289 std::uint8_t len{};
10296 std::uint16_t len{};
10303 std::uint32_t len{};
10310 std::uint64_t len{};
10317 while (get() != 0xFF)
10320 if (!get_cbor_binary(chunk))
10324 result.insert(
result.end(), chunk.begin(), chunk.end());
10331 auto last_token = get_token_string();
10333 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));
10344 bool get_cbor_array(
const std::size_t len,
10352 if (len !=
static_cast<std::size_t
>(-1))
10354 for (std::size_t i = 0; i < len; ++i)
10364 while (get() != 0xFF)
10373 return sax->end_array();
10382 bool get_cbor_object(
const std::size_t len,
10393 if (len !=
static_cast<std::size_t
>(-1))
10395 for (std::size_t i = 0; i < len; ++i)
10412 while (get() != 0xFF)
10428 return sax->end_object();
10438 bool parse_msgpack_internal()
10443 case char_traits<char_type>::eof():
10575 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10594 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10613 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10653 return get_msgpack_string(s) && sax->string(s);
10657 return sax->null();
10660 return sax->boolean(
false);
10663 return sax->boolean(
true);
10678 return get_msgpack_binary(b) && sax->binary(b);
10684 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10690 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10743 std::uint16_t len{};
10749 std::uint32_t len{};
10750 return get_number(
input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10755 std::uint16_t len{};
10761 std::uint32_t len{};
10762 return get_number(
input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10798 return sax->number_integer(
static_cast<std::int8_t
>(current));
10802 auto last_token = get_token_string();
10819 bool get_msgpack_string(string_t& result)
10867 std::uint8_t len{};
10873 std::uint16_t len{};
10879 std::uint32_t len{};
10885 auto last_token = get_token_string();
10887 exception_message(
input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10902 bool get_msgpack_binary(binary_t& result)
10905 auto assign_and_return_true = [&
result](std::int8_t subtype)
10907 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10915 std::uint8_t len{};
10922 std::uint16_t len{};
10929 std::uint32_t len{};
10936 std::uint8_t len{};
10937 std::int8_t subtype{};
10941 assign_and_return_true(subtype);
10946 std::uint16_t len{};
10947 std::int8_t subtype{};
10951 assign_and_return_true(subtype);
10956 std::uint32_t len{};
10957 std::int8_t subtype{};
10961 assign_and_return_true(subtype);
10966 std::int8_t subtype{};
10969 assign_and_return_true(subtype);
10974 std::int8_t subtype{};
10977 assign_and_return_true(subtype);
10982 std::int8_t subtype{};
10985 assign_and_return_true(subtype);
10990 std::int8_t subtype{};
10993 assign_and_return_true(subtype);
10998 std::int8_t subtype{};
11001 assign_and_return_true(subtype);
11013 bool get_msgpack_array(
const std::size_t len)
11020 for (std::size_t i = 0; i < len; ++i)
11028 return sax->end_array();
11035 bool get_msgpack_object(
const std::size_t len)
11043 for (std::size_t i = 0; i < len; ++i)
11058 return sax->end_object();
11072 bool parse_ubjson_internal(
const bool get_char =
true)
11074 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11091 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
11107 std::uint8_t len{};
11108 return get_number(input_format, len) && get_string(input_format, len, result);
11114 return get_number(input_format, len) && get_string(input_format, len, result);
11119 std::int16_t len{};
11120 return get_number(input_format, len) && get_string(input_format, len, result);
11125 std::int32_t len{};
11126 return get_number(input_format, len) && get_string(input_format, len, result);
11131 std::int64_t len{};
11132 return get_number(input_format, len) && get_string(input_format, len, result);
11141 std::uint16_t len{};
11142 return get_number(input_format, len) && get_string(input_format, len, result);
11151 std::uint32_t len{};
11152 return get_number(input_format, len) && get_string(input_format, len, result);
11161 std::uint64_t len{};
11162 return get_number(input_format, len) && get_string(input_format, len, result);
11168 auto last_token = get_token_string();
11169 std::string message;
11173 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11177 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11179 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11186 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11188 std::pair<std::size_t, char_int_type> size_and_type;
11190 bool no_ndarray =
true;
11197 if (size_and_type.first != npos)
11199 if (size_and_type.second != 0)
11201 if (size_and_type.second !=
'N')
11203 for (std::size_t i = 0; i < size_and_type.first; ++i)
11209 dim.push_back(dimlen);
11215 for (std::size_t i = 0; i < size_and_type.first; ++i)
11221 dim.push_back(dimlen);
11227 while (current !=
']')
11233 dim.push_back(dimlen);
11251 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11255 prefix = get_ignore_noop();
11280 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11281 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11296 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11297 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11312 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11313 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11328 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11329 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11331 if (!value_in_range_of<std::size_t>(number))
11334 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11366 result = conditional_static_cast<std::size_t>(number);
11381 if (!value_in_range_of<std::size_t>(number))
11384 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11386 result = detail::conditional_static_cast<std::size_t>(number);
11398 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));
11400 std::vector<size_t> dim;
11405 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11407 result = dim.at(dim.size() - 1);
11421 string_t
key =
"_ArraySize_";
11430 if (result == 0 || result == npos)
11432 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));
11440 return sax->end_array();
11449 auto last_token = get_token_string();
11450 std::string message;
11454 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11458 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11460 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11474 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
11478 bool is_ndarray =
false;
11482 if (current ==
'$')
11486 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(),
result.second)))
11488 auto last_token = get_token_string();
11490 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11505 auto last_token = get_token_string();
11507 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11510 const bool is_error = get_ubjson_size_value(
result.first, is_ndarray);
11513 if (inside_ndarray)
11515 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11516 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11518 result.second |= (1 << 8);
11523 if (current ==
'#')
11525 const bool is_error = get_ubjson_size_value(
result.first, is_ndarray);
11528 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11529 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11541 bool get_ubjson_value(
const char_int_type prefix)
11545 case char_traits<char_type>::eof():
11546 return unexpect_eof(input_format,
"value");
11549 return sax->boolean(
true);
11551 return sax->boolean(
false);
11554 return sax->null();
11559 return get_number(input_format, number) && sax->number_unsigned(number);
11565 return get_number(input_format, number) && sax->number_integer(number);
11571 return get_number(input_format, number) && sax->number_integer(number);
11577 return get_number(input_format, number) && sax->number_integer(number);
11583 return get_number(input_format, number) && sax->number_integer(number);
11593 return get_number(input_format, number) && sax->number_unsigned(number);
11603 return get_number(input_format, number) && sax->number_unsigned(number);
11613 return get_number(input_format, number) && sax->number_unsigned(number);
11622 const auto byte1_raw = get();
11627 const auto byte2_raw = get();
11633 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11634 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11644 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11645 const double val = [&half]
11647 const int exp = (half >> 10u) & 0x1Fu;
11648 const unsigned int mant = half & 0x3FFu;
11654 return std::ldexp(mant, -24);
11657 ? std::numeric_limits<double>::infinity()
11658 :
std::numeric_limits<double>::quiet_NaN();
11660 return std::ldexp(mant + 1024, exp - 25);
11663 return sax->number_float((half & 0x8000u) != 0
11664 ?
static_cast<number_float_t
>(-
val)
11665 :
static_cast<number_float_t
>(val),
"");
11671 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11677 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11682 return get_ubjson_high_precision_number();
11694 auto last_token = get_token_string();
11696 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11698 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11699 return sax->string(s);
11705 return get_ubjson_string(s) && sax->string(s);
11709 return get_ubjson_array();
11712 return get_ubjson_object();
11717 auto last_token = get_token_string();
11718 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));
11724 bool get_ubjson_array()
11726 std::pair<std::size_t, char_int_type> size_and_type;
11735 if (input_format ==
input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11737 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
11738 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)
11740 return p.first < t;
11742 string_t
key =
"_ArrayType_";
11745 auto last_token = get_token_string();
11747 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11750 string_t
type = it->second;
11756 if (size_and_type.second ==
'C')
11758 size_and_type.second =
'U';
11761 key =
"_ArrayData_";
11767 for (std::size_t i = 0; i < size_and_type.first; ++i)
11775 return (sax->end_array() && sax->end_object());
11778 if (size_and_type.first != npos)
11785 if (size_and_type.second != 0)
11787 if (size_and_type.second !=
'N')
11789 for (std::size_t i = 0; i < size_and_type.first; ++i)
11800 for (std::size_t i = 0; i < size_and_type.first; ++i)
11816 while (current !=
']')
11826 return sax->end_array();
11832 bool get_ubjson_object()
11834 std::pair<std::size_t, char_int_type> size_and_type;
11841 if (input_format ==
input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11843 auto last_token = get_token_string();
11845 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11849 if (size_and_type.first != npos)
11856 if (size_and_type.second != 0)
11858 for (std::size_t i = 0; i < size_and_type.first; ++i)
11873 for (std::size_t i = 0; i < size_and_type.first; ++i)
11894 while (current !=
'}')
11909 return sax->end_object();
11915 bool get_ubjson_high_precision_number()
11918 std::size_t
size{};
11919 bool no_ndarray =
true;
11920 auto res = get_ubjson_size_value(size, no_ndarray);
11927 std::vector<char> number_vector;
11928 for (std::size_t i = 0; i <
size; ++i)
11935 number_vector.push_back(
static_cast<char>(current));
11941 const auto result_number = number_lexer.scan();
11942 const auto number_string = number_lexer.get_token_string();
11943 const auto result_remainder = number_lexer.scan();
11950 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11953 switch (result_number)
11955 case token_type::value_integer:
11956 return sax->number_integer(number_lexer.get_number_integer());
11957 case token_type::value_unsigned:
11958 return sax->number_unsigned(number_lexer.get_number_unsigned());
11959 case token_type::value_float:
11960 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11961 case token_type::uninitialized:
11962 case token_type::literal_true:
11963 case token_type::literal_false:
11964 case token_type::literal_null:
11965 case token_type::value_string:
11966 case token_type::begin_array:
11967 case token_type::begin_object:
11968 case token_type::end_array:
11969 case token_type::end_object:
11970 case token_type::name_separator:
11971 case token_type::value_separator:
11972 case token_type::parse_error:
11973 case token_type::end_of_input:
11974 case token_type::literal_or_value:
11977 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11994 char_int_type get()
11997 return current = ia.get_character();
12003 char_int_type get_ignore_noop()
12009 while (current ==
'N');
12029 template<
typename NumberType,
bool InputIsLittleEndian = false>
12030 bool get_number(
const input_format_t format, NumberType& result)
12033 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
12034 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
12045 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
12049 vec[i] =
static_cast<std::uint8_t
>(current);
12054 std::memcpy(&result, vec.data(),
sizeof(NumberType));
12072 template<
typename NumberType>
12074 const NumberType len,
12077 bool success =
true;
12078 for (NumberType i = 0; i < len; i++)
12086 result.push_back(
static_cast<typename string_t::value_type
>(current));
12105 template<
typename NumberType>
12107 const NumberType len,
12110 bool success =
true;
12111 for (NumberType i = 0; i < len; i++)
12119 result.push_back(
static_cast<std::uint8_t
>(current));
12130 bool unexpect_eof(const
input_format_t format, const
char* context)
const
12134 return sax->parse_error(chars_read,
"<end of file>",
12135 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12143 std::string get_token_string()
const
12145 std::array<char, 3> cr{{}};
12146 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12147 return std::string{cr.data()};
12157 const std::string&
detail,
12158 const std::string& context)
const
12160 std::string error_msg =
"syntax error while parsing ";
12165 error_msg +=
"CBOR";
12169 error_msg +=
"MessagePack";
12173 error_msg +=
"UBJSON";
12177 error_msg +=
"BSON";
12181 error_msg +=
"BJData";
12196 InputAdapterType ia;
12199 char_int_type current = char_traits<char_type>::eof();
12202 std::size_t chars_read = 0;
12205 const bool is_little_endian = little_endianness();
12211 json_sax_t* sax =
nullptr;
12214#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12215 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12217#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12218 make_array<bjd_type>( \
12219 bjd_type{'C', "char"}, \
12220 bjd_type{'D', "double"}, \
12221 bjd_type{'I', "int16"}, \
12222 bjd_type{'L', "int64"}, \
12223 bjd_type{'M', "uint64"}, \
12224 bjd_type{'U', "uint8"}, \
12225 bjd_type{'d', "single"}, \
12226 bjd_type{'i', "int8"}, \
12227 bjd_type{'l', "int32"}, \
12228 bjd_type{'m', "uint32"}, \
12229 bjd_type{'u', "uint16"})
12237 using bjd_type = std::pair<char_int_type, string_t>;
12242#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12243#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12246#ifndef JSON_HAS_CPP_17
12247 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12248 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12271#include <functional>
12316template<
typename BasicJsonType>
12318 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12325template<
typename BasicJsonType,
typename InputAdapterType>
12328 using number_integer_t =
typename BasicJsonType::number_integer_t;
12329 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12330 using number_float_t =
typename BasicJsonType::number_float_t;
12331 using string_t =
typename BasicJsonType::string_t;
12339 const bool allow_exceptions_ =
true,
12340 const bool skip_comments =
false)
12341 : callback(
std::move(cb))
12342 , m_lexer(
std::move(adapter), skip_comments)
12343 , allow_exceptions(allow_exceptions_)
12364 sax_parse_internal(&sdp);
12367 if (
strict && (get_token() != token_type::end_of_input))
12372 exception_message(token_type::end_of_input,
"value"),
nullptr));
12384 if (result.is_discarded())
12392 sax_parse_internal(&sdp);
12395 if (
strict && (get_token() != token_type::end_of_input))
12410 result.assert_invariant();
12425 template<
typename SAX>
12430 const bool result = sax_parse_internal(sax);
12433 if (result &&
strict && (get_token() != token_type::end_of_input))
12444 template<
typename SAX>
12446 bool sax_parse_internal(SAX* sax)
12450 std::vector<bool> states;
12452 bool skip_to_state_evaluation =
false;
12456 if (!skip_to_state_evaluation)
12459 switch (last_token)
12461 case token_type::begin_object:
12469 if (get_token() == token_type::end_object)
12499 states.push_back(
false);
12506 case token_type::begin_array:
12514 if (get_token() == token_type::end_array)
12524 states.push_back(
true);
12530 case token_type::value_float:
12549 case token_type::literal_false:
12558 case token_type::literal_null:
12567 case token_type::literal_true:
12576 case token_type::value_integer:
12585 case token_type::value_string:
12594 case token_type::value_unsigned:
12603 case token_type::parse_error:
12610 case token_type::end_of_input:
12617 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
12624 case token_type::uninitialized:
12625 case token_type::end_array:
12626 case token_type::end_object:
12627 case token_type::name_separator:
12628 case token_type::value_separator:
12629 case token_type::literal_or_value:
12640 skip_to_state_evaluation =
false;
12644 if (states.empty())
12653 if (get_token() == token_type::value_separator)
12674 skip_to_state_evaluation =
true;
12686 if (get_token() == token_type::value_separator)
12728 skip_to_state_evaluation =
true;
12741 return last_token = m_lexer.
scan();
12744 std::string exception_message(
const token_type expected,
const std::string& context)
12746 std::string error_msg =
"syntax error ";
12748 if (!context.empty())
12750 error_msg +=
concat(
"while parsing ", context,
' ');
12755 if (last_token == token_type::parse_error)
12765 if (expected != token_type::uninitialized)
12775 const parser_callback_t<BasicJsonType> callback =
nullptr;
12777 token_type last_token = token_type::uninitialized;
12781 const bool allow_exceptions =
true;
12833 using difference_type = std::ptrdiff_t;
12834 static constexpr difference_type begin_value = 0;
12835 static constexpr difference_type end_value = begin_value + 1;
12839 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
12850 m_it = begin_value;
12862 return m_it == begin_value;
12868 return m_it == end_value;
12873 return lhs.m_it == rhs.m_it;
12878 return lhs.m_it < rhs.m_it;
12883 auto result = *
this;
12890 return lhs.m_it - rhs.m_it;
12901 auto result = *
this;
12914 auto result = *
this;
12971#include <type_traits>
12993template<
typename IteratorType>
class iteration_proxy;
12994template<
typename IteratorType>
class iteration_proxy_value;
13012template<
typename BasicJsonType>
13019 friend BasicJsonType;
13023 using object_t =
typename BasicJsonType::object_t;
13024 using array_t =
typename BasicJsonType::array_t;
13027 "iter_impl only accepts (const) basic_json");
13029 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13030 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
13031 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13046 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13047 typename BasicJsonType::const_pointer,
13048 typename BasicJsonType::pointer>::type;
13051 typename std::conditional<std::is_const<BasicJsonType>::value,
13052 typename BasicJsonType::const_reference,
13053 typename BasicJsonType::reference>::type;
13070 switch (m_object->m_data.m_type)
13117 : m_object(other.m_object),
m_it(other.m_it)
13128 if (&other !=
this)
13130 m_object = other.m_object;
13142 : m_object(other.m_object),
m_it(other.m_it)
13153 m_object = other.m_object;
13163 void set_begin() noexcept
13167 switch (m_object->m_data.m_type)
13211 switch (m_object->m_data.m_type)
13250 switch (m_object->m_data.m_type)
13294 switch (m_object->m_data.m_type)
13334 auto result = *
this;
13347 switch (m_object->m_data.m_type)
13385 auto result = *
this;
13398 switch (m_object->m_data.m_type)
13434 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 >
13445 switch (m_object->m_data.m_type)
13470 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 >
13490 switch (m_object->m_data.m_type)
13517 return !other.operator < (*this);
13546 switch (m_object->m_data.m_type)
13590 auto result = *
this;
13612 auto result = *
this;
13625 switch (m_object->m_data.m_type)
13654 switch (m_object->m_data.m_type)
13688 const typename object_t::key_type&
key()
const
13765template<
typename Base>
13839 auto it = --this->base();
13846 auto it = --this->base();
13847 return it.operator * ();
13867#include <type_traits>
13890 std::is_same<T, void>::value,
13909#include <algorithm>
13937template<
typename RefStringType>
13947 template<
typename T>
13948 struct string_t_helper
13956 using type = StringType;
13961 using string_t =
typename string_t_helper<RefStringType>::type;
13966 : reference_tokens(split(s))
13973 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13977 return detail::concat(a,
'/', detail::escape(b));
14003 reference_tokens.insert(reference_tokens.end(),
14004 ptr.reference_tokens.begin(),
14005 ptr.reference_tokens.end());
14021 return *
this /= std::to_string(array_idx);
14069 reference_tokens.pop_back();
14081 return reference_tokens.back();
14088 reference_tokens.push_back(
token);
14095 reference_tokens.push_back(std::move(
token));
14102 return reference_tokens.empty();
14116 template<
typename BasicJsonType>
14117 static typename BasicJsonType::size_type array_index(
const string_t& s)
14119 using size_type =
typename BasicJsonType::size_type;
14133 const char* p = s.c_str();
14134 char* p_end =
nullptr;
14136 const unsigned long long res = std::strtoull(p, &p_end, 10);
14146 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14151 return static_cast<size_type
>(res);
14163 result.reference_tokens = {reference_tokens[0]};
14176 template<
typename BasicJsonType>
14177 BasicJsonType& get_and_create(BasicJsonType& j)
const
14183 for (
const auto& reference_token : reference_tokens)
14189 if (reference_token ==
"0")
14212 result = &
result->operator[](array_index<BasicJsonType>(reference_token));
14256 template<
typename BasicJsonType>
14257 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14259 for (
const auto& reference_token : reference_tokens)
14262 if (ptr->is_null())
14266 std::all_of(reference_token.begin(), reference_token.end(),
14267 [](
const unsigned char x)
14269 return std::isdigit(x);
14273 *ptr = (nums || reference_token ==
"-")
14278 switch (ptr->type())
14283 ptr = &ptr->operator[](reference_token);
14289 if (reference_token ==
"-")
14292 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14297 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14324 template<
typename BasicJsonType>
14325 BasicJsonType& get_checked(BasicJsonType* ptr)
const
14327 for (
const auto& reference_token : reference_tokens)
14329 switch (ptr->type())
14334 ptr = &ptr->at(reference_token);
14344 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14345 ") is out of range"), ptr));
14349 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14382 template<
typename BasicJsonType>
14383 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
14385 for (
const auto& reference_token : reference_tokens)
14387 switch (ptr->type())
14392 ptr = &ptr->operator[](reference_token);
14405 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14431 template<
typename BasicJsonType>
14432 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
14434 for (
const auto& reference_token : reference_tokens)
14436 switch (ptr->type())
14441 ptr = &ptr->at(reference_token);
14451 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14452 ") is out of range"), ptr));
14456 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14480 template<
typename BasicJsonType>
14481 bool contains(
const BasicJsonType* ptr)
const
14483 for (
const auto& reference_token : reference_tokens)
14485 switch (ptr->type())
14489 if (!ptr->contains(reference_token))
14495 ptr = &ptr->operator[](reference_token);
14506 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14518 for (std::size_t i = 1; i < reference_token.size(); i++)
14528 const auto idx = array_index<BasicJsonType>(reference_token);
14529 if (idx >= ptr->size())
14535 ptr = &ptr->operator[](idx);
14569 static std::vector<string_t> split(
const string_t& reference_string)
14571 std::vector<string_t>
result;
14574 if (reference_string.empty())
14590 std::size_t slash = reference_string.find_first_of(
'/', 1),
14597 start = (slash == string_t::npos) ? 0 : slash + 1,
14599 slash = reference_string.find_first_of(
'/', start))
14603 auto reference_token = reference_string.substr(start, slash - start);
14606 for (std::size_t pos = reference_token.find_first_of(
'~');
14607 pos != string_t::npos;
14608 pos = reference_token.find_first_of(
'~', pos + 1))
14614 (reference_token[pos + 1] !=
'0' &&
14615 reference_token[pos + 1] !=
'1')))
14622 detail::unescape(reference_token);
14623 result.push_back(reference_token);
14637 template<
typename BasicJsonType>
14638 static void flatten(
const string_t& reference_string,
14639 const BasicJsonType& value,
14640 BasicJsonType& result)
14642 switch (
value.type())
14646 if (
value.m_data.m_value.array->empty())
14649 result[reference_string] =
nullptr;
14654 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
14656 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
14657 value.m_data.m_value.array->operator[](i), result);
14665 if (
value.m_data.m_value.object->empty())
14668 result[reference_string] =
nullptr;
14673 for (
const auto& element : *
value.m_data.m_value.object)
14708 template<
typename BasicJsonType>
14709 static BasicJsonType
14710 unflatten(
const BasicJsonType& value)
14720 for (
const auto& element : *
value.m_data.m_value.object)
14731 json_pointer(element.first).get_and_create(result) = element.second;
14741 result.reference_tokens = reference_tokens;
14748 result.reference_tokens = std::move(reference_tokens);
14753#if JSON_HAS_THREE_WAY_COMPARISON
14756 template<
typename RefStringTypeRhs>
14759 return reference_tokens == rhs.reference_tokens;
14771 template<
typename RefStringTypeRhs>
14774 return reference_tokens <=> rhs.reference_tokens;
14779 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14786 template<
typename RefStringTypeLhs,
typename StringType>
14789 const StringType& rhs);
14793 template<
typename RefStringTypeRhs,
typename StringType>
14795 friend bool operator==(
const StringType& lhs,
14800 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14807 template<
typename RefStringTypeLhs,
typename StringType>
14810 const StringType& rhs);
14814 template<
typename RefStringTypeRhs,
typename StringType>
14816 friend bool operator!=(
const StringType& lhs,
14820 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14828 std::vector<string_t> reference_tokens;
14831#if !JSON_HAS_THREE_WAY_COMPARISON
14833template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14837 return lhs.reference_tokens == rhs.reference_tokens;
14840template<
typename RefStringTypeLhs,
14844 const StringType& rhs)
14849template<
typename RefStringTypeRhs,
14852inline
bool operator==(const StringType& lhs,
14858template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14862 return !(lhs == rhs);
14865template<
typename RefStringTypeLhs,
14869 const StringType& rhs)
14871 return !(lhs == rhs);
14874template<
typename RefStringTypeRhs,
14877inline
bool operator!=(const StringType& lhs,
14880 return !(lhs == rhs);
14883template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14887 return lhs.reference_tokens < rhs.reference_tokens;
14904#include <initializer_list>
14916template<
typename BasicJsonType>
14927 : value_ref(&
value)
14931 : owned_value(init)
14938 : owned_value(
std::forward<Args>(args)...)
14950 if (value_ref ==
nullptr)
14952 return std::move(owned_value);
14959 return value_ref ? *value_ref : owned_value;
14996#include <algorithm>
15022#include <algorithm>
15056template<typename CharType>
15060template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15074 void write_characters(const CharType* s,
std::
size_t length)
override
15076 v.insert(v.end(), s, s + length);
15080 std::vector<CharType, AllocatorType>& v;
15085template<
typename CharType>
15099 void write_characters(const CharType* s,
std::
size_t length)
override
15101 stream.write(s,
static_cast<std::streamsize
>(length));
15105 std::basic_ostream<CharType>& stream;
15110template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15124 void write_characters(const CharType* s,
std::
size_t length)
override
15126 str.append(s, length);
15133template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15137 template<
typename AllocatorType = std::allocator<CharType>>
15175template<
typename BasicJsonType,
typename CharType>
15178 using string_t =
typename BasicJsonType::string_t;
15179 using binary_t =
typename BasicJsonType::binary_t;
15180 using number_float_t =
typename BasicJsonType::number_float_t;
15201 case value_t::object:
15203 write_bson_object(*j.m_data.m_value.object);
15207 case value_t::null:
15208 case value_t::array:
15209 case value_t::string:
15210 case value_t::boolean:
15211 case value_t::number_integer:
15212 case value_t::number_unsigned:
15213 case value_t::number_float:
15214 case value_t::binary:
15215 case value_t::discarded:
15218 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15230 case value_t::null:
15232 oa->write_character(to_char_type(0xF6));
15236 case value_t::boolean:
15238 oa->write_character(j.m_data.m_value.boolean
15239 ? to_char_type(0xF5)
15240 : to_char_type(0xF4));
15244 case value_t::number_integer:
15246 if (j.m_data.m_value.number_integer >= 0)
15251 if (j.m_data.m_value.number_integer <= 0x17)
15253 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15255 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15257 oa->write_character(to_char_type(0x18));
15258 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15260 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15262 oa->write_character(to_char_type(0x19));
15263 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15265 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15267 oa->write_character(to_char_type(0x1A));
15268 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15272 oa->write_character(to_char_type(0x1B));
15273 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15280 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15281 if (j.m_data.m_value.number_integer >= -24)
15283 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15285 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15287 oa->write_character(to_char_type(0x38));
15288 write_number(
static_cast<std::uint8_t
>(positive_number));
15290 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15292 oa->write_character(to_char_type(0x39));
15293 write_number(
static_cast<std::uint16_t
>(positive_number));
15295 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15297 oa->write_character(to_char_type(0x3A));
15298 write_number(
static_cast<std::uint32_t
>(positive_number));
15302 oa->write_character(to_char_type(0x3B));
15303 write_number(
static_cast<std::uint64_t
>(positive_number));
15309 case value_t::number_unsigned:
15311 if (j.m_data.m_value.number_unsigned <= 0x17)
15313 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15315 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15317 oa->write_character(to_char_type(0x18));
15318 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15320 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15322 oa->write_character(to_char_type(0x19));
15323 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
15325 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15327 oa->write_character(to_char_type(0x1A));
15328 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
15332 oa->write_character(to_char_type(0x1B));
15333 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
15338 case value_t::number_float:
15340 if (std::isnan(j.m_data.m_value.number_float))
15343 oa->write_character(to_char_type(0xF9));
15344 oa->write_character(to_char_type(0x7E));
15345 oa->write_character(to_char_type(0x00));
15347 else if (std::isinf(j.m_data.m_value.number_float))
15350 oa->write_character(to_char_type(0xf9));
15351 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15352 oa->write_character(to_char_type(0x00));
15361 case value_t::string:
15364 const auto N = j.m_data.m_value.string->size();
15367 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15369 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15371 oa->write_character(to_char_type(0x78));
15372 write_number(
static_cast<std::uint8_t
>(N));
15374 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15376 oa->write_character(to_char_type(0x79));
15377 write_number(
static_cast<std::uint16_t
>(N));
15379 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15381 oa->write_character(to_char_type(0x7A));
15382 write_number(
static_cast<std::uint32_t
>(N));
15385 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15387 oa->write_character(to_char_type(0x7B));
15388 write_number(
static_cast<std::uint64_t
>(N));
15393 oa->write_characters(
15394 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15395 j.m_data.m_value.string->size());
15399 case value_t::array:
15402 const auto N = j.m_data.m_value.array->size();
15405 write_number(
static_cast<std::uint8_t
>(0x80 + N));
15407 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15409 oa->write_character(to_char_type(0x98));
15410 write_number(
static_cast<std::uint8_t
>(N));
15412 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15414 oa->write_character(to_char_type(0x99));
15415 write_number(
static_cast<std::uint16_t
>(N));
15417 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15419 oa->write_character(to_char_type(0x9A));
15420 write_number(
static_cast<std::uint32_t
>(N));
15423 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15425 oa->write_character(to_char_type(0x9B));
15426 write_number(
static_cast<std::uint64_t
>(N));
15431 for (
const auto& el : *j.m_data.m_value.array)
15438 case value_t::binary:
15440 if (j.m_data.m_value.binary->has_subtype())
15442 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15444 write_number(
static_cast<std::uint8_t
>(0xd8));
15445 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
15447 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15449 write_number(
static_cast<std::uint8_t
>(0xd9));
15450 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
15452 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15454 write_number(
static_cast<std::uint8_t
>(0xda));
15455 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
15457 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15459 write_number(
static_cast<std::uint8_t
>(0xdb));
15460 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
15465 const auto N = j.m_data.m_value.binary->size();
15468 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15470 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15472 oa->write_character(to_char_type(0x58));
15473 write_number(
static_cast<std::uint8_t
>(N));
15475 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15477 oa->write_character(to_char_type(0x59));
15478 write_number(
static_cast<std::uint16_t
>(N));
15480 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15482 oa->write_character(to_char_type(0x5A));
15483 write_number(
static_cast<std::uint32_t
>(N));
15486 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15488 oa->write_character(to_char_type(0x5B));
15489 write_number(
static_cast<std::uint64_t
>(N));
15494 oa->write_characters(
15495 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15501 case value_t::object:
15504 const auto N = j.m_data.m_value.object->size();
15507 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15509 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15511 oa->write_character(to_char_type(0xB8));
15512 write_number(
static_cast<std::uint8_t
>(N));
15514 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15516 oa->write_character(to_char_type(0xB9));
15517 write_number(
static_cast<std::uint16_t
>(N));
15519 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15521 oa->write_character(to_char_type(0xBA));
15522 write_number(
static_cast<std::uint32_t
>(N));
15525 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15527 oa->write_character(to_char_type(0xBB));
15528 write_number(
static_cast<std::uint64_t
>(N));
15533 for (
const auto& el : *j.m_data.m_value.object)
15535 write_cbor(el.first);
15536 write_cbor(el.second);
15541 case value_t::discarded:
15554 case value_t::null:
15556 oa->write_character(to_char_type(0xC0));
15560 case value_t::boolean:
15562 oa->write_character(j.m_data.m_value.boolean
15563 ? to_char_type(0xC3)
15564 : to_char_type(0xC2));
15568 case value_t::number_integer:
15570 if (j.m_data.m_value.number_integer >= 0)
15575 if (j.m_data.m_value.number_unsigned < 128)
15578 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15580 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15583 oa->write_character(to_char_type(0xCC));
15584 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15586 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15589 oa->write_character(to_char_type(0xCD));
15590 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15592 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15595 oa->write_character(to_char_type(0xCE));
15596 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15598 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15601 oa->write_character(to_char_type(0xCF));
15602 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15607 if (j.m_data.m_value.number_integer >= -32)
15610 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15612 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15613 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15616 oa->write_character(to_char_type(0xD0));
15617 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15619 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15620 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15623 oa->write_character(to_char_type(0xD1));
15624 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
15626 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15627 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15630 oa->write_character(to_char_type(0xD2));
15631 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
15633 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15634 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15637 oa->write_character(to_char_type(0xD3));
15638 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
15644 case value_t::number_unsigned:
15646 if (j.m_data.m_value.number_unsigned < 128)
15649 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15651 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15654 oa->write_character(to_char_type(0xCC));
15655 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15657 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15660 oa->write_character(to_char_type(0xCD));
15661 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15663 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15666 oa->write_character(to_char_type(0xCE));
15667 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15669 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15672 oa->write_character(to_char_type(0xCF));
15673 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15678 case value_t::number_float:
15684 case value_t::string:
15687 const auto N = j.m_data.m_value.string->size();
15691 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15693 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15696 oa->write_character(to_char_type(0xD9));
15697 write_number(
static_cast<std::uint8_t
>(N));
15699 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15702 oa->write_character(to_char_type(0xDA));
15703 write_number(
static_cast<std::uint16_t
>(N));
15705 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15708 oa->write_character(to_char_type(0xDB));
15709 write_number(
static_cast<std::uint32_t
>(N));
15713 oa->write_characters(
15714 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15715 j.m_data.m_value.string->size());
15719 case value_t::array:
15722 const auto N = j.m_data.m_value.array->size();
15726 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15728 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15731 oa->write_character(to_char_type(0xDC));
15732 write_number(
static_cast<std::uint16_t
>(N));
15734 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15737 oa->write_character(to_char_type(0xDD));
15738 write_number(
static_cast<std::uint32_t
>(N));
15742 for (
const auto& el : *j.m_data.m_value.array)
15749 case value_t::binary:
15753 const bool use_ext = j.m_data.m_value.binary->has_subtype();
15756 const auto N = j.m_data.m_value.binary->size();
15757 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15759 std::uint8_t output_type{};
15766 output_type = 0xD4;
15769 output_type = 0xD5;
15772 output_type = 0xD6;
15775 output_type = 0xD7;
15778 output_type = 0xD8;
15781 output_type = 0xC7;
15789 output_type = 0xC4;
15793 oa->write_character(to_char_type(output_type));
15796 write_number(
static_cast<std::uint8_t
>(N));
15799 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15801 const std::uint8_t output_type = use_ext
15805 oa->write_character(to_char_type(output_type));
15806 write_number(
static_cast<std::uint16_t
>(N));
15808 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15810 const std::uint8_t output_type = use_ext
15814 oa->write_character(to_char_type(output_type));
15815 write_number(
static_cast<std::uint32_t
>(N));
15821 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
15825 oa->write_characters(
15826 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15832 case value_t::object:
15835 const auto N = j.m_data.m_value.object->size();
15839 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15841 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15844 oa->write_character(to_char_type(0xDE));
15845 write_number(
static_cast<std::uint16_t
>(N));
15847 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15850 oa->write_character(to_char_type(0xDF));
15851 write_number(
static_cast<std::uint32_t
>(N));
15855 for (
const auto& el : *j.m_data.m_value.object)
15857 write_msgpack(el.first);
15858 write_msgpack(el.second);
15863 case value_t::discarded:
15877 const bool use_type,
const bool add_prefix =
true,
15878 const bool use_bjdata =
false)
15882 case value_t::null:
15886 oa->write_character(to_char_type(
'Z'));
15891 case value_t::boolean:
15895 oa->write_character(j.m_data.m_value.boolean
15896 ? to_char_type(
'T')
15897 : to_char_type(
'F'));
15902 case value_t::number_integer:
15904 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
15908 case value_t::number_unsigned:
15910 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
15914 case value_t::number_float:
15916 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
15920 case value_t::string:
15924 oa->write_character(to_char_type(
'S'));
15926 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
15927 oa->write_characters(
15928 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15929 j.m_data.m_value.string->size());
15933 case value_t::array:
15937 oa->write_character(to_char_type(
'['));
15940 bool prefix_required =
true;
15941 if (use_type && !j.m_data.m_value.array->empty())
15944 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15945 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15946 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15948 return ubjson_prefix(v, use_bjdata) == first_prefix;
15951 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15953 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15955 prefix_required =
false;
15956 oa->write_character(to_char_type(
'$'));
15957 oa->write_character(first_prefix);
15963 oa->write_character(to_char_type(
'#'));
15964 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
15967 for (
const auto& el : *j.m_data.m_value.array)
15969 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15974 oa->write_character(to_char_type(
']'));
15980 case value_t::binary:
15984 oa->write_character(to_char_type(
'['));
15987 if (use_type && !j.m_data.m_value.binary->empty())
15990 oa->write_character(to_char_type(
'$'));
15991 oa->write_character(
'U');
15996 oa->write_character(to_char_type(
'#'));
15997 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16002 oa->write_characters(
16003 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16004 j.m_data.m_value.binary->size());
16008 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16010 oa->write_character(to_char_type(
'U'));
16011 oa->write_character(j.m_data.m_value.binary->data()[i]);
16017 oa->write_character(to_char_type(
']'));
16023 case value_t::object:
16025 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())
16027 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type))
16035 oa->write_character(to_char_type(
'{'));
16038 bool prefix_required =
true;
16039 if (use_type && !j.m_data.m_value.object->empty())
16042 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16043 const bool same_prefix = std::all_of(j.begin(), j.end(),
16044 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16046 return ubjson_prefix(v, use_bjdata) == first_prefix;
16049 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16051 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16053 prefix_required =
false;
16054 oa->write_character(to_char_type(
'$'));
16055 oa->write_character(first_prefix);
16061 oa->write_character(to_char_type(
'#'));
16062 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16065 for (
const auto& el : *j.m_data.m_value.object)
16067 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16068 oa->write_characters(
16069 reinterpret_cast<const CharType*
>(el.first.c_str()),
16071 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
16076 oa->write_character(to_char_type(
'}'));
16082 case value_t::discarded:
16097 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
16099 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16102 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
16103 static_cast<void>(j);
16106 return 1ul + name.size() + 1u;
16112 void write_bson_entry_header(
const string_t& name,
16113 const std::uint8_t element_type)
16115 oa->write_character(to_char_type(element_type));
16116 oa->write_characters(
16117 reinterpret_cast<const CharType*
>(
name.c_str()),
16124 void write_bson_boolean(
const string_t& name,
16127 write_bson_entry_header(name, 0x08);
16128 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
16134 void write_bson_double(
const string_t& name,
16135 const double value)
16137 write_bson_entry_header(name, 0x01);
16138 write_number<double>(value,
true);
16144 static std::size_t calc_bson_string_size(
const string_t& value)
16146 return sizeof(std::int32_t) +
value.size() + 1ul;
16152 void write_bson_string(
const string_t& name,
16153 const string_t& value)
16155 write_bson_entry_header(name, 0x02);
16157 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16158 oa->write_characters(
16159 reinterpret_cast<const CharType*
>(
value.c_str()),
16166 void write_bson_null(
const string_t& name)
16168 write_bson_entry_header(name, 0x0A);
16174 static std::size_t calc_bson_integer_size(
const std::int64_t value)
16176 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
16177 ?
sizeof(std::int32_t)
16178 :
sizeof(std::int64_t);
16184 void write_bson_integer(
const string_t& name,
16185 const std::int64_t value)
16187 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16189 write_bson_entry_header(name, 0x10);
16190 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16194 write_bson_entry_header(name, 0x12);
16195 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16202 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
16204 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16205 ?
sizeof(std::int32_t)
16206 :
sizeof(std::int64_t);
16212 void write_bson_unsigned(
const string_t& name,
16213 const BasicJsonType& j)
16215 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16217 write_bson_entry_header(name, 0x10 );
16218 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16220 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16222 write_bson_entry_header(name, 0x12 );
16223 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16227 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_data.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
16234 void write_bson_object_entry(
const string_t& name,
16235 const typename BasicJsonType::object_t& value)
16237 write_bson_entry_header(name, 0x03);
16238 write_bson_object(value);
16244 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16246 std::size_t array_index = 0ul;
16248 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)
16250 return result + calc_bson_element_size(std::to_string(array_index++), el);
16253 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16259 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16261 return sizeof(std::int32_t) +
value.size() + 1ul;
16267 void write_bson_array(
const string_t& name,
16268 const typename BasicJsonType::array_t& value)
16270 write_bson_entry_header(name, 0x04);
16271 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16273 std::size_t array_index = 0ul;
16275 for (
const auto& el : value)
16277 write_bson_element(std::to_string(array_index++), el);
16280 oa->write_character(to_char_type(0x00));
16286 void write_bson_binary(
const string_t& name,
16287 const binary_t& value)
16289 write_bson_entry_header(name, 0x05);
16291 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16292 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16294 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16301 static std::size_t calc_bson_element_size(
const string_t& name,
16302 const BasicJsonType& j)
16304 const auto header_size = calc_bson_entry_header_size(name, j);
16307 case value_t::object:
16308 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16310 case value_t::array:
16311 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
16313 case value_t::binary:
16314 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
16316 case value_t::boolean:
16317 return header_size + 1ul;
16319 case value_t::number_float:
16320 return header_size + 8ul;
16322 case value_t::number_integer:
16323 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
16325 case value_t::number_unsigned:
16326 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
16328 case value_t::string:
16329 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
16331 case value_t::null:
16332 return header_size + 0ul;
16335 case value_t::discarded:
16349 void write_bson_element(
const string_t& name,
16350 const BasicJsonType& j)
16354 case value_t::object:
16355 return write_bson_object_entry(name, *j.m_data.m_value.object);
16357 case value_t::array:
16358 return write_bson_array(name, *j.m_data.m_value.array);
16360 case value_t::binary:
16361 return write_bson_binary(name, *j.m_data.m_value.binary);
16363 case value_t::boolean:
16364 return write_bson_boolean(name, j.m_data.m_value.boolean);
16366 case value_t::number_float:
16367 return write_bson_double(name, j.m_data.m_value.number_float);
16369 case value_t::number_integer:
16370 return write_bson_integer(name, j.m_data.m_value.number_integer);
16372 case value_t::number_unsigned:
16373 return write_bson_unsigned(name, j);
16375 case value_t::string:
16376 return write_bson_string(name, *j.m_data.m_value.string);
16378 case value_t::null:
16379 return write_bson_null(name);
16382 case value_t::discarded:
16396 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
16398 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
16399 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
16401 return result += calc_bson_element_size(el.first, el.second);
16404 return sizeof(std::int32_t) + document_size + 1ul;
16411 void write_bson_object(
const typename BasicJsonType::object_t& value)
16413 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
16415 for (
const auto& el : value)
16417 write_bson_element(el.first, el.second);
16420 oa->write_character(to_char_type(0x00));
16427 static constexpr CharType get_cbor_float_prefix(
float )
16429 return to_char_type(0xFA);
16432 static constexpr CharType get_cbor_float_prefix(
double )
16434 return to_char_type(0xFB);
16441 static constexpr CharType get_msgpack_float_prefix(
float )
16443 return to_char_type(0xCA);
16446 static constexpr CharType get_msgpack_float_prefix(
double )
16448 return to_char_type(0xCB);
16456 template<
typename NumberType,
typename std::enable_if<
16457 std::is_floating_point<NumberType>::value,
int>::type = 0>
16458 void write_number_with_ubjson_prefix(
const NumberType n,
16459 const bool add_prefix,
16460 const bool use_bjdata)
16464 oa->write_character(get_ubjson_float_prefix(n));
16466 write_number(n, use_bjdata);
16470 template<
typename NumberType,
typename std::enable_if<
16471 std::is_unsigned<NumberType>::value,
int>::type = 0>
16472 void write_number_with_ubjson_prefix(
const NumberType n,
16473 const bool add_prefix,
16474 const bool use_bjdata)
16476 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16480 oa->write_character(to_char_type(
'i'));
16482 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16484 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16488 oa->write_character(to_char_type(
'U'));
16490 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16492 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16496 oa->write_character(to_char_type(
'I'));
16498 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16500 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint16_t>::max)()))
16504 oa->write_character(to_char_type(
'u'));
16506 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
16508 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16512 oa->write_character(to_char_type(
'l'));
16514 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16516 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint32_t>::max)()))
16520 oa->write_character(to_char_type(
'm'));
16522 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
16524 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16528 oa->write_character(to_char_type(
'L'));
16530 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16532 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16536 oa->write_character(to_char_type(
'M'));
16538 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
16544 oa->write_character(to_char_type(
'H'));
16547 const auto number = BasicJsonType(n).dump();
16548 write_number_with_ubjson_prefix(
number.size(),
true, use_bjdata);
16549 for (std::size_t i = 0; i <
number.size(); ++i)
16551 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16557 template <
typename NumberType,
typename std::enable_if <
16558 std::is_signed<NumberType>::value&&
16559 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
16560 void write_number_with_ubjson_prefix(
const NumberType n,
16561 const bool add_prefix,
16562 const bool use_bjdata)
16564 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16568 oa->write_character(to_char_type(
'i'));
16570 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
16572 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)()))
16576 oa->write_character(to_char_type(
'U'));
16578 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16580 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16584 oa->write_character(to_char_type(
'I'));
16586 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16588 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)())))
16592 oa->write_character(to_char_type(
'u'));
16594 write_number(
static_cast<uint16_t
>(n), use_bjdata);
16596 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16600 oa->write_character(to_char_type(
'l'));
16602 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16604 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)())))
16608 oa->write_character(to_char_type(
'm'));
16610 write_number(
static_cast<uint32_t>(n), use_bjdata);
16612 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16616 oa->write_character(to_char_type(
'L'));
16618 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16625 oa->write_character(to_char_type(
'H'));
16628 const auto number = BasicJsonType(n).dump();
16629 write_number_with_ubjson_prefix(
number.size(),
true, use_bjdata);
16630 for (std::size_t i = 0; i <
number.size(); ++i)
16632 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16641 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16645 case value_t::null:
16648 case value_t::boolean:
16649 return j.m_data.m_value.boolean ?
'T' :
'F';
16651 case value_t::number_integer:
16653 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)())
16657 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)())
16661 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)())
16665 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)()))
16669 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)())
16673 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)()))
16677 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)())
16685 case value_t::number_unsigned:
16687 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16691 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16695 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16699 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16703 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16707 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16711 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16715 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16723 case value_t::number_float:
16724 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
16726 case value_t::string:
16729 case value_t::array:
16730 case value_t::binary:
16733 case value_t::object:
16736 case value_t::discarded:
16742 static constexpr CharType get_ubjson_float_prefix(
float )
16747 static constexpr CharType get_ubjson_float_prefix(
double )
16755 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type)
16757 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16758 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16761 string_t
key =
"_ArrayType_";
16762 auto it = bjdtype.find(
static_cast<string_t
>(
value.at(key)));
16763 if (it == bjdtype.end())
16767 CharType dtype = it->second;
16769 key =
"_ArraySize_";
16770 std::size_t len = (
value.at(key).empty() ? 0 : 1);
16771 for (
const auto& el :
value.at(key))
16773 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
16776 key =
"_ArrayData_";
16777 if (
value.at(key).size() != len)
16782 oa->write_character(
'[');
16783 oa->write_character(
'$');
16784 oa->write_character(dtype);
16785 oa->write_character(
'#');
16787 key =
"_ArraySize_";
16788 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
16790 key =
"_ArrayData_";
16791 if (dtype ==
'U' || dtype ==
'C')
16793 for (
const auto& el :
value.at(key))
16795 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
16798 else if (dtype ==
'i')
16800 for (
const auto& el :
value.at(key))
16802 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
16805 else if (dtype ==
'u')
16807 for (
const auto& el :
value.at(key))
16809 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
16812 else if (dtype ==
'I')
16814 for (
const auto& el :
value.at(key))
16816 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
16819 else if (dtype ==
'm')
16821 for (
const auto& el :
value.at(key))
16823 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
16826 else if (dtype ==
'l')
16828 for (
const auto& el :
value.at(key))
16830 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
16833 else if (dtype ==
'M')
16835 for (
const auto& el :
value.at(key))
16837 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
16840 else if (dtype ==
'L')
16842 for (
const auto& el :
value.at(key))
16844 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
16847 else if (dtype ==
'd')
16849 for (
const auto& el :
value.at(key))
16851 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
16854 else if (dtype ==
'D')
16856 for (
const auto& el :
value.at(key))
16858 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
16881 template<
typename NumberType>
16882 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
16885 std::array<CharType,
sizeof(NumberType)> vec{};
16886 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16889 if (is_little_endian != OutputIsLittleEndian)
16892 std::reverse(vec.begin(), vec.end());
16895 oa->write_characters(vec.data(),
sizeof(NumberType));
16901#pragma GCC diagnostic push
16902#pragma GCC diagnostic ignored "-Wfloat-equal"
16904 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16905 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16906 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
16909 ? get_cbor_float_prefix(
static_cast<float>(n))
16910 : get_msgpack_float_prefix(
static_cast<float>(n)));
16911 write_number(
static_cast<float>(n));
16916 ? get_cbor_float_prefix(n)
16917 : get_msgpack_float_prefix(n));
16921#pragma GCC diagnostic pop
16930 template <
typename C = CharType,
16931 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
16934 return *
reinterpret_cast<char*
>(&x);
16937 template <
typename C = CharType,
16938 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
16941 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16942 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16944 std::memcpy(&result, &x,
sizeof(x));
16948 template<
typename C = CharType,
16955 template <
typename InputCharType,
typename C = CharType,
16957 std::is_signed<C>::value &&
16958 std::is_signed<char>::value &&
16959 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
16968 const bool is_little_endian = little_endianness();
16991#include <algorithm>
17001#include <type_traits>
17021#include <type_traits>
17052template<
typename Target,
typename Source>
17055 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17058 std::memcpy(&target, &source,
sizeof(Source));
17069 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
17080 return {x.f - y.f, x.e};
17089 static_assert(
kPrecision == 64,
"internal error");
17114 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17115 const std::uint64_t u_hi = x.f >> 32u;
17116 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17117 const std::uint64_t v_hi = y.f >> 32u;
17119 const std::uint64_t p0 = u_lo * v_lo;
17120 const std::uint64_t p1 = u_lo * v_hi;
17121 const std::uint64_t p2 = u_hi * v_lo;
17122 const std::uint64_t p3 = u_hi * v_hi;
17124 const std::uint64_t p0_hi = p0 >> 32u;
17125 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17126 const std::uint64_t p1_hi = p1 >> 32u;
17127 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17128 const std::uint64_t p2_hi = p2 >> 32u;
17130 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17141 Q += std::uint64_t{1} << (64u - 32u - 1u);
17143 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17145 return {h, x.e + y.e + 64};
17156 while ((x.f >> 63u) == 0)
17171 const int delta = x.e - target_exponent;
17176 return {x.f << delta, target_exponent};
17193template<
typename FloatType>
17206 static_assert(std::numeric_limits<FloatType>::is_iec559,
17207 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17209 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17210 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17211 constexpr int kMinExp = 1 - kBias;
17212 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17214 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17216 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
17217 const std::uint64_t E = bits >> (kPrecision - 1);
17218 const std::uint64_t F = bits & (kHiddenBit - 1);
17220 const bool is_denormal = E == 0;
17221 const diyfp v = is_denormal
17222 ?
diyfp(F, kMinExp)
17223 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17246 const bool lower_boundary_is_closer = F == 0 && E > 1;
17248 const diyfp m_minus = lower_boundary_is_closer
17249 ?
diyfp((4 * v.
f) - 1, v.
e - 2)
17250 :
diyfp((2 * v.
f) - 1, v.
e - 1);
17385 constexpr int kCachedPowersMinDecExp = -300;
17386 constexpr int kCachedPowersDecStep = 8;
17388 static constexpr std::array<cached_power, 79> kCachedPowers =
17391 { 0xAB70FE17C79AC6CA, -1060, -300 },
17392 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17393 { 0xBE5691EF416BD60C, -1007, -284 },
17394 { 0x8DD01FAD907FFC3C, -980, -276 },
17395 { 0xD3515C2831559A83, -954, -268 },
17396 { 0x9D71AC8FADA6C9B5, -927, -260 },
17397 { 0xEA9C227723EE8BCB, -901, -252 },
17398 { 0xAECC49914078536D, -874, -244 },
17399 { 0x823C12795DB6CE57, -847, -236 },
17400 { 0xC21094364DFB5637, -821, -228 },
17401 { 0x9096EA6F3848984F, -794, -220 },
17402 { 0xD77485CB25823AC7, -768, -212 },
17403 { 0xA086CFCD97BF97F4, -741, -204 },
17404 { 0xEF340A98172AACE5, -715, -196 },
17405 { 0xB23867FB2A35B28E, -688, -188 },
17406 { 0x84C8D4DFD2C63F3B, -661, -180 },
17407 { 0xC5DD44271AD3CDBA, -635, -172 },
17408 { 0x936B9FCEBB25C996, -608, -164 },
17409 { 0xDBAC6C247D62A584, -582, -156 },
17410 { 0xA3AB66580D5FDAF6, -555, -148 },
17411 { 0xF3E2F893DEC3F126, -529, -140 },
17412 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17413 { 0x87625F056C7C4A8B, -475, -124 },
17414 { 0xC9BCFF6034C13053, -449, -116 },
17415 { 0x964E858C91BA2655, -422, -108 },
17416 { 0xDFF9772470297EBD, -396, -100 },
17417 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17418 { 0xF8A95FCF88747D94, -343, -84 },
17419 { 0xB94470938FA89BCF, -316, -76 },
17420 { 0x8A08F0F8BF0F156B, -289, -68 },
17421 { 0xCDB02555653131B6, -263, -60 },
17422 { 0x993FE2C6D07B7FAC, -236, -52 },
17423 { 0xE45C10C42A2B3B06, -210, -44 },
17424 { 0xAA242499697392D3, -183, -36 },
17425 { 0xFD87B5F28300CA0E, -157, -28 },
17426 { 0xBCE5086492111AEB, -130, -20 },
17427 { 0x8CBCCC096F5088CC, -103, -12 },
17428 { 0xD1B71758E219652C, -77, -4 },
17429 { 0x9C40000000000000, -50, 4 },
17430 { 0xE8D4A51000000000, -24, 12 },
17431 { 0xAD78EBC5AC620000, 3, 20 },
17432 { 0x813F3978F8940984, 30, 28 },
17433 { 0xC097CE7BC90715B3, 56, 36 },
17434 { 0x8F7E32CE7BEA5C70, 83, 44 },
17435 { 0xD5D238A4ABE98068, 109, 52 },
17436 { 0x9F4F2726179A2245, 136, 60 },
17437 { 0xED63A231D4C4FB27, 162, 68 },
17438 { 0xB0DE65388CC8ADA8, 189, 76 },
17439 { 0x83C7088E1AAB65DB, 216, 84 },
17440 { 0xC45D1DF942711D9A, 242, 92 },
17441 { 0x924D692CA61BE758, 269, 100 },
17442 { 0xDA01EE641A708DEA, 295, 108 },
17443 { 0xA26DA3999AEF774A, 322, 116 },
17444 { 0xF209787BB47D6B85, 348, 124 },
17445 { 0xB454E4A179DD1877, 375, 132 },
17446 { 0x865B86925B9BC5C2, 402, 140 },
17447 { 0xC83553C5C8965D3D, 428, 148 },
17448 { 0x952AB45CFA97A0B3, 455, 156 },
17449 { 0xDE469FBD99A05FE3, 481, 164 },
17450 { 0xA59BC234DB398C25, 508, 172 },
17451 { 0xF6C69A72A3989F5C, 534, 180 },
17452 { 0xB7DCBF5354E9BECE, 561, 188 },
17453 { 0x88FCF317F22241E2, 588, 196 },
17454 { 0xCC20CE9BD35C78A5, 614, 204 },
17455 { 0x98165AF37B2153DF, 641, 212 },
17456 { 0xE2A0B5DC971F303A, 667, 220 },
17457 { 0xA8D9D1535CE3B396, 694, 228 },
17458 { 0xFB9B7CD9A4A7443C, 720, 236 },
17459 { 0xBB764C4CA7A44410, 747, 244 },
17460 { 0x8BAB8EEFB6409C1A, 774, 252 },
17461 { 0xD01FEF10A657842C, 800, 260 },
17462 { 0x9B10A4E5E9913129, 827, 268 },
17463 { 0xE7109BFBA19C0C9D, 853, 276 },
17464 { 0xAC2820D9623BF429, 880, 284 },
17465 { 0x80444B5E7AA7CF85, 907, 292 },
17466 { 0xBF21E44003ACDD2D, 933, 300 },
17467 { 0x8E679C2F5E44FF8F, 960, 308 },
17468 { 0xD433179D9C8CB841, 986, 316 },
17469 { 0x9E19DB92B4E31BA9, 1013, 324 },
17479 const int f =
kAlpha - e - 1;
17480 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
17482 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17484 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
17486 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
17500 if (n >= 1000000000)
17502 pow10 = 1000000000;
17506 if (n >= 100000000)
17551inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17552 std::uint64_t rest, std::uint64_t ten_k)
17579 && delta - rest >= ten_k
17580 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17595 static_assert(
kAlpha >= -60,
"internal error");
17596 static_assert(
kGamma <= -32,
"internal error");
17613 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
17623 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
17625 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
17626 std::uint64_t p2 = M_plus.
f & (one.f - 1);
17634 std::uint32_t pow10{};
17662 const std::uint32_t d = p1 / pow10;
17663 const std::uint32_t r = p1 % pow10;
17669 buffer[length++] =
static_cast<char>(
'0' + d);
17688 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17693 decimal_exponent += n;
17704 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17705 grisu2_round(buffer, length, dist, delta, rest, ten_n);
17766 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17768 const std::uint64_t d = p2 >> -one.e;
17769 const std::uint64_t r = p2 & (one.f - 1);
17776 buffer[length++] =
static_cast<char>(
'0' + d);
17801 decimal_exponent -= m;
17809 const std::uint64_t ten_m = one.f;
17833inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17850 const diyfp c_minus_k(cached.
f, cached.
e);
17878 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17879 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
17881 decimal_exponent = -cached.
k;
17891template<
typename FloatType>
17896 "internal error: not enough precision");
17948 auto k =
static_cast<std::uint32_t
>(e);
17954 *buf++ =
static_cast<char>(
'0' + k);
17958 *buf++ =
static_cast<char>(
'0' + (k / 10));
17960 *buf++ =
static_cast<char>(
'0' + k);
17964 *buf++ =
static_cast<char>(
'0' + (k / 100));
17966 *buf++ =
static_cast<char>(
'0' + (k / 10));
17968 *buf++ =
static_cast<char>(
'0' + k);
17986 int min_exp,
int max_exp)
17992 const int n = len + decimal_exponent;
17998 if (k <= n && n <= max_exp)
18003 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18007 return buf + (
static_cast<size_t>(n) + 2);
18010 if (0 < n && n <= max_exp)
18017 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18019 return buf + (
static_cast<size_t>(k) + 1U);
18022 if (min_exp < n && n <= 0)
18027 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18030 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18031 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18046 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18048 buf += 1 +
static_cast<size_t>(k);
18067template<
typename FloatType>
18072 static_cast<void>(last);
18076 if (std::signbit(
value))
18083#pragma GCC diagnostic push
18084#pragma GCC diagnostic ignored "-Wfloat-equal"
18095#pragma GCC diagnostic pop
18098 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18105 int decimal_exponent = 0;
18108 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18111 constexpr int kMinExp = -4;
18113 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18116 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18117 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18156template<
typename BasicJsonType>
18159 using string_t =
typename BasicJsonType::string_t;
18160 using number_float_t =
typename BasicJsonType::number_float_t;
18161 using number_integer_t =
typename BasicJsonType::number_integer_t;
18162 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18163 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
18164 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18165 static constexpr std::uint8_t UTF8_REJECT = 1;
18176 ,
loc(
std::localeconv())
18214 const bool pretty_print,
18216 const unsigned int indent_step,
18217 const unsigned int current_indent = 0)
18219 switch (val.m_data.m_type)
18223 if (val.m_data.m_value.object->empty())
18225 o->write_characters(
"{}", 2);
18231 o->write_characters(
"{\n", 2);
18234 const auto new_indent = current_indent + indent_step;
18241 auto i = val.m_data.m_value.object->cbegin();
18242 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18245 o->write_character(
'\"');
18247 o->write_characters(
"\": ", 3);
18249 o->write_characters(
",\n", 2);
18253 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18254 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18256 o->write_character(
'\"');
18258 o->write_characters(
"\": ", 3);
18261 o->write_character(
'\n');
18262 o->write_characters(
indent_string.c_str(), current_indent);
18263 o->write_character(
'}');
18267 o->write_character(
'{');
18270 auto i = val.m_data.m_value.object->cbegin();
18271 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18273 o->write_character(
'\"');
18275 o->write_characters(
"\":", 2);
18277 o->write_character(
',');
18281 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18282 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18283 o->write_character(
'\"');
18285 o->write_characters(
"\":", 2);
18288 o->write_character(
'}');
18296 if (val.m_data.m_value.array->empty())
18298 o->write_characters(
"[]", 2);
18304 o->write_characters(
"[\n", 2);
18307 const auto new_indent = current_indent + indent_step;
18314 for (
auto i = val.m_data.m_value.array->cbegin();
18315 i != val.m_data.m_value.array->cend() - 1; ++i)
18319 o->write_characters(
",\n", 2);
18325 dump(val.m_data.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
18327 o->write_character(
'\n');
18328 o->write_characters(
indent_string.c_str(), current_indent);
18329 o->write_character(
']');
18333 o->write_character(
'[');
18336 for (
auto i = val.m_data.m_value.array->cbegin();
18337 i != val.m_data.m_value.array->cend() - 1; ++i)
18340 o->write_character(
',');
18345 dump(val.m_data.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
18347 o->write_character(
']');
18355 o->write_character(
'\"');
18356 dump_escaped(*val.m_data.m_value.string,
ensure_ascii);
18357 o->write_character(
'\"');
18365 o->write_characters(
"{\n", 2);
18368 const auto new_indent = current_indent + indent_step;
18376 o->write_characters(
"\"bytes\": [", 10);
18378 if (!val.m_data.m_value.binary->empty())
18380 for (
auto i = val.m_data.m_value.binary->cbegin();
18381 i != val.m_data.m_value.binary->cend() - 1; ++i)
18384 o->write_characters(
", ", 2);
18386 dump_integer(val.m_data.m_value.binary->back());
18389 o->write_characters(
"],\n", 3);
18392 o->write_characters(
"\"subtype\": ", 11);
18393 if (val.m_data.m_value.binary->has_subtype())
18395 dump_integer(val.m_data.m_value.binary->subtype());
18399 o->write_characters(
"null", 4);
18401 o->write_character(
'\n');
18402 o->write_characters(
indent_string.c_str(), current_indent);
18403 o->write_character(
'}');
18407 o->write_characters(
"{\"bytes\":[", 10);
18409 if (!val.m_data.m_value.binary->empty())
18411 for (
auto i = val.m_data.m_value.binary->cbegin();
18412 i != val.m_data.m_value.binary->cend() - 1; ++i)
18415 o->write_character(
',');
18417 dump_integer(val.m_data.m_value.binary->back());
18420 o->write_characters(
"],\"subtype\":", 12);
18421 if (val.m_data.m_value.binary->has_subtype())
18423 dump_integer(val.m_data.m_value.binary->subtype());
18424 o->write_character(
'}');
18428 o->write_characters(
"null}", 5);
18436 if (val.m_data.m_value.boolean)
18438 o->write_characters(
"true", 4);
18442 o->write_characters(
"false", 5);
18449 dump_integer(val.m_data.m_value.number_integer);
18455 dump_integer(val.m_data.m_value.number_unsigned);
18461 dump_float(val.m_data.m_value.number_float);
18467 o->write_characters(
"<discarded>", 11);
18473 o->write_characters(
"null", 4);
18499 std::uint32_t codepoint{};
18507 for (std::size_t i = 0; i < s.size(); ++i)
18509 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18511 switch (decode(
state, codepoint,
byte))
18570 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
18572 if (codepoint <= 0xFFFF)
18576 static_cast<std::uint16_t
>(codepoint)));
18582 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
18583 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18584 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18672 state = UTF8_ACCEPT;
18728 o->write_characters(
"\\ufffd", 6);
18732 o->write_characters(
"\xEF\xBF\xBD", 3);
18752 unsigned int count_digits(number_unsigned_t x)
noexcept
18754 unsigned int n_digits = 1;
18763 return n_digits + 1;
18767 return n_digits + 2;
18771 return n_digits + 3;
18783 static std::string hex_bytes(std::uint8_t
byte)
18785 std::string
result =
"FF";
18786 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
18787 result[0] = nibble_to_hex[
byte / 16];
18788 result[1] = nibble_to_hex[
byte % 16];
18793 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18794 bool is_negative_number(NumberType x)
18799 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18800 bool is_negative_number(NumberType )
18815 std::is_integral<NumberType>::value ||
18816 std::is_same<NumberType, number_unsigned_t>::value ||
18817 std::is_same<NumberType, number_integer_t>::value ||
18818 std::is_same<NumberType, binary_char_t>::value,
18820 void dump_integer(NumberType x)
18822 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18825 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18826 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18827 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18828 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18829 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18830 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18831 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18832 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18833 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18834 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18841 o->write_character(
'0');
18848 number_unsigned_t abs_value;
18850 unsigned int n_chars{};
18852 if (is_negative_number(x))
18855 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
18858 n_chars = 1 + count_digits(abs_value);
18862 abs_value =
static_cast<number_unsigned_t
>(
x);
18863 n_chars = count_digits(abs_value);
18871 buffer_ptr += n_chars;
18875 while (abs_value >= 100)
18877 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18879 *(--buffer_ptr) = digits_to_99[digits_index][1];
18880 *(--buffer_ptr) = digits_to_99[digits_index][0];
18883 if (abs_value >= 10)
18885 const auto digits_index =
static_cast<unsigned>(abs_value);
18886 *(--buffer_ptr) = digits_to_99[digits_index][1];
18887 *(--buffer_ptr) = digits_to_99[digits_index][0];
18891 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18905 void dump_float(number_float_t x)
18908 if (!std::isfinite(x))
18910 o->write_characters(
"null", 4);
18919 static constexpr bool is_ieee_single_or_double
18920 = (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) ||
18921 (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);
18923 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18926 void dump_float(number_float_t x, std::true_type )
18929 auto* end = ::nlohmann::detail::to_chars(begin, begin +
number_buffer.size(), x);
18931 o->write_characters(begin,
static_cast<size_t>(end - begin));
18934 void dump_float(number_float_t x, std::false_type )
18937 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
18969 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
18972 const bool value_is_int_like =
18976 return c ==
'.' || c ==
'e';
18979 if (value_is_int_like)
18981 o->write_characters(
".0", 2);
19006 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19008 static const std::array<std::uint8_t, 400> utf8d =
19011 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,
19012 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,
19013 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,
19014 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,
19015 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,
19016 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,
19017 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,
19018 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19019 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19020 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19021 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,
19022 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,
19023 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,
19024 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
19029 const std::uint8_t
type = utf8d[byte];
19031 codep = (
state != UTF8_ACCEPT)
19032 ? (
byte & 0x3fu) | (codep << 6u)
19033 : (0xFFu >> type) & (byte);
19035 const std::size_t index = 256u + (
static_cast<size_t>(
state) * 16u) +
static_cast<size_t>(
type);
19037 state = utf8d[index];
19046 number_unsigned_t remove_sign(number_unsigned_t x)
19061 number_unsigned_t remove_sign(number_integer_t x)
noexcept
19063 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19064 return static_cast<number_unsigned_t
>(-(
x + 1)) + 1;
19069 output_adapter_t<char> o =
nullptr;
19111#include <functional>
19112#include <initializer_list>
19115#include <stdexcept>
19116#include <type_traits>
19129template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19130 class Allocator = std::allocator<std::pair<const Key, T>>>
19135 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19140#ifdef JSON_HAS_CPP_14
19150 template <
class It>
19153 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19158 for (
auto it = this->begin(); it != this->end(); ++it)
19160 if (m_compare(it->first, key))
19162 return {it,
false};
19165 Container::emplace_back(key, std::forward<T>(t));
19166 return {std::prev(this->end()),
true};
19171 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19173 for (
auto it = this->begin(); it != this->end(); ++it)
19175 if (m_compare(it->first, key))
19177 return {it,
false};
19180 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19181 return {std::prev(this->end()),
true};
19186 return emplace(key, T{}).first->second;
19193 return emplace(std::forward<KeyType>(key), T{}).first->second;
19205 return at(std::forward<KeyType>(key));
19210 for (
auto it = this->begin(); it != this->end(); ++it)
19212 if (m_compare(it->first, key))
19218 JSON_THROW(std::out_of_range(
"key not found"));
19225 for (
auto it = this->begin(); it != this->end(); ++it)
19227 if (m_compare(it->first, key))
19233 JSON_THROW(std::out_of_range(
"key not found"));
19238 for (
auto it = this->begin(); it != this->end(); ++it)
19240 if (m_compare(it->first, key))
19246 JSON_THROW(std::out_of_range(
"key not found"));
19251 const T &
at(KeyType && key)
const
19253 for (
auto it = this->begin(); it != this->end(); ++it)
19255 if (m_compare(it->first, key))
19261 JSON_THROW(std::out_of_range(
"key not found"));
19266 for (
auto it = this->begin(); it != this->end(); ++it)
19268 if (m_compare(it->first, key))
19271 for (
auto next = it; ++next != this->end(); ++it)
19276 Container::pop_back();
19287 for (
auto it = this->begin(); it != this->end(); ++it)
19289 if (m_compare(it->first, key))
19292 for (
auto next = it; ++next != this->end(); ++it)
19297 Container::pop_back();
19306 return erase(pos, std::next(pos));
19316 const auto elements_affected = std::distance(first, last);
19317 const auto offset = std::distance(Container::begin(), first);
19339 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
19342 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19350 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
19359 return Container::begin() + offset;
19364 for (
auto it = this->begin(); it != this->end(); ++it)
19366 if (m_compare(it->first, key))
19378 for (
auto it = this->begin(); it != this->end(); ++it)
19380 if (m_compare(it->first, key))
19390 for (
auto it = this->begin(); it != this->end(); ++it)
19392 if (m_compare(it->first, key))
19397 return Container::end();
19404 for (
auto it = this->begin(); it != this->end(); ++it)
19406 if (m_compare(it->first, key))
19411 return Container::end();
19416 for (
auto it = this->begin(); it != this->end(); ++it)
19418 if (m_compare(it->first, key))
19423 return Container::end();
19428 return emplace(value.first, std::move(value.second));
19433 for (
auto it = this->begin(); it != this->end(); ++it)
19435 if (m_compare(it->first, value.first))
19437 return {it,
false};
19440 Container::push_back(value);
19441 return {--this->end(),
true};
19444 template<
typename InputIt>
19445 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19446 std::input_iterator_tag>::value>::type;
19448 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19451 for (
auto it = first; it != last; ++it)
19464#if defined(JSON_HAS_CPP_17)
19465 #if JSON_HAS_STATIC_RTTI
19468 #include <string_view>
19498 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
19504 friend class ::nlohmann::json_pointer;
19508 template<
typename BasicJsonType,
typename InputType>
19509 friend class ::nlohmann::detail::parser;
19510 friend ::nlohmann::detail::serializer<basic_json>;
19511 template<
typename BasicJsonType>
19512 friend class ::nlohmann::detail::iter_impl;
19513 template<
typename BasicJsonType,
typename CharType>
19514 friend class ::nlohmann::detail::binary_writer;
19515 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19516 friend class ::nlohmann::detail::binary_reader;
19517 template<
typename BasicJsonType>
19518 friend class ::nlohmann::detail::json_sax_dom_parser;
19519 template<
typename BasicJsonType>
19520 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19521 friend class ::nlohmann::detail::exception;
19525 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
19529 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19531 template<
typename InputAdapterType>
19532 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19533 InputAdapterType adapter,
19535 const bool allow_exceptions =
true,
19536 const bool ignore_comments =
false
19539 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19540 std::move(cb), allow_exceptions, ignore_comments);
19544 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
19545 template<
typename BasicJsonType>
19546 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
19547 template<
typename BasicJsonType>
19548 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
19549 template<
typename Iterator>
19550 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
19551 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
19553 template<
typename CharType>
19554 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
19556 template<
typename InputType>
19557 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
19558 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19561 using serializer = ::nlohmann::detail::serializer<basic_json>;
19567 template<
typename T,
typename SFINAE>
19623 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19625 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19652 result[
"copyright"] =
"(C) 2013-2023 Niels Lohmann";
19653 result[
"name"] =
"JSON for Modern C++";
19654 result[
"url"] =
"https://github.com/nlohmann/json";
19655 result[
"version"][
"string"] =
19664 result[
"platform"] =
"win32";
19665#elif defined __linux__
19666 result[
"platform"] =
"linux";
19667#elif defined __APPLE__
19668 result[
"platform"] =
"apple";
19669#elif defined __unix__
19670 result[
"platform"] =
"unix";
19672 result[
"platform"] =
"unknown";
19675#if defined(__ICC) || defined(__INTEL_COMPILER)
19676 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19677#elif defined(__clang__)
19678 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19679#elif defined(__GNUC__) || defined(__GNUG__)
19680 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19681 std::to_string(__GNUC__),
'.',
19682 std::to_string(__GNUC_MINOR__),
'.',
19683 std::to_string(__GNUC_PATCHLEVEL__))
19686#elif defined(__HP_cc) || defined(__HP_aCC)
19687 result[
"compiler"] =
"hp"
19688#elif defined(__IBMCPP__)
19689 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19690#elif defined(_MSC_VER)
19691 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19692#elif defined(__PGI)
19693 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19694#elif defined(__SUNPRO_CC)
19695 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19697 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19700#if defined(_MSVC_LANG)
19701 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
19702#elif defined(__cplusplus)
19703 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
19705 result[
"compiler"][
"c++"] =
"unknown";
19723#if defined(JSON_HAS_CPP_14)
19736 AllocatorType<std::pair<
const StringType,
19741 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19765 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19776 template<
typename T,
typename... Args>
19778 static T* create(Args&& ... args)
19780 AllocatorType<T> alloc;
19781 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19783 auto deleter = [&](T * obj)
19785 AllocatorTraits::deallocate(alloc, obj, 1);
19787 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19788 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19790 return obj.release();
19843 json_value() =
default;
19845 json_value(
boolean_t v) noexcept : boolean(v) {}
19857 case value_t::object:
19859 object = create<object_t>();
19863 case value_t::array:
19865 array = create<array_t>();
19869 case value_t::string:
19871 string = create<string_t>(
"");
19875 case value_t::binary:
19877 binary = create<binary_t>();
19881 case value_t::boolean:
19883 boolean =
static_cast<boolean_t>(
false);
19887 case value_t::number_integer:
19893 case value_t::number_unsigned:
19899 case value_t::number_float:
19905 case value_t::null:
19911 case value_t::discarded:
19957 (t == value_t::object &&
object ==
nullptr) ||
19958 (t == value_t::array && array ==
nullptr) ||
19959 (t == value_t::string &&
string ==
nullptr) ||
19960 (t == value_t::binary && binary ==
nullptr)
19966 if (t == value_t::array || t == value_t::object)
19969 std::vector<basic_json> stack;
19972 if (t == value_t::array)
19974 stack.reserve(
array->size());
19975 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
19980 for (
auto&& it : *
object)
19982 stack.push_back(std::move(it.second));
19986 while (!stack.empty())
19989 basic_json current_item(std::move(stack.back()));
19994 if (current_item.is_array())
19996 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
19998 current_item.m_data.m_value.array->clear();
20000 else if (current_item.is_object())
20002 for (
auto&& it : *current_item.m_data.m_value.object)
20004 stack.push_back(std::move(it.second));
20007 current_item.m_data.m_value.object->clear();
20017 case value_t::object:
20019 AllocatorType<object_t> alloc;
20020 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20021 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20025 case value_t::array:
20027 AllocatorType<array_t> alloc;
20028 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20029 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20033 case value_t::string:
20035 AllocatorType<string_t> alloc;
20036 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20037 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20041 case value_t::binary:
20043 AllocatorType<binary_t> alloc;
20044 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20045 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20049 case value_t::null:
20050 case value_t::boolean:
20051 case value_t::number_integer:
20052 case value_t::number_unsigned:
20053 case value_t::number_float:
20054 case value_t::discarded:
20082 void assert_invariant(
bool check_parents =
true) const noexcept
20089#if JSON_DIAGNOSTICS
20095 return j.m_parent ==
this;
20100 static_cast<void>(check_parents);
20105#if JSON_DIAGNOSTICS
20108 case value_t::array:
20110 for (
auto& element : *
m_data.m_value.array)
20112 element.m_parent =
this;
20117 case value_t::object:
20119 for (
auto& element : *
m_data.m_value.object)
20121 element.second.m_parent =
this;
20126 case value_t::null:
20127 case value_t::string:
20128 case value_t::boolean:
20129 case value_t::number_integer:
20130 case value_t::number_unsigned:
20131 case value_t::number_float:
20132 case value_t::binary:
20133 case value_t::discarded:
20140 iterator set_parents(
iterator it,
typename iterator::difference_type count_set_parents)
20142#if JSON_DIAGNOSTICS
20143 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20145 (it + i)->m_parent =
this;
20148 static_cast<void>(count_set_parents);
20153 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
20155#if JSON_DIAGNOSTICS
20156 if (old_capacity !=
static_cast<std::size_t
>(-1))
20170#ifdef JSON_HEDLEY_MSVC_VERSION
20171#pragma warning(push )
20172#pragma warning(disable : 4127)
20179#ifdef JSON_HEDLEY_MSVC_VERSION
20180#pragma warning( pop )
20185 static_cast<void>(j);
20186 static_cast<void>(old_capacity);
20218 assert_invariant();
20226 assert_invariant();
20231 template <
typename CompatibleType,
20236 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20237 std::forward<CompatibleType>(val))))
20239 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20241 assert_invariant();
20246 template <
typename BasicJsonType,
20251 using other_boolean_t =
typename BasicJsonType::boolean_t;
20252 using other_number_float_t =
typename BasicJsonType::number_float_t;
20253 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20254 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20255 using other_string_t =
typename BasicJsonType::string_t;
20256 using other_object_t =
typename BasicJsonType::object_t;
20257 using other_array_t =
typename BasicJsonType::array_t;
20258 using other_binary_t =
typename BasicJsonType::binary_t;
20260 switch (val.type())
20262 case value_t::boolean:
20263 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
20265 case value_t::number_float:
20266 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
20268 case value_t::number_integer:
20269 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
20271 case value_t::number_unsigned:
20272 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
20274 case value_t::string:
20275 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
20277 case value_t::object:
20278 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
20280 case value_t::array:
20281 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
20283 case value_t::binary:
20284 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
20286 case value_t::null:
20289 case value_t::discarded:
20290 m_data.m_type = value_t::discarded;
20297 assert_invariant();
20303 bool type_deduction =
true,
20304 value_t manual_type = value_t::array)
20308 bool is_an_object = std::all_of(init.begin(), init.end(),
20314 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
20318 if (!type_deduction)
20321 if (manual_type == value_t::array)
20323 is_an_object =
false;
20336 m_data.m_type = value_t::object;
20337 m_data.m_value = value_t::object;
20339 for (
auto& element_ref : init)
20342 m_data.m_value.object->emplace(
20343 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
20344 std::move((*element.m_data.m_value.array)[1]));
20350 m_data.m_type = value_t::array;
20351 m_data.m_value.array = create<array_t>(init.begin(), init.end());
20355 assert_invariant();
20364 res.m_data.m_type = value_t::binary;
20365 res.m_data.m_value = init;
20372 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20375 res.m_data.m_type = value_t::binary;
20376 res.m_data.m_value =
binary_t(init, subtype);
20386 res.m_data.m_type = value_t::binary;
20387 res.m_data.m_value = std::move(init);
20394 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
20397 res.m_data.m_type = value_t::binary;
20398 res.m_data.m_value =
binary_t(std::move(init), subtype);
20407 return basic_json(init,
false, value_t::array);
20415 return basic_json(init,
false, value_t::object);
20424 assert_invariant();
20429 template <
class InputIT,
typename std::enable_if <
20430 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
20431 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
20444 m_data.m_type = first.m_object->m_data.m_type;
20449 case value_t::boolean:
20450 case value_t::number_float:
20451 case value_t::number_integer:
20452 case value_t::number_unsigned:
20453 case value_t::string:
20456 || !last.m_it.primitive_iterator.is_end()))
20463 case value_t::null:
20464 case value_t::object:
20465 case value_t::array:
20466 case value_t::binary:
20467 case value_t::discarded:
20474 case value_t::number_integer:
20476 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
20480 case value_t::number_unsigned:
20482 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
20486 case value_t::number_float:
20488 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
20492 case value_t::boolean:
20494 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
20498 case value_t::string:
20500 m_data.m_value = *first.m_object->m_data.m_value.string;
20504 case value_t::object:
20506 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
20507 last.m_it.object_iterator);
20511 case value_t::array:
20513 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
20514 last.m_it.array_iterator);
20518 case value_t::binary:
20520 m_data.m_value = *first.m_object->m_data.m_value.binary;
20524 case value_t::null:
20525 case value_t::discarded:
20531 assert_invariant();
20538 template<
typename JsonRef,
20540 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
20546 : json_base_class_t(other)
20548 m_data.m_type = other.m_data.m_type;
20550 other.assert_invariant();
20554 case value_t::object:
20556 m_data.m_value = *other.m_data.m_value.object;
20560 case value_t::array:
20562 m_data.m_value = *other.m_data.m_value.array;
20566 case value_t::string:
20568 m_data.m_value = *other.m_data.m_value.string;
20572 case value_t::boolean:
20574 m_data.m_value = other.m_data.m_value.boolean;
20578 case value_t::number_integer:
20580 m_data.m_value = other.m_data.m_value.number_integer;
20584 case value_t::number_unsigned:
20586 m_data.m_value = other.m_data.m_value.number_unsigned;
20590 case value_t::number_float:
20592 m_data.m_value = other.m_data.m_value.number_float;
20596 case value_t::binary:
20598 m_data.m_value = *other.m_data.m_value.binary;
20602 case value_t::null:
20603 case value_t::discarded:
20609 assert_invariant();
20615 : json_base_class_t(std::forward<json_base_class_t>(other)),
20616 m_data(std::move(other.m_data))
20619 other.assert_invariant(
false);
20622 other.m_data.m_type = value_t::null;
20623 other.m_data.m_value = {};
20626 assert_invariant();
20632 std::is_nothrow_move_constructible<value_t>::value&&
20633 std::is_nothrow_move_assignable<value_t>::value&&
20634 std::is_nothrow_move_constructible<json_value>::value&&
20635 std::is_nothrow_move_assignable<json_value>::value&&
20636 std::is_nothrow_move_assignable<json_base_class_t>::value
20640 other.assert_invariant();
20645 json_base_class_t::operator=(std::move(other));
20648 assert_invariant();
20656 assert_invariant(
false);
20673 const char indent_char =
' ',
20674 const bool ensure_ascii =
false,
20682 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20686 s.dump(*
this,
false, ensure_ascii, 0);
20717 return m_data.m_type == value_t::null;
20724 return m_data.m_type == value_t::boolean;
20738 return m_data.m_type == value_t::number_integer ||
m_data.m_type == value_t::number_unsigned;
20745 return m_data.m_type == value_t::number_unsigned;
20752 return m_data.m_type == value_t::number_float;
20759 return m_data.m_type == value_t::object;
20766 return m_data.m_type == value_t::array;
20773 return m_data.m_type == value_t::string;
20780 return m_data.m_type == value_t::binary;
20787 return m_data.m_type == value_t::discarded;
20809 return m_data.m_value.boolean;
20834 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
20922 template<
typename ReferenceType,
typename ThisType>
20923 static ReferenceType get_ref_impl(ThisType& obj)
20926 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20943 template<
typename PointerType,
typename std::enable_if<
20944 std::is_pointer<PointerType>::value,
int>
::type = 0>
20945 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20948 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20953 template <
typename PointerType,
typename std::enable_if <
20954 std::is_pointer<PointerType>::value&&
20955 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
20956 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20959 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21001 template <
typename ValueType,
21007 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21009 auto ret = ValueType();
21010 JSONSerializer<ValueType>::from_json(*
this, ret);
21044 template <
typename ValueType,
21049 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21051 return JSONSerializer<ValueType>::from_json(*
this);
21069 template <
typename BasicJsonType,
21092 template<
typename BasicJsonType,
21094 std::is_same<BasicJsonType, basic_json_t>::value,
21105 template<
typename PointerType,
21107 std::is_pointer<PointerType>::value,
21110 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21113 return get_ptr<PointerType>();
21140 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21141#if defined(JSON_HAS_CPP_14)
21145 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21151 static_assert(!std::is_reference<ValueTypeCV>::value,
21152 "get() cannot be used with reference types, you might want to use get_ref()");
21183 template<
typename PointerType,
typename std::enable_if<
21184 std::is_pointer<PointerType>::value,
int>
::type = 0>
21185 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
21188 return get_ptr<PointerType>();
21193 template <
typename ValueType,
21198 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
21199 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21201 JSONSerializer<ValueType>::from_json(*
this, v);
21207 template<
typename ValueType,
21218 typename T, std::size_t N,
21219 typename Array = T (&)[N],
21223 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21224 std::declval<const basic_json_t&>(), v)))
21226 JSONSerializer<Array>::from_json(*
this, v);
21232 template<
typename ReferenceType,
typename std::enable_if<
21233 std::is_reference<ReferenceType>::value,
int>
::type = 0>
21237 return get_ref_impl<ReferenceType>(*
this);
21242 template <
typename ReferenceType,
typename std::enable_if <
21243 std::is_reference<ReferenceType>::value&&
21244 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
21248 return get_ref_impl<ReferenceType>(*
this);
21280 template <
typename ValueType,
typename std::enable_if <
21288#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21291#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
21299 return get<ValueType>();
21311 return *get_ptr<binary_t*>();
21323 return *get_ptr<const binary_t*>();
21345 return set_parent(
m_data.m_value.array->at(idx));
21368 return m_data.m_value.array->at(idx);
21392 auto it =
m_data.m_value.object->find(key);
21393 if (it ==
m_data.m_value.object->end())
21397 return set_parent(it->second);
21412 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21413 if (it ==
m_data.m_value.object->end())
21417 return set_parent(it->second);
21430 auto it =
m_data.m_value.object->find(key);
21431 if (it ==
m_data.m_value.object->end())
21450 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21451 if (it ==
m_data.m_value.object->end())
21465 m_data.m_type = value_t::array;
21466 m_data.m_value.array = create<array_t>();
21467 assert_invariant();
21474 if (idx >=
m_data.m_value.array->size())
21476#if JSON_DIAGNOSTICS
21478 const auto old_size =
m_data.m_value.array->size();
21479 const auto old_capacity =
m_data.m_value.array->capacity();
21481 m_data.m_value.array->resize(idx + 1);
21483#if JSON_DIAGNOSTICS
21492 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21495 assert_invariant();
21498 return m_data.m_value.array->operator[](idx);
21511 return m_data.m_value.array->operator[](idx);
21524 m_data.m_type = value_t::object;
21525 m_data.m_value.object = create<object_t>();
21526 assert_invariant();
21532 auto result =
m_data.m_value.object->emplace(std::move(key),
nullptr);
21533 return set_parent(result.first->second);
21546 auto it =
m_data.m_value.object->find(key);
21556 template<
typename T>
21559 return operator[](
typename object_t::key_type(key));
21562 template<
typename T>
21565 return operator[](
typename object_t::key_type(key));
21577 m_data.m_type = value_t::object;
21578 m_data.m_value.object = create<object_t>();
21579 assert_invariant();
21585 auto result =
m_data.m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
21586 return set_parent(result.first->second);
21601 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21610 template<
typename KeyType>
21614 template<
typename ValueType>
21615 using value_return_type = std::conditional <
21617 string_t,
typename std::decay<ValueType>::type >;
21625 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21626 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
21632 const auto it =
find(key);
21635 return it->template get<ValueType>();
21638 return default_value;
21646 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21650 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21651 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
21657 const auto it =
find(key);
21660 return it->template get<ReturnType>();
21663 return std::forward<ValueType>(default_value);
21674 && is_comparable_with_object_key<KeyType>::value
21676 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21677 ValueType
value(KeyType && key,
const ValueType& default_value)
const
21683 const auto it =
find(std::forward<KeyType>(key));
21686 return it->template get<ValueType>();
21689 return default_value;
21697 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
21701 && is_comparable_with_object_key<KeyType>::value
21703 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21704 ReturnType
value(KeyType && key, ValueType && default_value)
const
21710 const auto it =
find(std::forward<KeyType>(key));
21713 return it->template get<ReturnType>();
21716 return std::forward<ValueType>(default_value);
21726 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21735 return ptr.get_checked(
this).template get<ValueType>();
21739 return default_value;
21748 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21751 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21760 return ptr.get_checked(
this).template get<ReturnType>();
21764 return std::forward<ValueType>(default_value);
21774 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21776 ValueType
value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
21778 return value(ptr.convert(), default_value);
21781 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
21785 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21789 return value(ptr.convert(), std::forward<ValueType>(default_value));
21827 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21828 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21837 IteratorType result =
end();
21841 case value_t::boolean:
21842 case value_t::number_float:
21843 case value_t::number_integer:
21844 case value_t::number_unsigned:
21845 case value_t::string:
21846 case value_t::binary:
21855 AllocatorType<string_t> alloc;
21856 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
21857 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
21858 m_data.m_value.string =
nullptr;
21862 AllocatorType<binary_t> alloc;
21863 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
21864 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
21865 m_data.m_value.binary =
nullptr;
21868 m_data.m_type = value_t::null;
21869 assert_invariant();
21873 case value_t::object:
21875 result.m_it.object_iterator =
m_data.m_value.object->erase(pos.m_it.object_iterator);
21879 case value_t::array:
21881 result.m_it.array_iterator =
m_data.m_value.array->erase(pos.m_it.array_iterator);
21885 case value_t::null:
21886 case value_t::discarded:
21897 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21898 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21899 IteratorType
erase(IteratorType first, IteratorType last)
21907 IteratorType result =
end();
21911 case value_t::boolean:
21912 case value_t::number_float:
21913 case value_t::number_integer:
21914 case value_t::number_unsigned:
21915 case value_t::string:
21916 case value_t::binary:
21919 || !last.m_it.primitive_iterator.is_end()))
21926 AllocatorType<string_t> alloc;
21927 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
21928 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
21929 m_data.m_value.string =
nullptr;
21933 AllocatorType<binary_t> alloc;
21934 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
21935 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
21936 m_data.m_value.binary =
nullptr;
21939 m_data.m_type = value_t::null;
21940 assert_invariant();
21944 case value_t::object:
21946 result.m_it.object_iterator =
m_data.m_value.object->erase(first.m_it.object_iterator,
21947 last.m_it.object_iterator);
21951 case value_t::array:
21953 result.m_it.array_iterator =
m_data.m_value.array->erase(first.m_it.array_iterator,
21954 last.m_it.array_iterator);
21958 case value_t::null:
21959 case value_t::discarded:
21970 size_type erase_internal(KeyType && key)
21978 return m_data.m_value.object->erase(std::forward<KeyType>(key));
21983 size_type erase_internal(KeyType && key)
21991 const auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21992 if (it !=
m_data.m_value.object->end())
21994 m_data.m_value.object->erase(it);
22008 return erase_internal(key);
22017 return erase_internal(std::forward<KeyType>(key));
22053 auto result =
end();
22057 result.m_it.object_iterator =
m_data.m_value.object->find(key);
22067 auto result =
cend();
22071 result.m_it.object_iterator =
m_data.m_value.object->find(key);
22083 auto result =
end();
22087 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(key));
22099 auto result =
cend();
22103 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(key));
22124 return is_object() ?
m_data.m_value.object->count(std::forward<KeyType>(key)) : 0;
22129 bool contains(
const typename object_t::key_type& key)
const
22140 return is_object() &&
m_data.m_value.object->find(std::forward<KeyType>(key)) !=
m_data.m_value.object->end();
22147 return ptr.contains(
this);
22150 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22154 return ptr.contains(
this);
22171 result.set_begin();
22187 result.set_begin();
22267 return ref.items();
22278 return ref.items();
22285 return iteration_proxy<iterator>(*
this);
22290 iteration_proxy<const_iterator>
items() const noexcept
22292 return iteration_proxy<const_iterator>(*
this);
22310 case value_t::null:
22316 case value_t::array:
22319 return m_data.m_value.array->empty();
22322 case value_t::object:
22325 return m_data.m_value.object->empty();
22328 case value_t::string:
22329 case value_t::boolean:
22330 case value_t::number_integer:
22331 case value_t::number_unsigned:
22332 case value_t::number_float:
22333 case value_t::binary:
22334 case value_t::discarded:
22349 case value_t::null:
22355 case value_t::array:
22358 return m_data.m_value.array->size();
22361 case value_t::object:
22364 return m_data.m_value.object->size();
22367 case value_t::string:
22368 case value_t::boolean:
22369 case value_t::number_integer:
22370 case value_t::number_unsigned:
22371 case value_t::number_float:
22372 case value_t::binary:
22373 case value_t::discarded:
22388 case value_t::array:
22391 return m_data.m_value.array->max_size();
22394 case value_t::object:
22397 return m_data.m_value.object->max_size();
22400 case value_t::null:
22401 case value_t::string:
22402 case value_t::boolean:
22403 case value_t::number_integer:
22404 case value_t::number_unsigned:
22405 case value_t::number_float:
22406 case value_t::binary:
22407 case value_t::discarded:
22431 case value_t::number_integer:
22433 m_data.m_value.number_integer = 0;
22437 case value_t::number_unsigned:
22439 m_data.m_value.number_unsigned = 0;
22443 case value_t::number_float:
22445 m_data.m_value.number_float = 0.0;
22449 case value_t::boolean:
22451 m_data.m_value.boolean =
false;
22455 case value_t::string:
22457 m_data.m_value.string->clear();
22461 case value_t::binary:
22463 m_data.m_value.binary->clear();
22467 case value_t::array:
22469 m_data.m_value.array->clear();
22473 case value_t::object:
22475 m_data.m_value.object->clear();
22479 case value_t::null:
22480 case value_t::discarded:
22499 m_data.m_type = value_t::array;
22500 m_data.m_value = value_t::array;
22501 assert_invariant();
22505 const auto old_capacity =
m_data.m_value.array->capacity();
22506 m_data.m_value.array->push_back(std::move(val));
22507 set_parent(
m_data.m_value.array->back(), old_capacity);
22532 m_data.m_type = value_t::array;
22533 m_data.m_value = value_t::array;
22534 assert_invariant();
22538 const auto old_capacity =
m_data.m_value.array->capacity();
22539 m_data.m_value.array->push_back(val);
22540 set_parent(
m_data.m_value.array->back(), old_capacity);
22564 m_data.m_type = value_t::object;
22565 m_data.m_value = value_t::object;
22566 assert_invariant();
22570 auto res =
m_data.m_value.object->insert(val);
22571 set_parent(res.first->second);
22586 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
22588 basic_json&& key = init.begin()->moved_or_copied();
22589 push_back(
typename object_t::value_type(
22590 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22608 template<
class... Args>
22620 m_data.m_type = value_t::array;
22621 m_data.m_value = value_t::array;
22622 assert_invariant();
22626 const auto old_capacity =
m_data.m_value.array->capacity();
22627 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
22628 return set_parent(
m_data.m_value.array->back(), old_capacity);
22633 template<
class... Args>
22645 m_data.m_type = value_t::object;
22646 m_data.m_value = value_t::object;
22647 assert_invariant();
22651 auto res =
m_data.m_value.object->emplace(std::forward<Args>(args)...);
22652 set_parent(res.first->second);
22656 it.m_it.object_iterator = res.first;
22659 return {it, res.second};
22665 template<
typename... Args>
22671 auto insert_pos = std::distance(
m_data.m_value.array->begin(), pos.m_it.array_iterator);
22672 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22673 result.m_it.array_iterator =
m_data.m_value.array->begin() + insert_pos;
22707 return insert(pos, val);
22758 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22803 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22820 m_data.m_type = value_t::object;
22821 m_data.m_value.object = create<object_t>();
22822 assert_invariant();
22842 for (
auto it = first; it != last; ++it)
22844 if (merge_objects && it.value().is_object())
22846 auto it2 =
m_data.m_value.object->find(it.key());
22847 if (it2 !=
m_data.m_value.object->end())
22849 it2->second.update(it.value(),
true);
22853 m_data.m_value.object->operator[](it.key()) = it.value();
22854#if JSON_DIAGNOSTICS
22855 m_data.m_value.object->operator[](it.key()).m_parent =
this;
22863 std::is_nothrow_move_constructible<value_t>::value&&
22864 std::is_nothrow_move_assignable<value_t>::value&&
22865 std::is_nothrow_move_constructible<json_value>::value&&
22866 std::is_nothrow_move_assignable<json_value>::value
22873 other.set_parents();
22874 assert_invariant();
22880 std::is_nothrow_move_constructible<value_t>::value&&
22881 std::is_nothrow_move_assignable<value_t>::value&&
22882 std::is_nothrow_move_constructible<json_value>::value&&
22883 std::is_nothrow_move_assignable<json_value>::value
22955 void swap(
typename binary_t::container_type& other)
22980#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22981 const auto lhs_type = lhs.type(); \
22982 const auto rhs_type = rhs.type(); \
22984 if (lhs_type == rhs_type) \
22986 switch (lhs_type) \
22988 case value_t::array: \
22989 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
22991 case value_t::object: \
22992 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
22994 case value_t::null: \
22995 return (null_result); \
22997 case value_t::string: \
22998 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23000 case value_t::boolean: \
23001 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23003 case value_t::number_integer: \
23004 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23006 case value_t::number_unsigned: \
23007 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23009 case value_t::number_float: \
23010 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23012 case value_t::binary: \
23013 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23015 case value_t::discarded: \
23017 return (unordered_result); \
23020 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23022 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23024 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23026 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23028 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23030 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23032 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23034 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23036 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23038 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23040 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23042 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23044 else if(compares_unordered(lhs, rhs))\
23046 return (unordered_result);\
23049 return (default_result);
23064#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23075 return compares_unordered(*
this,
rhs,
inverse);
23079#if JSON_HAS_THREE_WAY_COMPARISON
23085#pragma GCC diagnostic push
23086#pragma GCC diagnostic ignored "-Wfloat-equal"
23091#pragma GCC diagnostic pop
23097 template<
typename ScalarType>
23098 requires std::is_scalar_v<ScalarType>
23108 if (compares_unordered(
rhs,
true))
23123 std::partial_ordering::equivalent,
23124 std::partial_ordering::unordered,
23125 lhs_type <=> rhs_type)
23130 template<
typename ScalarType>
23131 requires std::is_scalar_v<ScalarType>
23132 std::partial_ordering operator<=>(ScalarType
rhs)
const noexcept
23137#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23146 if (compares_unordered(
rhs,
true))
23150 return !(
rhs < *
this);
23155 template<
typename ScalarType>
23156 requires std::is_scalar_v<ScalarType>
23157 bool operator<=(ScalarType
rhs)
const noexcept
23167 if (compares_unordered(
rhs,
true))
23171 return !(*
this <
rhs);
23176 template<
typename ScalarType>
23177 requires std::is_scalar_v<ScalarType>
23178 bool operator>=(ScalarType
rhs)
const noexcept
23189#pragma GCC diagnostic push
23190#pragma GCC diagnostic ignored "-Wfloat-equal"
23194#pragma GCC diagnostic pop
23200 template<
typename ScalarType,
typename std::enable_if<
23201 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23209 template<
typename ScalarType,
typename std::enable_if<
23210 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23220 if (compares_unordered(lhs,
rhs,
true))
23224 return !(lhs ==
rhs);
23229 template<
typename ScalarType,
typename std::enable_if<
23230 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23238 template<
typename ScalarType,
typename std::enable_if<
23239 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23257 template<
typename ScalarType,
typename std::enable_if<
23258 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23266 template<
typename ScalarType,
typename std::enable_if<
23267 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23277 if (compares_unordered(lhs,
rhs,
true))
23281 return !(
rhs < lhs);
23286 template<
typename ScalarType,
typename std::enable_if<
23287 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23295 template<
typename ScalarType,
typename std::enable_if<
23296 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23307 if (compares_unordered(lhs,
rhs))
23311 return !(lhs <=
rhs);
23316 template<
typename ScalarType,
typename std::enable_if<
23317 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23325 template<
typename ScalarType,
typename std::enable_if<
23326 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23336 if (compares_unordered(lhs,
rhs,
true))
23340 return !(lhs <
rhs);
23345 template<
typename ScalarType,
typename std::enable_if<
23346 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23354 template<
typename ScalarType,
typename std::enable_if<
23355 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23362#undef JSON_IMPLEMENT_OPERATOR
23378 const bool pretty_print = o.width() > 0;
23379 const auto indentation = pretty_print ? o.width() : 0;
23386 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23413 template<
typename InputType>
23417 const bool allow_exceptions =
true,
23418 const bool ignore_comments =
false)
23427 template<
typename IteratorType>
23432 const bool allow_exceptions =
true,
23433 const bool ignore_comments =
false)
23436 parser(
detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
23444 const bool allow_exceptions =
true,
23445 const bool ignore_comments =
false)
23448 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
23454 template<
typename InputType>
23455 static bool accept(InputType&& i,
23456 const bool ignore_comments =
false)
23463 template<
typename IteratorType>
23464 static bool accept(IteratorType first, IteratorType last,
23465 const bool ignore_comments =
false)
23473 const bool ignore_comments =
false)
23475 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23480 template <
typename InputType,
typename SAX>
23484 const
bool strict = true,
23485 const
bool ignore_comments = false)
23488 return format == input_format_t::json
23489 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23495 template<
class IteratorType,
class SAX>
23497 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23499 const
bool strict = true,
23500 const
bool ignore_comments = false)
23503 return format == input_format_t::json
23504 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23513 template <
typename SAX>
23518 const
bool strict = true,
23519 const
bool ignore_comments = false)
23522 return format == input_format_t::json
23524 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23562 case value_t::null:
23564 case value_t::object:
23566 case value_t::array:
23568 case value_t::string:
23570 case value_t::boolean:
23572 case value_t::binary:
23574 case value_t::discarded:
23575 return "discarded";
23576 case value_t::number_integer:
23577 case value_t::number_unsigned:
23578 case value_t::number_float:
23592 value_t m_type = value_t::null;
23605 m_value.array = create<array_t>(cnt, val);
23622#if JSON_DIAGNOSTICS
23639 std::vector<std::uint8_t> result;
23648 binary_writer<std::uint8_t>(o).write_cbor(j);
23655 binary_writer<char>(o).write_cbor(j);
23662 std::vector<std::uint8_t> result;
23671 binary_writer<std::uint8_t>(o).write_msgpack(j);
23678 binary_writer<char>(o).write_msgpack(j);
23684 const bool use_size =
false,
23685 const bool use_type =
false)
23687 std::vector<std::uint8_t> result;
23688 to_ubjson(j, result, use_size, use_type);
23695 const bool use_size =
false,
const bool use_type =
false)
23697 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
23703 const bool use_size =
false,
const bool use_type =
false)
23705 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
23711 const bool use_size =
false,
23712 const bool use_type =
false)
23714 std::vector<std::uint8_t> result;
23715 to_bjdata(j, result, use_size, use_type);
23722 const bool use_size =
false,
const bool use_type =
false)
23724 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
23730 const bool use_size =
false,
const bool use_type =
false)
23732 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
23739 std::vector<std::uint8_t> result;
23748 binary_writer<std::uint8_t>(o).write_bson(j);
23755 binary_writer<char>(o).write_bson(j);
23760 template<
typename InputType>
23763 const bool strict =
true,
23764 const bool allow_exceptions =
true,
23770 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23771 return res ? result :
basic_json(value_t::discarded);
23776 template<
typename IteratorType>
23779 const bool strict =
true,
23780 const bool allow_exceptions =
true,
23786 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23787 return res ? result :
basic_json(value_t::discarded);
23790 template<
typename T>
23794 const
bool strict = true,
23795 const
bool allow_exceptions = true,
23798 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23804 const
bool strict = true,
23805 const
bool allow_exceptions = true,
23812 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23813 return res ? result :
basic_json(value_t::discarded);
23818 template<
typename InputType>
23821 const bool strict =
true,
23822 const bool allow_exceptions =
true)
23827 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23828 return res ? result :
basic_json(value_t::discarded);
23833 template<
typename IteratorType>
23836 const bool strict =
true,
23837 const bool allow_exceptions =
true)
23842 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23843 return res ? result :
basic_json(value_t::discarded);
23846 template<
typename T>
23850 const
bool strict = true,
23851 const
bool allow_exceptions = true)
23853 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23859 const
bool strict = true,
23860 const
bool allow_exceptions = true)
23866 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23867 return res ? result :
basic_json(value_t::discarded);
23872 template<
typename InputType>
23875 const bool strict =
true,
23876 const bool allow_exceptions =
true)
23881 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23882 return res ? result :
basic_json(value_t::discarded);
23887 template<
typename IteratorType>
23890 const bool strict =
true,
23891 const bool allow_exceptions =
true)
23896 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23897 return res ? result :
basic_json(value_t::discarded);
23900 template<
typename T>
23904 const
bool strict = true,
23905 const
bool allow_exceptions = true)
23907 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23913 const
bool strict = true,
23914 const
bool allow_exceptions = true)
23920 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23921 return res ? result :
basic_json(value_t::discarded);
23926 template<
typename InputType>
23929 const bool strict =
true,
23930 const bool allow_exceptions =
true)
23935 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23936 return res ? result :
basic_json(value_t::discarded);
23941 template<
typename IteratorType>
23944 const bool strict =
true,
23945 const bool allow_exceptions =
true)
23950 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23951 return res ? result :
basic_json(value_t::discarded);
23956 template<
typename InputType>
23959 const bool strict =
true,
23960 const bool allow_exceptions =
true)
23965 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23966 return res ? result :
basic_json(value_t::discarded);
23971 template<
typename IteratorType>
23974 const bool strict =
true,
23975 const bool allow_exceptions =
true)
23980 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23981 return res ? result :
basic_json(value_t::discarded);
23984 template<
typename T>
23988 const
bool strict = true,
23989 const
bool allow_exceptions = true)
23991 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23997 const
bool strict = true,
23998 const
bool allow_exceptions = true)
24004 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24005 return res ? result :
basic_json(value_t::discarded);
24020 return ptr.get_unchecked(
this);
24023 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24027 return ptr.get_unchecked(
this);
24034 return ptr.get_unchecked(
this);
24037 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24041 return ptr.get_unchecked(
this);
24048 return ptr.get_checked(
this);
24051 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24055 return ptr.get_checked(
this);
24062 return ptr.get_checked(
this);
24065 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24069 return ptr.get_checked(
this);
24077 json_pointer::flatten(
"", *
this, result);
24085 return json_pointer::unflatten(*
this);
24103 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24105 const auto get_op = [](
const std::string & op)
24109 return patch_operations::add;
24111 if (op ==
"remove")
24113 return patch_operations::remove;
24115 if (op ==
"replace")
24117 return patch_operations::replace;
24121 return patch_operations::move;
24125 return patch_operations::copy;
24129 return patch_operations::test;
24132 return patch_operations::invalid;
24147 if (top_pointer != ptr)
24149 result.at(top_pointer);
24153 const auto last_path = ptr.
back();
24158 switch (parent.
m_data.m_type)
24160 case value_t::null:
24161 case value_t::object:
24164 parent[last_path] = val;
24168 case value_t::array:
24170 if (last_path ==
"-")
24177 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24191 case value_t::string:
24192 case value_t::boolean:
24193 case value_t::number_integer:
24194 case value_t::number_unsigned:
24195 case value_t::number_float:
24196 case value_t::binary:
24197 case value_t::discarded:
24204 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24207 const auto last_path = ptr.
back();
24215 auto it = parent.
find(last_path);
24228 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24239 for (
const auto& val : json_patch)
24242 const auto get_value = [&val](
const std::string & op,
24243 const std::string & member,
24247 auto it = val.m_data.m_value.object->find(member);
24250 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24277 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24278 const auto path = get_value(op,
"path",
true).template get<std::string>();
24281 switch (get_op(op))
24283 case patch_operations::add:
24285 operation_add(ptr, get_value(
"add",
"value",
false));
24289 case patch_operations::remove:
24291 operation_remove(ptr);
24295 case patch_operations::replace:
24298 result.at(ptr) = get_value(
"replace",
"value",
false);
24302 case patch_operations::move:
24304 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24314 operation_remove(from_ptr);
24315 operation_add(ptr, v);
24319 case patch_operations::copy:
24321 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24330 operation_add(ptr, v);
24334 case patch_operations::test:
24336 bool success =
false;
24341 success = (result.at(ptr) == get_value(
"test",
"value",
false));
24357 case patch_operations::invalid:
24373 result.patch_inplace(json_patch);
24381 const std::string& path =
"")
24387 if (source == target)
24392 if (source.type() != target.type())
24397 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24402 switch (source.type())
24404 case value_t::array:
24408 while (i < source.size() && i < target.size())
24411 auto temp_diff =
diff(source[i], target[i],
detail::concat(path,
'/', std::to_string(i)));
24412 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
24421 while (i < source.size())
24425 result.insert(result.begin() + end_index,
object(
24434 while (i < target.size())
24440 {
"value", target[i]}
24448 case value_t::object:
24451 for (
auto it = source.cbegin(); it != source.cend(); ++it)
24456 if (target.find(it.key()) != target.end())
24459 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
24460 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
24465 result.push_back(
object(
24467 {
"op",
"remove"}, {
"path", path_key}
24473 for (
auto it = target.cbegin(); it != target.cend(); ++it)
24475 if (source.find(it.key()) == source.end())
24481 {
"op",
"add"}, {
"path", path_key},
24482 {
"value", it.value()}
24490 case value_t::null:
24491 case value_t::string:
24492 case value_t::boolean:
24493 case value_t::number_integer:
24494 case value_t::number_unsigned:
24495 case value_t::number_float:
24496 case value_t::binary:
24497 case value_t::discarded:
24503 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24530 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
24532 if (it.value().is_null())
24544 *
this = apply_patch;
24561inline namespace json_literals
24567#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24568 inline nlohmann::json
operator ""_json(
const char* s, std::size_t n)
24570 inline nlohmann::json
operator "" _json(
const char* s, std::size_t n)
24573 return nlohmann::json::parse(s, s + n);
24579#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24604 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
24606 return nlohmann::detail::hash(j);
24612struct less< ::nlohmann::detail::value_t>
24619 ::nlohmann::detail::value_t rhs)
const noexcept
24621#if JSON_HAS_THREE_WAY_COMPARISON
24622 return std::is_lt(lhs <=> rhs);
24624 return ::nlohmann::detail::operator<(lhs, rhs);
24630#ifndef JSON_HAS_CPP_20
24635inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
24636 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24637 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24646#if JSON_USE_GLOBAL_UDLS
24647 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24648 using nlohmann::literals::json_literals::operator
""_json;
24649 using nlohmann::literals::json_literals::operator
""_json_pointer;
24651 using nlohmann::literals::json_literals::operator
"" _json;
24652 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24668#if defined(__clang__)
24669 #pragma clang diagnostic pop
24674#undef JSON_INTERNAL_CATCH
24676#undef JSON_PRIVATE_UNLESS_TESTED
24677#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24678#undef NLOHMANN_BASIC_JSON_TPL
24679#undef JSON_EXPLICIT
24680#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24681#undef JSON_INLINE_VARIABLE
24682#undef JSON_NO_UNIQUE_ADDRESS
24683#undef JSON_DISABLE_ENUM_SERIALIZATION
24684#undef JSON_USE_GLOBAL_UDLS
24686#ifndef JSON_TEST_KEEP_MACROS
24689 #undef JSON_HAS_CPP_11
24690 #undef JSON_HAS_CPP_14
24691 #undef JSON_HAS_CPP_17
24692 #undef JSON_HAS_CPP_20
24693 #undef JSON_HAS_FILESYSTEM
24694 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24695 #undef JSON_HAS_THREE_WAY_COMPARISON
24696 #undef JSON_HAS_RANGES
24697 #undef JSON_HAS_STATIC_RTTI
24698 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24712#undef JSON_HEDLEY_ALWAYS_INLINE
24713#undef JSON_HEDLEY_ARM_VERSION
24714#undef JSON_HEDLEY_ARM_VERSION_CHECK
24715#undef JSON_HEDLEY_ARRAY_PARAM
24716#undef JSON_HEDLEY_ASSUME
24717#undef JSON_HEDLEY_BEGIN_C_DECLS
24718#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24719#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24720#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24721#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24722#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24723#undef JSON_HEDLEY_CLANG_HAS_FEATURE
24724#undef JSON_HEDLEY_CLANG_HAS_WARNING
24725#undef JSON_HEDLEY_COMPCERT_VERSION
24726#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24727#undef JSON_HEDLEY_CONCAT
24728#undef JSON_HEDLEY_CONCAT3
24729#undef JSON_HEDLEY_CONCAT3_EX
24730#undef JSON_HEDLEY_CONCAT_EX
24731#undef JSON_HEDLEY_CONST
24732#undef JSON_HEDLEY_CONSTEXPR
24733#undef JSON_HEDLEY_CONST_CAST
24734#undef JSON_HEDLEY_CPP_CAST
24735#undef JSON_HEDLEY_CRAY_VERSION
24736#undef JSON_HEDLEY_CRAY_VERSION_CHECK
24737#undef JSON_HEDLEY_C_DECL
24738#undef JSON_HEDLEY_DEPRECATED
24739#undef JSON_HEDLEY_DEPRECATED_FOR
24740#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24741#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24742#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24743#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24744#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24745#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24746#undef JSON_HEDLEY_DIAGNOSTIC_POP
24747#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24748#undef JSON_HEDLEY_DMC_VERSION
24749#undef JSON_HEDLEY_DMC_VERSION_CHECK
24750#undef JSON_HEDLEY_EMPTY_BASES
24751#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24752#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24753#undef JSON_HEDLEY_END_C_DECLS
24754#undef JSON_HEDLEY_FLAGS
24755#undef JSON_HEDLEY_FLAGS_CAST
24756#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24757#undef JSON_HEDLEY_GCC_HAS_BUILTIN
24758#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24759#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24760#undef JSON_HEDLEY_GCC_HAS_EXTENSION
24761#undef JSON_HEDLEY_GCC_HAS_FEATURE
24762#undef JSON_HEDLEY_GCC_HAS_WARNING
24763#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24764#undef JSON_HEDLEY_GCC_VERSION
24765#undef JSON_HEDLEY_GCC_VERSION_CHECK
24766#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24767#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24768#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24769#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24770#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24771#undef JSON_HEDLEY_GNUC_HAS_FEATURE
24772#undef JSON_HEDLEY_GNUC_HAS_WARNING
24773#undef JSON_HEDLEY_GNUC_VERSION
24774#undef JSON_HEDLEY_GNUC_VERSION_CHECK
24775#undef JSON_HEDLEY_HAS_ATTRIBUTE
24776#undef JSON_HEDLEY_HAS_BUILTIN
24777#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24778#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24779#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24780#undef JSON_HEDLEY_HAS_EXTENSION
24781#undef JSON_HEDLEY_HAS_FEATURE
24782#undef JSON_HEDLEY_HAS_WARNING
24783#undef JSON_HEDLEY_IAR_VERSION
24784#undef JSON_HEDLEY_IAR_VERSION_CHECK
24785#undef JSON_HEDLEY_IBM_VERSION
24786#undef JSON_HEDLEY_IBM_VERSION_CHECK
24787#undef JSON_HEDLEY_IMPORT
24788#undef JSON_HEDLEY_INLINE
24789#undef JSON_HEDLEY_INTEL_CL_VERSION
24790#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24791#undef JSON_HEDLEY_INTEL_VERSION
24792#undef JSON_HEDLEY_INTEL_VERSION_CHECK
24793#undef JSON_HEDLEY_IS_CONSTANT
24794#undef JSON_HEDLEY_IS_CONSTEXPR_
24795#undef JSON_HEDLEY_LIKELY
24796#undef JSON_HEDLEY_MALLOC
24797#undef JSON_HEDLEY_MCST_LCC_VERSION
24798#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24799#undef JSON_HEDLEY_MESSAGE
24800#undef JSON_HEDLEY_MSVC_VERSION
24801#undef JSON_HEDLEY_MSVC_VERSION_CHECK
24802#undef JSON_HEDLEY_NEVER_INLINE
24803#undef JSON_HEDLEY_NON_NULL
24804#undef JSON_HEDLEY_NO_ESCAPE
24805#undef JSON_HEDLEY_NO_RETURN
24806#undef JSON_HEDLEY_NO_THROW
24807#undef JSON_HEDLEY_NULL
24808#undef JSON_HEDLEY_PELLES_VERSION
24809#undef JSON_HEDLEY_PELLES_VERSION_CHECK
24810#undef JSON_HEDLEY_PGI_VERSION
24811#undef JSON_HEDLEY_PGI_VERSION_CHECK
24812#undef JSON_HEDLEY_PREDICT
24813#undef JSON_HEDLEY_PRINTF_FORMAT
24814#undef JSON_HEDLEY_PRIVATE
24815#undef JSON_HEDLEY_PUBLIC
24816#undef JSON_HEDLEY_PURE
24817#undef JSON_HEDLEY_REINTERPRET_CAST
24818#undef JSON_HEDLEY_REQUIRE
24819#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24820#undef JSON_HEDLEY_REQUIRE_MSG
24821#undef JSON_HEDLEY_RESTRICT
24822#undef JSON_HEDLEY_RETURNS_NON_NULL
24823#undef JSON_HEDLEY_SENTINEL
24824#undef JSON_HEDLEY_STATIC_ASSERT
24825#undef JSON_HEDLEY_STATIC_CAST
24826#undef JSON_HEDLEY_STRINGIFY
24827#undef JSON_HEDLEY_STRINGIFY_EX
24828#undef JSON_HEDLEY_SUNPRO_VERSION
24829#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24830#undef JSON_HEDLEY_TINYC_VERSION
24831#undef JSON_HEDLEY_TINYC_VERSION_CHECK
24832#undef JSON_HEDLEY_TI_ARMCL_VERSION
24833#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24834#undef JSON_HEDLEY_TI_CL2000_VERSION
24835#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24836#undef JSON_HEDLEY_TI_CL430_VERSION
24837#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24838#undef JSON_HEDLEY_TI_CL6X_VERSION
24839#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24840#undef JSON_HEDLEY_TI_CL7X_VERSION
24841#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24842#undef JSON_HEDLEY_TI_CLPRU_VERSION
24843#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24844#undef JSON_HEDLEY_TI_VERSION
24845#undef JSON_HEDLEY_TI_VERSION_CHECK
24846#undef JSON_HEDLEY_UNAVAILABLE
24847#undef JSON_HEDLEY_UNLIKELY
24848#undef JSON_HEDLEY_UNPREDICTABLE
24849#undef JSON_HEDLEY_UNREACHABLE
24850#undef JSON_HEDLEY_UNREACHABLE_RETURN
24851#undef JSON_HEDLEY_VERSION
24852#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24853#undef JSON_HEDLEY_VERSION_DECODE_MINOR
24854#undef JSON_HEDLEY_VERSION_DECODE_REVISION
24855#undef JSON_HEDLEY_VERSION_ENCODE
24856#undef JSON_HEDLEY_WARNING
24857#undef JSON_HEDLEY_WARN_UNUSED_RESULT
24858#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24859#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
constexpr bool is_string() const noexcept
return whether value is a string
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
reference operator[](KeyType &&key)
access specified object element
size_type size() const noexcept
returns the number of elements
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
const_iterator end() const noexcept
returns an iterator to one past the last element
reference back()
access the last element
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
const_reference front() const
access the first element
constexpr bool is_array() const noexcept
return whether value is an array
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
data(size_type cnt, const basic_json &val)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
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)
create a BJData serialization of a given JSON value
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
std::size_t size_type
a type to represent container sizes
constexpr bool is_structured() const noexcept
return whether type is structured
const_reference operator[](KeyType &&key) const
access specified object element
const value_type & const_reference
the type of an element const reference
void swap(binary_t &other)
exchanges the values
ReferenceType get_ref()
get a reference value (implicit)
size_type max_size() const noexcept
returns the maximum possible number of elements
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
ReferenceType get_ref() const
get a reference value (implicit)
constexpr bool is_discarded() const noexcept
return whether value is discarded
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
reference operator+=(initializer_list_t init)
add an object to an object
void push_back(basic_json &&val)
add an object to an array
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
const_reference back() const
access the last element
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
reference operator+=(const basic_json &val)
add an object to an array
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
static allocator_type get_allocator()
returns the allocator associated with the container
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
reference at(KeyType &&key)
access specified object element with bounds checking
iterator end() noexcept
returns an iterator to one past the last element
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
void push_back(initializer_list_t init)
add an object to an object
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
ValueType & get_to(ValueType &v) const
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
iterator begin() noexcept
returns an iterator to the first element
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
const_iterator cend() const noexcept
returns an iterator to one past the last element
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
basic_json flatten() const
return flattened JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
size_type erase(KeyType &&key)
remove element from a JSON object given a key
const binary_t & get_binary() const
get a binary value
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
value_type & reference
the type of an element reference
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
const_reference at(KeyType &&key) const
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
IteratorType erase(IteratorType pos)
remove element given an iterator
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
NumberFloatType number_float_t
a type for a number (floating-point)
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
AllocatorType< basic_json > allocator_type
the allocator type
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
reference operator[](T *key)
reference at(size_type idx)
access specified array element with bounds checking
iterator find(KeyType &&key)
find an element in a JSON object
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
BooleanType boolean_t
a type for a boolean
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
reference operator+=(const typename object_t::value_type &val)
add an object to an object
const_iterator cbegin() const noexcept
returns a const iterator to the first element
reference operator[](typename object_t::key_type key)
access specified object element
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
~basic_json() noexcept
destructor
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
void swap(typename binary_t::container_type &other)
exchanges the values
binary_t & get_binary()
get a binary value
const_iterator begin() const noexcept
returns an iterator to the first element
constexpr bool is_number() const noexcept
return whether value is a number
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
const_reference operator[](T *key) const
reference operator[](size_type idx)
access specified array element
basic_json(const JsonRef &ref)
JSONSerializer< T, SFINAE > json_serializer
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
NumberIntegerType number_integer_t
a type for a number (integer)
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
constexpr bool is_binary() const noexcept
return whether value is a binary array
void swap(object_t &other)
exchanges the values
basic_json unflatten() const
unflatten a previously flattened JSON value
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
bool empty() const noexcept
checks whether the container is empty.
void swap(array_t &other)
exchanges the values
void erase(const size_type idx)
remove element from a JSON array given an index
reference operator+=(basic_json &&val)
add an object to an array
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
reference emplace_back(Args &&... args)
add an object to an array
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
StringType string_t
a type for a string
friend class ::nlohmann::detail::parser
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
void push_back(const basic_json &val)
add an object to an array
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
json_value m_value
the value of the current element
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
constexpr bool is_boolean() const noexcept
return whether value is a boolean
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
reference front()
access the first element
constexpr bool is_primitive() const noexcept
return whether type is primitive
constexpr bool is_null() const noexcept
return whether value is null
void clear() noexcept
clears the contents
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
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)
basic_json(basic_json &&other) noexcept
move constructor
iter_impl< basic_json > iterator
an iterator for a basic_json container
basic_json(const value_t v)
create an empty value with a given type
const_reference operator[](size_type idx) const
access specified array element
std::ptrdiff_t difference_type
a type to represent differences between iterators
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
void swap(string_t &other)
exchanges the values
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
const_reference at(size_type idx) const
access specified array element with bounds checking
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
basic_json(const basic_json &other)
copy constructor
void push_back(const typename object_t::value_type &val)
add an object to an object
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
constexpr bool is_object() const noexcept
return whether value is an object
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
iterator insert_iterator(const_iterator pos, Args &&... args)
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
const_iterator find(KeyType &&key) const
find an element in a JSON object
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
an internal type for a backed binary type
bool operator!=(const byte_container_with_subtype &rhs) const
byte_container_with_subtype() noexcept(noexcept(container_type()))
std::uint64_t subtype_type
bool operator==(const byte_container_with_subtype &rhs) const
BinaryType container_type
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
constexpr subtype_type subtype() const noexcept
return the binary subtype
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
void clear_subtype() noexcept
clears the binary subtype
deserialization of CBOR, MessagePack, and UBJSON values
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
binary_reader & operator=(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
binary_reader & operator=(binary_reader &&)=default
serialization to CBOR and MessagePack values
void write_bson(const BasicJsonType &j)
static constexpr CharType to_char_type(std::uint8_t x) noexcept
static CharType to_char_type(std::uint8_t x) noexcept
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static constexpr CharType to_char_type(InputCharType x) noexcept
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
void write_msgpack(const BasicJsonType &j)
void write_cbor(const BasicJsonType &j)
general exception of the basic_json class
const int id
the id of the exception
static std::string diagnostics(std::nullptr_t)
static std::string name(const std::string &ename, int id_)
const char * what() const noexcept override
returns the explanatory string
static std::string diagnostics(const BasicJsonType *leaf_element)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
iter_impl operator+(difference_type i) const
add to iterator
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
bool operator<(const iter_impl &other) const
comparison: smaller
bool operator<=(const iter_impl &other) const
comparison: less than or equal
iter_impl & operator-=(difference_type i)
subtract from iterator
iter_impl & operator--()
pre-decrement (–it)
const object_t::key_type & key() const
return the key of an object iterator
bool operator==(const IterImpl &other) const
comparison: equal
iter_impl operator++(int) &
post-increment (it++)
iter_impl & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
pointer operator->() const
dereference the iterator
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
difference_type operator-(const iter_impl &other) const
return difference
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
reference value() const
return the value of an iterator
bool operator>(const iter_impl &other) const
comparison: greater than
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
iter_impl & operator++()
pre-increment (++it)
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl operator-(difference_type i) const
subtract from iterator
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
bool operator!=(const IterImpl &other) const
comparison: not equal
iter_impl operator--(int) &
post-decrement (it–)
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
void set_end() noexcept
set the iterator past the last value
iteration_proxy_value operator++(int) &
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
std::ptrdiff_t difference_type
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
const string_type & key() const
return key of the iterator
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
proxy class for the items() function
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
iteration_proxy & operator=(iteration_proxy const &)=default
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
json_ref(value_type &&value)
value_type const & operator*() const
value_type const * operator->() const
json_ref(std::initializer_list< json_ref > init)
json_ref(Args &&... args)
value_type moved_or_copied() const
a template for a reverse iterator class
json_reverse_iterator operator++(int) &
post-increment (it++)
json_reverse_iterator operator--(int) &
post-decrement (it–)
json_reverse_iterator & operator++()
pre-increment (++it)
std::ptrdiff_t difference_type
json_reverse_iterator & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
difference_type operator-(const json_reverse_iterator &other) const
return difference
typename Base::reference reference
the reference type for the pointed-to element
reference value() const
return the value of an iterator
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
json_reverse_iterator & operator--()
pre-decrement (–it)
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator operator+(difference_type i) const
add to iterator
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool start_object(std::size_t=static_cast< std::size_t >(-1))
bool number_integer(number_integer_t)
bool start_array(std::size_t=static_cast< std::size_t >(-1))
bool number_unsigned(number_unsigned_t)
typename BasicJsonType::binary_t binary_t
bool number_float(number_float_t, const string_t &)
bool parse_error(std::size_t, const std::string &, const detail::exception &)
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::string_t string_t
bool parse_error(std::size_t, const std::string &, const Exception &ex)
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true)
typename BasicJsonType::string_t string_t
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
bool string(string_t &val)
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::binary_t binary_t
bool start_object(std::size_t len)
bool start_array(std::size_t len)
typename BasicJsonType::number_integer_t number_integer_t
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
~json_sax_dom_callback_parser()=default
typename BasicJsonType::parse_event_t parse_event_t
typename BasicJsonType::parser_callback_t parser_callback_t
bool number_unsigned(number_unsigned_t val)
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
bool number_integer(number_integer_t val)
bool binary(binary_t &val)
SAX implementation to create a JSON value from SAX events.
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool string(string_t &val)
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
bool parse_error(std::size_t, const std::string &, const Exception &ex)
~json_sax_dom_parser()=default
typename BasicJsonType::string_t string_t
bool start_object(std::size_t len)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_unsigned(number_unsigned_t val)
bool number_integer(number_integer_t val)
typename BasicJsonType::number_integer_t number_integer_t
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
json_sax_dom_parser(json_sax_dom_parser &&)=default
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::number_float_t number_float_t
bool start_array(std::size_t len)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
bool skip_bom()
skip the UTF-8 byte order mark
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
std::string get_token_string() const
constexpr number_integer_t get_number_integer() const noexcept
return integer value
constexpr position_t get_position() const noexcept
return position of last read token
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
typename lexer_base< BasicJsonType >::token_type token_type
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
output_adapter(StringType &s)
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(std::vector< CharType, AllocatorType > &vec)
output adapter for output streams
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
void write_character(CharType c) override
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
output adapter for byte vectors
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
void write_character(CharType c) override
exception indicating a parse error
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
const std::size_t byte
byte index of the parse error
void parse(const bool strict, BasicJsonType &result)
public parser interface
bool accept(const bool strict=true)
public accept interface
parser(InputAdapterType &&adapter, parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
bool sax_parse(SAX *sax, const bool strict=true)
primitive_iterator_t & operator++() noexcept
primitive_iterator_t & operator-=(difference_type n) noexcept
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
primitive_iterator_t & operator--() noexcept
void set_end() noexcept
set iterator to a defined past the end
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr bool is_end() const noexcept
return whether the iterator is at end
primitive_iterator_t operator++(int) &noexcept
primitive_iterator_t & operator+=(difference_type n) noexcept
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr difference_type get_value() const noexcept
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t operator+(difference_type n) noexcept
void set_begin() noexcept
set iterator to a defined beginning
primitive_iterator_t operator--(int) &noexcept
std::array< char, 512 > string_buffer
string buffer
std::size_t bytes_after_last_accept
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
std::size_t undumped_chars
const char thousands_sep
the locale's thousand separator character
const char decimal_point
the locale's decimal point character
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
string_t indent_string
the indentation string
const std::lconv * loc
the locale
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
const char indent_char
the indentation character
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
typename string_t_helper< RefStringType >::type string_t
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
json_pointer(const string_t &s="")
create JSON pointer
bool empty() const noexcept
return whether pointer points to the root document
friend bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for equality
void pop_back()
remove last reference token
string_t to_string() const
return a string representation of the JSON pointer
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
json_pointer parent_pointer() const
returns the parent of this JSON pointer
friend bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for inequality
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
friend class json_pointer
const string_t & back() const
return last reference token
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
friend bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointer for less-than
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_INLINE_VARIABLE
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_PRIVATE_UNLESS_TESTED
#define NLOHMANN_JSON_VERSION_PATCH
#define JSON_HEDLEY_LIKELY(expr)
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
#define JSON_HEDLEY_RETURNS_NON_NULL
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
#define NLOHMANN_JSON_NAMESPACE_END
#define JSON_NO_UNIQUE_ADDRESS
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
#define NLOHMANN_JSON_NAMESPACE_BEGIN
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
cached_power get_cached_power_for_binary_exponent(int e)
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
constexpr bool is_transparent()
constexpr bool is_c_string()
detail namespace with internal helper functions
input_format_t
the supported input formats
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
typename make_void< Ts... >::type void_t
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
OutStringType concat(Args &&... args)
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
decltype(T::to_json(std::declval< Args >()...)) to_json_function
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
decltype(std::declval< T >().template get< U >()) get_template_function
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
typename T::pointer pointer_t
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
typename utility_internal::Gen< T, N >::type make_integer_sequence
typename T::value_type value_type_t
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
T conditional_static_cast(U value)
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
typename std::enable_if< B, T >::type enable_if_t
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
typename T::mapped_type mapped_type_t
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
cbor_tag_handler_t
how to treat CBOR tags
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(T::from_json(std::declval< Args >()...)) from_json_function
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
make_integer_sequence< size_t, N > make_index_sequence
std::integral_constant< bool, Value > bool_constant
void concat_into(OutStringType &)
typename T::key_type key_type_t
constexpr bool value_in_range_of(T val)
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
typename detector< nonesuch, void, Op, Args... >::type detected_t
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
std::size_t hash(const BasicJsonType &j)
hash a JSON value
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
typename T::iterator_category iterator_category_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
decltype(std::declval< T & >().end_array()) end_array_function_t
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
void to_json(BasicJsonType &j, T b) noexcept
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
decltype(std::declval< T & >().null()) null_function_t
make_index_sequence< sizeof...(Ts)> index_sequence_for
typename T::difference_type difference_type_t
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
typename T::is_transparent detect_is_transparent
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
typename T::reference reference_t
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
decltype(std::declval< T & >().end_object()) end_object_function_t
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
typename T::key_compare detect_key_compare
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
void int_to_string(string_type &target, std::size_t value)
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
is_detected< string_can_append, StringType, Arg > detect_string_can_append
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
void accept(sys::state &state, message const &m)
uint32_t size(sys::state const &state)
void reset(file_system &fs)
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
namespace for Niels Lohmann
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
typename BasicJsonType::object_t object_t
typename BasicJsonType::default_object_comparator_t object_comparator_t
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
static constexpr int_type eof() noexcept
static char_type to_char_type(int_type i) noexcept
static int_type to_int_type(char_type c) noexcept
static char_type to_char_type(int_type i) noexcept
static constexpr int_type eof() noexcept
static int_type to_int_type(char_type c) noexcept
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static constexpr int kPrecision
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
primitive_iterator_t primitive_iterator
generic iterator for all other types
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
std::numeric_limits< RealIntegerType > RealLimits
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
typename BasicJsonType::object_t object_t
static constexpr auto value
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
typename BasicJsonType::object_t object_t
ConstructibleStringType laundered_type
static constexpr auto value
static constexpr bool value
typename std::iterator_traits< T >::value_type value_type
static one test(decltype(&C::capacity))
static constexpr bool value
static constexpr bool value
ptrdiff_t difference_type
std::random_access_iterator_tag iterator_category
typename It::iterator_category iterator_category
typename It::difference_type difference_type
typename It::value_type value_type
typename It::reference reference
typename It::pointer pointer
Default base class of the basic_json class.
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t lines_read
the number of lines read
std::size_t chars_read_total
the total number of characters read
static JSON_INLINE_VARIABLE constexpr T value
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
static constexpr bool test(T val)
static constexpr bool test(T)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
std::vector< std::pair< const Key, T >, Allocator > Container
std::pair< iterator, bool > insert(value_type &&value)
typename Container::value_type value_type
std::equal_to< Key > key_compare
iterator erase(iterator pos)
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
T & operator[](KeyType &&key)
typename Container::iterator iterator
const T & at(KeyType &&key) const
const T & operator[](KeyType &&key) const
iterator find(const key_type &key)
iterator erase(iterator first, iterator last)
const T & at(const key_type &key) const
const_iterator find(const key_type &key) const
T & operator[](const key_type &key)
size_type erase(KeyType &&key)
typename Container::size_type size_type
ordered_map() noexcept(noexcept(Container()))
void insert(InputIt first, InputIt last)
size_type count(const key_type &key) const
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
size_type erase(const key_type &key)
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
std::pair< iterator, bool > insert(const value_type &value)
size_type count(KeyType &&key) const
ordered_map(It first, It last, const Allocator &alloc=Allocator())
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
const T & operator[](const key_type &key) const
iterator find(KeyType &&key)
T & at(const key_type &key)
typename Container::const_iterator const_iterator
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values