18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
60#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
63 #warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 12
70#define NLOHMANN_JSON_VERSION_PATCH 0
72#ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76#ifndef JSON_DIAGNOSTIC_POSITIONS
77 #define JSON_DIAGNOSTIC_POSITIONS 0
80#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
81 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
85 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
87 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
90#if JSON_DIAGNOSTIC_POSITIONS
91 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
93 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
96#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
97 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
99 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
102#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
103 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
107#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
108#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
109 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
111#define NLOHMANN_JSON_ABI_TAGS \
112 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
113 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
114 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
115 NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
118#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
119 _v ## major ## _ ## minor ## _ ## patch
120#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
121 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
123#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
124#define NLOHMANN_JSON_NAMESPACE_VERSION
126#define NLOHMANN_JSON_NAMESPACE_VERSION \
127 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
128 NLOHMANN_JSON_VERSION_MINOR, \
129 NLOHMANN_JSON_VERSION_PATCH)
133#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
134#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
135 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
137#ifndef NLOHMANN_JSON_NAMESPACE
138#define NLOHMANN_JSON_NAMESPACE \
139 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
140 NLOHMANN_JSON_ABI_TAGS, \
141 NLOHMANN_JSON_NAMESPACE_VERSION)
144#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
145#define NLOHMANN_JSON_NAMESPACE_BEGIN \
148 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
149 NLOHMANN_JSON_ABI_TAGS, \
150 NLOHMANN_JSON_NAMESPACE_VERSION) \
154#ifndef NLOHMANN_JSON_NAMESPACE_END
155#define NLOHMANN_JSON_NAMESPACE_END \
173#include <forward_list>
176#ifdef JSON_HAS_CPP_17
181#include <type_traits>
182#include <unordered_map>
245#include <type_traits>
290template<
class Default,
292 template<
class...>
class Op,
300template<
class Default,
template<
class...>
class Op,
class... Args>
307template<
template<
class...>
class Op,
class... Args>
310template<
template<
class...>
class Op,
class... Args>
313template<
template<
class...>
class Op,
class... Args>
316template<
class Default,
template<
class...>
class Op,
class... Args>
319template<
class Default,
template<
class...>
class Op,
class... Args>
322template<
class Expected,
template<
class...>
class Op,
class... Args>
325template<
class To,
template<
class...>
class Op,
class... Args>
327 std::is_convertible<
detected_t<Op, Args...>, To>;
348#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
349#if defined(JSON_HEDLEY_VERSION)
350 #undef JSON_HEDLEY_VERSION
352#define JSON_HEDLEY_VERSION 15
354#if defined(JSON_HEDLEY_STRINGIFY_EX)
355 #undef JSON_HEDLEY_STRINGIFY_EX
357#define JSON_HEDLEY_STRINGIFY_EX(x) #x
359#if defined(JSON_HEDLEY_STRINGIFY)
360 #undef JSON_HEDLEY_STRINGIFY
362#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
364#if defined(JSON_HEDLEY_CONCAT_EX)
365 #undef JSON_HEDLEY_CONCAT_EX
367#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
369#if defined(JSON_HEDLEY_CONCAT)
370 #undef JSON_HEDLEY_CONCAT
372#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
374#if defined(JSON_HEDLEY_CONCAT3_EX)
375 #undef JSON_HEDLEY_CONCAT3_EX
377#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
379#if defined(JSON_HEDLEY_CONCAT3)
380 #undef JSON_HEDLEY_CONCAT3
382#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
384#if defined(JSON_HEDLEY_VERSION_ENCODE)
385 #undef JSON_HEDLEY_VERSION_ENCODE
387#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
389#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
390 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
392#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
394#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
395 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
397#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
399#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
400 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
402#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
404#if defined(JSON_HEDLEY_GNUC_VERSION)
405 #undef JSON_HEDLEY_GNUC_VERSION
407#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
408 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
409#elif defined(__GNUC__)
410 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
413#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
414 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
416#if defined(JSON_HEDLEY_GNUC_VERSION)
417 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
419 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
422#if defined(JSON_HEDLEY_MSVC_VERSION)
423 #undef JSON_HEDLEY_MSVC_VERSION
425#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
426 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
427#elif defined(_MSC_FULL_VER) && !defined(__ICL)
428 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
429#elif defined(_MSC_VER) && !defined(__ICL)
430 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
433#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
434 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
436#if !defined(JSON_HEDLEY_MSVC_VERSION)
437 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
438#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
439 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
440#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
441 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
443 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
446#if defined(JSON_HEDLEY_INTEL_VERSION)
447 #undef JSON_HEDLEY_INTEL_VERSION
449#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
450 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
451#elif defined(__INTEL_COMPILER) && !defined(__ICL)
452 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
455#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
456 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
458#if defined(JSON_HEDLEY_INTEL_VERSION)
459 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
461 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
464#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
465 #undef JSON_HEDLEY_INTEL_CL_VERSION
467#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
468 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
471#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
472 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
474#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
475 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
477 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
480#if defined(JSON_HEDLEY_PGI_VERSION)
481 #undef JSON_HEDLEY_PGI_VERSION
483#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
484 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
487#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
488 #undef JSON_HEDLEY_PGI_VERSION_CHECK
490#if defined(JSON_HEDLEY_PGI_VERSION)
491 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
493 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
496#if defined(JSON_HEDLEY_SUNPRO_VERSION)
497 #undef JSON_HEDLEY_SUNPRO_VERSION
499#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
500 #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)
501#elif defined(__SUNPRO_C)
502 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
503#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
504 #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)
505#elif defined(__SUNPRO_CC)
506 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
509#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
510 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
512#if defined(JSON_HEDLEY_SUNPRO_VERSION)
513 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
515 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
518#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
519 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
521#if defined(__EMSCRIPTEN__)
522 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
525#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
526 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
528#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
529 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
531 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
534#if defined(JSON_HEDLEY_ARM_VERSION)
535 #undef JSON_HEDLEY_ARM_VERSION
537#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
538 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
539#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
540 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
543#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
544 #undef JSON_HEDLEY_ARM_VERSION_CHECK
546#if defined(JSON_HEDLEY_ARM_VERSION)
547 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
549 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
552#if defined(JSON_HEDLEY_IBM_VERSION)
553 #undef JSON_HEDLEY_IBM_VERSION
555#if defined(__ibmxl__)
556 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
557#elif defined(__xlC__) && defined(__xlC_ver__)
558 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
559#elif defined(__xlC__)
560 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
563#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
564 #undef JSON_HEDLEY_IBM_VERSION_CHECK
566#if defined(JSON_HEDLEY_IBM_VERSION)
567 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
569 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
572#if defined(JSON_HEDLEY_TI_VERSION)
573 #undef JSON_HEDLEY_TI_VERSION
576 defined(__TI_COMPILER_VERSION__) && \
578 defined(__TMS470__) || defined(__TI_ARM__) || \
579 defined(__MSP430__) || \
580 defined(__TMS320C2000__) \
582#if (__TI_COMPILER_VERSION__ >= 16000000)
583 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
587#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
588 #undef JSON_HEDLEY_TI_VERSION_CHECK
590#if defined(JSON_HEDLEY_TI_VERSION)
591 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
593 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
596#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
597 #undef JSON_HEDLEY_TI_CL2000_VERSION
599#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
600 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
603#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
604 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
606#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
607 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
609 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
612#if defined(JSON_HEDLEY_TI_CL430_VERSION)
613 #undef JSON_HEDLEY_TI_CL430_VERSION
615#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
616 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
619#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
620 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
622#if defined(JSON_HEDLEY_TI_CL430_VERSION)
623 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
625 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
628#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
629 #undef JSON_HEDLEY_TI_ARMCL_VERSION
631#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
632 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
635#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
636 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
638#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
639 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
641 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
644#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
645 #undef JSON_HEDLEY_TI_CL6X_VERSION
647#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
648 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
651#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
652 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
654#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
655 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
657 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
660#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
661 #undef JSON_HEDLEY_TI_CL7X_VERSION
663#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
664 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
667#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
668 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
670#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
671 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
673 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
676#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
677 #undef JSON_HEDLEY_TI_CLPRU_VERSION
679#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
680 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
683#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
684 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
686#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
687 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
689 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
692#if defined(JSON_HEDLEY_CRAY_VERSION)
693 #undef JSON_HEDLEY_CRAY_VERSION
696 #if defined(_RELEASE_PATCHLEVEL)
697 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
699 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
703#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
704 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
706#if defined(JSON_HEDLEY_CRAY_VERSION)
707 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
709 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
712#if defined(JSON_HEDLEY_IAR_VERSION)
713 #undef JSON_HEDLEY_IAR_VERSION
715#if defined(__IAR_SYSTEMS_ICC__)
717 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
719 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
723#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
724 #undef JSON_HEDLEY_IAR_VERSION_CHECK
726#if defined(JSON_HEDLEY_IAR_VERSION)
727 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
729 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
732#if defined(JSON_HEDLEY_TINYC_VERSION)
733 #undef JSON_HEDLEY_TINYC_VERSION
735#if defined(__TINYC__)
736 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
739#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
740 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
742#if defined(JSON_HEDLEY_TINYC_VERSION)
743 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
745 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
748#if defined(JSON_HEDLEY_DMC_VERSION)
749 #undef JSON_HEDLEY_DMC_VERSION
752 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
755#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
756 #undef JSON_HEDLEY_DMC_VERSION_CHECK
758#if defined(JSON_HEDLEY_DMC_VERSION)
759 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
761 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
764#if defined(JSON_HEDLEY_COMPCERT_VERSION)
765 #undef JSON_HEDLEY_COMPCERT_VERSION
767#if defined(__COMPCERT_VERSION__)
768 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
771#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
772 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
774#if defined(JSON_HEDLEY_COMPCERT_VERSION)
775 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
777 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
780#if defined(JSON_HEDLEY_PELLES_VERSION)
781 #undef JSON_HEDLEY_PELLES_VERSION
784 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
787#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
788 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
790#if defined(JSON_HEDLEY_PELLES_VERSION)
791 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
793 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
796#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
797 #undef JSON_HEDLEY_MCST_LCC_VERSION
799#if defined(__LCC__) && defined(__LCC_MINOR__)
800 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
803#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
804 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
806#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
807 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
809 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
812#if defined(JSON_HEDLEY_GCC_VERSION)
813 #undef JSON_HEDLEY_GCC_VERSION
816 defined(JSON_HEDLEY_GNUC_VERSION) && \
817 !defined(__clang__) && \
818 !defined(JSON_HEDLEY_INTEL_VERSION) && \
819 !defined(JSON_HEDLEY_PGI_VERSION) && \
820 !defined(JSON_HEDLEY_ARM_VERSION) && \
821 !defined(JSON_HEDLEY_CRAY_VERSION) && \
822 !defined(JSON_HEDLEY_TI_VERSION) && \
823 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
824 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
825 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
826 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
827 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
828 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
829 !defined(__COMPCERT__) && \
830 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
831 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
834#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
835 #undef JSON_HEDLEY_GCC_VERSION_CHECK
837#if defined(JSON_HEDLEY_GCC_VERSION)
838 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
840 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
843#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
844 #undef JSON_HEDLEY_HAS_ATTRIBUTE
847 defined(__has_attribute) && \
849 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
851# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
853# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
856#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
857 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
859#if defined(__has_attribute)
860 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
862 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
865#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
866 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
868#if defined(__has_attribute)
869 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
871 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
874#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
875 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
878 defined(__has_cpp_attribute) && \
879 defined(__cplusplus) && \
880 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
881 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
883 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
886#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
887 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
889#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
890 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
892 !defined(JSON_HEDLEY_PGI_VERSION) && \
893 !defined(JSON_HEDLEY_IAR_VERSION) && \
894 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
895 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
896 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
898 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
901#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
902 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
904#if defined(__has_cpp_attribute) && defined(__cplusplus)
905 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
907 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
910#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
911 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
913#if defined(__has_cpp_attribute) && defined(__cplusplus)
914 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
916 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
919#if defined(JSON_HEDLEY_HAS_BUILTIN)
920 #undef JSON_HEDLEY_HAS_BUILTIN
922#if defined(__has_builtin)
923 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
925 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
928#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
929 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
931#if defined(__has_builtin)
932 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
934 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
937#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
938 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
940#if defined(__has_builtin)
941 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
943 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
946#if defined(JSON_HEDLEY_HAS_FEATURE)
947 #undef JSON_HEDLEY_HAS_FEATURE
949#if defined(__has_feature)
950 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
952 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
955#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
956 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
958#if defined(__has_feature)
959 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
961 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
964#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
965 #undef JSON_HEDLEY_GCC_HAS_FEATURE
967#if defined(__has_feature)
968 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
970 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
973#if defined(JSON_HEDLEY_HAS_EXTENSION)
974 #undef JSON_HEDLEY_HAS_EXTENSION
976#if defined(__has_extension)
977 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
979 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
982#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
983 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
985#if defined(__has_extension)
986 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
988 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
991#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
992 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
994#if defined(__has_extension)
995 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
997 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1000#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
1001 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1003#if defined(__has_declspec_attribute)
1004 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1006 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1009#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1010 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1012#if defined(__has_declspec_attribute)
1013 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1015 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1018#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1019 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1021#if defined(__has_declspec_attribute)
1022 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1024 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1027#if defined(JSON_HEDLEY_HAS_WARNING)
1028 #undef JSON_HEDLEY_HAS_WARNING
1030#if defined(__has_warning)
1031 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1033 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1036#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1037 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1039#if defined(__has_warning)
1040 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1042 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1045#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1046 #undef JSON_HEDLEY_GCC_HAS_WARNING
1048#if defined(__has_warning)
1049 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1051 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1055 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1056 defined(__clang__) || \
1057 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1058 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1059 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1060 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1061 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1062 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1063 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1064 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1065 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1066 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1067 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1068 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1069 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1070 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1071 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1072 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1073 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1074#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1075 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1077 #define JSON_HEDLEY_PRAGMA(value)
1080#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1081 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1083#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1084 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1086#if defined(__clang__)
1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1089#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1090 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1091 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1092#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1093 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1094 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1096 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1097 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1098 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1099 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1100#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1101 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1102 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1104 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1105 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1106 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1107 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1108 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1109 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1111 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1112#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1113 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1114 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1116 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1117 #define JSON_HEDLEY_DIAGNOSTIC_POP
1122#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1123 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1125#if defined(__cplusplus)
1126# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1127# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1128# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1129# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1130 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1131 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1132 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1133 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1135 JSON_HEDLEY_DIAGNOSTIC_POP
1137# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1138 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1139 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1140 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1142 JSON_HEDLEY_DIAGNOSTIC_POP
1145# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1146 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1147 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1149 JSON_HEDLEY_DIAGNOSTIC_POP
1153#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1157#if defined(JSON_HEDLEY_CONST_CAST)
1158 #undef JSON_HEDLEY_CONST_CAST
1160#if defined(__cplusplus)
1161# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1163 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1164 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1165 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1166# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1167 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1168 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1170 JSON_HEDLEY_DIAGNOSTIC_POP \
1173# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1176#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1177 #undef JSON_HEDLEY_REINTERPRET_CAST
1179#if defined(__cplusplus)
1180 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1182 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1185#if defined(JSON_HEDLEY_STATIC_CAST)
1186 #undef JSON_HEDLEY_STATIC_CAST
1188#if defined(__cplusplus)
1189 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1191 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1194#if defined(JSON_HEDLEY_CPP_CAST)
1195 #undef JSON_HEDLEY_CPP_CAST
1197#if defined(__cplusplus)
1198# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1199# define JSON_HEDLEY_CPP_CAST(T, expr) \
1200 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1201 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1203 JSON_HEDLEY_DIAGNOSTIC_POP
1204# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1205# define JSON_HEDLEY_CPP_CAST(T, expr) \
1206 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1207 _Pragma("diag_suppress=Pe137") \
1208 JSON_HEDLEY_DIAGNOSTIC_POP
1210# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1213# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1216#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1217 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1219#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1221#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1222 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1223#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1224 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1225#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1226 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1227#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1228 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1229#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1230 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1231#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1232 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1233#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1234 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1236 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1237 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1238 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1239 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1240 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1241 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1242 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1243 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1244 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1245 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1246 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1247 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1248#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1249 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1250#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1251 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1252#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1253 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1254#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1255 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1257 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1260#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1261 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1263#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1264 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1265#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1267#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1269#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1271#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1273#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1274 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1276 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1277 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1278 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1279 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1280 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1281#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1282 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1283#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1284 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1285#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1286 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1288 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1291#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1292 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1294#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1295 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1296#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1297 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1298#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1299 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1300#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1301 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1302#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1303 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1304#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1305 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1306#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1307 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1308#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1309 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1311 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1312 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1313 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1314 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1315#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1316 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1317#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1318 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1320 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1323#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1324 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1326#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1327 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1328#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1329 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1330#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1331 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1333 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1336#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1337 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1339#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1340 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1341#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1342 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1343#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1344 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1345#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1346 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1348 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1351#if defined(JSON_HEDLEY_DEPRECATED)
1352 #undef JSON_HEDLEY_DEPRECATED
1354#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1355 #undef JSON_HEDLEY_DEPRECATED_FOR
1358 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1359 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1360 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1361 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1363 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1364 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1365 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1366 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1367 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1368 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1369 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1370 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1371 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1372 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1373 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1374 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1375 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1376 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1377#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1378 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1379 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1381 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1382 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1383 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1384 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1385 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1386 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1387 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1388 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1389 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1390 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1391 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1392 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1393 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1394 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1395 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1396 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1397 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1398 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1400 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1401 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1402 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1403 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1404 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1405#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1406 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1407 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1409 #define JSON_HEDLEY_DEPRECATED(since)
1410 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1413#if defined(JSON_HEDLEY_UNAVAILABLE)
1414 #undef JSON_HEDLEY_UNAVAILABLE
1417 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1418 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1419 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1420 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1421 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1423 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1426#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1427 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1429#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1430 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1433 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1434 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1435 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1436 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1437 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1438 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1439 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1440 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1441 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1442 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1443 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1444 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1445 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1446 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1447 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1448 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1449 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1451 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1452#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1454 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1455#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1456 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1457 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1458#elif defined(_Check_return_)
1459 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1460 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1462 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1463 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1466#if defined(JSON_HEDLEY_SENTINEL)
1467 #undef JSON_HEDLEY_SENTINEL
1470 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1471 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1474 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1475 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1477 #define JSON_HEDLEY_SENTINEL(position)
1480#if defined(JSON_HEDLEY_NO_RETURN)
1481 #undef JSON_HEDLEY_NO_RETURN
1483#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1484 #define JSON_HEDLEY_NO_RETURN __noreturn
1486 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1487 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1488 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1489#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1490 #define JSON_HEDLEY_NO_RETURN _Noreturn
1491#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1492 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1494 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1495 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1496 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1497 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1498 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1499 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1500 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1501 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1502 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1503 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1504 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1505 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1506 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1507 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1508 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1509 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1510 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1511 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1512#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1513 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1515 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1516 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1517 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1518#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1519 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1520#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1521 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1522#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1523 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1525 #define JSON_HEDLEY_NO_RETURN
1528#if defined(JSON_HEDLEY_NO_ESCAPE)
1529 #undef JSON_HEDLEY_NO_ESCAPE
1531#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1532 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1534 #define JSON_HEDLEY_NO_ESCAPE
1537#if defined(JSON_HEDLEY_UNREACHABLE)
1538 #undef JSON_HEDLEY_UNREACHABLE
1540#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1541 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1543#if defined(JSON_HEDLEY_ASSUME)
1544 #undef JSON_HEDLEY_ASSUME
1547 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1548 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1549 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1550 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1551#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1552 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1554 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1555 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1556 #if defined(__cplusplus)
1557 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1559 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1563 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1564 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1565 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1566 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1567 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1568 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1569 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1570 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1571#elif defined(JSON_HEDLEY_ASSUME)
1572 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1574#if !defined(JSON_HEDLEY_ASSUME)
1575 #if defined(JSON_HEDLEY_UNREACHABLE)
1576 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1578 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1581#if defined(JSON_HEDLEY_UNREACHABLE)
1583 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1584 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1585 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1587 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1590 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1592#if !defined(JSON_HEDLEY_UNREACHABLE)
1593 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1597#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1598 #pragma clang diagnostic ignored "-Wpedantic"
1600#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1601 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1603#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1604 #if defined(__clang__)
1605 #pragma clang diagnostic ignored "-Wvariadic-macros"
1606 #elif defined(JSON_HEDLEY_GCC_VERSION)
1607 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1610#if defined(JSON_HEDLEY_NON_NULL)
1611 #undef JSON_HEDLEY_NON_NULL
1614 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1615 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1616 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1617 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1618 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1620 #define JSON_HEDLEY_NON_NULL(...)
1624#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1625 #undef JSON_HEDLEY_PRINTF_FORMAT
1627#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1628 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1629#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1630 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1632 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1633 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1634 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1635 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1636 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1637 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1638 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1639 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1640 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1641 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1642 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1643 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1644 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1645 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1646 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1647 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1648 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1649 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1650#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1651 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1653 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1656#if defined(JSON_HEDLEY_CONSTEXPR)
1657 #undef JSON_HEDLEY_CONSTEXPR
1659#if defined(__cplusplus)
1660 #if __cplusplus >= 201103L
1661 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1664#if !defined(JSON_HEDLEY_CONSTEXPR)
1665 #define JSON_HEDLEY_CONSTEXPR
1668#if defined(JSON_HEDLEY_PREDICT)
1669 #undef JSON_HEDLEY_PREDICT
1671#if defined(JSON_HEDLEY_LIKELY)
1672 #undef JSON_HEDLEY_LIKELY
1674#if defined(JSON_HEDLEY_UNLIKELY)
1675 #undef JSON_HEDLEY_UNLIKELY
1677#if defined(JSON_HEDLEY_UNPREDICTABLE)
1678 #undef JSON_HEDLEY_UNPREDICTABLE
1680#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1681 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1684 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1685 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1686 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1687# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1688# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1689# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1690# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1691# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1693 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1694 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1695 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1696 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1697 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1698 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1699 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1700 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1701 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1702 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1703 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1704 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1705 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1706 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1707 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1708 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1709# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1710 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1711# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1713 double hedley_probability_ = (probability); \
1714 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1716# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1718 double hedley_probability_ = (probability); \
1719 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1721# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1722# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1724# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1725# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1726# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1727# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1728# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1730#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1731 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1734#if defined(JSON_HEDLEY_MALLOC)
1735 #undef JSON_HEDLEY_MALLOC
1738 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1739 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1740 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1741 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1742 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1743 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1744 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1745 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1746 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1747 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1748 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1749 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1750 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1751 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1752 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1753 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1754 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1755 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1756 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1757#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1758 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1760 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1761 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1762 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1764 #define JSON_HEDLEY_MALLOC
1767#if defined(JSON_HEDLEY_PURE)
1768 #undef JSON_HEDLEY_PURE
1771 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1772 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1773 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1774 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1775 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1776 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1777 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1778 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1779 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1780 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1781 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1782 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1783 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1784 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1785 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1786 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1787 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1788 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1789 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1790# define JSON_HEDLEY_PURE __attribute__((__pure__))
1791#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1792# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1793#elif defined(__cplusplus) && \
1795 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1796 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1797 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1799# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1801# define JSON_HEDLEY_PURE
1804#if defined(JSON_HEDLEY_CONST)
1805 #undef JSON_HEDLEY_CONST
1808 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1809 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1810 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1811 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1812 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1813 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1814 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1815 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1816 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1817 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1818 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1819 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1820 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1821 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1822 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1823 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1824 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1825 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1826 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1827 #define JSON_HEDLEY_CONST __attribute__((__const__))
1829 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1830 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1832 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1835#if defined(JSON_HEDLEY_RESTRICT)
1836 #undef JSON_HEDLEY_RESTRICT
1838#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1839 #define JSON_HEDLEY_RESTRICT restrict
1841 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1842 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1843 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1844 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1845 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1846 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1847 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1848 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1849 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1850 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1851 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1852 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1853 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1854 defined(__clang__) || \
1855 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1856 #define JSON_HEDLEY_RESTRICT __restrict
1857#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1858 #define JSON_HEDLEY_RESTRICT _Restrict
1860 #define JSON_HEDLEY_RESTRICT
1863#if defined(JSON_HEDLEY_INLINE)
1864 #undef JSON_HEDLEY_INLINE
1867 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1868 (defined(__cplusplus) && (__cplusplus >= 199711L))
1869 #define JSON_HEDLEY_INLINE inline
1871 defined(JSON_HEDLEY_GCC_VERSION) || \
1872 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1873 #define JSON_HEDLEY_INLINE __inline__
1875 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1876 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1877 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1878 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1879 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1880 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1881 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1882 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1883 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1884 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1885 #define JSON_HEDLEY_INLINE __inline
1887 #define JSON_HEDLEY_INLINE
1890#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1891 #undef JSON_HEDLEY_ALWAYS_INLINE
1894 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1895 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1896 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1897 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1898 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1899 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1900 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1901 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1902 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1903 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1904 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1905 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1906 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1907 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1908 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1909 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1910 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1911 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1912 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1913# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1915 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1916 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1917# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1918#elif defined(__cplusplus) && \
1920 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1921 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1922 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1923 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1924 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1925 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1927# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1928#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1929# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1931# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1934#if defined(JSON_HEDLEY_NEVER_INLINE)
1935 #undef JSON_HEDLEY_NEVER_INLINE
1938 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1939 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1940 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1941 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1942 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1943 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1944 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1945 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1946 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1947 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1948 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1949 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1950 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1951 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1952 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1953 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1954 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1955 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1956 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1957 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1959 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1960 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1961 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1962#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1963 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1964#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1965 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1966#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1967 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1968#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1969 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1970#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1971 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1973 #define JSON_HEDLEY_NEVER_INLINE
1976#if defined(JSON_HEDLEY_PRIVATE)
1977 #undef JSON_HEDLEY_PRIVATE
1979#if defined(JSON_HEDLEY_PUBLIC)
1980 #undef JSON_HEDLEY_PUBLIC
1982#if defined(JSON_HEDLEY_IMPORT)
1983 #undef JSON_HEDLEY_IMPORT
1985#if defined(_WIN32) || defined(__CYGWIN__)
1986# define JSON_HEDLEY_PRIVATE
1987# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1988# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1991 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1992 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1993 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1994 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1995 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1996 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1998 defined(__TI_EABI__) && \
2000 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
2001 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2004 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2005# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2006# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2008# define JSON_HEDLEY_PRIVATE
2009# define JSON_HEDLEY_PUBLIC
2011# define JSON_HEDLEY_IMPORT extern
2014#if defined(JSON_HEDLEY_NO_THROW)
2015 #undef JSON_HEDLEY_NO_THROW
2018 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2019 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2020 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2021 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2022 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2024 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2025 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2026 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2027 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2029 #define JSON_HEDLEY_NO_THROW
2032#if defined(JSON_HEDLEY_FALL_THROUGH)
2033 #undef JSON_HEDLEY_FALL_THROUGH
2036 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2037 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2038 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2039 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2040#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2041 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2042#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2043 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2044#elif defined(__fallthrough)
2045 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2047 #define JSON_HEDLEY_FALL_THROUGH
2050#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2051 #undef JSON_HEDLEY_RETURNS_NON_NULL
2054 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2055 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2056 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2057 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2058#elif defined(_Ret_notnull_)
2059 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2061 #define JSON_HEDLEY_RETURNS_NON_NULL
2064#if defined(JSON_HEDLEY_ARRAY_PARAM)
2065 #undef JSON_HEDLEY_ARRAY_PARAM
2068 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2069 !defined(__STDC_NO_VLA__) && \
2070 !defined(__cplusplus) && \
2071 !defined(JSON_HEDLEY_PGI_VERSION) && \
2072 !defined(JSON_HEDLEY_TINYC_VERSION)
2073 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2075 #define JSON_HEDLEY_ARRAY_PARAM(name)
2078#if defined(JSON_HEDLEY_IS_CONSTANT)
2079 #undef JSON_HEDLEY_IS_CONSTANT
2081#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2082 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2086#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2087 #undef JSON_HEDLEY_IS_CONSTEXPR_
2090 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2091 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2092 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2093 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2094 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2095 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2096 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2097 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2098 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2099 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2100 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2102#if !defined(__cplusplus)
2104 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2105 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2106 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2107 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2108 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2109 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2110 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2111#if defined(__INTPTR_TYPE__)
2112 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2115 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2119 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2120 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2121 !defined(JSON_HEDLEY_PGI_VERSION) && \
2122 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2123 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2124 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2125 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2126 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2127 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2128#if defined(__INTPTR_TYPE__)
2129 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2132 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2135 defined(JSON_HEDLEY_GCC_VERSION) || \
2136 defined(JSON_HEDLEY_INTEL_VERSION) || \
2137 defined(JSON_HEDLEY_TINYC_VERSION) || \
2138 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2139 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2140 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2141 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2142 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2143 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2145# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2149 ((void*) ((expr) * 0L) ) : \
2150((struct { char v[sizeof(void) * 2]; } *) 1) \
2156#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2157 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2158 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2160 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2162 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2163 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2165 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2168#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2169 #undef JSON_HEDLEY_BEGIN_C_DECLS
2171#if defined(JSON_HEDLEY_END_C_DECLS)
2172 #undef JSON_HEDLEY_END_C_DECLS
2174#if defined(JSON_HEDLEY_C_DECL)
2175 #undef JSON_HEDLEY_C_DECL
2177#if defined(__cplusplus)
2178 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2179 #define JSON_HEDLEY_END_C_DECLS }
2180 #define JSON_HEDLEY_C_DECL extern "C"
2182 #define JSON_HEDLEY_BEGIN_C_DECLS
2183 #define JSON_HEDLEY_END_C_DECLS
2184 #define JSON_HEDLEY_C_DECL
2187#if defined(JSON_HEDLEY_STATIC_ASSERT)
2188 #undef JSON_HEDLEY_STATIC_ASSERT
2191 !defined(__cplusplus) && ( \
2192 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2193 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2194 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2195 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2196 defined(_Static_assert) \
2198# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2200 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2201 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2202 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2203# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2205# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2208#if defined(JSON_HEDLEY_NULL)
2209 #undef JSON_HEDLEY_NULL
2211#if defined(__cplusplus)
2212 #if __cplusplus >= 201103L
2213 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2215 #define JSON_HEDLEY_NULL NULL
2217 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2220 #define JSON_HEDLEY_NULL NULL
2222 #define JSON_HEDLEY_NULL ((void*) 0)
2225#if defined(JSON_HEDLEY_MESSAGE)
2226 #undef JSON_HEDLEY_MESSAGE
2228#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2229# define JSON_HEDLEY_MESSAGE(msg) \
2230 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2231 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2232 JSON_HEDLEY_PRAGMA(message msg) \
2233 JSON_HEDLEY_DIAGNOSTIC_POP
2235 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2236 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2237# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2238#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2239# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2240#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2241# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2242#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2243# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2245# define JSON_HEDLEY_MESSAGE(msg)
2248#if defined(JSON_HEDLEY_WARNING)
2249 #undef JSON_HEDLEY_WARNING
2251#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2252# define JSON_HEDLEY_WARNING(msg) \
2253 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2254 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2255 JSON_HEDLEY_PRAGMA(clang warning msg) \
2256 JSON_HEDLEY_DIAGNOSTIC_POP
2258 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2259 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2260 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2261# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2263 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2264 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2265# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2267# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2270#if defined(JSON_HEDLEY_REQUIRE)
2271 #undef JSON_HEDLEY_REQUIRE
2273#if defined(JSON_HEDLEY_REQUIRE_MSG)
2274 #undef JSON_HEDLEY_REQUIRE_MSG
2276#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2277# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2278# define JSON_HEDLEY_REQUIRE(expr) \
2279 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2280 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2281 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2282 JSON_HEDLEY_DIAGNOSTIC_POP
2283# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2284 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2285 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2286 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2287 JSON_HEDLEY_DIAGNOSTIC_POP
2289# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2290# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2293# define JSON_HEDLEY_REQUIRE(expr)
2294# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2297#if defined(JSON_HEDLEY_FLAGS)
2298 #undef JSON_HEDLEY_FLAGS
2300#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2301 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2303 #define JSON_HEDLEY_FLAGS
2306#if defined(JSON_HEDLEY_FLAGS_CAST)
2307 #undef JSON_HEDLEY_FLAGS_CAST
2309#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2310# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2311 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2312 _Pragma("warning(disable:188)") \
2314 JSON_HEDLEY_DIAGNOSTIC_POP \
2317# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2320#if defined(JSON_HEDLEY_EMPTY_BASES)
2321 #undef JSON_HEDLEY_EMPTY_BASES
2324 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2325 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2326 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2328 #define JSON_HEDLEY_EMPTY_BASES
2333#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2334 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2336#if defined(__clang__)
2337 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2339 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2342#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2343 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2345#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2347#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2348 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2350#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2352#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2353 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2355#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2357#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2358 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2360#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2362#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2363 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2365#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2367#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2368 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2370#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2372#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2373 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2375#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2387#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2388 #if defined(__clang__)
2389 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2390 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2392 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2393 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2394 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2401#if !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2402 #if (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
2403 #define JSON_HAS_CPP_23
2404 #define JSON_HAS_CPP_20
2405 #define JSON_HAS_CPP_17
2406 #define JSON_HAS_CPP_14
2407 #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
2408 #define JSON_HAS_CPP_20
2409 #define JSON_HAS_CPP_17
2410 #define JSON_HAS_CPP_14
2411 #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2412 #define JSON_HAS_CPP_17
2413 #define JSON_HAS_CPP_14
2414 #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2415 #define JSON_HAS_CPP_14
2418 #define JSON_HAS_CPP_11
2422 #if __has_include(<version>)
2427#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2428 #ifdef JSON_HAS_CPP_17
2429 #if defined(__cpp_lib_filesystem)
2430 #define JSON_HAS_FILESYSTEM 1
2431 #elif defined(__cpp_lib_experimental_filesystem)
2432 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2433 #elif !defined(__has_include)
2434 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2435 #elif __has_include(<filesystem>)
2436 #define JSON_HAS_FILESYSTEM 1
2437 #elif __has_include(<experimental/filesystem>)
2438 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2442 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2443 #undef JSON_HAS_FILESYSTEM
2444 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2448 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2449 #undef JSON_HAS_FILESYSTEM
2450 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2454 #if defined(__clang_major__) && __clang_major__ < 7
2455 #undef JSON_HAS_FILESYSTEM
2456 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2460 #if defined(_MSC_VER) && _MSC_VER < 1914
2461 #undef JSON_HAS_FILESYSTEM
2462 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2466 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2467 #undef JSON_HAS_FILESYSTEM
2468 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2472 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2473 #undef JSON_HAS_FILESYSTEM
2474 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2479#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2480 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2483#ifndef JSON_HAS_FILESYSTEM
2484 #define JSON_HAS_FILESYSTEM 0
2487#ifndef JSON_HAS_THREE_WAY_COMPARISON
2488 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2489 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2490 #define JSON_HAS_THREE_WAY_COMPARISON 1
2492 #define JSON_HAS_THREE_WAY_COMPARISON 0
2496#ifndef JSON_HAS_RANGES
2498 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2499 #define JSON_HAS_RANGES 0
2500 #elif defined(__cpp_lib_ranges)
2501 #define JSON_HAS_RANGES 1
2503 #define JSON_HAS_RANGES 0
2507#ifndef JSON_HAS_STATIC_RTTI
2508 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2509 #define JSON_HAS_STATIC_RTTI 1
2511 #define JSON_HAS_STATIC_RTTI 0
2515#ifdef JSON_HAS_CPP_17
2516 #define JSON_INLINE_VARIABLE inline
2518 #define JSON_INLINE_VARIABLE
2521#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2522 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2524 #define JSON_NO_UNIQUE_ADDRESS
2528#if defined(__clang__)
2529 #pragma clang diagnostic push
2530 #pragma clang diagnostic ignored "-Wdocumentation"
2531 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2535#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2536 #define JSON_THROW(exception) throw exception
2537 #define JSON_TRY try
2538 #define JSON_CATCH(exception) catch(exception)
2539 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2542 #define JSON_THROW(exception) std::abort()
2543 #define JSON_TRY if(true)
2544 #define JSON_CATCH(exception) if(false)
2545 #define JSON_INTERNAL_CATCH(exception) if(false)
2549#if defined(JSON_THROW_USER)
2551 #define JSON_THROW JSON_THROW_USER
2553#if defined(JSON_TRY_USER)
2555 #define JSON_TRY JSON_TRY_USER
2557#if defined(JSON_CATCH_USER)
2559 #define JSON_CATCH JSON_CATCH_USER
2560 #undef JSON_INTERNAL_CATCH
2561 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2563#if defined(JSON_INTERNAL_CATCH_USER)
2564 #undef JSON_INTERNAL_CATCH
2565 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2569#if !defined(JSON_ASSERT)
2571 #define JSON_ASSERT(x) assert(x)
2575#if defined(JSON_TESTS_PRIVATE)
2576 #define JSON_PRIVATE_UNLESS_TESTED public
2578 #define JSON_PRIVATE_UNLESS_TESTED private
2586#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2587 template<typename BasicJsonType> \
2588 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2591 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2593 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2594 auto it = std::find_if(std::begin(m), std::end(m), \
2595 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2597 return ej_pair.first == e; \
2599 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2601 template<typename BasicJsonType> \
2602 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2605 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2607 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2608 auto it = std::find_if(std::begin(m), std::end(m), \
2609 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2611 return ej_pair.second == j; \
2613 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2619#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2620 template<template<typename, typename, typename...> class ObjectType, \
2621 template<typename, typename...> class ArrayType, \
2622 class StringType, class BooleanType, class NumberIntegerType, \
2623 class NumberUnsignedType, class NumberFloatType, \
2624 template<typename> class AllocatorType, \
2625 template<typename, typename = void> class JSONSerializer, \
2627 class CustomBaseClass>
2629#define NLOHMANN_BASIC_JSON_TPL \
2630 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2631 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2632 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2636#define NLOHMANN_JSON_EXPAND( x ) x
2637#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
2638#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2639 NLOHMANN_JSON_PASTE64, \
2640 NLOHMANN_JSON_PASTE63, \
2641 NLOHMANN_JSON_PASTE62, \
2642 NLOHMANN_JSON_PASTE61, \
2643 NLOHMANN_JSON_PASTE60, \
2644 NLOHMANN_JSON_PASTE59, \
2645 NLOHMANN_JSON_PASTE58, \
2646 NLOHMANN_JSON_PASTE57, \
2647 NLOHMANN_JSON_PASTE56, \
2648 NLOHMANN_JSON_PASTE55, \
2649 NLOHMANN_JSON_PASTE54, \
2650 NLOHMANN_JSON_PASTE53, \
2651 NLOHMANN_JSON_PASTE52, \
2652 NLOHMANN_JSON_PASTE51, \
2653 NLOHMANN_JSON_PASTE50, \
2654 NLOHMANN_JSON_PASTE49, \
2655 NLOHMANN_JSON_PASTE48, \
2656 NLOHMANN_JSON_PASTE47, \
2657 NLOHMANN_JSON_PASTE46, \
2658 NLOHMANN_JSON_PASTE45, \
2659 NLOHMANN_JSON_PASTE44, \
2660 NLOHMANN_JSON_PASTE43, \
2661 NLOHMANN_JSON_PASTE42, \
2662 NLOHMANN_JSON_PASTE41, \
2663 NLOHMANN_JSON_PASTE40, \
2664 NLOHMANN_JSON_PASTE39, \
2665 NLOHMANN_JSON_PASTE38, \
2666 NLOHMANN_JSON_PASTE37, \
2667 NLOHMANN_JSON_PASTE36, \
2668 NLOHMANN_JSON_PASTE35, \
2669 NLOHMANN_JSON_PASTE34, \
2670 NLOHMANN_JSON_PASTE33, \
2671 NLOHMANN_JSON_PASTE32, \
2672 NLOHMANN_JSON_PASTE31, \
2673 NLOHMANN_JSON_PASTE30, \
2674 NLOHMANN_JSON_PASTE29, \
2675 NLOHMANN_JSON_PASTE28, \
2676 NLOHMANN_JSON_PASTE27, \
2677 NLOHMANN_JSON_PASTE26, \
2678 NLOHMANN_JSON_PASTE25, \
2679 NLOHMANN_JSON_PASTE24, \
2680 NLOHMANN_JSON_PASTE23, \
2681 NLOHMANN_JSON_PASTE22, \
2682 NLOHMANN_JSON_PASTE21, \
2683 NLOHMANN_JSON_PASTE20, \
2684 NLOHMANN_JSON_PASTE19, \
2685 NLOHMANN_JSON_PASTE18, \
2686 NLOHMANN_JSON_PASTE17, \
2687 NLOHMANN_JSON_PASTE16, \
2688 NLOHMANN_JSON_PASTE15, \
2689 NLOHMANN_JSON_PASTE14, \
2690 NLOHMANN_JSON_PASTE13, \
2691 NLOHMANN_JSON_PASTE12, \
2692 NLOHMANN_JSON_PASTE11, \
2693 NLOHMANN_JSON_PASTE10, \
2694 NLOHMANN_JSON_PASTE9, \
2695 NLOHMANN_JSON_PASTE8, \
2696 NLOHMANN_JSON_PASTE7, \
2697 NLOHMANN_JSON_PASTE6, \
2698 NLOHMANN_JSON_PASTE5, \
2699 NLOHMANN_JSON_PASTE4, \
2700 NLOHMANN_JSON_PASTE3, \
2701 NLOHMANN_JSON_PASTE2, \
2702 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2703#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2704#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2705#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2706#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2707#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2708#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)
2709#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)
2710#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)
2711#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)
2712#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)
2713#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)
2714#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)
2715#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)
2716#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)
2717#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)
2718#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)
2719#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)
2720#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)
2721#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)
2722#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)
2723#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)
2724#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)
2725#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)
2726#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)
2727#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)
2728#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)
2729#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)
2730#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)
2731#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)
2732#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)
2733#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)
2734#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)
2735#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)
2736#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)
2737#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)
2738#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)
2739#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)
2740#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)
2741#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)
2742#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)
2743#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)
2744#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)
2745#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)
2746#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)
2747#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)
2748#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)
2749#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)
2750#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)
2751#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)
2752#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)
2753#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)
2754#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)
2755#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)
2756#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)
2757#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)
2758#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)
2759#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)
2760#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)
2761#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)
2762#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)
2763#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)
2764#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)
2765#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)
2767#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2768#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2769#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
2777#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2778 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2779 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2780 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2781 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2789#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2790 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2791 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2792 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2793 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2801#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2802 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2803 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2811#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2812 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2813 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2814 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2815 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2823#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2824 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2825 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2826 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2827 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2835#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2836 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2837 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2845#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2846 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2847 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2848 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2849 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2857#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2858 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2859 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2860 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2861 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2869#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2870 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2871 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2879#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2880 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2881 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2882 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2883 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2891#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2892 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2893 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2894 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2895 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2903#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2904 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2905 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2913#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2914 namespace detail { \
2915 using std::std_name; \
2917 template<typename... T> \
2918 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2921 namespace detail2 { \
2922 struct std_name##_tag \
2926 template<typename... T> \
2927 std_name##_tag std_name(T&&...); \
2929 template<typename... T> \
2930 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2932 template<typename... T> \
2933 struct would_call_std_##std_name \
2935 static constexpr auto const value = ::nlohmann::detail:: \
2936 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2940 template<typename... T> \
2941 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2945#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2946 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2949#if JSON_USE_IMPLICIT_CONVERSIONS
2950 #define JSON_EXPLICIT
2952 #define JSON_EXPLICIT explicit
2955#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2956 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2959#ifndef JSON_USE_GLOBAL_UDLS
2960 #define JSON_USE_GLOBAL_UDLS 1
2963#if JSON_HAS_THREE_WAY_COMPARISON
3026#if JSON_HAS_THREE_WAY_COMPARISON
3027 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
3032 static constexpr std::array<std::uint8_t, 9> order = {{
3039 const auto l_index =
static_cast<std::size_t
>(lhs);
3040 const auto r_index =
static_cast<std::size_t
>(rhs);
3041#if JSON_HAS_THREE_WAY_COMPARISON
3042 if (l_index < order.size() && r_index < order.size())
3044 return order[l_index] <=> order[r_index];
3046 return std::partial_ordering::unordered;
3048 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3056#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
3059 return std::is_lt(lhs <=> rhs);
3097template<
typename StringType>
3099 const StringType& t)
3102 for (
auto pos = s.find(f);
3103 pos != StringType::npos;
3104 s.replace(pos, f.size(), t),
3105 pos = s.find(f, pos + t.size()))
3116template<
typename StringType>
3131template<
typename StringType>
3172 constexpr operator size_t()
const
3197#include <type_traits>
3208using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3210#ifdef JSON_HAS_CPP_14
3213using std::enable_if_t;
3214using std::index_sequence;
3215using std::make_index_sequence;
3216using std::index_sequence_for;
3221template<
bool B,
typename T =
void>
3248template <
typename T, T... Ints>
3252 static constexpr std::size_t
size() noexcept
3254 return sizeof...(Ints);
3263template <
size_t... Ints>
3269template <
typename Seq,
size_t SeqSize,
size_t Rem>
3273template <
typename T, T... Ints,
size_t SeqSize>
3279template <
typename T, T... Ints,
size_t SeqSize>
3287template <
typename T,
size_t N>
3294template <
typename T>
3309template <
typename T, T N>
3325template <
typename... Ts>
3343#ifndef JSON_HAS_CPP_17
3344 template<
typename T>
3348template<
typename T,
typename... Args>
3349constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3351 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3371#include <type_traits>
3398template<
typename It,
typename =
void>
3401template<
typename It>
3405 typename It::reference, typename It::iterator_category >>
3416template<
typename T,
typename =
void>
3495#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3496 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3521 template<
typename T =
void,
typename SFINAE =
void>
3526 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3528 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3529 class StringType = std::string,
class BooleanType = bool,
3530 class NumberIntegerType = std::int64_t,
3531 class NumberUnsignedType = std::uint64_t,
3532 class NumberFloatType = double,
3533 template<
typename U>
class AllocatorType = std::allocator,
3534 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3536 class BinaryType = std::vector<std::uint8_t>,
3537 class CustomBaseClass =
void>
3542 template<
typename RefStringType>
3553 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3598template<
typename BasicJsonContext>
3600 std::integral_constant < bool,
3601 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3602 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3643template<
typename T,
typename... Args>
3646template<
typename T,
typename... Args>
3649template<
typename T,
typename U>
3653template<
typename BasicJsonType,
typename T,
typename =
void>
3660template <
typename BasicJsonType,
typename T>
3666template<
typename BasicJsonType,
typename T>
3669 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3673 const BasicJsonType&, T&>
::value;
3678template<
typename BasicJsonType,
typename T,
typename =
void>
3681template<
typename BasicJsonType,
typename T>
3684 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3693template<
typename BasicJsonType,
typename T,
typename =
void>
3696template<
typename BasicJsonType,
typename T>
3699 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3710struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3713template<
typename BasicJsonType>
3718 using type =
typename std::conditional < has_key_compare<object_t>::value,
3722template<
typename BasicJsonType>
3754 return static_cast<int_type>(std::char_traits<char>::eof());
3778 return static_cast<int_type>(std::char_traits<char>::eof());
3789template<
class B,
class... Bn>
3791: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3794template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3799template <
typename T>
3802template <
typename T1,
typename T2>
3804 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3806template <
typename T1,
typename T2>
3808 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3810template <
typename... Ts>
3812 :
conjunction<is_default_constructible<Ts>...> {};
3814template <
typename... Ts>
3816 :
conjunction<is_default_constructible<Ts>...> {};
3818template <
typename T,
typename... Args>
3821template <
typename T1,
typename T2>
3824template <
typename T1,
typename T2>
3827template <
typename... Ts>
3830template <
typename... Ts>
3833template<
typename T,
typename =
void>
3855 using t_ref =
typename std::add_lvalue_reference<T>::type;
3863 static constexpr auto is_iterator_begin =
3867 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3880template<
typename T,
typename =
void>
3886template<
typename BasicJsonType,
typename CompatibleObjectType,
3890template<
typename BasicJsonType,
typename CompatibleObjectType>
3892 BasicJsonType, CompatibleObjectType,
3901 typename CompatibleObjectType::key_type>
::value &&
3903 typename CompatibleObjectType::mapped_type>
::value;
3906template<
typename BasicJsonType,
typename CompatibleObjectType>
3910template<
typename BasicJsonType,
typename ConstructibleObjectType,
3914template<
typename BasicJsonType,
typename ConstructibleObjectType>
3916 BasicJsonType, ConstructibleObjectType,
3924 (std::is_move_assignable<ConstructibleObjectType>::value ||
3925 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3927 typename object_t::key_type>
::value &&
3929 typename object_t::mapped_type,
3930 typename ConstructibleObjectType::mapped_type >
::value)) ||
3932 typename ConstructibleObjectType::mapped_type>
::value ||
3935 typename ConstructibleObjectType::mapped_type >
::value);
3938template<
typename BasicJsonType,
typename ConstructibleObjectType>
3941 ConstructibleObjectType> {};
3943template<
typename BasicJsonType,
typename CompatibleStringType>
3950template<
typename BasicJsonType,
typename ConstructibleStringType>
3954#ifdef __INTEL_COMPILER
3955 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3967template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3970template<
typename BasicJsonType,
typename CompatibleArrayType>
3972 BasicJsonType, CompatibleArrayType,
3978 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3985template<
typename BasicJsonType,
typename CompatibleArrayType>
3989template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3992template<
typename BasicJsonType,
typename ConstructibleArrayType>
3994 BasicJsonType, ConstructibleArrayType,
3996 typename BasicJsonType::value_type>
::value >>
3997 : std::true_type {};
3999template<
typename BasicJsonType,
typename ConstructibleArrayType>
4001 BasicJsonType, ConstructibleArrayType,
4003 typename BasicJsonType::value_type>
::value&&
4006(std::is_move_assignable<ConstructibleArrayType>::value ||
4007 std::is_copy_assignable<ConstructibleArrayType>::value)&&
4013!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
4015detected_t<range_value_t, ConstructibleArrayType >>
::value >>
4021 typename BasicJsonType::array_t::value_type>
::value ||
4029template<
typename BasicJsonType,
typename ConstructibleArrayType>
4033template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
4037template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4039 RealIntegerType, CompatibleNumberIntegerType,
4041 std::is_integral<CompatibleNumberIntegerType>
::value&&
4042 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
4050 CompatibleNumberIntegerType>
::value &&
4051 CompatibleLimits::is_integer &&
4052 RealLimits::is_signed == CompatibleLimits::is_signed;
4055template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4058 CompatibleNumberIntegerType> {};
4060template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
4063template<
typename BasicJsonType,
typename CompatibleType>
4065 BasicJsonType, CompatibleType,
4072template<
typename BasicJsonType,
typename CompatibleType>
4076template<
typename T1,
typename T2>
4079template<
typename T1,
typename... Args>
4082template<
typename BasicJsonType,
typename T>
4085template<
typename BasicJsonType>
4088template<
typename BasicJsonType>
4093template<
template <
typename...>
class Primary,
typename T>
4096template<
template <
typename...>
class Primary,
typename... Args>
4103template<
typename Compare,
typename A,
typename B,
typename =
void>
4106template<
typename Compare,
typename A,
typename B>
4108decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4109decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4110>> : std::true_type {};
4117template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4121 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4123 && (!RequireTransparentComparator
4124 || is_detected <detect_is_transparent, Comparator>::value)
4127 std::false_type >::type;
4135template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4139 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4140 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4143 std::false_type >::type;
4145template<
typename ObjectType,
typename KeyType>
4149template<
typename BasicJsonType,
typename KeyType>
4153 typename BasicJsonType::object_t, KeyType >
::value,
4155 std::false_type >::type;
4159template <
typename T>
4169 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4176template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4179 return static_cast<T
>(
value);
4182template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4188template<
typename... Types>
4191template<
typename... Types>
4194template<
typename... Types>
4198template<
typename... Types>
4202template<
typename OfType,
typename T>
4204 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4207template<
typename OfType,
typename T,
4208 bool OfTypeSigned = std::is_signed<OfType>::value,
4209 bool TSigned = std::is_signed<T>::value>
4212template<
typename OfType,
typename T>
4217 using CommonType =
typename std::common_type<OfType, T>::type;
4218 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4222template<
typename OfType,
typename T>
4227 using CommonType =
typename std::common_type<OfType, T>::type;
4228 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4232template<
typename OfType,
typename T>
4237 using CommonType =
typename std::common_type<OfType, T>::type;
4238 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4242template<
typename OfType,
typename T>
4247 using CommonType =
typename std::common_type<OfType, T>::type;
4248 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4249 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4253template<
typename OfType,
typename T,
4254 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4258template<
typename OfType,
typename T>
4267template<
typename OfType,
typename T>
4276template<
typename OfType,
typename T>
4295 using TUnExt =
typename std::remove_extent<T>::type;
4296 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4297 using TUnPtr =
typename std::remove_pointer<T>::type;
4298 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4300 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4301 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4366template<
typename... Args>
4367inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4369template<
typename StringType,
typename... Args>
4370inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4372template<
typename... Args>
4378template<
typename... Args>
4385template<
typename StringType,
typename... Args>
4391template<
typename OutStringType>
4395template<
typename StringType,
typename Arg>
4398template<
typename StringType,
typename Arg>
4401template<
typename StringType,
typename Arg>
4404template<
typename StringType,
typename Arg>
4407template<
typename StringType,
typename Arg>
4408using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4410template<
typename StringType,
typename Arg>
4413template<
typename StringType,
typename Arg>
4414using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4416template<
typename StringType,
typename Arg>
4419template <
typename OutStringType,
typename Arg,
typename... Args,
4420 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4422inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4424template <
typename OutStringType,
typename Arg,
typename... Args,
4425 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4428inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4430template <
typename OutStringType,
typename Arg,
typename... Args,
4431 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4435inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4437template<
typename OutStringType,
typename Arg,
typename... Args,
4439inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4441 out.append(std::forward<Arg>(arg));
4445template <
typename OutStringType,
typename Arg,
typename... Args,
4446 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4447 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4448inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4450 out += std::forward<Arg>(arg);
4454template <
typename OutStringType,
typename Arg,
typename... Args,
4455 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4456 && !detect_string_can_append_op<OutStringType, Arg>::value
4457 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4458inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4460 out.append(arg.begin(), arg.end());
4464template <
typename OutStringType,
typename Arg,
typename... Args,
4465 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4466 && !detect_string_can_append_op<OutStringType, Arg>::value
4467 && !detect_string_can_append_iter<OutStringType, Arg>::value
4468 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4469inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4471 out.append(arg.data(), arg.size());
4475template<
typename OutStringType = std::string,
typename... Args>
4495#if defined(__clang__)
4496 #pragma clang diagnostic push
4497 #pragma clang diagnostic ignored "-Wweak-vtables"
4514 const char*
what() const noexcept
override
4524 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4526 static std::string
name(
const std::string& ename,
int id_)
4528 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4536 template<
typename BasicJsonType>
4540 std::vector<std::string> tokens;
4541 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4543 switch (current->m_parent->type())
4547 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4549 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4551 tokens.emplace_back(std::to_string(i));
4560 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4562 if (&element.second == current)
4564 tokens.emplace_back(element.first.c_str());
4589 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4590 [](
const std::string & a,
const std::string & b)
4592 return concat(a,
'/', detail::escape(b));
4595 return concat(
'(', str,
") ", get_byte_positions(leaf_element));
4597 return get_byte_positions(leaf_element);
4603 std::runtime_error m;
4604#if JSON_DIAGNOSTIC_POSITIONS
4605 template<
typename BasicJsonType>
4606 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4608 if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
4610 return concat(
"(bytes ", std::to_string(leaf_element->start_pos()),
"-", std::to_string(leaf_element->end_pos()),
") ");
4615 template<
typename BasicJsonType>
4616 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4618 static_cast<void>(leaf_element);
4638 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4639 static parse_error
create(
int id_,
const position_t& pos,
const std::string& what_arg, BasicJsonContext context)
4646 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4647 static parse_error
create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4650 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4652 return {id_, byte_, w.c_str()};
4667 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4670 static std::string position_string(
const position_t& pos)
4682 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4683 static invalid_iterator
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4686 return {id_, w.c_str()};
4700 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4701 static type_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4704 return {id_, w.c_str()};
4717 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4718 static out_of_range
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4721 return {id_, w.c_str()};
4734 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4735 static other_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4738 return {id_, w.c_str()};
4749#if defined(__clang__)
4750 #pragma clang diagnostic pop
4795#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4796#include <experimental/filesystem>
4800namespace std_fs = std::experimental::filesystem;
4803#elif JSON_HAS_FILESYSTEM
4804#include <filesystem>
4808namespace std_fs = std::filesystem;
4824template<
typename BasicJsonType>
4825inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4834#ifdef JSON_HAS_CPP_17
4835#ifndef JSON_USE_IMPLICIT_CONVERSIONS
4836template<
typename BasicJsonType,
typename T>
4837void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4845 opt.emplace(j.template
get<T>());
4853template <
typename BasicJsonType,
typename ArithmeticType,
4854 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4855 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4859 switch (
static_cast<value_t>(j))
4863 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4868 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4873 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4889template<
typename BasicJsonType>
4890inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4896 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4899template<
typename BasicJsonType>
4900inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4906 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4910 typename BasicJsonType,
typename StringType,
4912 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4913 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4914 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4915 && !is_json_ref<StringType>::value,
int > = 0 >
4923 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4926template<
typename BasicJsonType>
4927inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4932template<
typename BasicJsonType>
4933inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4938template<
typename BasicJsonType>
4939inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4944#if !JSON_DISABLE_ENUM_SERIALIZATION
4945template<
typename BasicJsonType,
typename EnumType,
4946 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4949 typename std::underlying_type<EnumType>::type val;
4951 e =
static_cast<EnumType
>(val);
4956template<
typename BasicJsonType,
typename T,
typename Allocator,
4957 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4958inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4965 std::transform(j.rbegin(), j.rend(),
4966 std::front_inserter(l), [](
const BasicJsonType & i)
4968 return i.template get<T>();
4973template<
typename BasicJsonType,
typename T,
4974 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4975inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4982 std::transform(j.begin(), j.end(), std::begin(l),
4983 [](
const BasicJsonType & elem)
4985 return elem.template get<T>();
4989template<
typename BasicJsonType,
typename T, std::
size_t N>
4991->
decltype(j.template
get<T>(), void())
4993 for (std::size_t i = 0; i < N; ++i)
4995 arr[i] = j.at(i).template
get<T>();
4999template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2>
5001->
decltype(j.template
get<T>(), void())
5003 for (std::size_t i1 = 0; i1 < N1; ++i1)
5005 for (std::size_t i2 = 0; i2 < N2; ++i2)
5007 arr[i1][i2] = j.at(i1).at(i2).template
get<T>();
5012template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3>
5014->
decltype(j.template
get<T>(), void())
5016 for (std::size_t i1 = 0; i1 < N1; ++i1)
5018 for (std::size_t i2 = 0; i2 < N2; ++i2)
5020 for (std::size_t i3 = 0; i3 < N3; ++i3)
5022 arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template
get<T>();
5028template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3, std::
size_t N4>
5029auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3][N4])
5030->
decltype(j.template
get<T>(), void())
5032 for (std::size_t i1 = 0; i1 < N1; ++i1)
5034 for (std::size_t i2 = 0; i2 < N2; ++i2)
5036 for (std::size_t i3 = 0; i3 < N3; ++i3)
5038 for (std::size_t i4 = 0; i4 < N4; ++i4)
5040 arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template
get<T>();
5047template<
typename BasicJsonType>
5050 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
5053template<
typename BasicJsonType,
typename T, std::
size_t N>
5056->
decltype(j.template
get<T>(), void())
5058 for (std::size_t i = 0; i < N; ++i)
5060 arr[i] = j.at(i).template
get<T>();
5064template<
typename BasicJsonType,
typename ConstructibleArrayType,
5066 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5070 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
5076 ConstructibleArrayType ret;
5077 ret.reserve(j.size());
5078 std::transform(j.begin(), j.end(),
5079 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
5085 arr = std::move(ret);
5088template<
typename BasicJsonType,
typename ConstructibleArrayType,
5090 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5097 ConstructibleArrayType ret;
5099 j.begin(), j.end(), std::inserter(ret, end(ret)),
5100 [](
const BasicJsonType & i)
5106 arr = std::move(ret);
5109template <
typename BasicJsonType,
typename ConstructibleArrayType,
5111 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
5112 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
5114 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
5115 !is_basic_json<ConstructibleArrayType>::value,
5117auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
5130template <
typename BasicJsonType,
typename T, std::size_t... Idx >
5134 return { { std::forward<BasicJsonType>(j).at(Idx).template
get<T>()... } };
5137template <
typename BasicJsonType,
typename T, std::
size_t N >
5149template<
typename BasicJsonType>
5150inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
5157 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5160template<
typename BasicJsonType,
typename ConstructibleObjectType,
5161 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5162inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5169 ConstructibleObjectType ret;
5170 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5171 using value_type =
typename ConstructibleObjectType::value_type;
5173 inner_object->begin(), inner_object->end(),
5174 std::inserter(ret, ret.begin()),
5175 [](
typename BasicJsonType::object_t::value_type
const & p)
5177 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5179 obj = std::move(ret);
5186template <
typename BasicJsonType,
typename ArithmeticType,
5188 std::is_arithmetic<ArithmeticType>::value&&
5189 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5190 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5191 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5192 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5194inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5196 switch (
static_cast<value_t>(j))
5200 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5205 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5210 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5215 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5230template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5233 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5236template<
typename BasicJsonType>
5242template <
typename BasicJsonType,
class A1,
class A2 >
5245 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
5246 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
5249template<
typename BasicJsonType,
typename A1,
typename A2>
5255template<
typename BasicJsonType,
typename... Args>
5261template<
typename BasicJsonType,
typename... Args>
5267template<
typename BasicJsonType,
typename TupleRelated>
5279template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5281 typename BasicJsonType::string_t, Key >
::value >>
5282inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5289 for (
const auto& p : j)
5299template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5301 typename BasicJsonType::string_t, Key >
::value >>
5302inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5309 for (
const auto& p : j)
5319#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5320template<
typename BasicJsonType>
5321inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5327 const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5328#ifdef JSON_HAS_CPP_20
5329 p = std_fs::path(std::u8string_view(
reinterpret_cast<const char8_t*
>(s.data()), s.size()));
5331 p = std_fs::u8path(s);
5338 template<
typename BasicJsonType,
typename T>
5340 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5341 ->
decltype(
from_json(j, std::forward<T>(val)))
5343 return from_json(j, std::forward<T>(val));
5349#ifndef JSON_HAS_CPP_17
5358#ifndef JSON_HAS_CPP_17
5377#ifdef JSON_HAS_CPP_17
5385#include <type_traits>
5435template<
typename StringType>
5439 using std::to_string;
5443template<
typename StringType>
5469 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
5473 IteratorType anchor{};
5475 std::size_t array_index = 0;
5477 mutable std::size_t array_index_last = 0;
5486 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5488 : anchor(
std::move(it))
5489 , array_index(array_index_)
5496 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5499 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5529 return anchor == o.anchor;
5535 return anchor != o.anchor;
5543 switch (anchor.m_object->type())
5548 if (array_index != array_index_last)
5551 array_index_last = array_index;
5553 return array_index_str;
5558 return anchor.key();
5575 typename IteratorType::reference
value()
const
5577 return anchor.value();
5586 typename IteratorType::pointer container =
nullptr;
5593 : container(&cont) {}
5617template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5618auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5625template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5626auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5641#if defined(__clang__)
5643 #pragma clang diagnostic push
5644 #pragma clang diagnostic ignored "-Wmismatched-tags"
5646template<
typename IteratorType>
5647class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5648 :
public std::integral_constant<std::size_t, 2> {};
5650template<std::
size_t N,
typename IteratorType>
5651class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5655 get<N>(std::declval <
5656 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5658#if defined(__clang__)
5659 #pragma clang diagnostic pop
5665 template <
typename IteratorType>
5666 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5698 template<
typename BasicJsonType>
5699 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5701 j.m_data.m_value.destroy(j.m_data.m_type);
5703 j.m_data.m_value = b;
5704 j.assert_invariant();
5711 template<
typename BasicJsonType>
5712 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5714 j.m_data.m_value.destroy(j.m_data.m_type);
5716 j.m_data.m_value = s;
5717 j.assert_invariant();
5720 template<
typename BasicJsonType>
5721 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5723 j.m_data.m_value.destroy(j.m_data.m_type);
5725 j.m_data.m_value = std::move(s);
5726 j.assert_invariant();
5729 template <
typename BasicJsonType,
typename CompatibleStringType,
5730 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5732 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5734 j.m_data.m_value.destroy(j.m_data.m_type);
5736 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5737 j.assert_invariant();
5744 template<
typename BasicJsonType>
5745 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5747 j.m_data.m_value.destroy(j.m_data.m_type);
5749 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5750 j.assert_invariant();
5753 template<
typename BasicJsonType>
5754 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5756 j.m_data.m_value.destroy(j.m_data.m_type);
5758 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5759 j.assert_invariant();
5766 template<
typename BasicJsonType>
5767 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5769 j.m_data.m_value.destroy(j.m_data.m_type);
5771 j.m_data.m_value = val;
5772 j.assert_invariant();
5779 template<
typename BasicJsonType>
5780 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5782 j.m_data.m_value.destroy(j.m_data.m_type);
5784 j.m_data.m_value = val;
5785 j.assert_invariant();
5792 template<
typename BasicJsonType>
5793 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5795 j.m_data.m_value.destroy(j.m_data.m_type);
5797 j.m_data.m_value = val;
5798 j.assert_invariant();
5805 template<
typename BasicJsonType>
5806 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5808 j.m_data.m_value.destroy(j.m_data.m_type);
5810 j.m_data.m_value = arr;
5812 j.assert_invariant();
5815 template<
typename BasicJsonType>
5816 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5818 j.m_data.m_value.destroy(j.m_data.m_type);
5820 j.m_data.m_value = std::move(arr);
5822 j.assert_invariant();
5825 template <
typename BasicJsonType,
typename CompatibleArrayType,
5826 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5828 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5833 j.m_data.m_value.destroy(j.m_data.m_type);
5835 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5837 j.assert_invariant();
5840 template<
typename BasicJsonType>
5841 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5843 j.m_data.m_value.destroy(j.m_data.m_type);
5846 j.m_data.m_value.array->reserve(arr.size());
5847 for (
const bool x : arr)
5849 j.m_data.m_value.array->push_back(x);
5850 j.set_parent(j.m_data.m_value.array->back());
5852 j.assert_invariant();
5855 template<
typename BasicJsonType,
typename T,
5857 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5859 j.m_data.m_value.destroy(j.m_data.m_type);
5862 j.m_data.m_value.array->resize(arr.size());
5865 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5868 j.assert_invariant();
5875 template<
typename BasicJsonType>
5876 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5878 j.m_data.m_value.destroy(j.m_data.m_type);
5880 j.m_data.m_value = obj;
5882 j.assert_invariant();
5885 template<
typename BasicJsonType>
5886 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5888 j.m_data.m_value.destroy(j.m_data.m_type);
5890 j.m_data.m_value = std::move(obj);
5892 j.assert_invariant();
5895 template <
typename BasicJsonType,
typename CompatibleObjectType,
5896 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5897 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5902 j.m_data.m_value.destroy(j.m_data.m_type);
5904 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5906 j.assert_invariant();
5914#ifdef JSON_HAS_CPP_17
5915template<
typename BasicJsonType,
typename T,
5916 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
5917void to_json(BasicJsonType& j,
const std::optional<T>& opt)
5919 if (opt.has_value())
5930template<
typename BasicJsonType,
typename T,
5932inline void to_json(BasicJsonType& j, T b)
noexcept
5937template <
typename BasicJsonType,
typename BoolRef,
5939 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5940 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5941 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5942 && !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>,
5943 typename BasicJsonType::boolean_t >
::value))
5944 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5945inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5950template<
typename BasicJsonType,
typename CompatibleString,
5951 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5952inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5957template<
typename BasicJsonType>
5958inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5963template<
typename BasicJsonType,
typename FloatType,
5964 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5965inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5970template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5971 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5972inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5977template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5978 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5979inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5984#if !JSON_DISABLE_ENUM_SERIALIZATION
5985template<
typename BasicJsonType,
typename EnumType,
5986 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5987inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5989 using underlying_type =
typename std::underlying_type<EnumType>::type;
5995template<
typename BasicJsonType>
5996inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
6001template <
typename BasicJsonType,
typename CompatibleArrayType,
6002 enable_if_t < is_compatible_array_type<BasicJsonType,
6004 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
6006 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
6007 !is_basic_json<CompatibleArrayType>::value,
6009inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
6014template<
typename BasicJsonType>
6015inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
6020template<
typename BasicJsonType,
typename T,
6021 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
6022inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
6027template<
typename BasicJsonType>
6028inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
6033template <
typename BasicJsonType,
typename CompatibleObjectType,
6034 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
6035inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
6040template<
typename BasicJsonType>
6041inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6047 typename BasicJsonType,
typename T, std::size_t N,
6048 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
6051inline void to_json(BasicJsonType& j,
const T(&arr)[N])
6056template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
6057inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
6059 j = { p.first, p.second };
6063template<
typename BasicJsonType,
typename T,
6067 j = { {b.key(), b.value()} };
6070template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
6073 j = { std::get<Idx>(t)... };
6076template<
typename BasicJsonType,
typename Tuple>
6079 using array_t =
typename BasicJsonType::array_t;
6083template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
6089#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
6090template<
typename BasicJsonType>
6091inline void to_json(BasicJsonType& j,
const std_fs::path& p)
6093#ifdef JSON_HAS_CPP_20
6094 const std::u8string s = p.u8string();
6095 j = std::string(s.begin(), s.end());
6104 template<
typename BasicJsonType,
typename T>
6105 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
6106 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
6108 return to_json(j, std::forward<T>(val));
6113#ifndef JSON_HAS_CPP_17
6122#ifndef JSON_HAS_CPP_17
6134template<
typename ValueType,
typename>
6139 template<
typename BasicJsonType,
typename TargetType = ValueType>
6140 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
6141 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
6142 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
6144 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
6149 template<
typename BasicJsonType,
typename TargetType = ValueType>
6154 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
6159 template<
typename BasicJsonType,
typename TargetType = ValueType>
6160 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
6161 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
6162 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
6164 ::nlohmann::to_json(j, std::forward<TargetType>(val));
6192template<
typename BinaryType>
6217 , m_subtype(subtype_)
6218 , m_has_subtype(true)
6224 , m_subtype(subtype_)
6225 , m_has_subtype(true)
6230 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
6231 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
6236 return !(rhs == *
this);
6243 m_subtype = subtype_;
6244 m_has_subtype =
true;
6251 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
6258 return m_has_subtype;
6266 m_has_subtype =
false;
6271 bool m_has_subtype =
false;
6295#include <functional>
6307inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6309 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6324template<
typename BasicJsonType>
6325std::size_t
hash(
const BasicJsonType& j)
6327 using string_t =
typename BasicJsonType::string_t;
6328 using number_integer_t =
typename BasicJsonType::number_integer_t;
6329 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6330 using number_float_t =
typename BasicJsonType::number_float_t;
6332 const auto type =
static_cast<std::size_t
>(j.type());
6335 case BasicJsonType::value_t::null:
6336 case BasicJsonType::value_t::discarded:
6341 case BasicJsonType::value_t::object:
6343 auto seed =
combine(type, j.size());
6344 for (
const auto& element : j.items())
6346 const auto h = std::hash<string_t> {}(element.key());
6353 case BasicJsonType::value_t::array:
6355 auto seed =
combine(type, j.size());
6356 for (
const auto& element : j)
6363 case BasicJsonType::value_t::string:
6365 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6369 case BasicJsonType::value_t::boolean:
6371 const auto h = std::hash<bool> {}(j.template
get<bool>());
6375 case BasicJsonType::value_t::number_integer:
6381 case BasicJsonType::value_t::number_unsigned:
6387 case BasicJsonType::value_t::number_float:
6393 case BasicJsonType::value_t::binary:
6395 auto seed =
combine(type, j.get_binary().size());
6396 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6398 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6399 for (
const auto byte : j.get_binary())
6401 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6438#ifdef __cpp_lib_byteswap
6462#include <type_traits>
6516 return std::fgetc(m_file);
6523 return fread(dest, 1,
sizeof(T) * count, m_file);
6551 is->clear(is->rdstate() & std::ios::eofbit);
6556 : is(&i), sb(i.rdbuf())
6565 : is(rhs.is), sb(rhs.sb)
6576 auto res = sb->sbumpc();
6580 is->clear(is->rdstate() | std::ios::eofbit);
6588 auto res =
static_cast<std::size_t
>(sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(count *
sizeof(T))));
6591 is->clear(is->rdstate() | std::ios::eofbit);
6598 std::istream* is =
nullptr;
6599 std::streambuf* sb =
nullptr;
6605template<
typename IteratorType>
6609 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6612 : current(
std::move(first)), end(
std::move(last))
6620 std::advance(current, 1);
6631 auto* ptr =
reinterpret_cast<char*
>(dest);
6632 for (std::size_t read_index = 0; read_index < count *
sizeof(T); ++read_index)
6636 ptr[read_index] =
static_cast<char>(*current);
6637 std::advance(current, 1);
6644 return count *
sizeof(T);
6648 IteratorType current;
6651 template<
typename BaseInputAdapter,
size_t T>
6656 return current == end;
6660template<
typename BaseInputAdapter,
size_t T>
6663template<
typename BaseInputAdapter>
6668 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6669 size_t& utf8_bytes_index,
6670 size_t& utf8_bytes_filled)
6672 utf8_bytes_index = 0;
6676 utf8_bytes[0] = std::char_traits<char>::eof();
6677 utf8_bytes_filled = 1;
6682 const auto wc = input.get_character();
6687 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6688 utf8_bytes_filled = 1;
6690 else if (wc <= 0x7FF)
6692 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6693 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6694 utf8_bytes_filled = 2;
6696 else if (wc <= 0xFFFF)
6698 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6699 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6700 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6701 utf8_bytes_filled = 3;
6703 else if (wc <= 0x10FFFF)
6705 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6706 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6707 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6708 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6709 utf8_bytes_filled = 4;
6714 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6715 utf8_bytes_filled = 1;
6721template<
typename BaseInputAdapter>
6726 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6727 size_t& utf8_bytes_index,
6728 size_t& utf8_bytes_filled)
6730 utf8_bytes_index = 0;
6734 utf8_bytes[0] = std::char_traits<char>::eof();
6735 utf8_bytes_filled = 1;
6740 const auto wc = input.get_character();
6745 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6746 utf8_bytes_filled = 1;
6748 else if (wc <= 0x7FF)
6750 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6751 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6752 utf8_bytes_filled = 2;
6754 else if (0xD800 > wc || wc >= 0xE000)
6756 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6757 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6758 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6759 utf8_bytes_filled = 3;
6765 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6766 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6767 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6768 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6769 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6770 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6771 utf8_bytes_filled = 4;
6775 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6776 utf8_bytes_filled = 1;
6784template<
typename BaseInputAdapter,
typename W
ideCharType>
6791 : base_adapter(base) {}
6796 if (utf8_bytes_index == utf8_bytes_filled)
6798 fill_buffer<sizeof(WideCharType)>();
6806 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6807 return utf8_bytes[utf8_bytes_index++];
6818 BaseInputAdapter base_adapter;
6827 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6830 std::size_t utf8_bytes_index = 0;
6832 std::size_t utf8_bytes_filled = 0;
6835template<
typename IteratorType,
typename Enable =
void>
6839 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6844 return adapter_type(std::move(first), std::move(last));
6858template<
typename IteratorType>
6862 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6873template<
typename IteratorType>
6877 return factory_type::create(first, last);
6890template<
typename ContainerType,
typename Enable =
void>
6893template<
typename ContainerType>
6895 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6907template<
typename ContainerType>
6920 if (file ==
nullptr)
6922 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));
6941template <
typename CharT,
6942 typename std::enable_if <
6943 std::is_pointer<CharT>::value&&
6944 !std::is_array<CharT>::value&&
6945 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6946 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6952 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));
6954 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6955 const auto* ptr =
reinterpret_cast<const char*
>(b);
6959template<
typename T, std::
size_t N>
6971 template <
typename CharT,
6972 typename std::enable_if <
6973 std::is_pointer<CharT>::value&&
6974 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6975 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6978 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6980 template<
class IteratorType,
6981 typename std::enable_if<
6982 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
6989 return std::move(ia);
7012#include <type_traits>
7034#include <initializer_list>
7056template<
typename BasicJsonType>
7090 return "<uninitialized>";
7092 return "true literal";
7094 return "false literal";
7096 return "null literal";
7098 return "string literal";
7102 return "number literal";
7116 return "<parse error>";
7118 return "end of input";
7120 return "'[', '{', or a literal";
7123 return "unknown token";
7133template<
typename BasicJsonType,
typename InputAdapterType>
7136 using number_integer_t =
typename BasicJsonType::number_integer_t;
7137 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7138 using number_float_t =
typename BasicJsonType::number_float_t;
7139 using string_t =
typename BasicJsonType::string_t;
7140 using char_type =
typename InputAdapterType::char_type;
7146 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7147 : ia(
std::move(adapter))
7148 , ignore_comments(ignore_comments_)
7149 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7166 static char get_decimal_point() noexcept
7168 const auto* loc = localeconv();
7170 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7198 const auto factors = { 12u, 8u, 4u, 0u };
7199 for (
const auto factor : factors)
7203 if (current >=
'0' && current <=
'9')
7205 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7207 else if (current >=
'A' && current <=
'F')
7209 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7211 else if (current >=
'a' && current <=
'f')
7213 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7221 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7240 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7242 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7245 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7254 error_message =
"invalid string: ill-formed UTF-8 byte";
7291 case char_traits<char_type>::eof():
7293 error_message =
"invalid string: missing closing quote";
7294 return token_type::parse_error;
7300 return token_type::value_string;
7344 const int codepoint1 = get_codepoint();
7345 int codepoint = codepoint1;
7349 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7350 return token_type::parse_error;
7354 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7359 const int codepoint2 = get_codepoint();
7363 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7364 return token_type::parse_error;
7371 codepoint =
static_cast<int>(
7373 (
static_cast<unsigned int>(codepoint1) << 10u)
7375 +
static_cast<unsigned int>(codepoint2)
7383 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7384 return token_type::parse_error;
7389 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7390 return token_type::parse_error;
7397 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7398 return token_type::parse_error;
7403 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7406 if (codepoint < 0x80)
7409 add(
static_cast<char_int_type
>(codepoint));
7411 else if (codepoint <= 0x7FF)
7414 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7415 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7417 else if (codepoint <= 0xFFFF)
7420 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7421 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7422 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7427 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7428 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7429 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7430 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7438 error_message =
"invalid string: forbidden character after backslash";
7439 return token_type::parse_error;
7448 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7449 return token_type::parse_error;
7454 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7455 return token_type::parse_error;
7460 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7461 return token_type::parse_error;
7466 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7467 return token_type::parse_error;
7472 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7473 return token_type::parse_error;
7478 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7479 return token_type::parse_error;
7484 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7485 return token_type::parse_error;
7490 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7491 return token_type::parse_error;
7496 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7497 return token_type::parse_error;
7502 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7503 return token_type::parse_error;
7508 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7509 return token_type::parse_error;
7514 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7515 return token_type::parse_error;
7520 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7521 return token_type::parse_error;
7526 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7527 return token_type::parse_error;
7532 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7533 return token_type::parse_error;
7538 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7539 return token_type::parse_error;
7544 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7545 return token_type::parse_error;
7550 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7551 return token_type::parse_error;
7556 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7557 return token_type::parse_error;
7562 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7563 return token_type::parse_error;
7568 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7569 return token_type::parse_error;
7574 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7575 return token_type::parse_error;
7580 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7581 return token_type::parse_error;
7586 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7587 return token_type::parse_error;
7592 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7593 return token_type::parse_error;
7598 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7599 return token_type::parse_error;
7604 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7605 return token_type::parse_error;
7610 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7611 return token_type::parse_error;
7616 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7617 return token_type::parse_error;
7622 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7623 return token_type::parse_error;
7628 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7629 return token_type::parse_error;
7634 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7635 return token_type::parse_error;
7772 return token_type::parse_error;
7782 return token_type::parse_error;
7806 return token_type::parse_error;
7816 return token_type::parse_error;
7826 return token_type::parse_error;
7838 return token_type::parse_error;
7848 return token_type::parse_error;
7856 error_message =
"invalid string: ill-formed UTF-8 byte";
7857 return token_type::parse_error;
7900 error_message =
"invalid comment; missing closing '*/'";
7928 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7935 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7937 f = std::strtof(str, endptr);
7941 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7943 f = std::strtod(str, endptr);
7947 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7949 f = std::strtold(str, endptr);
7992 token_type scan_number()
7999 token_type number_type = token_type::value_unsigned;
8007 goto scan_number_minus;
8013 goto scan_number_zero;
8027 goto scan_number_any1;
8037 number_type = token_type::value_integer;
8043 goto scan_number_zero;
8057 goto scan_number_any1;
8062 error_message =
"invalid number; expected digit after '-'";
8063 return token_type::parse_error;
8073 add(decimal_point_char);
8074 decimal_point_position = token_buffer.size() - 1;
8075 goto scan_number_decimal1;
8082 goto scan_number_exponent;
8086 goto scan_number_done;
8105 goto scan_number_any1;
8110 add(decimal_point_char);
8111 decimal_point_position = token_buffer.size() - 1;
8112 goto scan_number_decimal1;
8119 goto scan_number_exponent;
8123 goto scan_number_done;
8126scan_number_decimal1:
8128 number_type = token_type::value_float;
8143 goto scan_number_decimal2;
8148 error_message =
"invalid number; expected digit after '.'";
8149 return token_type::parse_error;
8153scan_number_decimal2:
8169 goto scan_number_decimal2;
8176 goto scan_number_exponent;
8180 goto scan_number_done;
8183scan_number_exponent:
8185 number_type = token_type::value_float;
8192 goto scan_number_sign;
8207 goto scan_number_any2;
8213 "invalid number; expected '+', '-', or digit after exponent";
8214 return token_type::parse_error;
8234 goto scan_number_any2;
8239 error_message =
"invalid number; expected digit after exponent sign";
8240 return token_type::parse_error;
8260 goto scan_number_any2;
8264 goto scan_number_done;
8272 char* endptr =
nullptr;
8276 if (number_type == token_type::value_unsigned)
8278 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8281 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8283 if (errno != ERANGE)
8285 value_unsigned =
static_cast<number_unsigned_t
>(x);
8286 if (value_unsigned == x)
8288 return token_type::value_unsigned;
8292 else if (number_type == token_type::value_integer)
8294 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8297 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8299 if (errno != ERANGE)
8301 value_integer =
static_cast<number_integer_t
>(x);
8302 if (value_integer == x)
8304 return token_type::value_integer;
8311 strtof(value_float, token_buffer.data(), &endptr);
8314 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8316 return token_type::value_float;
8325 token_type scan_literal(const char_type* literal_text, const std::
size_t length,
8326 token_type return_type)
8329 for (std::size_t i = 1; i < length; ++i)
8333 error_message =
"invalid literal";
8334 return token_type::parse_error;
8345 void reset() noexcept
8347 token_buffer.clear();
8348 token_string.clear();
8349 decimal_point_position = std::string::npos;
8365 ++position.chars_read_total;
8366 ++position.chars_read_current_line;
8375 current = ia.get_character();
8383 if (current ==
'\n')
8385 ++position.lines_read;
8386 position.chars_read_current_line = 0;
8404 --position.chars_read_total;
8407 if (position.chars_read_current_line == 0)
8409 if (position.lines_read > 0)
8411 --position.lines_read;
8416 --position.chars_read_current_line;
8422 token_string.pop_back();
8427 void add(char_int_type c)
8429 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8440 return value_integer;
8446 return value_unsigned;
8459 if (decimal_point_char !=
'.' && decimal_point_position != std::string::npos)
8461 token_buffer[decimal_point_position] =
'.';
8463 return token_buffer;
8483 for (
const auto c : token_string)
8485 if (
static_cast<unsigned char>(c) <=
'\x1F')
8488 std::array<char, 9> cs{{}};
8489 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8490 result += cs.data();
8495 result.push_back(
static_cast<std::string::value_type
>(c));
8506 return error_message;
8522 return get() == 0xBB &&
get() == 0xBF;
8537 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8543 if (position.chars_read_total == 0 && !
skip_bom())
8545 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8546 return token_type::parse_error;
8553 while (ignore_comments && current ==
'/')
8555 if (!scan_comment())
8557 return token_type::parse_error;
8568 return token_type::begin_array;
8570 return token_type::end_array;
8572 return token_type::begin_object;
8574 return token_type::end_object;
8576 return token_type::name_separator;
8578 return token_type::value_separator;
8583 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')}};
8584 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8588 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')}};
8589 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8593 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')}};
8594 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8599 return scan_string();
8613 return scan_number();
8619 return token_type::end_of_input;
8623 error_message =
"invalid literal";
8624 return token_type::parse_error;
8630 InputAdapterType ia;
8633 const bool ignore_comments =
false;
8639 bool next_unget =
false;
8645 std::vector<char_type> token_string {};
8648 string_t token_buffer {};
8651 const char* error_message =
"";
8654 number_integer_t value_integer = 0;
8655 number_unsigned_t value_unsigned = 0;
8656 number_float_t value_float = 0;
8659 const char_int_type decimal_point_char =
'.';
8661 std::size_t decimal_point_position = std::string::npos;
8681template<
typename BasicJsonType>
8785 const std::string& last_token,
8800 return (std::numeric_limits<std::size_t>::max)();
8816template<
typename BasicJsonType,
typename InputAdapterType>
8833 : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
8845 handle_value(
nullptr);
8881 handle_value(std::move(val));
8887 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
8889#if JSON_DIAGNOSTIC_POSITIONS
8896 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8914 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
8923#if JSON_DIAGNOSTIC_POSITIONS
8927 ref_stack.back()->end_position = m_lexer_ref->get_position();
8931 ref_stack.back()->set_parents();
8932 ref_stack.pop_back();
8938 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
8940#if JSON_DIAGNOSTIC_POSITIONS
8945 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8962#if JSON_DIAGNOSTIC_POSITIONS
8966 ref_stack.back()->end_position = m_lexer_ref->get_position();
8970 ref_stack.back()->set_parents();
8971 ref_stack.pop_back();
8975 template<
class Exception>
8977 const Exception& ex)
8980 static_cast<void>(ex);
8981 if (allow_exceptions)
8995#if JSON_DIAGNOSTIC_POSITIONS
8996 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9003 v.end_position = m_lexer_ref->get_position();
9010 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9017 v.start_position = v.end_position - 4;
9021 case value_t::string:
9024 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9033 case value_t::discarded:
9035 v.end_position = std::string::npos;
9036 v.start_position = v.end_position;
9040 case value_t::binary:
9041 case value_t::number_integer:
9042 case value_t::number_unsigned:
9043 case value_t::number_float:
9045 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9048 case value_t::object:
9049 case value_t::array:
9069 template<
typename Value>
9071 BasicJsonType* handle_value(Value&& v)
9073 if (ref_stack.empty())
9075 root = BasicJsonType(std::forward<Value>(v));
9077#if JSON_DIAGNOSTIC_POSITIONS
9078 handle_diagnostic_positions_for_json_value(root);
9084 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9086 if (ref_stack.back()->is_array())
9088 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
9090#if JSON_DIAGNOSTIC_POSITIONS
9091 handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
9094 return &(ref_stack.back()->m_data.m_value.array->back());
9099 *object_element = BasicJsonType(std::forward<Value>(v));
9101#if JSON_DIAGNOSTIC_POSITIONS
9102 handle_diagnostic_positions_for_json_value(*object_element);
9105 return object_element;
9109 BasicJsonType& root;
9111 std::vector<BasicJsonType*> ref_stack {};
9113 BasicJsonType* object_element =
nullptr;
9115 bool errored =
false;
9117 const bool allow_exceptions =
true;
9119 lexer_t* m_lexer_ref =
nullptr;
9122template<
typename BasicJsonType,
typename InputAdapterType>
9137 const bool allow_exceptions_ =
true,
9139 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9141 keep_stack.push_back(
true);
9153 handle_value(
nullptr);
9189 handle_value(std::move(val));
9197 keep_stack.push_back(keep);
9199 auto val = handle_value(BasicJsonType::value_t::object,
true);
9200 ref_stack.push_back(val.second);
9202 if (ref_stack.back())
9205#if JSON_DIAGNOSTIC_POSITIONS
9212 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9227 BasicJsonType k = BasicJsonType(val);
9230 const bool keep = callback(
static_cast<int>(ref_stack.size()),
parse_event_t::key, k);
9231 key_keep_stack.push_back(keep);
9234 if (keep && ref_stack.back())
9236 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
9244 if (ref_stack.back())
9249 *ref_stack.back() = discarded;
9251#if JSON_DIAGNOSTIC_POSITIONS
9253 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9259#if JSON_DIAGNOSTIC_POSITIONS
9263 ref_stack.back()->end_position = m_lexer_ref->get_position();
9267 ref_stack.back()->set_parents();
9273 ref_stack.pop_back();
9274 keep_stack.pop_back();
9276 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
9279 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
9281 if (it->is_discarded())
9283 ref_stack.back()->erase(it);
9295 keep_stack.push_back(keep);
9297 auto val = handle_value(BasicJsonType::value_t::array,
true);
9298 ref_stack.push_back(val.second);
9300 if (ref_stack.back())
9303#if JSON_DIAGNOSTIC_POSITIONS
9310 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9328 if (ref_stack.back())
9334#if JSON_DIAGNOSTIC_POSITIONS
9338 ref_stack.back()->end_position = m_lexer_ref->get_position();
9342 ref_stack.back()->set_parents();
9347 *ref_stack.back() = discarded;
9349#if JSON_DIAGNOSTIC_POSITIONS
9351 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9358 ref_stack.pop_back();
9359 keep_stack.pop_back();
9362 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
9364 ref_stack.back()->m_data.m_value.array->pop_back();
9370 template<
class Exception>
9372 const Exception& ex)
9375 static_cast<void>(ex);
9376 if (allow_exceptions)
9390#if JSON_DIAGNOSTIC_POSITIONS
9391 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9398 v.end_position = m_lexer_ref->get_position();
9405 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9412 v.start_position = v.end_position - 4;
9416 case value_t::string:
9419 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9423 case value_t::discarded:
9425 v.end_position = std::string::npos;
9426 v.start_position = v.end_position;
9430 case value_t::binary:
9431 case value_t::number_integer:
9432 case value_t::number_unsigned:
9433 case value_t::number_float:
9435 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9439 case value_t::object:
9440 case value_t::array:
9469 template<
typename Value>
9470 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
9476 if (!keep_stack.back())
9478 return {
false,
nullptr};
9482 auto value = BasicJsonType(std::forward<Value>(v));
9484#if JSON_DIAGNOSTIC_POSITIONS
9485 handle_diagnostic_positions_for_json_value(value);
9489 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
9494 return {
false,
nullptr};
9497 if (ref_stack.empty())
9499 root = std::move(value);
9500 return {
true, & root};
9505 if (!ref_stack.back())
9507 return {
false,
nullptr};
9511 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9514 if (ref_stack.back()->is_array())
9516 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
9517 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
9524 const bool store_element = key_keep_stack.back();
9525 key_keep_stack.pop_back();
9529 return {
false,
nullptr};
9533 *object_element = std::move(value);
9534 return {
true, object_element};
9538 BasicJsonType& root;
9540 std::vector<BasicJsonType*> ref_stack {};
9542 std::vector<bool> keep_stack {};
9544 std::vector<bool> key_keep_stack {};
9546 BasicJsonType* object_element =
nullptr;
9548 bool errored =
false;
9552 const bool allow_exceptions =
true;
9554 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
9556 lexer_t* m_lexer_ref =
nullptr;
9559template<
typename BasicJsonType>
9673 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9675template<
typename T,
typename Integer>
9677 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9679template<
typename T,
typename Un
signed>
9681 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9683template<
typename T,
typename Float,
typename String>
9685 std::declval<Float>(), std::declval<const String&>()));
9687template<
typename T,
typename String>
9689 decltype(std::declval<T&>().string(std::declval<String&>()));
9691template<
typename T,
typename Binary>
9693 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9697 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9699template<
typename T,
typename String>
9701 decltype(std::declval<T&>().key(std::declval<String&>()));
9708 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9713template<
typename T,
typename Exception>
9715 std::declval<std::size_t>(), std::declval<const std::string&>(),
9716 std::declval<const Exception&>()));
9718template<
typename SAX,
typename BasicJsonType>
9723 "BasicJsonType must be of type basic_json<...>");
9725 using number_integer_t =
typename BasicJsonType::number_integer_t;
9726 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9727 using number_float_t =
typename BasicJsonType::number_float_t;
9728 using string_t =
typename BasicJsonType::string_t;
9729 using binary_t =
typename BasicJsonType::binary_t;
9730 using exception_t =
typename BasicJsonType::exception;
9749template<
typename SAX,
typename BasicJsonType>
9754 "BasicJsonType must be of type basic_json<...>");
9756 using number_integer_t =
typename BasicJsonType::number_integer_t;
9757 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9758 using number_float_t =
typename BasicJsonType::number_float_t;
9759 using string_t =
typename BasicJsonType::string_t;
9760 using binary_t =
typename BasicJsonType::binary_t;
9761 using exception_t =
typename BasicJsonType::exception;
9765 "Missing/invalid function: bool null()");
9767 "Missing/invalid function: bool boolean(bool)");
9769 "Missing/invalid function: bool boolean(bool)");
9773 "Missing/invalid function: bool number_integer(number_integer_t)");
9777 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9779 number_float_t, string_t>
::value,
9780 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9783 "Missing/invalid function: bool string(string_t&)");
9786 "Missing/invalid function: bool binary(binary_t&)");
9788 "Missing/invalid function: bool start_object(std::size_t)");
9790 "Missing/invalid function: bool key(string_t&)");
9792 "Missing/invalid function: bool end_object()");
9794 "Missing/invalid function: bool start_array(std::size_t)");
9796 "Missing/invalid function: bool end_array()");
9799 "Missing/invalid function: bool parse_error(std::size_t, const "
9800 "std::string&, const exception&)");
9834 return *
reinterpret_cast<char*
>(&num) == 1;
9844template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
9847 using number_integer_t =
typename BasicJsonType::number_integer_t;
9848 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9849 using number_float_t =
typename BasicJsonType::number_float_t;
9850 using string_t =
typename BasicJsonType::string_t;
9851 using binary_t =
typename BasicJsonType::binary_t;
9852 using json_sax_t = SAX;
9853 using char_type =
typename InputAdapterType::char_type;
9885 const
bool strict = true,
9889 bool result =
false;
9894 result = parse_bson_internal();
9898 result = parse_cbor_internal(
true, tag_handler);
9902 result = parse_msgpack_internal();
9907 result = parse_ubjson_internal();
9929 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9930 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9946 bool parse_bson_internal()
9948 std::int32_t document_size{};
9949 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9961 return sax->end_object();
9971 bool get_bson_cstr(string_t& result)
9973 auto out = std::back_inserter(result);
9981 if (current == 0x00)
9985 *out++ =
static_cast<typename string_t::value_type
>(current);
10000 template<
typename NumberType>
10001 bool get_bson_string(
const NumberType len, string_t& result)
10005 auto last_token = get_token_string();
10006 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10007 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
10010 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) &&
get() != char_traits<char_type>::eof();
10022 template<
typename NumberType>
10023 bool get_bson_binary(
const NumberType len, binary_t& result)
10027 auto last_token = get_token_string();
10028 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10029 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
10033 std::uint8_t subtype{};
10034 get_number<std::uint8_t>(input_format_t::bson, subtype);
10035 result.set_subtype(subtype);
10037 return get_binary(input_format_t::bson, len, result);
10050 bool parse_bson_element_internal(
const char_int_type element_type,
10051 const std::size_t element_type_parse_position)
10053 switch (element_type)
10058 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10063 std::int32_t len{};
10065 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
10070 return parse_bson_internal();
10075 return parse_bson_array();
10080 std::int32_t len{};
10082 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
10087 return sax->boolean(
get() != 0);
10092 return sax->null();
10097 std::int32_t
value{};
10098 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10103 std::int64_t
value{};
10104 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10109 std::uint64_t
value{};
10110 return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
10115 std::array<char, 3> cr{{}};
10116 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
10117 const std::string cr_str{cr.data()};
10118 return sax->parse_error(element_type_parse_position, cr_str,
10119 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
10136 bool parse_bson_element_list(
const bool is_array)
10140 while (
auto element_type =
get())
10147 const std::size_t element_type_parse_position = chars_read;
10153 if (!is_array && !sax->key(key))
10158 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
10174 bool parse_bson_array()
10176 std::int32_t document_size{};
10177 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10189 return sax->end_array();
10204 bool parse_cbor_internal(
const bool get_char,
10205 const cbor_tag_handler_t tag_handler)
10207 switch (get_char ?
get() : current)
10210 case char_traits<char_type>::eof():
10238 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10242 std::uint8_t number{};
10243 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10248 std::uint16_t number{};
10249 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10254 std::uint32_t number{};
10255 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10260 std::uint64_t number{};
10261 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10289 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
10293 std::uint8_t number{};
10294 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10299 std::uint16_t number{};
10300 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10305 std::uint32_t number{};
10306 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10311 std::uint64_t number{};
10312 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
10313 -
static_cast<number_integer_t
>(number));
10348 return get_cbor_binary(b) && sax->binary(b);
10383 return get_cbor_string(s) && sax->string(s);
10411 return get_cbor_array(
10412 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10416 std::uint8_t len{};
10417 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10422 std::uint16_t len{};
10423 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10428 std::uint32_t len{};
10429 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10434 std::uint64_t len{};
10435 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10466 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10470 std::uint8_t len{};
10471 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10476 std::uint16_t len{};
10477 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10482 std::uint32_t len{};
10483 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10488 std::uint64_t len{};
10489 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10515 switch (tag_handler)
10517 case cbor_tag_handler_t::error:
10519 auto last_token = get_token_string();
10520 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10521 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10524 case cbor_tag_handler_t::ignore:
10531 std::uint8_t subtype_to_ignore{};
10532 get_number(input_format_t::cbor, subtype_to_ignore);
10537 std::uint16_t subtype_to_ignore{};
10538 get_number(input_format_t::cbor, subtype_to_ignore);
10543 std::uint32_t subtype_to_ignore{};
10544 get_number(input_format_t::cbor, subtype_to_ignore);
10549 std::uint64_t subtype_to_ignore{};
10550 get_number(input_format_t::cbor, subtype_to_ignore);
10556 return parse_cbor_internal(
true, tag_handler);
10559 case cbor_tag_handler_t::store:
10567 std::uint8_t subtype{};
10568 get_number(input_format_t::cbor, subtype);
10574 std::uint16_t subtype{};
10575 get_number(input_format_t::cbor, subtype);
10581 std::uint32_t subtype{};
10582 get_number(input_format_t::cbor, subtype);
10588 std::uint64_t subtype{};
10589 get_number(input_format_t::cbor, subtype);
10594 return parse_cbor_internal(
true, tag_handler);
10597 return get_cbor_binary(b) && sax->binary(b);
10607 return sax->boolean(
false);
10610 return sax->boolean(
true);
10613 return sax->null();
10617 const auto byte1_raw =
get();
10622 const auto byte2_raw =
get();
10628 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10629 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10639 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10640 const double val = [&half]
10642 const int exp = (half >> 10u) & 0x1Fu;
10643 const unsigned int mant = half & 0x3FFu;
10649 return std::ldexp(mant, -24);
10652 ? std::numeric_limits<double>::infinity()
10653 : std::numeric_limits<double>::quiet_NaN();
10655 return std::ldexp(mant + 1024, exp - 25);
10658 return sax->number_float((half & 0x8000u) != 0
10659 ?
static_cast<number_float_t
>(-val)
10660 :
static_cast<number_float_t
>(val),
"");
10666 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10672 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10677 auto last_token = get_token_string();
10678 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10679 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10695 bool get_cbor_string(string_t& result)
10730 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10735 std::uint8_t len{};
10736 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10741 std::uint16_t len{};
10742 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10747 std::uint32_t len{};
10748 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10753 std::uint64_t len{};
10754 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10759 while (
get() != 0xFF)
10762 if (!get_cbor_string(chunk))
10766 result.append(chunk);
10773 auto last_token = get_token_string();
10774 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10775 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10791 bool get_cbor_binary(binary_t& result)
10826 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10831 std::uint8_t len{};
10832 return get_number(input_format_t::cbor, len) &&
10833 get_binary(input_format_t::cbor, len, result);
10838 std::uint16_t len{};
10839 return get_number(input_format_t::cbor, len) &&
10840 get_binary(input_format_t::cbor, len, result);
10845 std::uint32_t len{};
10846 return get_number(input_format_t::cbor, len) &&
10847 get_binary(input_format_t::cbor, len, result);
10852 std::uint64_t len{};
10853 return get_number(input_format_t::cbor, len) &&
10854 get_binary(input_format_t::cbor, len, result);
10859 while (
get() != 0xFF)
10862 if (!get_cbor_binary(chunk))
10866 result.insert(result.end(), chunk.begin(), chunk.end());
10873 auto last_token = get_token_string();
10874 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10875 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));
10886 bool get_cbor_array(
const std::size_t len,
10887 const cbor_tag_handler_t tag_handler)
10896 for (std::size_t i = 0; i < len; ++i)
10906 while (
get() != 0xFF)
10915 return sax->end_array();
10924 bool get_cbor_object(
const std::size_t len,
10925 const cbor_tag_handler_t tag_handler)
10937 for (std::size_t i = 0; i < len; ++i)
10954 while (
get() != 0xFF)
10970 return sax->end_object();
10980 bool parse_msgpack_internal()
10985 case char_traits<char_type>::eof():
11117 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
11136 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11155 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11195 return get_msgpack_string(s) && sax->string(s);
11199 return sax->null();
11202 return sax->boolean(
false);
11205 return sax->boolean(
true);
11220 return get_msgpack_binary(b) && sax->binary(b);
11226 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11232 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11237 std::uint8_t number{};
11238 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11243 std::uint16_t number{};
11244 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11249 std::uint32_t number{};
11250 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11255 std::uint64_t number{};
11256 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11261 std::int8_t number{};
11262 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11267 std::int16_t number{};
11268 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11273 std::int32_t number{};
11274 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11279 std::int64_t number{};
11280 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11285 std::uint16_t len{};
11286 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
11291 std::uint32_t len{};
11292 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
11297 std::uint16_t len{};
11298 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
11303 std::uint32_t len{};
11304 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
11340 return sax->number_integer(
static_cast<std::int8_t
>(current));
11344 auto last_token = get_token_string();
11345 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11346 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
11361 bool get_msgpack_string(string_t& result)
11404 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
11409 std::uint8_t len{};
11410 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11415 std::uint16_t len{};
11416 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11421 std::uint32_t len{};
11422 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11427 auto last_token = get_token_string();
11428 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11429 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
11444 bool get_msgpack_binary(binary_t& result)
11447 auto assign_and_return_true = [&result](std::int8_t subtype)
11449 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
11457 std::uint8_t len{};
11458 return get_number(input_format_t::msgpack, len) &&
11459 get_binary(input_format_t::msgpack, len, result);
11464 std::uint16_t len{};
11465 return get_number(input_format_t::msgpack, len) &&
11466 get_binary(input_format_t::msgpack, len, result);
11471 std::uint32_t len{};
11472 return get_number(input_format_t::msgpack, len) &&
11473 get_binary(input_format_t::msgpack, len, result);
11478 std::uint8_t len{};
11479 std::int8_t subtype{};
11480 return get_number(input_format_t::msgpack, len) &&
11481 get_number(input_format_t::msgpack, subtype) &&
11482 get_binary(input_format_t::msgpack, len, result) &&
11483 assign_and_return_true(subtype);
11488 std::uint16_t len{};
11489 std::int8_t subtype{};
11490 return get_number(input_format_t::msgpack, len) &&
11491 get_number(input_format_t::msgpack, subtype) &&
11492 get_binary(input_format_t::msgpack, len, result) &&
11493 assign_and_return_true(subtype);
11498 std::uint32_t len{};
11499 std::int8_t subtype{};
11500 return get_number(input_format_t::msgpack, len) &&
11501 get_number(input_format_t::msgpack, subtype) &&
11502 get_binary(input_format_t::msgpack, len, result) &&
11503 assign_and_return_true(subtype);
11508 std::int8_t subtype{};
11509 return get_number(input_format_t::msgpack, subtype) &&
11510 get_binary(input_format_t::msgpack, 1, result) &&
11511 assign_and_return_true(subtype);
11516 std::int8_t subtype{};
11517 return get_number(input_format_t::msgpack, subtype) &&
11518 get_binary(input_format_t::msgpack, 2, result) &&
11519 assign_and_return_true(subtype);
11524 std::int8_t subtype{};
11525 return get_number(input_format_t::msgpack, subtype) &&
11526 get_binary(input_format_t::msgpack, 4, result) &&
11527 assign_and_return_true(subtype);
11532 std::int8_t subtype{};
11533 return get_number(input_format_t::msgpack, subtype) &&
11534 get_binary(input_format_t::msgpack, 8, result) &&
11535 assign_and_return_true(subtype);
11540 std::int8_t subtype{};
11541 return get_number(input_format_t::msgpack, subtype) &&
11542 get_binary(input_format_t::msgpack, 16, result) &&
11543 assign_and_return_true(subtype);
11555 bool get_msgpack_array(
const std::size_t len)
11562 for (std::size_t i = 0; i < len; ++i)
11570 return sax->end_array();
11577 bool get_msgpack_object(
const std::size_t len)
11585 for (std::size_t i = 0; i < len; ++i)
11600 return sax->end_object();
11614 bool parse_ubjson_internal(
const bool get_char =
true)
11616 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11633 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
11649 std::uint8_t len{};
11650 return get_number(input_format, len) && get_string(input_format, len, result);
11656 return get_number(input_format, len) && get_string(input_format, len, result);
11661 std::int16_t len{};
11662 return get_number(input_format, len) && get_string(input_format, len, result);
11667 std::int32_t len{};
11668 return get_number(input_format, len) && get_string(input_format, len, result);
11673 std::int64_t len{};
11674 return get_number(input_format, len) && get_string(input_format, len, result);
11679 if (input_format != input_format_t::bjdata)
11683 std::uint16_t len{};
11684 return get_number(input_format, len) && get_string(input_format, len, result);
11689 if (input_format != input_format_t::bjdata)
11693 std::uint32_t len{};
11694 return get_number(input_format, len) && get_string(input_format, len, result);
11699 if (input_format != input_format_t::bjdata)
11703 std::uint64_t len{};
11704 return get_number(input_format, len) && get_string(input_format, len, result);
11710 auto last_token = get_token_string();
11711 std::string message;
11713 if (input_format != input_format_t::bjdata)
11715 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11719 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11721 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11728 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11730 std::pair<std::size_t, char_int_type> size_and_type;
11732 bool no_ndarray =
true;
11739 if (size_and_type.first != npos)
11741 if (size_and_type.second != 0)
11743 if (size_and_type.second !=
'N')
11745 for (std::size_t i = 0; i < size_and_type.first; ++i)
11751 dim.push_back(dimlen);
11757 for (std::size_t i = 0; i < size_and_type.first; ++i)
11763 dim.push_back(dimlen);
11769 while (current !=
']')
11775 dim.push_back(dimlen);
11793 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11797 prefix = get_ignore_noop();
11804 std::uint8_t number{};
11809 result =
static_cast<std::size_t
>(number);
11815 std::int8_t number{};
11822 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11823 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11825 result =
static_cast<std::size_t
>(number);
11831 std::int16_t number{};
11838 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11839 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11841 result =
static_cast<std::size_t
>(number);
11847 std::int32_t number{};
11854 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11855 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11857 result =
static_cast<std::size_t
>(number);
11863 std::int64_t number{};
11870 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11871 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11873 if (!value_in_range_of<std::size_t>(number))
11875 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11876 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11878 result =
static_cast<std::size_t
>(number);
11884 if (input_format != input_format_t::bjdata)
11888 std::uint16_t number{};
11893 result =
static_cast<std::size_t
>(number);
11899 if (input_format != input_format_t::bjdata)
11903 std::uint32_t number{};
11908 result = conditional_static_cast<std::size_t>(number);
11914 if (input_format != input_format_t::bjdata)
11918 std::uint64_t number{};
11923 if (!value_in_range_of<std::size_t>(number))
11925 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11926 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11934 if (input_format != input_format_t::bjdata)
11940 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));
11942 std::vector<size_t> dim;
11947 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11949 result = dim.at(dim.size() - 1);
11963 string_t
key =
"_ArraySize_";
11964 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
11972 if (result == 0 || result == npos)
11974 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));
11982 return sax->end_array();
11991 auto last_token = get_token_string();
11992 std::string message;
11994 if (input_format != input_format_t::bjdata)
11996 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
12000 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
12002 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
12016 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
12018 result.first = npos;
12020 bool is_ndarray =
false;
12024 if (current ==
'$')
12026 result.second =
get();
12027 if (input_format == input_format_t::bjdata
12028 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
12030 auto last_token = get_token_string();
12031 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12032 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
12047 auto last_token = get_token_string();
12048 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12049 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
12052 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12053 if (input_format == input_format_t::bjdata && is_ndarray)
12055 if (inside_ndarray)
12057 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12058 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
12060 result.second |= (1 << 8);
12065 if (current ==
'#')
12067 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12068 if (input_format == input_format_t::bjdata && is_ndarray)
12070 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12071 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
12083 bool get_ubjson_value(
const char_int_type prefix)
12087 case char_traits<char_type>::eof():
12088 return unexpect_eof(input_format,
"value");
12091 return sax->boolean(
true);
12093 return sax->boolean(
false);
12096 return sax->null();
12100 if (input_format != input_format_t::bjdata)
12104 std::uint8_t number{};
12105 return get_number(input_format, number) && sax->number_unsigned(number);
12110 std::uint8_t number{};
12111 return get_number(input_format, number) && sax->number_unsigned(number);
12116 std::int8_t number{};
12117 return get_number(input_format, number) && sax->number_integer(number);
12122 std::int16_t number{};
12123 return get_number(input_format, number) && sax->number_integer(number);
12128 std::int32_t number{};
12129 return get_number(input_format, number) && sax->number_integer(number);
12134 std::int64_t number{};
12135 return get_number(input_format, number) && sax->number_integer(number);
12140 if (input_format != input_format_t::bjdata)
12144 std::uint16_t number{};
12145 return get_number(input_format, number) && sax->number_unsigned(number);
12150 if (input_format != input_format_t::bjdata)
12154 std::uint32_t number{};
12155 return get_number(input_format, number) && sax->number_unsigned(number);
12160 if (input_format != input_format_t::bjdata)
12164 std::uint64_t number{};
12165 return get_number(input_format, number) && sax->number_unsigned(number);
12170 if (input_format != input_format_t::bjdata)
12174 const auto byte1_raw =
get();
12179 const auto byte2_raw =
get();
12185 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
12186 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
12196 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
12197 const double val = [&half]
12199 const int exp = (half >> 10u) & 0x1Fu;
12200 const unsigned int mant = half & 0x3FFu;
12206 return std::ldexp(mant, -24);
12209 ? std::numeric_limits<double>::infinity()
12210 : std::numeric_limits<double>::quiet_NaN();
12212 return std::ldexp(mant + 1024, exp - 25);
12215 return sax->number_float((half & 0x8000u) != 0
12216 ?
static_cast<number_float_t
>(-val)
12217 :
static_cast<number_float_t
>(val),
"");
12223 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12229 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12234 return get_ubjson_high_precision_number();
12246 auto last_token = get_token_string();
12247 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
12248 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
12250 string_t s(1,
static_cast<typename string_t::value_type
>(current));
12251 return sax->string(s);
12257 return get_ubjson_string(s) && sax->string(s);
12261 return get_ubjson_array();
12264 return get_ubjson_object();
12269 auto last_token = get_token_string();
12270 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));
12276 bool get_ubjson_array()
12278 std::pair<std::size_t, char_int_type> size_and_type;
12287 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12289 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
12290 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)
12292 return p.first < t;
12294 string_t
key =
"_ArrayType_";
12297 auto last_token = get_token_string();
12298 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12299 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
12302 string_t type = it->second;
12308 if (size_and_type.second ==
'C' || size_and_type.second ==
'B')
12310 size_and_type.second =
'U';
12313 key =
"_ArrayData_";
12319 for (std::size_t i = 0; i < size_and_type.first; ++i)
12327 return (sax->end_array() && sax->end_object());
12331 if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second ==
'B')
12334 return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
12337 if (size_and_type.first != npos)
12344 if (size_and_type.second != 0)
12346 if (size_and_type.second !=
'N')
12348 for (std::size_t i = 0; i < size_and_type.first; ++i)
12359 for (std::size_t i = 0; i < size_and_type.first; ++i)
12375 while (current !=
']')
12385 return sax->end_array();
12391 bool get_ubjson_object()
12393 std::pair<std::size_t, char_int_type> size_and_type;
12400 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12402 auto last_token = get_token_string();
12403 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12404 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
12408 if (size_and_type.first != npos)
12415 if (size_and_type.second != 0)
12417 for (std::size_t i = 0; i < size_and_type.first; ++i)
12432 for (std::size_t i = 0; i < size_and_type.first; ++i)
12453 while (current !=
'}')
12468 return sax->end_object();
12474 bool get_ubjson_high_precision_number()
12477 std::size_t size{};
12478 bool no_ndarray =
true;
12479 auto res = get_ubjson_size_value(size, no_ndarray);
12486 std::vector<char> number_vector;
12487 for (std::size_t i = 0; i < size; ++i)
12494 number_vector.push_back(
static_cast<char>(current));
12499 auto number_lexer = detail::lexer<BasicJsonType, ia_type>(
detail::input_adapter(number_vector),
false);
12500 const auto result_number = number_lexer.scan();
12501 const auto number_string = number_lexer.get_token_string();
12502 const auto result_remainder = number_lexer.scan();
12508 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12509 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12512 switch (result_number)
12514 case token_type::value_integer:
12515 return sax->number_integer(number_lexer.get_number_integer());
12516 case token_type::value_unsigned:
12517 return sax->number_unsigned(number_lexer.get_number_unsigned());
12518 case token_type::value_float:
12519 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12520 case token_type::uninitialized:
12521 case token_type::literal_true:
12522 case token_type::literal_false:
12523 case token_type::literal_null:
12524 case token_type::value_string:
12525 case token_type::begin_array:
12526 case token_type::begin_object:
12527 case token_type::end_array:
12528 case token_type::end_object:
12529 case token_type::name_separator:
12530 case token_type::value_separator:
12531 case token_type::parse_error:
12532 case token_type::end_of_input:
12533 case token_type::literal_or_value:
12535 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12536 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12553 char_int_type
get()
12556 return current = ia.get_character();
12568 bool get_to(T& dest,
const input_format_t format,
const char* context)
12570 auto new_chars_read = ia.get_elements(&dest);
12571 chars_read += new_chars_read;
12576 sax->parse_error(chars_read,
"<end of file>", parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12585 char_int_type get_ignore_noop()
12591 while (current ==
'N');
12596 template<
class NumberType>
12597 static void byte_swap(NumberType& number)
12599 constexpr std::size_t sz =
sizeof(number);
12600#ifdef __cpp_lib_byteswap
12601 if constexpr (sz == 1)
12605 if constexpr(std::is_integral_v<NumberType>)
12607 number = std::byteswap(number);
12611 auto* ptr =
reinterpret_cast<std::uint8_t*
>(&number);
12612 for (std::size_t i = 0; i < sz / 2; ++i)
12633 template<
typename NumberType,
bool InputIsLittleEndian = false>
12634 bool get_number(
const input_format_t format, NumberType& result)
12642 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
12663 template<
typename NumberType>
12664 bool get_string(
const input_format_t format,
12665 const NumberType len,
12668 bool success =
true;
12669 for (NumberType i = 0; i < len; i++)
12677 result.push_back(
static_cast<typename string_t::value_type
>(current));
12696 template<
typename NumberType>
12697 bool get_binary(
const input_format_t format,
12698 const NumberType len,
12701 bool success =
true;
12702 for (NumberType i = 0; i < len; i++)
12710 result.push_back(
static_cast<std::uint8_t
>(current));
12721 bool unexpect_eof(const input_format_t format, const
char* context)
const
12725 return sax->parse_error(chars_read,
"<end of file>",
12726 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12734 std::string get_token_string()
const
12736 std::array<char, 3> cr{{}};
12737 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12738 return std::string{cr.data()};
12747 std::string exception_message(
const input_format_t format,
12748 const std::string& detail,
12749 const std::string& context)
const
12751 std::string error_msg =
"syntax error while parsing ";
12755 case input_format_t::cbor:
12756 error_msg +=
"CBOR";
12759 case input_format_t::msgpack:
12760 error_msg +=
"MessagePack";
12763 case input_format_t::ubjson:
12764 error_msg +=
"UBJSON";
12767 case input_format_t::bson:
12768 error_msg +=
"BSON";
12771 case input_format_t::bjdata:
12772 error_msg +=
"BJData";
12775 case input_format_t::json:
12780 return concat(error_msg,
' ', context,
": ", detail);
12787 InputAdapterType ia;
12790 char_int_type current = char_traits<char_type>::eof();
12793 std::size_t chars_read = 0;
12802 json_sax_t* sax =
nullptr;
12805#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12806 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12808#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12809 make_array<bjd_type>( \
12810 bjd_type{'B', "byte"}, \
12811 bjd_type{'C', "char"}, \
12812 bjd_type{'D', "double"}, \
12813 bjd_type{'I', "int16"}, \
12814 bjd_type{'L', "int64"}, \
12815 bjd_type{'M', "uint64"}, \
12816 bjd_type{'U', "uint8"}, \
12817 bjd_type{'d', "single"}, \
12818 bjd_type{'i', "int8"}, \
12819 bjd_type{'l', "int32"}, \
12820 bjd_type{'m', "uint32"}, \
12821 bjd_type{'u', "uint16"})
12829 using bjd_type = std::pair<char_int_type, string_t>;
12834#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12835#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12838#ifndef JSON_HAS_CPP_17
12839 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12840 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12863#include <functional>
12908template<
typename BasicJsonType>
12910 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12917template<
typename BasicJsonType,
typename InputAdapterType>
12920 using number_integer_t =
typename BasicJsonType::number_integer_t;
12921 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12922 using number_float_t =
typename BasicJsonType::number_float_t;
12923 using string_t =
typename BasicJsonType::string_t;
12931 const bool allow_exceptions_ =
true,
12932 const bool skip_comments =
false)
12933 : callback(
std::move(cb))
12934 , m_lexer(
std::move(adapter), skip_comments)
12935 , allow_exceptions(allow_exceptions_)
12956 sax_parse_internal(&sdp);
12959 if (
strict && (get_token() != token_type::end_of_input))
12962 m_lexer.get_token_string(),
12964 exception_message(token_type::end_of_input,
"value"),
nullptr));
12976 if (result.is_discarded())
12984 sax_parse_internal(&sdp);
12987 if (
strict && (get_token() != token_type::end_of_input))
12990 m_lexer.get_token_string(),
12991 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13002 result.assert_invariant();
13017 template<
typename SAX>
13022 const bool result = sax_parse_internal(sax);
13025 if (result &&
strict && (get_token() != token_type::end_of_input))
13027 return sax->parse_error(m_lexer.get_position(),
13028 m_lexer.get_token_string(),
13029 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13036 template<
typename SAX>
13038 bool sax_parse_internal(SAX* sax)
13042 std::vector<bool> states;
13044 bool skip_to_state_evaluation =
false;
13048 if (!skip_to_state_evaluation)
13051 switch (last_token)
13053 case token_type::begin_object:
13061 if (get_token() == token_type::end_object)
13073 return sax->parse_error(m_lexer.get_position(),
13074 m_lexer.get_token_string(),
13075 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13085 return sax->parse_error(m_lexer.get_position(),
13086 m_lexer.get_token_string(),
13087 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13091 states.push_back(
false);
13098 case token_type::begin_array:
13106 if (get_token() == token_type::end_array)
13116 states.push_back(
true);
13122 case token_type::value_float:
13124 const auto res = m_lexer.get_number_float();
13128 return sax->parse_error(m_lexer.get_position(),
13129 m_lexer.get_token_string(),
13130 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
13141 case token_type::literal_false:
13150 case token_type::literal_null:
13159 case token_type::literal_true:
13168 case token_type::value_integer:
13177 case token_type::value_string:
13186 case token_type::value_unsigned:
13195 case token_type::parse_error:
13198 return sax->parse_error(m_lexer.get_position(),
13199 m_lexer.get_token_string(),
13200 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
13202 case token_type::end_of_input:
13206 return sax->parse_error(m_lexer.get_position(),
13207 m_lexer.get_token_string(),
13208 parse_error::create(101, m_lexer.get_position(),
13209 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
13212 return sax->parse_error(m_lexer.get_position(),
13213 m_lexer.get_token_string(),
13214 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13216 case token_type::uninitialized:
13217 case token_type::end_array:
13218 case token_type::end_object:
13219 case token_type::name_separator:
13220 case token_type::value_separator:
13221 case token_type::literal_or_value:
13224 return sax->parse_error(m_lexer.get_position(),
13225 m_lexer.get_token_string(),
13226 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13232 skip_to_state_evaluation =
false;
13236 if (states.empty())
13245 if (get_token() == token_type::value_separator)
13266 skip_to_state_evaluation =
true;
13270 return sax->parse_error(m_lexer.get_position(),
13271 m_lexer.get_token_string(),
13272 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
13278 if (get_token() == token_type::value_separator)
13283 return sax->parse_error(m_lexer.get_position(),
13284 m_lexer.get_token_string(),
13285 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13296 return sax->parse_error(m_lexer.get_position(),
13297 m_lexer.get_token_string(),
13298 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13320 skip_to_state_evaluation =
true;
13324 return sax->parse_error(m_lexer.get_position(),
13325 m_lexer.get_token_string(),
13326 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
13331 token_type get_token()
13333 return last_token = m_lexer.scan();
13336 std::string exception_message(
const token_type expected,
const std::string& context)
13338 std::string error_msg =
"syntax error ";
13340 if (!context.empty())
13342 error_msg +=
concat(
"while parsing ", context,
' ');
13347 if (last_token == token_type::parse_error)
13349 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
13350 m_lexer.get_token_string(),
'\'');
13354 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
13357 if (expected != token_type::uninitialized)
13359 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
13367 const parser_callback_t<BasicJsonType> callback =
nullptr;
13369 token_type last_token = token_type::uninitialized;
13373 const bool allow_exceptions =
true;
13425 using difference_type = std::ptrdiff_t;
13426 static constexpr difference_type begin_value = 0;
13427 static constexpr difference_type end_value = begin_value + 1;
13431 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
13442 m_it = begin_value;
13454 return m_it == begin_value;
13460 return m_it == end_value;
13465 return lhs.m_it == rhs.m_it;
13470 return lhs.m_it < rhs.m_it;
13475 auto result = *
this;
13482 return lhs.m_it - rhs.m_it;
13493 auto result = *
this;
13506 auto result = *
this;
13563#include <type_traits>
13585template<
typename IteratorType>
class iteration_proxy;
13586template<
typename IteratorType>
class iteration_proxy_value;
13604template<
typename BasicJsonType>
13610 friend other_iter_impl;
13611 friend BasicJsonType;
13615 using object_t =
typename BasicJsonType::object_t;
13616 using array_t =
typename BasicJsonType::array_t;
13619 "iter_impl only accepts (const) basic_json");
13621 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13622 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
13623 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13638 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13639 typename BasicJsonType::const_pointer,
13640 typename BasicJsonType::pointer>::type;
13643 typename std::conditional<std::is_const<BasicJsonType>::value,
13644 typename BasicJsonType::const_reference,
13645 typename BasicJsonType::reference>::type;
13662 switch (m_object->m_data.m_type)
13666 m_it.object_iterator =
typename object_t::iterator();
13672 m_it.array_iterator =
typename array_t::iterator();
13709 : m_object(other.m_object),
m_it(other.m_it)
13720 if (&other !=
this)
13722 m_object = other.m_object;
13734 : m_object(other.m_object),
m_it(other.m_it)
13745 m_object = other.m_object;
13755 void set_begin() noexcept
13759 switch (m_object->m_data.m_type)
13763 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13769 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13776 m_it.primitive_iterator.set_end();
13789 m_it.primitive_iterator.set_begin();
13803 switch (m_object->m_data.m_type)
13807 m_it.object_iterator = m_object->m_data.m_value.object->end();
13813 m_it.array_iterator = m_object->m_data.m_value.array->end();
13827 m_it.primitive_iterator.set_end();
13842 switch (m_object->m_data.m_type)
13846 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13847 return m_it.object_iterator->second;
13852 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13853 return *
m_it.array_iterator;
13886 switch (m_object->m_data.m_type)
13890 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13891 return &(
m_it.object_iterator->second);
13896 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13897 return &*
m_it.array_iterator;
13926 auto result = *
this;
13939 switch (m_object->m_data.m_type)
13943 std::advance(
m_it.object_iterator, 1);
13949 std::advance(
m_it.array_iterator, 1);
13963 ++
m_it.primitive_iterator;
13977 auto result = *
this;
13990 switch (m_object->m_data.m_type)
13994 std::advance(
m_it.object_iterator, -1);
14000 std::advance(
m_it.array_iterator, -1);
14014 --
m_it.primitive_iterator;
14026 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 >
14036 if (m_object ==
nullptr)
14041 switch (m_object->m_data.m_type)
14044 return (
m_it.object_iterator == other.m_it.object_iterator);
14047 return (
m_it.array_iterator == other.m_it.array_iterator);
14058 return (
m_it.primitive_iterator == other.m_it.primitive_iterator);
14066 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 >
14085 if (m_object ==
nullptr)
14091 switch (m_object->m_data.m_type)
14097 return (
m_it.array_iterator < other.
m_it.array_iterator);
14108 return (
m_it.primitive_iterator < other.
m_it.primitive_iterator);
14118 return !other.operator < (*this);
14147 switch (m_object->m_data.m_type)
14154 std::advance(
m_it.array_iterator, i);
14168 m_it.primitive_iterator += i;
14191 auto result = *
this;
14213 auto result = *
this;
14226 switch (m_object->m_data.m_type)
14232 return m_it.array_iterator - other.
m_it.array_iterator;
14243 return m_it.primitive_iterator - other.
m_it.primitive_iterator;
14255 switch (m_object->m_data.m_type)
14261 return *std::next(
m_it.array_iterator, n);
14289 const typename object_t::key_type&
key()
const
14295 return m_it.object_iterator->first;
14366template<
typename Base>
14440 auto it = --this->base();
14447 auto it = --this->base();
14448 return it.operator * ();
14468#include <type_traits>
14491 std::is_same<T, void>::value,
14510#include <algorithm>
14538template<
typename RefStringType>
14548 template<
typename T>
14549 struct string_t_helper
14557 using type = StringType;
14562 using string_t =
typename string_t_helper<RefStringType>::type;
14567 : reference_tokens(split(s))
14574 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14578 return detail::concat(a,
'/', detail::escape(b));
14604 reference_tokens.insert(reference_tokens.end(),
14605 ptr.reference_tokens.begin(),
14606 ptr.reference_tokens.end());
14622 return *
this /= std::to_string(array_idx);
14670 reference_tokens.pop_back();
14682 return reference_tokens.back();
14689 reference_tokens.push_back(token);
14696 reference_tokens.push_back(std::move(token));
14703 return reference_tokens.empty();
14717 template<
typename BasicJsonType>
14718 static typename BasicJsonType::size_type array_index(
const string_t& s)
14720 using size_type =
typename BasicJsonType::size_type;
14734 const char* p = s.c_str();
14735 char* p_end =
nullptr;
14737 const unsigned long long res = std::strtoull(p, &p_end, 10);
14747 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14752 return static_cast<size_type
>(res);
14756 json_pointer top()
const
14763 json_pointer result = *
this;
14764 result.reference_tokens = {reference_tokens[0]};
14777 template<
typename BasicJsonType>
14778 BasicJsonType& get_and_create(BasicJsonType& j)
const
14784 for (
const auto& reference_token : reference_tokens)
14786 switch (result->type())
14790 if (reference_token ==
"0")
14793 result = &result->operator[](0);
14798 result = &result->operator[](reference_token);
14806 result = &result->operator[](reference_token);
14813 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14857 template<
typename BasicJsonType>
14858 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14860 for (
const auto& reference_token : reference_tokens)
14863 if (ptr->is_null())
14867 std::all_of(reference_token.begin(), reference_token.end(),
14868 [](
const unsigned char x)
14870 return std::isdigit(x);
14874 *ptr = (nums || reference_token ==
"-")
14879 switch (ptr->type())
14884 ptr = &ptr->operator[](reference_token);
14890 if (reference_token ==
"-")
14893 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14898 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14925 template<
typename BasicJsonType>
14926 BasicJsonType& get_checked(BasicJsonType* ptr)
const
14928 for (
const auto& reference_token : reference_tokens)
14930 switch (ptr->type())
14935 ptr = &ptr->at(reference_token);
14945 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14946 ") is out of range"), ptr));
14950 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14983 template<
typename BasicJsonType>
14984 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
14986 for (
const auto& reference_token : reference_tokens)
14988 switch (ptr->type())
14993 ptr = &ptr->operator[](reference_token);
15006 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15032 template<
typename BasicJsonType>
15033 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
15035 for (
const auto& reference_token : reference_tokens)
15037 switch (ptr->type())
15042 ptr = &ptr->at(reference_token);
15052 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15053 ") is out of range"), ptr));
15057 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15081 template<
typename BasicJsonType>
15082 bool contains(
const BasicJsonType* ptr)
const
15084 for (
const auto& reference_token : reference_tokens)
15086 switch (ptr->type())
15090 if (!ptr->contains(reference_token))
15096 ptr = &ptr->operator[](reference_token);
15107 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
15119 for (std::size_t i = 1; i < reference_token.size(); i++)
15129 const auto idx = array_index<BasicJsonType>(reference_token);
15130 if (idx >= ptr->size())
15136 ptr = &ptr->operator[](idx);
15170 static std::vector<string_t> split(
const string_t& reference_string)
15172 std::vector<string_t> result;
15175 if (reference_string.empty())
15191 std::size_t slash = reference_string.find_first_of(
'/', 1),
15198 start = (slash == string_t::npos) ? 0 : slash + 1,
15200 slash = reference_string.find_first_of(
'/', start))
15204 auto reference_token = reference_string.substr(start, slash - start);
15207 for (std::size_t pos = reference_token.find_first_of(
'~');
15208 pos != string_t::npos;
15209 pos = reference_token.find_first_of(
'~', pos + 1))
15215 (reference_token[pos + 1] !=
'0' &&
15216 reference_token[pos + 1] !=
'1')))
15224 result.push_back(reference_token);
15238 template<
typename BasicJsonType>
15239 static void flatten(
const string_t& reference_string,
15240 const BasicJsonType& value,
15241 BasicJsonType& result)
15243 switch (
value.type())
15247 if (
value.m_data.m_value.array->empty())
15250 result[reference_string] =
nullptr;
15255 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
15258 value.m_data.m_value.array->operator[](i), result);
15266 if (
value.m_data.m_value.object->empty())
15269 result[reference_string] =
nullptr;
15274 for (
const auto& element : *
value.m_data.m_value.object)
15293 result[reference_string] =
value;
15309 template<
typename BasicJsonType>
15310 static BasicJsonType
15311 unflatten(
const BasicJsonType& value)
15318 BasicJsonType result;
15321 for (
const auto& element : *
value.m_data.m_value.object)
15332 json_pointer(element.first).get_and_create(result) = element.second;
15339 json_pointer<string_t> convert() const&
15341 json_pointer<string_t> result;
15342 result.reference_tokens = reference_tokens;
15346 json_pointer<string_t> convert()&&
15348 json_pointer<string_t> result;
15349 result.reference_tokens = std::move(reference_tokens);
15354#if JSON_HAS_THREE_WAY_COMPARISON
15357 template<
typename RefStringTypeRhs>
15358 bool operator==(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
15360 return reference_tokens == rhs.reference_tokens;
15368 return *
this == json_pointer(rhs);
15372 template<
typename RefStringTypeRhs>
15373 std::strong_ordering operator<=>(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
15375 return reference_tokens <=> rhs.reference_tokens;
15380 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15382 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
15383 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15387 template<
typename RefStringTypeLhs,
typename StringType>
15389 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
15390 const StringType& rhs);
15394 template<
typename RefStringTypeRhs,
typename StringType>
15396 friend bool operator==(
const StringType& lhs,
15397 const json_pointer<RefStringTypeRhs>& rhs);
15401 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15403 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
15404 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15408 template<
typename RefStringTypeLhs,
typename StringType>
15410 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
15411 const StringType& rhs);
15415 template<
typename RefStringTypeRhs,
typename StringType>
15417 friend bool operator!=(
const StringType& lhs,
15418 const json_pointer<RefStringTypeRhs>& rhs);
15421 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15423 friend bool operator<(
const json_pointer<RefStringTypeLhs>& lhs,
15424 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15429 std::vector<string_t> reference_tokens;
15432#if !JSON_HAS_THREE_WAY_COMPARISON
15434template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15438 return lhs.reference_tokens == rhs.reference_tokens;
15441template<
typename RefStringTypeLhs,
15445 const StringType& rhs)
15450template<
typename RefStringTypeRhs,
15453inline
bool operator==(const StringType& lhs,
15459template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15463 return !(lhs == rhs);
15466template<
typename RefStringTypeLhs,
15470 const StringType& rhs)
15472 return !(lhs == rhs);
15475template<
typename RefStringTypeRhs,
15478inline
bool operator!=(const StringType& lhs,
15481 return !(lhs == rhs);
15484template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15488 return lhs.reference_tokens < rhs.reference_tokens;
15505#include <initializer_list>
15517template<
typename BasicJsonType>
15528 : value_ref(&
value)
15532 : owned_value(init)
15539 : owned_value(
std::forward<Args>(args)...)
15551 if (value_ref ==
nullptr)
15553 return std::move(owned_value);
15560 return value_ref ? *value_ref : owned_value;
15569 mutable value_type owned_value =
nullptr;
15570 value_type
const* value_ref =
nullptr;
15599#include <algorithm>
15625#include <algorithm>
15659template<typename CharType>
15663template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15679 v.insert(v.end(), s, s + length);
15683 std::vector<CharType, AllocatorType>& v;
15688template<
typename CharType>
15704 stream.write(s,
static_cast<std::streamsize
>(length));
15708 std::basic_ostream<CharType>& stream;
15713template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15729 str.append(s, length);
15736template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15740 template<
typename AllocatorType = std::allocator<CharType>>
15785template<
typename BasicJsonType,
typename CharType>
15788 using string_t =
typename BasicJsonType::string_t;
15789 using binary_t =
typename BasicJsonType::binary_t;
15790 using number_float_t =
typename BasicJsonType::number_float_t;
15813 write_bson_object(*j.m_data.m_value.object);
15848 oa->write_character(j.m_data.m_value.boolean
15856 if (j.m_data.m_value.number_integer >= 0)
15861 if (j.m_data.m_value.number_integer <= 0x17)
15863 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15865 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15868 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15870 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15873 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15875 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15878 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15883 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15890 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15891 if (j.m_data.m_value.number_integer >= -24)
15893 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15895 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15898 write_number(
static_cast<std::uint8_t
>(positive_number));
15900 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15903 write_number(
static_cast<std::uint16_t
>(positive_number));
15905 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15908 write_number(
static_cast<std::uint32_t
>(positive_number));
15913 write_number(
static_cast<std::uint64_t
>(positive_number));
15921 if (j.m_data.m_value.number_unsigned <= 0x17)
15923 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15925 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15928 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15930 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15933 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
15935 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15938 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
15943 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
15950 if (std::isnan(j.m_data.m_value.number_float))
15957 else if (std::isinf(j.m_data.m_value.number_float))
15974 const auto N = j.m_data.m_value.string->size();
15977 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15979 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15982 write_number(
static_cast<std::uint8_t
>(N));
15984 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15987 write_number(
static_cast<std::uint16_t
>(N));
15989 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15992 write_number(
static_cast<std::uint32_t
>(N));
15995 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15998 write_number(
static_cast<std::uint64_t
>(N));
16003 oa->write_characters(
16004 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16005 j.m_data.m_value.string->size());
16012 const auto N = j.m_data.m_value.array->size();
16015 write_number(
static_cast<std::uint8_t
>(0x80 + N));
16017 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16020 write_number(
static_cast<std::uint8_t
>(N));
16022 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16025 write_number(
static_cast<std::uint16_t
>(N));
16027 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16030 write_number(
static_cast<std::uint32_t
>(N));
16033 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16036 write_number(
static_cast<std::uint64_t
>(N));
16041 for (
const auto& el : *j.m_data.m_value.array)
16050 if (j.m_data.m_value.binary->has_subtype())
16052 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
16054 write_number(
static_cast<std::uint8_t
>(0xd8));
16055 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
16057 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
16059 write_number(
static_cast<std::uint8_t
>(0xd9));
16060 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
16062 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
16064 write_number(
static_cast<std::uint8_t
>(0xda));
16065 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
16067 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
16069 write_number(
static_cast<std::uint8_t
>(0xdb));
16070 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
16075 const auto N = j.m_data.m_value.binary->size();
16078 write_number(
static_cast<std::uint8_t
>(0x40 + N));
16080 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16083 write_number(
static_cast<std::uint8_t
>(N));
16085 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16088 write_number(
static_cast<std::uint16_t
>(N));
16090 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16093 write_number(
static_cast<std::uint32_t
>(N));
16096 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16099 write_number(
static_cast<std::uint64_t
>(N));
16104 oa->write_characters(
16105 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16114 const auto N = j.m_data.m_value.object->size();
16117 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
16119 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16122 write_number(
static_cast<std::uint8_t
>(N));
16124 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16127 write_number(
static_cast<std::uint16_t
>(N));
16129 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16132 write_number(
static_cast<std::uint32_t
>(N));
16135 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16138 write_number(
static_cast<std::uint64_t
>(N));
16143 for (
const auto& el : *j.m_data.m_value.object)
16172 oa->write_character(j.m_data.m_value.boolean
16180 if (j.m_data.m_value.number_integer >= 0)
16185 if (j.m_data.m_value.number_unsigned < 128)
16188 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16190 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16194 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16196 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16200 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16202 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16206 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16208 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16212 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16217 if (j.m_data.m_value.number_integer >= -32)
16220 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16222 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
16223 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16227 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16229 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
16230 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16234 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
16236 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
16237 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16241 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
16243 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
16244 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16248 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
16256 if (j.m_data.m_value.number_unsigned < 128)
16259 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16261 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16265 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16267 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16271 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16273 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16277 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16279 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16283 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16297 const auto N = j.m_data.m_value.string->size();
16301 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
16303 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16307 write_number(
static_cast<std::uint8_t
>(N));
16309 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16313 write_number(
static_cast<std::uint16_t
>(N));
16315 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16319 write_number(
static_cast<std::uint32_t
>(N));
16323 oa->write_characters(
16324 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16325 j.m_data.m_value.string->size());
16332 const auto N = j.m_data.m_value.array->size();
16336 write_number(
static_cast<std::uint8_t
>(0x90 | N));
16338 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16342 write_number(
static_cast<std::uint16_t
>(N));
16344 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16348 write_number(
static_cast<std::uint32_t
>(N));
16352 for (
const auto& el : *j.m_data.m_value.array)
16363 const bool use_ext = j.m_data.m_value.binary->has_subtype();
16366 const auto N = j.m_data.m_value.binary->size();
16367 if (N <= (std::numeric_limits<std::uint8_t>::max)())
16369 std::uint8_t output_type{};
16376 output_type = 0xD4;
16379 output_type = 0xD5;
16382 output_type = 0xD6;
16385 output_type = 0xD7;
16388 output_type = 0xD8;
16391 output_type = 0xC7;
16399 output_type = 0xC4;
16406 write_number(
static_cast<std::uint8_t
>(N));
16409 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16411 const std::uint8_t output_type = use_ext
16416 write_number(
static_cast<std::uint16_t
>(N));
16418 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16420 const std::uint8_t output_type = use_ext
16425 write_number(
static_cast<std::uint32_t
>(N));
16431 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
16435 oa->write_characters(
16436 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16445 const auto N = j.m_data.m_value.object->size();
16449 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
16451 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16455 write_number(
static_cast<std::uint16_t
>(N));
16457 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16461 write_number(
static_cast<std::uint32_t
>(N));
16465 for (
const auto& el : *j.m_data.m_value.object)
16488 const bool use_type,
const bool add_prefix =
true,
16508 oa->write_character(j.m_data.m_value.boolean
16517 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16523 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16529 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16539 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16540 oa->write_characters(
16541 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16542 j.m_data.m_value.string->size());
16553 bool prefix_required =
true;
16554 if (use_type && !j.m_data.m_value.array->empty())
16557 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16558 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16559 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16561 return ubjson_prefix(v, use_bjdata) == first_prefix;
16564 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16566 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16568 prefix_required =
false;
16570 oa->write_character(first_prefix);
16577 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16580 for (
const auto& el : *j.m_data.m_value.array)
16582 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16600 if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
16604 oa->write_character(bjdata_draft3 ?
'B' :
'U');
16610 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16615 oa->write_characters(
16616 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16617 j.m_data.m_value.binary->size());
16621 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16623 oa->write_character(
to_char_type(bjdata_draft3 ?
'B' :
'U'));
16624 oa->write_character(j.m_data.m_value.binary->data()[i]);
16638 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())
16640 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version))
16651 bool prefix_required =
true;
16652 if (use_type && !j.m_data.m_value.object->empty())
16655 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16656 const bool same_prefix = std::all_of(j.begin(), j.end(),
16657 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16659 return ubjson_prefix(v, use_bjdata) == first_prefix;
16662 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16664 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16666 prefix_required =
false;
16668 oa->write_character(first_prefix);
16675 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16678 for (
const auto& el : *j.m_data.m_value.object)
16680 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16681 oa->write_characters(
16682 reinterpret_cast<const CharType*
>(el.first.c_str()),
16684 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16710 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
16712 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16716 static_cast<void>(j);
16719 return 1ul + name.size() + 1u;
16725 void write_bson_entry_header(
const string_t& name,
16726 const std::uint8_t element_type)
16728 oa->write_character(to_char_type(element_type));
16729 oa->write_characters(
16730 reinterpret_cast<const CharType*
>(name.c_str()),
16737 void write_bson_boolean(
const string_t& name,
16740 write_bson_entry_header(name, 0x08);
16741 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
16747 void write_bson_double(
const string_t& name,
16748 const double value)
16750 write_bson_entry_header(name, 0x01);
16751 write_number<double>(value,
true);
16757 static std::size_t calc_bson_string_size(
const string_t& value)
16759 return sizeof(std::int32_t) +
value.size() + 1ul;
16765 void write_bson_string(
const string_t& name,
16768 write_bson_entry_header(name, 0x02);
16770 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16771 oa->write_characters(
16772 reinterpret_cast<const CharType*
>(
value.c_str()),
16779 void write_bson_null(
const string_t& name)
16781 write_bson_entry_header(name, 0x0A);
16787 static std::size_t calc_bson_integer_size(
const std::int64_t value)
16789 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
16790 ?
sizeof(std::int32_t)
16791 :
sizeof(std::int64_t);
16797 void write_bson_integer(
const string_t& name,
16798 const std::int64_t value)
16800 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16802 write_bson_entry_header(name, 0x10);
16803 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16807 write_bson_entry_header(name, 0x12);
16808 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16815 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
16817 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16818 ?
sizeof(std::int32_t)
16819 : sizeof(std::int64_t);
16825 void write_bson_unsigned(
const string_t& name,
16826 const BasicJsonType& j)
16828 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16830 write_bson_entry_header(name, 0x10 );
16831 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16833 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16835 write_bson_entry_header(name, 0x12 );
16836 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16840 write_bson_entry_header(name, 0x11 );
16841 write_number<std::uint64_t>(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned),
true);
16848 void write_bson_object_entry(
const string_t& name,
16849 const typename BasicJsonType::object_t& value)
16851 write_bson_entry_header(name, 0x03);
16852 write_bson_object(value);
16858 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16860 std::size_t array_index = 0ul;
16862 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)
16864 return result + calc_bson_element_size(std::to_string(array_index++), el);
16867 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16873 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16875 return sizeof(std::int32_t) +
value.size() + 1ul;
16881 void write_bson_array(
const string_t& name,
16882 const typename BasicJsonType::array_t& value)
16884 write_bson_entry_header(name, 0x04);
16885 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16887 std::size_t array_index = 0ul;
16889 for (
const auto& el : value)
16891 write_bson_element(std::to_string(array_index++), el);
16894 oa->write_character(to_char_type(0x00));
16900 void write_bson_binary(
const string_t& name,
16903 write_bson_entry_header(name, 0x05);
16905 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16906 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16908 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16915 static std::size_t calc_bson_element_size(
const string_t& name,
16916 const BasicJsonType& j)
16918 const auto header_size = calc_bson_entry_header_size(name, j);
16921 case value_t::object:
16922 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16924 case value_t::array:
16925 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
16927 case value_t::binary:
16928 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
16930 case value_t::boolean:
16931 return header_size + 1ul;
16933 case value_t::number_float:
16934 return header_size + 8ul;
16936 case value_t::number_integer:
16937 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
16939 case value_t::number_unsigned:
16940 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
16942 case value_t::string:
16943 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
16945 case value_t::null:
16946 return header_size + 0ul;
16949 case value_t::discarded:
16963 void write_bson_element(
const string_t& name,
16964 const BasicJsonType& j)
16968 case value_t::object:
16969 return write_bson_object_entry(name, *j.m_data.m_value.object);
16971 case value_t::array:
16972 return write_bson_array(name, *j.m_data.m_value.array);
16974 case value_t::binary:
16975 return write_bson_binary(name, *j.m_data.m_value.binary);
16977 case value_t::boolean:
16978 return write_bson_boolean(name, j.m_data.m_value.boolean);
16980 case value_t::number_float:
16981 return write_bson_double(name, j.m_data.m_value.number_float);
16983 case value_t::number_integer:
16984 return write_bson_integer(name, j.m_data.m_value.number_integer);
16986 case value_t::number_unsigned:
16987 return write_bson_unsigned(name, j);
16989 case value_t::string:
16990 return write_bson_string(name, *j.m_data.m_value.string);
16992 case value_t::null:
16993 return write_bson_null(name);
16996 case value_t::discarded:
17010 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
17012 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
17013 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
17015 return result += calc_bson_element_size(el.first, el.second);
17018 return sizeof(std::int32_t) + document_size + 1ul;
17025 void write_bson_object(
const typename BasicJsonType::object_t& value)
17027 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
17029 for (
const auto& el : value)
17031 write_bson_element(el.first, el.second);
17034 oa->write_character(to_char_type(0x00));
17041 static constexpr CharType get_cbor_float_prefix(
float )
17043 return to_char_type(0xFA);
17046 static constexpr CharType get_cbor_float_prefix(
double )
17048 return to_char_type(0xFB);
17055 static constexpr CharType get_msgpack_float_prefix(
float )
17057 return to_char_type(0xCA);
17060 static constexpr CharType get_msgpack_float_prefix(
double )
17062 return to_char_type(0xCB);
17070 template<
typename NumberType,
typename std::enable_if<
17071 std::is_floating_point<NumberType>::value,
int>::type = 0>
17072 void write_number_with_ubjson_prefix(
const NumberType n,
17073 const bool add_prefix,
17074 const bool use_bjdata)
17078 oa->write_character(get_ubjson_float_prefix(n));
17080 write_number(n, use_bjdata);
17084 template<
typename NumberType,
typename std::enable_if<
17085 std::is_unsigned<NumberType>::value,
int>::type = 0>
17086 void write_number_with_ubjson_prefix(
const NumberType n,
17087 const bool add_prefix,
17088 const bool use_bjdata)
17090 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17094 oa->write_character(to_char_type(
'i'));
17096 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17098 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
17102 oa->write_character(to_char_type(
'U'));
17104 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17106 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17110 oa->write_character(to_char_type(
'I'));
17112 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17114 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
17118 oa->write_character(to_char_type(
'u'));
17120 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
17122 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17126 oa->write_character(to_char_type(
'l'));
17128 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17130 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
17134 oa->write_character(to_char_type(
'm'));
17136 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
17138 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17142 oa->write_character(to_char_type(
'L'));
17144 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17146 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
17150 oa->write_character(to_char_type(
'M'));
17152 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
17158 oa->write_character(to_char_type(
'H'));
17161 const auto number = BasicJsonType(n).dump();
17162 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17163 for (std::size_t i = 0; i < number.size(); ++i)
17165 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17171 template <
typename NumberType,
typename std::enable_if <
17172 std::is_signed<NumberType>::value&&
17173 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
17174 void write_number_with_ubjson_prefix(
const NumberType n,
17175 const bool add_prefix,
17176 const bool use_bjdata)
17178 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
17182 oa->write_character(to_char_type(
'i'));
17184 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
17186 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)()))
17190 oa->write_character(to_char_type(
'U'));
17192 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17194 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
17198 oa->write_character(to_char_type(
'I'));
17200 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17202 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)())))
17206 oa->write_character(to_char_type(
'u'));
17208 write_number(
static_cast<uint16_t
>(n), use_bjdata);
17210 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
17214 oa->write_character(to_char_type(
'l'));
17216 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17218 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)())))
17222 oa->write_character(to_char_type(
'm'));
17224 write_number(
static_cast<uint32_t
>(n), use_bjdata);
17226 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
17230 oa->write_character(to_char_type(
'L'));
17232 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17239 oa->write_character(to_char_type(
'H'));
17242 const auto number = BasicJsonType(n).dump();
17243 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17244 for (std::size_t i = 0; i < number.size(); ++i)
17246 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17255 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
17259 case value_t::null:
17262 case value_t::boolean:
17263 return j.m_data.m_value.boolean ?
'T' :
'F';
17265 case value_t::number_integer:
17267 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)())
17271 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)())
17275 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)())
17279 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)()))
17283 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)())
17287 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)()))
17291 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)())
17299 case value_t::number_unsigned:
17301 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17305 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17309 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17313 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
17317 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17321 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
17325 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17329 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
17337 case value_t::number_float:
17338 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
17340 case value_t::string:
17343 case value_t::array:
17344 case value_t::binary:
17347 case value_t::object:
17350 case value_t::discarded:
17356 static constexpr CharType get_ubjson_float_prefix(
float )
17361 static constexpr CharType get_ubjson_float_prefix(
double )
17369 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type,
const bjdata_version_t bjdata_version)
17371 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
17372 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'},
17373 {
"char",
'C'}, {
"byte",
'B'}
17378 if (it == bjdtype.end())
17382 CharType dtype = it->second;
17384 key =
"_ArraySize_";
17385 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
17386 for (
const auto& el :
value.at(
key))
17388 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
17391 key =
"_ArrayData_";
17397 oa->write_character(
'[');
17398 oa->write_character(
'$');
17399 oa->write_character(dtype);
17400 oa->write_character(
'#');
17402 key =
"_ArraySize_";
17403 write_ubjson(
value.at(
key), use_count, use_type,
true,
true, bjdata_version);
17405 key =
"_ArrayData_";
17406 if (dtype ==
'U' || dtype ==
'C' || dtype ==
'B')
17408 for (
const auto& el :
value.at(
key))
17410 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
17413 else if (dtype ==
'i')
17415 for (
const auto& el :
value.at(
key))
17417 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
17420 else if (dtype ==
'u')
17422 for (
const auto& el :
value.at(
key))
17424 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
17427 else if (dtype ==
'I')
17429 for (
const auto& el :
value.at(
key))
17431 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
17434 else if (dtype ==
'm')
17436 for (
const auto& el :
value.at(
key))
17438 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
17441 else if (dtype ==
'l')
17443 for (
const auto& el :
value.at(
key))
17445 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
17448 else if (dtype ==
'M')
17450 for (
const auto& el :
value.at(
key))
17452 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
17455 else if (dtype ==
'L')
17457 for (
const auto& el :
value.at(
key))
17459 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
17462 else if (dtype ==
'd')
17464 for (
const auto& el :
value.at(
key))
17466 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
17469 else if (dtype ==
'D')
17471 for (
const auto& el :
value.at(
key))
17473 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
17496 template<
typename NumberType>
17497 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
17500 std::array<CharType,
sizeof(NumberType)> vec{};
17501 std::memcpy(vec.data(), &n,
sizeof(NumberType));
17504 if (is_little_endian != OutputIsLittleEndian)
17507 std::reverse(vec.begin(), vec.end());
17510 oa->write_characters(vec.data(),
sizeof(NumberType));
17516#pragma GCC diagnostic push
17517#pragma GCC diagnostic ignored "-Wfloat-equal"
17519 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17520 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17521 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
17524 ? get_cbor_float_prefix(
static_cast<float>(n))
17525 : get_msgpack_float_prefix(
static_cast<float>(n)));
17526 write_number(
static_cast<float>(n));
17531 ? get_cbor_float_prefix(n)
17532 : get_msgpack_float_prefix(n));
17536#pragma GCC diagnostic pop
17545 template <
typename C = CharType,
17546 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
17549 return *
reinterpret_cast<char*
>(&x);
17552 template <
typename C = CharType,
17553 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
17556 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17557 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
17559 std::memcpy(&result, &x,
sizeof(x));
17563 template<
typename C = CharType,
17570 template <
typename InputCharType,
typename C = CharType,
17572 std::is_signed<C>::value &&
17573 std::is_signed<char>::value &&
17574 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
17606#include <algorithm>
17616#include <type_traits>
17636#include <type_traits>
17667template<
typename Target,
typename Source>
17670 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17673 std::memcpy(&target, &source,
sizeof(Source));
17684 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
17695 return {x.f - y.f, x.e};
17704 static_assert(
kPrecision == 64,
"internal error");
17729 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17730 const std::uint64_t u_hi = x.f >> 32u;
17731 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17732 const std::uint64_t v_hi = y.f >> 32u;
17734 const std::uint64_t p0 = u_lo * v_lo;
17735 const std::uint64_t p1 = u_lo * v_hi;
17736 const std::uint64_t p2 = u_hi * v_lo;
17737 const std::uint64_t p3 = u_hi * v_hi;
17739 const std::uint64_t p0_hi = p0 >> 32u;
17740 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17741 const std::uint64_t p1_hi = p1 >> 32u;
17742 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17743 const std::uint64_t p2_hi = p2 >> 32u;
17745 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17756 Q += std::uint64_t{1} << (64u - 32u - 1u);
17758 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17760 return {h, x.e + y.e + 64};
17771 while ((x.f >> 63u) == 0)
17786 const int delta = x.e - target_exponent;
17791 return {x.f << delta, target_exponent};
17808template<
typename FloatType>
17821 static_assert(std::numeric_limits<FloatType>::is_iec559,
17822 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17824 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17825 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17826 constexpr int kMinExp = 1 - kBias;
17827 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17829 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17832 const std::uint64_t E = bits >> (kPrecision - 1);
17833 const std::uint64_t F = bits & (kHiddenBit - 1);
17835 const bool is_denormal = E == 0;
17836 const diyfp v = is_denormal
17837 ?
diyfp(F, kMinExp)
17838 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17861 const bool lower_boundary_is_closer = F == 0 && E > 1;
17863 const diyfp m_minus = lower_boundary_is_closer
17864 ?
diyfp((4 * v.
f) - 1, v.
e - 2)
17865 :
diyfp((2 * v.
f) - 1, v.
e - 1);
18000 constexpr int kCachedPowersMinDecExp = -300;
18001 constexpr int kCachedPowersDecStep = 8;
18003 static constexpr std::array<cached_power, 79> kCachedPowers =
18006 { 0xAB70FE17C79AC6CA, -1060, -300 },
18007 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
18008 { 0xBE5691EF416BD60C, -1007, -284 },
18009 { 0x8DD01FAD907FFC3C, -980, -276 },
18010 { 0xD3515C2831559A83, -954, -268 },
18011 { 0x9D71AC8FADA6C9B5, -927, -260 },
18012 { 0xEA9C227723EE8BCB, -901, -252 },
18013 { 0xAECC49914078536D, -874, -244 },
18014 { 0x823C12795DB6CE57, -847, -236 },
18015 { 0xC21094364DFB5637, -821, -228 },
18016 { 0x9096EA6F3848984F, -794, -220 },
18017 { 0xD77485CB25823AC7, -768, -212 },
18018 { 0xA086CFCD97BF97F4, -741, -204 },
18019 { 0xEF340A98172AACE5, -715, -196 },
18020 { 0xB23867FB2A35B28E, -688, -188 },
18021 { 0x84C8D4DFD2C63F3B, -661, -180 },
18022 { 0xC5DD44271AD3CDBA, -635, -172 },
18023 { 0x936B9FCEBB25C996, -608, -164 },
18024 { 0xDBAC6C247D62A584, -582, -156 },
18025 { 0xA3AB66580D5FDAF6, -555, -148 },
18026 { 0xF3E2F893DEC3F126, -529, -140 },
18027 { 0xB5B5ADA8AAFF80B8, -502, -132 },
18028 { 0x87625F056C7C4A8B, -475, -124 },
18029 { 0xC9BCFF6034C13053, -449, -116 },
18030 { 0x964E858C91BA2655, -422, -108 },
18031 { 0xDFF9772470297EBD, -396, -100 },
18032 { 0xA6DFBD9FB8E5B88F, -369, -92 },
18033 { 0xF8A95FCF88747D94, -343, -84 },
18034 { 0xB94470938FA89BCF, -316, -76 },
18035 { 0x8A08F0F8BF0F156B, -289, -68 },
18036 { 0xCDB02555653131B6, -263, -60 },
18037 { 0x993FE2C6D07B7FAC, -236, -52 },
18038 { 0xE45C10C42A2B3B06, -210, -44 },
18039 { 0xAA242499697392D3, -183, -36 },
18040 { 0xFD87B5F28300CA0E, -157, -28 },
18041 { 0xBCE5086492111AEB, -130, -20 },
18042 { 0x8CBCCC096F5088CC, -103, -12 },
18043 { 0xD1B71758E219652C, -77, -4 },
18044 { 0x9C40000000000000, -50, 4 },
18045 { 0xE8D4A51000000000, -24, 12 },
18046 { 0xAD78EBC5AC620000, 3, 20 },
18047 { 0x813F3978F8940984, 30, 28 },
18048 { 0xC097CE7BC90715B3, 56, 36 },
18049 { 0x8F7E32CE7BEA5C70, 83, 44 },
18050 { 0xD5D238A4ABE98068, 109, 52 },
18051 { 0x9F4F2726179A2245, 136, 60 },
18052 { 0xED63A231D4C4FB27, 162, 68 },
18053 { 0xB0DE65388CC8ADA8, 189, 76 },
18054 { 0x83C7088E1AAB65DB, 216, 84 },
18055 { 0xC45D1DF942711D9A, 242, 92 },
18056 { 0x924D692CA61BE758, 269, 100 },
18057 { 0xDA01EE641A708DEA, 295, 108 },
18058 { 0xA26DA3999AEF774A, 322, 116 },
18059 { 0xF209787BB47D6B85, 348, 124 },
18060 { 0xB454E4A179DD1877, 375, 132 },
18061 { 0x865B86925B9BC5C2, 402, 140 },
18062 { 0xC83553C5C8965D3D, 428, 148 },
18063 { 0x952AB45CFA97A0B3, 455, 156 },
18064 { 0xDE469FBD99A05FE3, 481, 164 },
18065 { 0xA59BC234DB398C25, 508, 172 },
18066 { 0xF6C69A72A3989F5C, 534, 180 },
18067 { 0xB7DCBF5354E9BECE, 561, 188 },
18068 { 0x88FCF317F22241E2, 588, 196 },
18069 { 0xCC20CE9BD35C78A5, 614, 204 },
18070 { 0x98165AF37B2153DF, 641, 212 },
18071 { 0xE2A0B5DC971F303A, 667, 220 },
18072 { 0xA8D9D1535CE3B396, 694, 228 },
18073 { 0xFB9B7CD9A4A7443C, 720, 236 },
18074 { 0xBB764C4CA7A44410, 747, 244 },
18075 { 0x8BAB8EEFB6409C1A, 774, 252 },
18076 { 0xD01FEF10A657842C, 800, 260 },
18077 { 0x9B10A4E5E9913129, 827, 268 },
18078 { 0xE7109BFBA19C0C9D, 853, 276 },
18079 { 0xAC2820D9623BF429, 880, 284 },
18080 { 0x80444B5E7AA7CF85, 907, 292 },
18081 { 0xBF21E44003ACDD2D, 933, 300 },
18082 { 0x8E679C2F5E44FF8F, 960, 308 },
18083 { 0xD433179D9C8CB841, 986, 316 },
18084 { 0x9E19DB92B4E31BA9, 1013, 324 },
18094 const int f =
kAlpha - e - 1;
18095 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
18097 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
18099 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
18101 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
18115 if (n >= 1000000000)
18117 pow10 = 1000000000;
18121 if (n >= 100000000)
18166inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
18167 std::uint64_t rest, std::uint64_t ten_k)
18194 && delta - rest >= ten_k
18195 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
18210 static_assert(
kAlpha >= -60,
"internal error");
18211 static_assert(
kGamma <= -32,
"internal error");
18228 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).f;
18229 std::uint64_t dist =
diyfp::sub(M_plus, w ).f;
18238 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
18240 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
18241 std::uint64_t p2 = M_plus.
f & (one.f - 1);
18249 std::uint32_t pow10{};
18277 const std::uint32_t d = p1 / pow10;
18278 const std::uint32_t r = p1 % pow10;
18284 buffer[length++] =
static_cast<char>(
'0' + d);
18303 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
18308 decimal_exponent += n;
18319 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
18320 grisu2_round(buffer, length, dist, delta, rest, ten_n);
18381 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
18383 const std::uint64_t d = p2 >> -one.e;
18384 const std::uint64_t r = p2 & (one.f - 1);
18391 buffer[length++] =
static_cast<char>(
'0' + d);
18416 decimal_exponent -= m;
18424 const std::uint64_t ten_m = one.f;
18448inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
18465 const diyfp c_minus_k(cached.
f, cached.
e);
18493 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
18494 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
18496 decimal_exponent = -cached.
k;
18506template<
typename FloatType>
18511 "internal error: not enough precision");
18563 auto k =
static_cast<std::uint32_t
>(e);
18569 *buf++ =
static_cast<char>(
'0' + k);
18573 *buf++ =
static_cast<char>(
'0' + (k / 10));
18575 *buf++ =
static_cast<char>(
'0' + k);
18579 *buf++ =
static_cast<char>(
'0' + (k / 100));
18581 *buf++ =
static_cast<char>(
'0' + (k / 10));
18583 *buf++ =
static_cast<char>(
'0' + k);
18601 int min_exp,
int max_exp)
18607 const int n = len + decimal_exponent;
18613 if (k <= n && n <= max_exp)
18618 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18622 return buf + (
static_cast<size_t>(n) + 2);
18625 if (0 < n && n <= max_exp)
18632 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18634 return buf + (
static_cast<size_t>(k) + 1U);
18637 if (min_exp < n && n <= 0)
18642 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18645 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18646 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18661 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18663 buf += 1 +
static_cast<size_t>(k);
18682template<
typename FloatType>
18687 static_cast<void>(last);
18691 if (std::signbit(
value))
18698#pragma GCC diagnostic push
18699#pragma GCC diagnostic ignored "-Wfloat-equal"
18710#pragma GCC diagnostic pop
18713 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18720 int decimal_exponent = 0;
18723 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18726 constexpr int kMinExp = -4;
18728 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18731 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18732 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18771template<
typename BasicJsonType>
18774 using string_t =
typename BasicJsonType::string_t;
18775 using number_float_t =
typename BasicJsonType::number_float_t;
18776 using number_integer_t =
typename BasicJsonType::number_integer_t;
18777 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18778 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
18779 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18780 static constexpr std::uint8_t UTF8_REJECT = 1;
18791 ,
loc(
std::localeconv())
18829 const bool pretty_print,
18831 const unsigned int indent_step,
18832 const unsigned int current_indent = 0)
18834 switch (val.m_data.m_type)
18838 if (val.m_data.m_value.object->empty())
18840 o->write_characters(
"{}", 2);
18846 o->write_characters(
"{\n", 2);
18849 const auto new_indent = current_indent + indent_step;
18856 auto i = val.m_data.m_value.object->cbegin();
18857 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18860 o->write_character(
'\"');
18862 o->write_characters(
"\": ", 3);
18864 o->write_characters(
",\n", 2);
18868 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18869 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18871 o->write_character(
'\"');
18873 o->write_characters(
"\": ", 3);
18876 o->write_character(
'\n');
18877 o->write_characters(
indent_string.c_str(), current_indent);
18878 o->write_character(
'}');
18882 o->write_character(
'{');
18885 auto i = val.m_data.m_value.object->cbegin();
18886 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18888 o->write_character(
'\"');
18890 o->write_characters(
"\":", 2);
18892 o->write_character(
',');
18896 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18897 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18898 o->write_character(
'\"');
18900 o->write_characters(
"\":", 2);
18903 o->write_character(
'}');
18911 if (val.m_data.m_value.array->empty())
18913 o->write_characters(
"[]", 2);
18919 o->write_characters(
"[\n", 2);
18922 const auto new_indent = current_indent + indent_step;
18929 for (
auto i = val.m_data.m_value.array->cbegin();
18930 i != val.m_data.m_value.array->cend() - 1; ++i)
18934 o->write_characters(
",\n", 2);
18940 dump(val.m_data.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
18942 o->write_character(
'\n');
18943 o->write_characters(
indent_string.c_str(), current_indent);
18944 o->write_character(
']');
18948 o->write_character(
'[');
18951 for (
auto i = val.m_data.m_value.array->cbegin();
18952 i != val.m_data.m_value.array->cend() - 1; ++i)
18955 o->write_character(
',');
18960 dump(val.m_data.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
18962 o->write_character(
']');
18970 o->write_character(
'\"');
18971 dump_escaped(*val.m_data.m_value.string,
ensure_ascii);
18972 o->write_character(
'\"');
18980 o->write_characters(
"{\n", 2);
18983 const auto new_indent = current_indent + indent_step;
18991 o->write_characters(
"\"bytes\": [", 10);
18993 if (!val.m_data.m_value.binary->empty())
18995 for (
auto i = val.m_data.m_value.binary->cbegin();
18996 i != val.m_data.m_value.binary->cend() - 1; ++i)
18999 o->write_characters(
", ", 2);
19001 dump_integer(val.m_data.m_value.binary->back());
19004 o->write_characters(
"],\n", 3);
19007 o->write_characters(
"\"subtype\": ", 11);
19008 if (val.m_data.m_value.binary->has_subtype())
19010 dump_integer(val.m_data.m_value.binary->subtype());
19014 o->write_characters(
"null", 4);
19016 o->write_character(
'\n');
19017 o->write_characters(
indent_string.c_str(), current_indent);
19018 o->write_character(
'}');
19022 o->write_characters(
"{\"bytes\":[", 10);
19024 if (!val.m_data.m_value.binary->empty())
19026 for (
auto i = val.m_data.m_value.binary->cbegin();
19027 i != val.m_data.m_value.binary->cend() - 1; ++i)
19030 o->write_character(
',');
19032 dump_integer(val.m_data.m_value.binary->back());
19035 o->write_characters(
"],\"subtype\":", 12);
19036 if (val.m_data.m_value.binary->has_subtype())
19038 dump_integer(val.m_data.m_value.binary->subtype());
19039 o->write_character(
'}');
19043 o->write_characters(
"null}", 5);
19051 if (val.m_data.m_value.boolean)
19053 o->write_characters(
"true", 4);
19057 o->write_characters(
"false", 5);
19064 dump_integer(val.m_data.m_value.number_integer);
19070 dump_integer(val.m_data.m_value.number_unsigned);
19076 dump_float(val.m_data.m_value.number_float);
19082 o->write_characters(
"<discarded>", 11);
19088 o->write_characters(
"null", 4);
19114 std::uint32_t codepoint{};
19122 for (std::size_t i = 0; i < s.size(); ++i)
19124 const auto byte =
static_cast<std::uint8_t
>(s[i]);
19126 switch (decode(
state, codepoint,
byte))
19185 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
19187 if (codepoint <= 0xFFFF)
19191 static_cast<std::uint16_t
>(codepoint)));
19197 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
19198 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
19199 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
19287 state = UTF8_ACCEPT;
19343 o->write_characters(
"\\ufffd", 6);
19347 o->write_characters(
"\xEF\xBF\xBD", 3);
19367 unsigned int count_digits(number_unsigned_t x)
noexcept
19369 unsigned int n_digits = 1;
19378 return n_digits + 1;
19382 return n_digits + 2;
19386 return n_digits + 3;
19398 static std::string hex_bytes(std::uint8_t
byte)
19400 std::string result =
"FF";
19401 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
19402 result[0] = nibble_to_hex[
byte / 16];
19403 result[1] = nibble_to_hex[
byte % 16];
19408 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
19409 bool is_negative_number(NumberType x)
19414 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
19415 bool is_negative_number(NumberType )
19430 std::is_integral<NumberType>::value ||
19431 std::is_same<NumberType, number_unsigned_t>::value ||
19432 std::is_same<NumberType, number_integer_t>::value ||
19433 std::is_same<NumberType, binary_char_t>::value,
19435 void dump_integer(NumberType x)
19437 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
19440 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
19441 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
19442 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
19443 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
19444 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
19445 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
19446 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
19447 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
19448 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
19449 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
19456 o->write_character(
'0');
19461 auto buffer_ptr = number_buffer.begin();
19463 number_unsigned_t abs_value;
19465 unsigned int n_chars{};
19467 if (is_negative_number(x))
19470 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
19473 n_chars = 1 + count_digits(abs_value);
19477 abs_value =
static_cast<number_unsigned_t
>(x);
19478 n_chars = count_digits(abs_value);
19486 buffer_ptr += n_chars;
19490 while (abs_value >= 100)
19492 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
19494 *(--buffer_ptr) = digits_to_99[digits_index][1];
19495 *(--buffer_ptr) = digits_to_99[digits_index][0];
19498 if (abs_value >= 10)
19500 const auto digits_index =
static_cast<unsigned>(abs_value);
19501 *(--buffer_ptr) = digits_to_99[digits_index][1];
19502 *(--buffer_ptr) = digits_to_99[digits_index][0];
19506 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19509 o->write_characters(number_buffer.data(), n_chars);
19520 void dump_float(number_float_t x)
19523 if (!std::isfinite(x))
19525 o->write_characters(
"null", 4);
19534 static constexpr bool is_ieee_single_or_double
19535 = (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) ||
19536 (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);
19538 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
19541 void dump_float(number_float_t x, std::true_type )
19543 auto* begin = number_buffer.data();
19544 auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
19546 o->write_characters(begin,
static_cast<size_t>(end - begin));
19549 void dump_float(number_float_t x, std::false_type )
19552 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
19556 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
19561 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
19564 if (thousands_sep !=
'\0')
19567 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
19568 std::fill(end, number_buffer.end(),
'\0');
19569 JSON_ASSERT((end - number_buffer.begin()) <= len);
19570 len = (end - number_buffer.begin());
19574 if (decimal_point !=
'\0' && decimal_point !=
'.')
19577 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
19578 if (dec_pos != number_buffer.end())
19584 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
19587 const bool value_is_int_like =
19588 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
19591 return c ==
'.' || c ==
'e';
19594 if (value_is_int_like)
19596 o->write_characters(
".0", 2);
19621 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19623 static const std::array<std::uint8_t, 400> utf8d =
19626 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,
19627 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,
19628 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,
19629 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,
19630 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,
19631 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,
19632 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,
19633 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19634 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19635 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19636 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,
19637 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,
19638 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,
19639 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
19644 const std::uint8_t type = utf8d[byte];
19646 codep = (state != UTF8_ACCEPT)
19647 ? (
byte & 0x3fu) | (codep << 6u)
19648 : (0xFFu >> type) & (byte);
19650 const std::size_t index = 256u + (
static_cast<size_t>(state) * 16u) +
static_cast<size_t>(type);
19652 state = utf8d[index];
19661 number_unsigned_t remove_sign(number_unsigned_t x)
19676 number_unsigned_t remove_sign(number_integer_t x)
noexcept
19678 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19679 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
19684 output_adapter_t<char> o =
nullptr;
19726#include <functional>
19727#include <initializer_list>
19730#include <stdexcept>
19731#include <type_traits>
19744template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19745 class Allocator = std::allocator<std::pair<const Key, T>>>
19750 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19755#ifdef JSON_HAS_CPP_14
19765 template <
class It>
19768 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19773 for (
auto it = this->begin(); it != this->end(); ++it)
19775 if (m_compare(it->first, key))
19777 return {it,
false};
19780 Container::emplace_back(key, std::forward<T>(t));
19781 return {std::prev(this->end()),
true};
19786 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19788 for (
auto it = this->begin(); it != this->end(); ++it)
19790 if (m_compare(it->first, key))
19792 return {it,
false};
19795 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19796 return {std::prev(this->end()),
true};
19801 return emplace(key, T{}).first->second;
19808 return emplace(std::forward<KeyType>(key), T{}).first->second;
19820 return at(std::forward<KeyType>(key));
19825 for (
auto it = this->begin(); it != this->end(); ++it)
19827 if (m_compare(it->first, key))
19833 JSON_THROW(std::out_of_range(
"key not found"));
19840 for (
auto it = this->begin(); it != this->end(); ++it)
19842 if (m_compare(it->first, key))
19848 JSON_THROW(std::out_of_range(
"key not found"));
19853 for (
auto it = this->begin(); it != this->end(); ++it)
19855 if (m_compare(it->first, key))
19861 JSON_THROW(std::out_of_range(
"key not found"));
19866 const T &
at(KeyType && key)
const
19868 for (
auto it = this->begin(); it != this->end(); ++it)
19870 if (m_compare(it->first, key))
19876 JSON_THROW(std::out_of_range(
"key not found"));
19881 for (
auto it = this->begin(); it != this->end(); ++it)
19883 if (m_compare(it->first, key))
19886 for (
auto next = it; ++next != this->end(); ++it)
19891 Container::pop_back();
19902 for (
auto it = this->begin(); it != this->end(); ++it)
19904 if (m_compare(it->first, key))
19907 for (
auto next = it; ++next != this->end(); ++it)
19912 Container::pop_back();
19921 return erase(pos, std::next(pos));
19931 const auto elements_affected = std::distance(first, last);
19932 const auto offset = std::distance(Container::begin(), first);
19954 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
19957 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19965 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
19974 return Container::begin() + offset;
19979 for (
auto it = this->begin(); it != this->end(); ++it)
19981 if (m_compare(it->first, key))
19993 for (
auto it = this->begin(); it != this->end(); ++it)
19995 if (m_compare(it->first, key))
20005 for (
auto it = this->begin(); it != this->end(); ++it)
20007 if (m_compare(it->first, key))
20012 return Container::end();
20019 for (
auto it = this->begin(); it != this->end(); ++it)
20021 if (m_compare(it->first, key))
20026 return Container::end();
20031 for (
auto it = this->begin(); it != this->end(); ++it)
20033 if (m_compare(it->first, key))
20038 return Container::end();
20043 return emplace(value.first, std::move(value.second));
20048 for (
auto it = this->begin(); it != this->end(); ++it)
20050 if (m_compare(it->first, value.first))
20052 return {it,
false};
20055 Container::push_back(value);
20056 return {--this->end(),
true};
20059 template<
typename InputIt>
20060 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20061 std::input_iterator_tag>::value>::type;
20063 template<
typename InputIt,
typename = require_input_iter<InputIt>>
20066 for (
auto it = first; it != last; ++it)
20079#if defined(JSON_HAS_CPP_17)
20080 #if JSON_HAS_STATIC_RTTI
20083 #include <string_view>
20113 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
20119 friend class ::nlohmann::json_pointer;
20123 template<
typename BasicJsonType,
typename InputType>
20124 friend class ::nlohmann::detail::parser;
20125 friend ::nlohmann::detail::serializer<basic_json>;
20126 template<
typename BasicJsonType>
20127 friend class ::nlohmann::detail::iter_impl;
20128 template<
typename BasicJsonType,
typename CharType>
20129 friend class ::nlohmann::detail::binary_writer;
20130 template<
typename BasicJsonType,
typename InputType,
typename SAX>
20131 friend class ::nlohmann::detail::binary_reader;
20132 template<
typename BasicJsonType,
typename InputAdapterType>
20133 friend class ::nlohmann::detail::json_sax_dom_parser;
20134 template<
typename BasicJsonType,
typename InputAdapterType>
20135 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
20136 friend class ::nlohmann::detail::exception;
20140 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
20144 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
20146 template<
typename InputAdapterType>
20147 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
20148 InputAdapterType adapter,
20150 const bool allow_exceptions =
true,
20151 const bool ignore_comments =
false
20154 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20155 std::move(cb), allow_exceptions, ignore_comments);
20159 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
20160 template<
typename BasicJsonType>
20161 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
20162 template<
typename BasicJsonType>
20163 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
20164 template<
typename Iterator>
20165 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
20166 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
20168 template<
typename CharType>
20169 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
20171 template<
typename InputType>
20172 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
20173 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
20176 using serializer = ::nlohmann::detail::serializer<basic_json>;
20182 template<
typename T,
typename SFINAE>
20240 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
20242 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
20269 result[
"copyright"] =
"(C) 2013-2025 Niels Lohmann";
20270 result[
"name"] =
"JSON for Modern C++";
20271 result[
"url"] =
"https://github.com/nlohmann/json";
20272 result[
"version"][
"string"] =
20281 result[
"platform"] =
"win32";
20282#elif defined __linux__
20283 result[
"platform"] =
"linux";
20284#elif defined __APPLE__
20285 result[
"platform"] =
"apple";
20286#elif defined __unix__
20287 result[
"platform"] =
"unix";
20289 result[
"platform"] =
"unknown";
20292#if defined(__ICC) || defined(__INTEL_COMPILER)
20293 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
20294#elif defined(__clang__)
20295 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
20296#elif defined(__GNUC__) || defined(__GNUG__)
20297 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
20298 std::to_string(__GNUC__),
'.',
20299 std::to_string(__GNUC_MINOR__),
'.',
20300 std::to_string(__GNUC_PATCHLEVEL__))
20303#elif defined(__HP_cc) || defined(__HP_aCC)
20304 result[
"compiler"] =
"hp"
20305#elif defined(__IBMCPP__)
20306 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
20307#elif defined(_MSC_VER)
20308 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
20309#elif defined(__PGI)
20310 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
20311#elif defined(__SUNPRO_CC)
20312 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
20314 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
20317#if defined(_MSVC_LANG)
20318 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
20319#elif defined(__cplusplus)
20320 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
20322 result[
"compiler"][
"c++"] =
"unknown";
20340#if defined(JSON_HAS_CPP_14)
20343 using default_object_comparator_t = std::less<>;
20353 AllocatorType<std::pair<
const StringType,
20358 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
20382 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
20393 template<
typename T,
typename... Args>
20395 static T* create(Args&& ... args)
20397 AllocatorType<T> alloc;
20398 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
20400 auto deleter = [&](T * obj)
20402 AllocatorTraits::deallocate(alloc, obj, 1);
20404 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
20405 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
20407 return obj.release();
20453 number_integer_t number_integer;
20455 number_unsigned_t number_unsigned;
20457 number_float_t number_float;
20460 json_value() =
default;
20462 json_value(boolean_t v) noexcept : boolean(v) {}
20468 json_value(number_float_t v) noexcept :
number_float(v) {}
20470 json_value(value_t t)
20474 case value_t::object:
20476 object = create<object_t>();
20480 case value_t::array:
20482 array = create<array_t>();
20486 case value_t::string:
20488 string = create<string_t>(
"");
20492 case value_t::binary:
20494 binary = create<binary_t>();
20498 case value_t::boolean:
20500 boolean =
static_cast<boolean_t
>(
false);
20504 case value_t::number_integer:
20510 case value_t::number_unsigned:
20516 case value_t::number_float:
20522 case value_t::null:
20528 case value_t::discarded:
20534 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0",
nullptr));
20542 json_value(
const string_t& value) :
string(create<string_t>(
value)) {}
20545 json_value(string_t&& value) :
string(create<string_t>(std::move(
value))) {}
20548 json_value(
const object_t& value) :
object(create<object_t>(
value)) {}
20551 json_value(object_t&& value) :
object(create<object_t>(std::move(
value))) {}
20554 json_value(
const array_t& value) :
array(create<array_t>(
value)) {}
20557 json_value(array_t&& value) :
array(create<array_t>(std::move(
value))) {}
20560 json_value(
const typename binary_t::container_type& value) :
binary(create<binary_t>(
value)) {}
20563 json_value(
typename binary_t::container_type&& value) :
binary(create<binary_t>(std::move(
value))) {}
20566 json_value(
const binary_t& value) :
binary(create<binary_t>(
value)) {}
20569 json_value(binary_t&& value) :
binary(create<binary_t>(std::move(
value))) {}
20571 void destroy(value_t t)
20574 (t == value_t::object &&
object ==
nullptr) ||
20575 (t == value_t::array && array ==
nullptr) ||
20576 (t == value_t::string &&
string ==
nullptr) ||
20577 (t == value_t::binary && binary ==
nullptr)
20583 if (t == value_t::array || t == value_t::object)
20586 std::vector<basic_json> stack;
20589 if (t == value_t::array)
20591 stack.reserve(
array->size());
20592 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
20596 stack.reserve(
object->size());
20597 for (
auto&& it : *
object)
20599 stack.push_back(std::move(it.second));
20603 while (!stack.empty())
20606 basic_json current_item(std::move(stack.back()));
20611 if (current_item.is_array())
20613 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
20615 current_item.m_data.m_value.array->clear();
20617 else if (current_item.is_object())
20619 for (
auto&& it : *current_item.m_data.m_value.object)
20621 stack.push_back(std::move(it.second));
20624 current_item.m_data.m_value.object->clear();
20634 case value_t::object:
20636 AllocatorType<object_t> alloc;
20637 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20638 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20642 case value_t::array:
20644 AllocatorType<array_t> alloc;
20645 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20646 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20650 case value_t::string:
20652 AllocatorType<string_t> alloc;
20653 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20654 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20658 case value_t::binary:
20660 AllocatorType<binary_t> alloc;
20661 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20662 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20666 case value_t::null:
20667 case value_t::boolean:
20668 case value_t::number_integer:
20669 case value_t::number_unsigned:
20670 case value_t::number_float:
20671 case value_t::discarded:
20699 void assert_invariant(
bool check_parents =
true) const noexcept
20701 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
20702 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
20703 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
20704 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
20706#if JSON_DIAGNOSTICS
20710 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
20712 return j.m_parent ==
this;
20717 static_cast<void>(check_parents);
20722#if JSON_DIAGNOSTICS
20723 switch (m_data.m_type)
20725 case value_t::array:
20727 for (
auto& element : *m_data.m_value.array)
20729 element.m_parent =
this;
20734 case value_t::object:
20736 for (
auto& element : *m_data.m_value.object)
20738 element.second.m_parent =
this;
20743 case value_t::null:
20744 case value_t::string:
20745 case value_t::boolean:
20746 case value_t::number_integer:
20747 case value_t::number_unsigned:
20748 case value_t::number_float:
20749 case value_t::binary:
20750 case value_t::discarded:
20757 iterator set_parents(iterator it,
typename iterator::difference_type count_set_parents)
20759#if JSON_DIAGNOSTICS
20760 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20762 (it + i)->m_parent =
this;
20765 static_cast<void>(count_set_parents);
20772#if JSON_DIAGNOSTICS
20787#ifdef JSON_HEDLEY_MSVC_VERSION
20788#pragma warning(push )
20789#pragma warning(disable : 4127)
20796#ifdef JSON_HEDLEY_MSVC_VERSION
20797#pragma warning( pop )
20802 static_cast<void>(j);
20803 static_cast<void>(old_capacity);
20835 assert_invariant();
20843 assert_invariant();
20848 template <
typename CompatibleType,
20853 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20854 std::forward<CompatibleType>(val))))
20856 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20858 assert_invariant();
20863 template <
typename BasicJsonType,
20867#if JSON_DIAGNOSTIC_POSITIONS
20868 : start_position(val.start_pos()),
20869 end_position(val.end_pos())
20872 using other_boolean_t =
typename BasicJsonType::boolean_t;
20873 using other_number_float_t =
typename BasicJsonType::number_float_t;
20874 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20875 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20876 using other_string_t =
typename BasicJsonType::string_t;
20877 using other_object_t =
typename BasicJsonType::object_t;
20878 using other_array_t =
typename BasicJsonType::array_t;
20879 using other_binary_t =
typename BasicJsonType::binary_t;
20881 switch (val.type())
20883 case value_t::boolean:
20886 case value_t::number_float:
20889 case value_t::number_integer:
20892 case value_t::number_unsigned:
20895 case value_t::string:
20898 case value_t::object:
20901 case value_t::array:
20904 case value_t::binary:
20907 case value_t::null:
20910 case value_t::discarded:
20911 m_data.m_type = value_t::discarded;
20919 assert_invariant();
20925 bool type_deduction =
true,
20926 value_t manual_type = value_t::array)
20930 bool is_an_object = std::all_of(init.begin(), init.end(),
20936 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
20940 if (!type_deduction)
20943 if (manual_type == value_t::array)
20945 is_an_object =
false;
20958 m_data.m_type = value_t::object;
20959 m_data.m_value = value_t::object;
20961 for (
auto& element_ref : init)
20964 m_data.m_value.object->emplace(
20965 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
20966 std::move((*element.m_data.m_value.array)[1]));
20972 m_data.m_type = value_t::array;
20973 m_data.m_value.array = create<array_t>(init.begin(), init.end());
20977 assert_invariant();
20986 res.m_data.m_type = value_t::binary;
20987 res.m_data.m_value = init;
20994 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20997 res.m_data.m_type = value_t::binary;
20998 res.m_data.m_value =
binary_t(init, subtype);
21008 res.m_data.m_type = value_t::binary;
21009 res.m_data.m_value = std::move(init);
21016 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
21019 res.m_data.m_type = value_t::binary;
21020 res.m_data.m_value =
binary_t(std::move(init), subtype);
21029 return basic_json(init,
false, value_t::array);
21037 return basic_json(init,
false, value_t::object);
21046 assert_invariant();
21051 template <
class InputIT,
typename std::enable_if <
21052 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
21053 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
21066 m_data.m_type = first.m_object->m_data.m_type;
21071 case value_t::boolean:
21072 case value_t::number_float:
21073 case value_t::number_integer:
21074 case value_t::number_unsigned:
21075 case value_t::string:
21078 || !last.m_it.primitive_iterator.is_end()))
21085 case value_t::null:
21086 case value_t::object:
21087 case value_t::array:
21088 case value_t::binary:
21089 case value_t::discarded:
21096 case value_t::number_integer:
21098 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
21102 case value_t::number_unsigned:
21104 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
21108 case value_t::number_float:
21110 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
21114 case value_t::boolean:
21116 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
21120 case value_t::string:
21122 m_data.m_value = *first.m_object->m_data.m_value.string;
21126 case value_t::object:
21128 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
21129 last.m_it.object_iterator);
21133 case value_t::array:
21135 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
21136 last.m_it.array_iterator);
21140 case value_t::binary:
21142 m_data.m_value = *first.m_object->m_data.m_value.binary;
21146 case value_t::null:
21147 case value_t::discarded:
21153 assert_invariant();
21160 template<
typename JsonRef,
21162 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
21168 : json_base_class_t(other)
21170 , start_position(other.start_position)
21171 , end_position(other.end_position)
21176 other.assert_invariant();
21180 case value_t::object:
21182 m_data.m_value = *other.m_data.m_value.object;
21186 case value_t::array:
21188 m_data.m_value = *other.m_data.m_value.array;
21192 case value_t::string:
21194 m_data.m_value = *other.m_data.m_value.string;
21198 case value_t::boolean:
21200 m_data.m_value = other.m_data.m_value.boolean;
21204 case value_t::number_integer:
21206 m_data.m_value = other.m_data.m_value.number_integer;
21210 case value_t::number_unsigned:
21212 m_data.m_value = other.m_data.m_value.number_unsigned;
21216 case value_t::number_float:
21218 m_data.m_value = other.m_data.m_value.number_float;
21222 case value_t::binary:
21224 m_data.m_value = *other.m_data.m_value.binary;
21228 case value_t::null:
21229 case value_t::discarded:
21235 assert_invariant();
21241 : json_base_class_t(std::forward<json_base_class_t>(other)),
21242 m_data(std::move(other.m_data))
21243#if JSON_DIAGNOSTIC_POSITIONS
21244 , start_position(other.start_position)
21245 , end_position(other.end_position)
21249 other.assert_invariant(
false);
21252 other.m_data.m_type = value_t::null;
21253 other.m_data.m_value = {};
21255#if JSON_DIAGNOSTIC_POSITIONS
21256 other.start_position = std::string::npos;
21257 other.end_position = std::string::npos;
21261 assert_invariant();
21267 std::is_nothrow_move_constructible<value_t>::value&&
21268 std::is_nothrow_move_assignable<value_t>::value&&
21269 std::is_nothrow_move_constructible<json_value>::value&&
21270 std::is_nothrow_move_assignable<json_value>::value&&
21271 std::is_nothrow_move_assignable<json_base_class_t>::value
21275 other.assert_invariant();
21281#if JSON_DIAGNOSTIC_POSITIONS
21282 swap(start_position, other.start_position);
21283 swap(end_position, other.end_position);
21286 json_base_class_t::operator=(std::move(other));
21289 assert_invariant();
21297 assert_invariant(
false);
21314 const char indent_char =
' ',
21315 const bool ensure_ascii =
false,
21323 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
21327 s.dump(*
this,
false, ensure_ascii, 0);
21358 return m_data.m_type == value_t::null;
21365 return m_data.m_type == value_t::boolean;
21379 return m_data.m_type == value_t::number_integer ||
m_data.m_type == value_t::number_unsigned;
21386 return m_data.m_type == value_t::number_unsigned;
21393 return m_data.m_type == value_t::number_float;
21400 return m_data.m_type == value_t::object;
21407 return m_data.m_type == value_t::array;
21414 return m_data.m_type == value_t::string;
21421 return m_data.m_type == value_t::binary;
21428 return m_data.m_type == value_t::discarded;
21446 boolean_t get_impl(boolean_t* )
const
21450 return m_data.m_value.boolean;
21457 object_t* get_impl_ptr(object_t* )
noexcept
21459 return is_object() ? m_data.m_value.object :
nullptr;
21463 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
21465 return is_object() ? m_data.m_value.object :
nullptr;
21469 array_t* get_impl_ptr(array_t* )
noexcept
21471 return is_array() ? m_data.m_value.array :
nullptr;
21475 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
21477 return is_array() ? m_data.m_value.array :
nullptr;
21483 return is_string() ? m_data.m_value.string :
nullptr;
21489 return is_string() ? m_data.m_value.string :
nullptr;
21493 boolean_t* get_impl_ptr(boolean_t* )
noexcept
21495 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21499 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
21501 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21507 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21513 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21519 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21525 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21531 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21537 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21543 return is_binary() ? m_data.m_value.binary :
nullptr;
21549 return is_binary() ? m_data.m_value.binary :
nullptr;
21563 template<
typename ReferenceType,
typename ThisType>
21564 static ReferenceType get_ref_impl(ThisType& obj)
21567 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
21574 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
21584 template<
typename PointerType,
typename std::enable_if<
21585 std::is_pointer<PointerType>::value,
int>::type = 0>
21586 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21589 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21594 template <
typename PointerType,
typename std::enable_if <
21595 std::is_pointer<PointerType>::value&&
21596 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
21597 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21600 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21642 template <
typename ValueType,
21648 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21650 auto ret = ValueType();
21651 JSONSerializer<ValueType>::from_json(*
this, ret);
21685 template <
typename ValueType,
21687 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
21689 ValueType get_impl(detail::priority_tag<1> )
const noexcept(
noexcept(
21690 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21692 return JSONSerializer<ValueType>::from_json(*
this);
21710 template <
typename BasicJsonType,
21712 detail::is_basic_json<BasicJsonType>::value,
21714 BasicJsonType get_impl(detail::priority_tag<2> )
const
21733 template<
typename BasicJsonType,
21735 std::is_same<BasicJsonType, basic_json_t>::value,
21737 basic_json get_impl(detail::priority_tag<3> )
const
21746 template<
typename PointerType,
21748 std::is_pointer<PointerType>::value,
21750 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
21751 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21754 return get_ptr<PointerType>();
21781 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21782#if defined(JSON_HAS_CPP_14)
21786 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21792 static_assert(!std::is_reference<ValueTypeCV>::value,
21793 "get() cannot be used with reference types, you might want to use get_ref()");
21794 return get_impl<ValueType>(detail::priority_tag<4> {});
21824 template<
typename PointerType,
typename std::enable_if<
21825 std::is_pointer<PointerType>::value,
int>::type = 0>
21826 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
21834 template <
typename ValueType,
21839 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
21840 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21842 JSONSerializer<ValueType>::from_json(*
this, v);
21848 template<
typename ValueType,
21859 typename T, std::size_t N,
21860 typename Array = T (&)[N],
21864 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21865 std::declval<const basic_json_t&>(), v)))
21867 JSONSerializer<Array>::from_json(*
this, v);
21873 template<
typename ReferenceType,
typename std::enable_if<
21874 std::is_reference<ReferenceType>::value,
int>::type = 0>
21878 return get_ref_impl<ReferenceType>(*
this);
21883 template <
typename ReferenceType,
typename std::enable_if <
21884 std::is_reference<ReferenceType>::value&&
21885 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
21889 return get_ref_impl<ReferenceType>(*
this);
21921 template <
typename ValueType,
typename std::enable_if <
21929#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21932#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
21936 >::value,
int >::type = 0 >
21986 return set_parent(
m_data.m_value.array->at(idx));
22009 return m_data.m_value.array->at(idx);
22033 auto it =
m_data.m_value.object->find(
key);
22034 if (it ==
m_data.m_value.object->end())
22038 return set_parent(it->second);
22053 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22054 if (it ==
m_data.m_value.object->end())
22058 return set_parent(it->second);
22071 auto it =
m_data.m_value.object->find(
key);
22072 if (it ==
m_data.m_value.object->end())
22091 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22092 if (it ==
m_data.m_value.object->end())
22106 m_data.m_type = value_t::array;
22107 m_data.m_value.array = create<array_t>();
22108 assert_invariant();
22115 if (idx >=
m_data.m_value.array->size())
22117#if JSON_DIAGNOSTICS
22119 const auto old_size =
m_data.m_value.array->size();
22120 const auto old_capacity =
m_data.m_value.array->capacity();
22122 m_data.m_value.array->resize(idx + 1);
22124#if JSON_DIAGNOSTICS
22133 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
22136 assert_invariant();
22139 return m_data.m_value.array->operator[](idx);
22152 return m_data.m_value.array->operator[](idx);
22165 m_data.m_type = value_t::object;
22166 m_data.m_value.object = create<object_t>();
22167 assert_invariant();
22173 auto result =
m_data.m_value.object->emplace(std::move(
key),
nullptr);
22174 return set_parent(result.first->second);
22187 auto it =
m_data.m_value.object->find(
key);
22197 template<
typename T>
22203 template<
typename T>
22218 m_data.m_type = value_t::object;
22219 m_data.m_value.object = create<object_t>();
22220 assert_invariant();
22226 auto result =
m_data.m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
22227 return set_parent(result.first->second);
22242 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22251 template<
typename KeyType>
22253 object_comparator_t,
const typename object_t::key_type&, KeyType >;
22255 template<
typename ValueType>
22256 using value_return_type = std::conditional <
22258 string_t,
typename std::decay<ValueType>::type >;
22266 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22267 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const
22279 return default_value;
22287 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22291 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22292 ReturnType
value(
const typename object_t::key_type&
key, ValueType && default_value)
const
22304 return std::forward<ValueType>(default_value);
22315 && is_comparable_with_object_key<KeyType>::value
22317 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22318 ValueType
value(KeyType &&
key,
const ValueType& default_value)
const
22324 const auto it =
find(std::forward<KeyType>(
key));
22330 return default_value;
22338 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
22342 && is_comparable_with_object_key<KeyType>::value
22344 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22345 ReturnType
value(KeyType &&
key, ValueType && default_value)
const
22351 const auto it =
find(std::forward<KeyType>(
key));
22357 return std::forward<ValueType>(default_value);
22367 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22380 return default_value;
22389 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22392 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22405 return std::forward<ValueType>(default_value);
22415 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22417 ValueType
value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
22419 return value(ptr.convert(), default_value);
22422 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
22426 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22430 return value(ptr.convert(), std::forward<ValueType>(default_value));
22468 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22469 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22478 IteratorType result =
end();
22482 case value_t::boolean:
22483 case value_t::number_float:
22484 case value_t::number_integer:
22485 case value_t::number_unsigned:
22486 case value_t::string:
22487 case value_t::binary:
22496 AllocatorType<string_t> alloc;
22497 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
22498 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
22499 m_data.m_value.string =
nullptr;
22503 AllocatorType<binary_t> alloc;
22504 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
22505 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
22506 m_data.m_value.binary =
nullptr;
22509 m_data.m_type = value_t::null;
22510 assert_invariant();
22514 case value_t::object:
22516 result.m_it.object_iterator =
m_data.m_value.object->erase(pos.m_it.object_iterator);
22520 case value_t::array:
22522 result.m_it.array_iterator =
m_data.m_value.array->erase(pos.m_it.array_iterator);
22526 case value_t::null:
22527 case value_t::discarded:
22538 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22539 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22540 IteratorType
erase(IteratorType first, IteratorType last)
22548 IteratorType result =
end();
22552 case value_t::boolean:
22553 case value_t::number_float:
22554 case value_t::number_integer:
22555 case value_t::number_unsigned:
22556 case value_t::string:
22557 case value_t::binary:
22560 || !last.m_it.primitive_iterator.is_end()))
22567 AllocatorType<string_t> alloc;
22568 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
22569 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
22570 m_data.m_value.string =
nullptr;
22574 AllocatorType<binary_t> alloc;
22575 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
22576 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
22577 m_data.m_value.binary =
nullptr;
22580 m_data.m_type = value_t::null;
22581 assert_invariant();
22585 case value_t::object:
22587 result.m_it.object_iterator =
m_data.m_value.object->erase(first.m_it.object_iterator,
22588 last.m_it.object_iterator);
22592 case value_t::array:
22594 result.m_it.array_iterator =
m_data.m_value.array->erase(first.m_it.array_iterator,
22595 last.m_it.array_iterator);
22599 case value_t::null:
22600 case value_t::discarded:
22611 size_type erase_internal(KeyType &&
key)
22619 return m_data.m_value.object->erase(std::forward<KeyType>(
key));
22623 !detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
22624 size_type erase_internal(KeyType &&
key)
22632 const auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22633 if (it != m_data.m_value.object->end())
22635 m_data.m_value.object->erase(it);
22649 return erase_internal(
key);
22658 return erase_internal(std::forward<KeyType>(
key));
22694 auto result =
end();
22698 result.m_it.object_iterator =
m_data.m_value.object->find(
key);
22708 auto result =
cend();
22712 result.m_it.object_iterator =
m_data.m_value.object->find(
key);
22724 auto result =
end();
22728 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22740 auto result =
cend();
22744 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22788 return ptr.contains(
this);
22791 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22795 return ptr.contains(
this);
22812 result.set_begin();
22828 result.set_begin();
22908 return ref.items();
22919 return ref.items();
22926 return iteration_proxy<iterator>(*
this);
22931 iteration_proxy<const_iterator>
items() const noexcept
22933 return iteration_proxy<const_iterator>(*
this);
22951 case value_t::null:
22957 case value_t::array:
22960 return m_data.m_value.array->empty();
22963 case value_t::object:
22966 return m_data.m_value.object->empty();
22969 case value_t::string:
22970 case value_t::boolean:
22971 case value_t::number_integer:
22972 case value_t::number_unsigned:
22973 case value_t::number_float:
22974 case value_t::binary:
22975 case value_t::discarded:
22990 case value_t::null:
22996 case value_t::array:
22999 return m_data.m_value.array->size();
23002 case value_t::object:
23005 return m_data.m_value.object->size();
23008 case value_t::string:
23009 case value_t::boolean:
23010 case value_t::number_integer:
23011 case value_t::number_unsigned:
23012 case value_t::number_float:
23013 case value_t::binary:
23014 case value_t::discarded:
23029 case value_t::array:
23032 return m_data.m_value.array->max_size();
23035 case value_t::object:
23038 return m_data.m_value.object->max_size();
23041 case value_t::null:
23042 case value_t::string:
23043 case value_t::boolean:
23044 case value_t::number_integer:
23045 case value_t::number_unsigned:
23046 case value_t::number_float:
23047 case value_t::binary:
23048 case value_t::discarded:
23072 case value_t::number_integer:
23074 m_data.m_value.number_integer = 0;
23078 case value_t::number_unsigned:
23080 m_data.m_value.number_unsigned = 0;
23084 case value_t::number_float:
23086 m_data.m_value.number_float = 0.0;
23090 case value_t::boolean:
23092 m_data.m_value.boolean =
false;
23096 case value_t::string:
23098 m_data.m_value.string->clear();
23102 case value_t::binary:
23104 m_data.m_value.binary->clear();
23108 case value_t::array:
23110 m_data.m_value.array->clear();
23114 case value_t::object:
23116 m_data.m_value.object->clear();
23120 case value_t::null:
23121 case value_t::discarded:
23140 m_data.m_type = value_t::array;
23141 m_data.m_value = value_t::array;
23142 assert_invariant();
23146 const auto old_capacity =
m_data.m_value.array->capacity();
23147 m_data.m_value.array->push_back(std::move(val));
23148 set_parent(
m_data.m_value.array->back(), old_capacity);
23173 m_data.m_type = value_t::array;
23174 m_data.m_value = value_t::array;
23175 assert_invariant();
23179 const auto old_capacity =
m_data.m_value.array->capacity();
23180 m_data.m_value.array->push_back(val);
23181 set_parent(
m_data.m_value.array->back(), old_capacity);
23205 m_data.m_type = value_t::object;
23206 m_data.m_value = value_t::object;
23207 assert_invariant();
23211 auto res =
m_data.m_value.object->insert(val);
23212 set_parent(res.first->second);
23227 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
23230 push_back(
typename object_t::value_type(
23231 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23249 template<
class... Args>
23261 m_data.m_type = value_t::array;
23262 m_data.m_value = value_t::array;
23263 assert_invariant();
23267 const auto old_capacity =
m_data.m_value.array->capacity();
23268 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
23269 return set_parent(
m_data.m_value.array->back(), old_capacity);
23274 template<
class... Args>
23286 m_data.m_type = value_t::object;
23287 m_data.m_value = value_t::object;
23288 assert_invariant();
23292 auto res =
m_data.m_value.object->emplace(std::forward<Args>(args)...);
23293 set_parent(res.first->second);
23297 it.m_it.object_iterator = res.first;
23300 return {it, res.second};
23306 template<
typename... Args>
23312 auto insert_pos = std::distance(
m_data.m_value.array->begin(), pos.m_it.array_iterator);
23313 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
23314 result.m_it.array_iterator =
m_data.m_value.array->begin() + insert_pos;
23348 return insert(pos, val);
23399 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
23444 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
23462 m_data.m_type = value_t::object;
23463 m_data.m_value.object = create<object_t>();
23464 assert_invariant();
23484 for (
auto it = first; it != last; ++it)
23486 if (merge_objects && it.value().is_object())
23488 auto it2 =
m_data.m_value.object->find(it.key());
23489 if (it2 !=
m_data.m_value.object->end())
23491 it2->second.update(it.value(),
true);
23495 m_data.m_value.object->operator[](it.key()) = it.value();
23496#if JSON_DIAGNOSTICS
23497 m_data.m_value.object->operator[](it.key()).m_parent =
this;
23505 std::is_nothrow_move_constructible<value_t>::value&&
23506 std::is_nothrow_move_assignable<value_t>::value&&
23507 std::is_nothrow_move_constructible<json_value>::value&&
23508 std::is_nothrow_move_assignable<json_value>::value
23515 other.set_parents();
23516 assert_invariant();
23522 std::is_nothrow_move_constructible<value_t>::value&&
23523 std::is_nothrow_move_assignable<value_t>::value&&
23524 std::is_nothrow_move_constructible<json_value>::value&&
23525 std::is_nothrow_move_assignable<json_value>::value
23597 void swap(
typename binary_t::container_type& other)
23622#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23623 const auto lhs_type = lhs.type(); \
23624 const auto rhs_type = rhs.type(); \
23626 if (lhs_type == rhs_type) \
23628 switch (lhs_type) \
23630 case value_t::array: \
23631 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23633 case value_t::object: \
23634 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23636 case value_t::null: \
23637 return (null_result); \
23639 case value_t::string: \
23640 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23642 case value_t::boolean: \
23643 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23645 case value_t::number_integer: \
23646 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23648 case value_t::number_unsigned: \
23649 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23651 case value_t::number_float: \
23652 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23654 case value_t::binary: \
23655 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23657 case value_t::discarded: \
23659 return (unordered_result); \
23662 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23664 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23666 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23668 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23670 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23672 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23674 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23676 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23678 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23680 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23682 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23684 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23686 else if(compares_unordered(lhs, rhs))\
23688 return (unordered_result);\
23691 return (default_result);
23702 || (
rhs.is_number_float() && std::isnan(
rhs.m_data.m_value.number_float) && lhs.
is_number()))
23706#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23715 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
23717 return compares_unordered(*
this, rhs, inverse);
23721#if JSON_HAS_THREE_WAY_COMPARISON
23724 bool operator==(const_reference rhs)
const noexcept
23727#pragma GCC diagnostic push
23728#pragma GCC diagnostic ignored "-Wfloat-equal"
23730 const_reference lhs = *
this;
23733#pragma GCC diagnostic pop
23739 template<
typename ScalarType>
23740 requires std::is_scalar_v<ScalarType>
23741 bool operator==(ScalarType rhs)
const noexcept
23743 return *
this == basic_json(rhs);
23748 bool operator!=(const_reference rhs)
const noexcept
23750 if (compares_unordered(rhs,
true))
23759 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23761 const_reference lhs = *
this;
23765 std::partial_ordering::equivalent,
23766 std::partial_ordering::unordered,
23767 lhs_type <=> rhs_type)
23772 template<
typename ScalarType>
23773 requires std::is_scalar_v<ScalarType>
23774 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23776 return *this <=> basic_json(rhs);
23779#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23786 bool operator<=(const_reference rhs)
const noexcept
23788 if (compares_unordered(rhs,
true))
23792 return !(rhs < *
this);
23797 template<
typename ScalarType>
23798 requires std::is_scalar_v<ScalarType>
23799 bool operator<=(ScalarType rhs)
const noexcept
23801 return *
this <= basic_json(rhs);
23807 bool operator>=(const_reference rhs)
const noexcept
23809 if (compares_unordered(rhs,
true))
23813 return !(*
this < rhs);
23818 template<
typename ScalarType>
23819 requires std::is_scalar_v<ScalarType>
23820 bool operator>=(ScalarType rhs)
const noexcept
23822 return *
this >= basic_json(rhs);
23828 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
23831#pragma GCC diagnostic push
23832#pragma GCC diagnostic ignored "-Wfloat-equal"
23836#pragma GCC diagnostic pop
23842 template<
typename ScalarType,
typename std::enable_if<
23843 std::is_scalar<ScalarType>::value,
int>::type = 0>
23844 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
23846 return lhs == basic_json(rhs);
23851 template<
typename ScalarType,
typename std::enable_if<
23852 std::is_scalar<ScalarType>::value,
int>::type = 0>
23853 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
23855 return basic_json(lhs) == rhs;
23860 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
23862 if (compares_unordered(lhs, rhs,
true))
23866 return !(lhs == rhs);
23871 template<
typename ScalarType,
typename std::enable_if<
23872 std::is_scalar<ScalarType>::value,
int>::type = 0>
23873 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
23875 return lhs != basic_json(rhs);
23880 template<
typename ScalarType,
typename std::enable_if<
23881 std::is_scalar<ScalarType>::value,
int>::type = 0>
23882 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
23884 return basic_json(lhs) != rhs;
23889 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
23899 template<
typename ScalarType,
typename std::enable_if<
23900 std::is_scalar<ScalarType>::value,
int>::type = 0>
23901 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
23903 return lhs < basic_json(rhs);
23908 template<
typename ScalarType,
typename std::enable_if<
23909 std::is_scalar<ScalarType>::value,
int>::type = 0>
23910 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
23912 return basic_json(lhs) < rhs;
23917 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
23919 if (compares_unordered(lhs, rhs,
true))
23923 return !(rhs < lhs);
23928 template<
typename ScalarType,
typename std::enable_if<
23929 std::is_scalar<ScalarType>::value,
int>::type = 0>
23930 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
23932 return lhs <= basic_json(rhs);
23937 template<
typename ScalarType,
typename std::enable_if<
23938 std::is_scalar<ScalarType>::value,
int>::type = 0>
23939 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
23941 return basic_json(lhs) <= rhs;
23946 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
23949 if (compares_unordered(lhs, rhs))
23953 return !(lhs <= rhs);
23958 template<
typename ScalarType,
typename std::enable_if<
23959 std::is_scalar<ScalarType>::value,
int>::type = 0>
23960 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
23962 return lhs > basic_json(rhs);
23967 template<
typename ScalarType,
typename std::enable_if<
23968 std::is_scalar<ScalarType>::value,
int>::type = 0>
23969 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
23971 return basic_json(lhs) > rhs;
23976 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
23978 if (compares_unordered(lhs, rhs,
true))
23982 return !(lhs < rhs);
23987 template<
typename ScalarType,
typename std::enable_if<
23988 std::is_scalar<ScalarType>::value,
int>::type = 0>
23989 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
23991 return lhs >= basic_json(rhs);
23996 template<
typename ScalarType,
typename std::enable_if<
23997 std::is_scalar<ScalarType>::value,
int>::type = 0>
23998 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
24000 return basic_json(lhs) >= rhs;
24004#undef JSON_IMPLEMENT_OPERATOR
24017 friend std::ostream& operator<<(std::ostream& o,
const basic_json& j)
24020 const bool pretty_print = o.width() > 0;
24021 const auto indentation = pretty_print ? o.width() : 0;
24027 serializer s(detail::output_adapter<char>(o), o.fill());
24028 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24039 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
24055 template<
typename InputType>
24057 static basic_json parse(InputType&& i,
24058 parser_callback_t cb =
nullptr,
24059 const bool allow_exceptions =
true,
24060 const bool ignore_comments =
false)
24063 parser(
detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
24069 template<
typename IteratorType>
24071 static basic_json parse(IteratorType first,
24073 parser_callback_t cb =
nullptr,
24074 const bool allow_exceptions =
true,
24075 const bool ignore_comments =
false)
24078 parser(
detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
24084 static basic_json parse(detail::span_input_adapter&& i,
24085 parser_callback_t cb =
nullptr,
24086 const bool allow_exceptions =
true,
24087 const bool ignore_comments =
false)
24090 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
24096 template<
typename InputType>
24097 static bool accept(InputType&& i,
24098 const bool ignore_comments =
false)
24100 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
24105 template<
typename IteratorType>
24106 static bool accept(IteratorType first, IteratorType last,
24107 const bool ignore_comments =
false)
24109 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
24114 static bool accept(detail::span_input_adapter&& i,
24115 const bool ignore_comments =
false)
24117 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
24122 template <
typename InputType,
typename SAX>
24126 const
bool strict = true,
24127 const
bool ignore_comments = false)
24130 return format == input_format_t::json
24131 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24137 template<
class IteratorType,
class SAX>
24139 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24141 const
bool strict = true,
24142 const
bool ignore_comments = false)
24145 return format == input_format_t::json
24146 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24155 template <
typename SAX>
24160 const
bool strict = true,
24161 const
bool ignore_comments = false)
24164 return format == input_format_t::json
24166 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24204 case value_t::null:
24206 case value_t::object:
24208 case value_t::array:
24210 case value_t::string:
24212 case value_t::boolean:
24214 case value_t::binary:
24216 case value_t::discarded:
24217 return "discarded";
24218 case value_t::number_integer:
24219 case value_t::number_unsigned:
24220 case value_t::number_float:
24234 value_t m_type = value_t::null;
24247 m_value.array = create<array_t>(cnt, val);
24264#if JSON_DIAGNOSTICS
24269#if JSON_DIAGNOSTIC_POSITIONS
24271 std::size_t start_position = std::string::npos;
24273 std::size_t end_position = std::string::npos;
24275 constexpr std::size_t start_pos() const noexcept
24277 return start_position;
24280 constexpr std::size_t end_pos() const noexcept
24282 return end_position;
24298 std::vector<std::uint8_t> result;
24307 binary_writer<std::uint8_t>(o).write_cbor(j);
24314 binary_writer<char>(o).write_cbor(j);
24321 std::vector<std::uint8_t> result;
24330 binary_writer<std::uint8_t>(o).write_msgpack(j);
24337 binary_writer<char>(o).write_msgpack(j);
24343 const bool use_size =
false,
24344 const bool use_type =
false)
24346 std::vector<std::uint8_t> result;
24347 to_ubjson(j, result, use_size, use_type);
24354 const bool use_size =
false,
const bool use_type =
false)
24356 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
24362 const bool use_size =
false,
const bool use_type =
false)
24364 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
24370 const bool use_size =
false,
24371 const bool use_type =
false,
24374 std::vector<std::uint8_t> result;
24375 to_bjdata(j, result, use_size, use_type, version);
24382 const bool use_size =
false,
const bool use_type =
false,
24385 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24391 const bool use_size =
false,
const bool use_type =
false,
24394 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24401 std::vector<std::uint8_t> result;
24410 binary_writer<std::uint8_t>(o).write_bson(j);
24417 binary_writer<char>(o).write_bson(j);
24422 template<
typename InputType>
24425 const bool strict =
true,
24426 const bool allow_exceptions =
true,
24432 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24433 return res ? result :
basic_json(value_t::discarded);
24438 template<
typename IteratorType>
24441 const bool strict =
true,
24442 const bool allow_exceptions =
true,
24448 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24449 return res ? result :
basic_json(value_t::discarded);
24452 template<
typename T>
24456 const
bool strict = true,
24457 const
bool allow_exceptions = true,
24460 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24466 const
bool strict = true,
24467 const
bool allow_exceptions = true,
24474 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24475 return res ? result :
basic_json(value_t::discarded);
24480 template<
typename InputType>
24483 const bool strict =
true,
24484 const bool allow_exceptions =
true)
24489 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24490 return res ? result :
basic_json(value_t::discarded);
24495 template<
typename IteratorType>
24498 const bool strict =
true,
24499 const bool allow_exceptions =
true)
24504 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24505 return res ? result :
basic_json(value_t::discarded);
24508 template<
typename T>
24512 const
bool strict = true,
24513 const
bool allow_exceptions = true)
24515 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24521 const
bool strict = true,
24522 const
bool allow_exceptions = true)
24528 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24529 return res ? result :
basic_json(value_t::discarded);
24534 template<
typename InputType>
24537 const bool strict =
true,
24538 const bool allow_exceptions =
true)
24543 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24544 return res ? result :
basic_json(value_t::discarded);
24549 template<
typename IteratorType>
24552 const bool strict =
true,
24553 const bool allow_exceptions =
true)
24558 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24559 return res ? result :
basic_json(value_t::discarded);
24562 template<
typename T>
24566 const
bool strict = true,
24567 const
bool allow_exceptions = true)
24569 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24575 const
bool strict = true,
24576 const
bool allow_exceptions = true)
24582 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24583 return res ? result :
basic_json(value_t::discarded);
24588 template<
typename InputType>
24591 const bool strict =
true,
24592 const bool allow_exceptions =
true)
24597 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24598 return res ? result :
basic_json(value_t::discarded);
24603 template<
typename IteratorType>
24606 const bool strict =
true,
24607 const bool allow_exceptions =
true)
24612 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24613 return res ? result :
basic_json(value_t::discarded);
24618 template<
typename InputType>
24621 const bool strict =
true,
24622 const bool allow_exceptions =
true)
24627 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24628 return res ? result :
basic_json(value_t::discarded);
24633 template<
typename IteratorType>
24636 const bool strict =
true,
24637 const bool allow_exceptions =
true)
24642 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24643 return res ? result :
basic_json(value_t::discarded);
24646 template<
typename T>
24650 const
bool strict = true,
24651 const
bool allow_exceptions = true)
24653 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24659 const
bool strict = true,
24660 const
bool allow_exceptions = true)
24666 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24667 return res ? result :
basic_json(value_t::discarded);
24682 return ptr.get_unchecked(
this);
24685 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24689 return ptr.get_unchecked(
this);
24696 return ptr.get_unchecked(
this);
24699 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24703 return ptr.get_unchecked(
this);
24710 return ptr.get_checked(
this);
24713 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24717 return ptr.get_checked(
this);
24724 return ptr.get_checked(
this);
24727 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24731 return ptr.get_checked(
this);
24739 json_pointer::flatten(
"", *
this, result);
24747 return json_pointer::unflatten(*
this);
24765 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24767 const auto get_op = [](
const string_t& op)
24771 return patch_operations::add;
24773 if (op ==
"remove")
24775 return patch_operations::remove;
24777 if (op ==
"replace")
24779 return patch_operations::replace;
24783 return patch_operations::move;
24787 return patch_operations::copy;
24791 return patch_operations::test;
24794 return patch_operations::invalid;
24809 if (top_pointer != ptr)
24811 result.
at(top_pointer);
24815 const auto last_path = ptr.
back();
24820 switch (parent.
m_data.m_type)
24822 case value_t::null:
24823 case value_t::object:
24826 parent[last_path] = val;
24830 case value_t::array:
24832 if (last_path ==
"-")
24839 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24853 case value_t::string:
24854 case value_t::boolean:
24855 case value_t::number_integer:
24856 case value_t::number_unsigned:
24857 case value_t::number_float:
24858 case value_t::binary:
24859 case value_t::discarded:
24866 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24869 const auto last_path = ptr.
back();
24877 auto it = parent.
find(last_path);
24890 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24901 for (
const auto& val : json_patch)
24904 const auto get_value = [&val](
const string_t& op,
24909 auto it = val.m_data.m_value.object->find(member);
24912 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24939 const auto op = get_value(
"op",
"op",
true).template
get<string_t>();
24940 const auto path = get_value(op,
"path",
true).template
get<string_t>();
24943 switch (get_op(op))
24945 case patch_operations::add:
24947 operation_add(ptr, get_value(
"add",
"value",
false));
24951 case patch_operations::remove:
24953 operation_remove(ptr);
24957 case patch_operations::replace:
24960 result.
at(ptr) = get_value(
"replace",
"value",
false);
24964 case patch_operations::move:
24966 const auto from_path = get_value(
"move",
"from",
true).template
get<string_t>();
24976 operation_remove(from_ptr);
24977 operation_add(ptr, v);
24981 case patch_operations::copy:
24983 const auto from_path = get_value(
"copy",
"from",
true).template
get<string_t>();
24992 operation_add(ptr, v);
24996 case patch_operations::test:
24998 bool success =
false;
25003 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25019 case patch_operations::invalid:
25049 if (source == target)
25054 if (source.
type() != target.
type())
25059 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25064 switch (source.
type())
25066 case value_t::array:
25070 while (i < source.
size() && i < target.
size())
25074 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25083 while (i < source.
size())
25087 result.
insert(result.
begin() + end_index,
object(
25090 {
"path", detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i))}
25096 while (i < target.
size())
25102 {
"value", target[i]}
25110 case value_t::object:
25113 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25118 if (target.
find(it.key()) != target.
end())
25121 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
25122 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25129 {
"op",
"remove"}, {
"path", path_key}
25135 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25137 if (source.
find(it.key()) == source.
end())
25143 {
"op",
"add"}, {
"path", path_key},
25144 {
"value", it.value()}
25152 case value_t::null:
25153 case value_t::string:
25154 case value_t::boolean:
25155 case value_t::number_integer:
25156 case value_t::number_unsigned:
25157 case value_t::number_float:
25158 case value_t::binary:
25159 case value_t::discarded:
25165 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25192 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25194 if (it.value().is_null())
25200 operator[](it.key()).merge_patch(it.value());
25206 *
this = apply_patch;
25229#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25230 inline nlohmann::json
operator ""_json(
const char* s, std::size_t n)
25232 inline nlohmann::json
operator "" _json(
const char* s, std::size_t n)
25235 return nlohmann::json::parse(s, s + n);
25241#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25266 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
25268 return nlohmann::detail::hash(j);
25274struct less< ::nlohmann::detail::value_t>
25281 ::nlohmann::detail::value_t rhs)
const noexcept
25283#if JSON_HAS_THREE_WAY_COMPARISON
25284 return std::is_lt(lhs <=> rhs);
25286 return ::nlohmann::detail::operator<(lhs, rhs);
25292#ifndef JSON_HAS_CPP_20
25297inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
25298 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
25299 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
25308#if JSON_USE_GLOBAL_UDLS
25309 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25310 using nlohmann::literals::json_literals::operator
""_json;
25311 using nlohmann::literals::json_literals::operator
""_json_pointer;
25313 using nlohmann::literals::json_literals::operator
"" _json;
25314 using nlohmann::literals::json_literals::operator
"" _json_pointer;
25330#if defined(__clang__)
25331 #pragma clang diagnostic pop
25336#undef JSON_INTERNAL_CATCH
25338#undef JSON_PRIVATE_UNLESS_TESTED
25339#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25340#undef NLOHMANN_BASIC_JSON_TPL
25341#undef JSON_EXPLICIT
25342#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
25343#undef JSON_INLINE_VARIABLE
25344#undef JSON_NO_UNIQUE_ADDRESS
25345#undef JSON_DISABLE_ENUM_SERIALIZATION
25346#undef JSON_USE_GLOBAL_UDLS
25348#ifndef JSON_TEST_KEEP_MACROS
25351 #undef JSON_HAS_CPP_11
25352 #undef JSON_HAS_CPP_14
25353 #undef JSON_HAS_CPP_17
25354 #undef JSON_HAS_CPP_20
25355 #undef JSON_HAS_CPP_23
25356 #undef JSON_HAS_FILESYSTEM
25357 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
25358 #undef JSON_HAS_THREE_WAY_COMPARISON
25359 #undef JSON_HAS_RANGES
25360 #undef JSON_HAS_STATIC_RTTI
25361 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
25375#undef JSON_HEDLEY_ALWAYS_INLINE
25376#undef JSON_HEDLEY_ARM_VERSION
25377#undef JSON_HEDLEY_ARM_VERSION_CHECK
25378#undef JSON_HEDLEY_ARRAY_PARAM
25379#undef JSON_HEDLEY_ASSUME
25380#undef JSON_HEDLEY_BEGIN_C_DECLS
25381#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25382#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25383#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25384#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25385#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25386#undef JSON_HEDLEY_CLANG_HAS_FEATURE
25387#undef JSON_HEDLEY_CLANG_HAS_WARNING
25388#undef JSON_HEDLEY_COMPCERT_VERSION
25389#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25390#undef JSON_HEDLEY_CONCAT
25391#undef JSON_HEDLEY_CONCAT3
25392#undef JSON_HEDLEY_CONCAT3_EX
25393#undef JSON_HEDLEY_CONCAT_EX
25394#undef JSON_HEDLEY_CONST
25395#undef JSON_HEDLEY_CONSTEXPR
25396#undef JSON_HEDLEY_CONST_CAST
25397#undef JSON_HEDLEY_CPP_CAST
25398#undef JSON_HEDLEY_CRAY_VERSION
25399#undef JSON_HEDLEY_CRAY_VERSION_CHECK
25400#undef JSON_HEDLEY_C_DECL
25401#undef JSON_HEDLEY_DEPRECATED
25402#undef JSON_HEDLEY_DEPRECATED_FOR
25403#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25404#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25405#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25406#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25407#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25408#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
25409#undef JSON_HEDLEY_DIAGNOSTIC_POP
25410#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25411#undef JSON_HEDLEY_DMC_VERSION
25412#undef JSON_HEDLEY_DMC_VERSION_CHECK
25413#undef JSON_HEDLEY_EMPTY_BASES
25414#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25415#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25416#undef JSON_HEDLEY_END_C_DECLS
25417#undef JSON_HEDLEY_FLAGS
25418#undef JSON_HEDLEY_FLAGS_CAST
25419#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25420#undef JSON_HEDLEY_GCC_HAS_BUILTIN
25421#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25422#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25423#undef JSON_HEDLEY_GCC_HAS_EXTENSION
25424#undef JSON_HEDLEY_GCC_HAS_FEATURE
25425#undef JSON_HEDLEY_GCC_HAS_WARNING
25426#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25427#undef JSON_HEDLEY_GCC_VERSION
25428#undef JSON_HEDLEY_GCC_VERSION_CHECK
25429#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25430#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25431#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25432#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25433#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25434#undef JSON_HEDLEY_GNUC_HAS_FEATURE
25435#undef JSON_HEDLEY_GNUC_HAS_WARNING
25436#undef JSON_HEDLEY_GNUC_VERSION
25437#undef JSON_HEDLEY_GNUC_VERSION_CHECK
25438#undef JSON_HEDLEY_HAS_ATTRIBUTE
25439#undef JSON_HEDLEY_HAS_BUILTIN
25440#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25441#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25442#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25443#undef JSON_HEDLEY_HAS_EXTENSION
25444#undef JSON_HEDLEY_HAS_FEATURE
25445#undef JSON_HEDLEY_HAS_WARNING
25446#undef JSON_HEDLEY_IAR_VERSION
25447#undef JSON_HEDLEY_IAR_VERSION_CHECK
25448#undef JSON_HEDLEY_IBM_VERSION
25449#undef JSON_HEDLEY_IBM_VERSION_CHECK
25450#undef JSON_HEDLEY_IMPORT
25451#undef JSON_HEDLEY_INLINE
25452#undef JSON_HEDLEY_INTEL_CL_VERSION
25453#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25454#undef JSON_HEDLEY_INTEL_VERSION
25455#undef JSON_HEDLEY_INTEL_VERSION_CHECK
25456#undef JSON_HEDLEY_IS_CONSTANT
25457#undef JSON_HEDLEY_IS_CONSTEXPR_
25458#undef JSON_HEDLEY_LIKELY
25459#undef JSON_HEDLEY_MALLOC
25460#undef JSON_HEDLEY_MCST_LCC_VERSION
25461#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
25462#undef JSON_HEDLEY_MESSAGE
25463#undef JSON_HEDLEY_MSVC_VERSION
25464#undef JSON_HEDLEY_MSVC_VERSION_CHECK
25465#undef JSON_HEDLEY_NEVER_INLINE
25466#undef JSON_HEDLEY_NON_NULL
25467#undef JSON_HEDLEY_NO_ESCAPE
25468#undef JSON_HEDLEY_NO_RETURN
25469#undef JSON_HEDLEY_NO_THROW
25470#undef JSON_HEDLEY_NULL
25471#undef JSON_HEDLEY_PELLES_VERSION
25472#undef JSON_HEDLEY_PELLES_VERSION_CHECK
25473#undef JSON_HEDLEY_PGI_VERSION
25474#undef JSON_HEDLEY_PGI_VERSION_CHECK
25475#undef JSON_HEDLEY_PREDICT
25476#undef JSON_HEDLEY_PRINTF_FORMAT
25477#undef JSON_HEDLEY_PRIVATE
25478#undef JSON_HEDLEY_PUBLIC
25479#undef JSON_HEDLEY_PURE
25480#undef JSON_HEDLEY_REINTERPRET_CAST
25481#undef JSON_HEDLEY_REQUIRE
25482#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25483#undef JSON_HEDLEY_REQUIRE_MSG
25484#undef JSON_HEDLEY_RESTRICT
25485#undef JSON_HEDLEY_RETURNS_NON_NULL
25486#undef JSON_HEDLEY_SENTINEL
25487#undef JSON_HEDLEY_STATIC_ASSERT
25488#undef JSON_HEDLEY_STATIC_CAST
25489#undef JSON_HEDLEY_STRINGIFY
25490#undef JSON_HEDLEY_STRINGIFY_EX
25491#undef JSON_HEDLEY_SUNPRO_VERSION
25492#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25493#undef JSON_HEDLEY_TINYC_VERSION
25494#undef JSON_HEDLEY_TINYC_VERSION_CHECK
25495#undef JSON_HEDLEY_TI_ARMCL_VERSION
25496#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25497#undef JSON_HEDLEY_TI_CL2000_VERSION
25498#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25499#undef JSON_HEDLEY_TI_CL430_VERSION
25500#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25501#undef JSON_HEDLEY_TI_CL6X_VERSION
25502#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25503#undef JSON_HEDLEY_TI_CL7X_VERSION
25504#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25505#undef JSON_HEDLEY_TI_CLPRU_VERSION
25506#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25507#undef JSON_HEDLEY_TI_VERSION
25508#undef JSON_HEDLEY_TI_VERSION_CHECK
25509#undef JSON_HEDLEY_UNAVAILABLE
25510#undef JSON_HEDLEY_UNLIKELY
25511#undef JSON_HEDLEY_UNPREDICTABLE
25512#undef JSON_HEDLEY_UNREACHABLE
25513#undef JSON_HEDLEY_UNREACHABLE_RETURN
25514#undef JSON_HEDLEY_VERSION
25515#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25516#undef JSON_HEDLEY_VERSION_DECODE_MINOR
25517#undef JSON_HEDLEY_VERSION_DECODE_REVISION
25518#undef JSON_HEDLEY_VERSION_ENCODE
25519#undef JSON_HEDLEY_WARNING
25520#undef JSON_HEDLEY_WARN_UNUSED_RESULT
25521#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25522#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
Definition json.hpp:20114
constexpr bool is_string() const noexcept
Definition json.hpp:21412
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition json.hpp:22645
detail::cbor_tag_handler_t cbor_tag_handler_t
Definition json.hpp:20187
reference operator[](KeyType &&key)
access specified object element
Definition json.hpp:22213
size_type size() const noexcept
Definition json.hpp:22986
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:24440
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 > {}))
Definition json.hpp:21785
const_iterator end() const noexcept
returns an iterator to one past the last element
Definition json.hpp:22843
reference back()
access the last element
Definition json.hpp:22449
basic_json value_type
Definition json.hpp:20224
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition json.hpp:20852
detail::parse_error parse_error
Definition json.hpp:20206
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:22859
detail::input_format_t input_format_t
Definition json.hpp:20193
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition json.hpp:25032
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
Definition json.hpp:24200
const_reference front() const
access the first element
Definition json.hpp:22442
constexpr bool is_array() const noexcept
Definition json.hpp:21405
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)
Definition json.hpp:23504
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22393
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22762
iter_impl< const basic_json > const_iterator
Definition json.hpp:20247
constexpr bool is_number_integer() const noexcept
Definition json.hpp:21377
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
Definition json.hpp:20251
data(size_type cnt, const basic_json &val)
Definition json.hpp:24244
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:24635
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24680
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
Definition json.hpp:20242
std::size_t size_type
Definition json.hpp:20234
detail::type_error type_error
Definition json.hpp:20208
constexpr bool is_structured() const noexcept
return whether type is structured
Definition json.hpp:21349
const_reference operator[](KeyType &&key) const
access specified object element
Definition json.hpp:22237
detail::error_handler_t error_handler_t
Definition json.hpp:20185
const value_type & const_reference
Definition json.hpp:20229
detail::invalid_iterator invalid_iterator
Definition json.hpp:20207
void swap(binary_t &other)
exchanges the values
Definition json.hpp:23581
ReferenceType get_ref()
Definition json.hpp:21875
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition json.hpp:23025
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:23450
ReferenceType get_ref() const
get a reference value (implicit)
Definition json.hpp:21886
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition json.hpp:21426
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
Definition json.hpp:23699
reference operator+=(initializer_list_t init)
add an object to an object
Definition json.hpp:23241
void push_back(basic_json &&val)
add an object to an array
Definition json.hpp:23129
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition json.hpp:22182
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:22931
const_reference back() const
access the last element
Definition json.hpp:22458
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition json.hpp:22540
reference operator+=(const basic_json &val)
add an object to an array
Definition json.hpp:23186
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.hpp:23521
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:24536
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:20994
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition json.hpp:23353
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:24620
static allocator_type get_allocator()
returns the allocator associated with the container
Definition json.hpp:20257
nlohmann::byte_container_with_subtype< std::vector< std::uint8_t > > binary_t
Definition json.hpp:20382
reference at(KeyType &&key)
access specified object element with bounds checking
Definition json.hpp:22045
iterator end() noexcept
Definition json.hpp:22834
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition json.hpp:21384
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:23457
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition json.hpp:24399
detail::exception exception
Definition json.hpp:20205
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:22866
data m_data
Definition json.hpp:24262
void push_back(initializer_list_t init)
add an object to an object
Definition json.hpp:23225
detail::parser_callback_t< basic_json > parser_callback_t
Definition json.hpp:20819
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition json.hpp:21035
ValueType & get_to(ValueType &v) const
Definition json.hpp:21852
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24335
iterator begin() noexcept
Definition json.hpp:22809
detail::parse_event_t parse_event_t
Definition json.hpp:20815
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
Definition json.hpp:23699
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition json.hpp:22292
const_iterator cend() const noexcept
Definition json.hpp:22850
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:24590
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:24722
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition json.hpp:21005
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition json.hpp:20840
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:24424
basic_json flatten() const
return flattened JSON value
Definition json.hpp:24736
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:24551
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition json.hpp:22656
std::vector< basic_json, std::allocator< basic_json > > array_t
Definition json.hpp:20358
nlohmann::ordered_map< std::string, basic_json, default_object_comparator_t, std::allocator< std::pair< const std::string, basic_json > > > object_t
Definition json.hpp:20350
const binary_t & get_binary() const
get a binary value
Definition json.hpp:21957
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition json.hpp:23373
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
Definition json.hpp:24761
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22345
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:24694
value_type & reference
Definition json.hpp:20227
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
Definition json.hpp:20191
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition json.hpp:22779
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:24305
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition json.hpp:24415
iterator find(const typename object_t::key_type &key)
Definition json.hpp:22692
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition json.hpp:20983
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition json.hpp:24369
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition json.hpp:22083
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition json.hpp:20265
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition json.hpp:21042
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition json.hpp:22706
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition json.hpp:24296
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition json.hpp:22470
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition json.hpp:23326
double number_float_t
Definition json.hpp:20378
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:22267
std::allocator< basic_json > allocator_type
Definition json.hpp:20237
typename std::allocator_traits< allocator_type >::pointer pointer
Definition json.hpp:20240
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition json.hpp:21313
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition json.hpp:25184
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition json.hpp:21839
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition json.hpp:24381
reference operator[](T *key)
Definition json.hpp:22198
reference at(size_type idx)
access specified array element with bounds checking
Definition json.hpp:21979
iterator find(KeyType &&key)
find an element in a JSON object
Definition json.hpp:22722
constexpr bool is_number_float() const noexcept
Definition json.hpp:21391
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition json.hpp:22873
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:24342
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24708
bool boolean_t
Definition json.hpp:20366
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const string_t &path="")
creates a diff as a JSON patch
Definition json.hpp:25042
detail::value_t value_t
Definition json.hpp:20179
std::less< std::string > default_object_comparator_t
Definition json.hpp:20345
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:23217
const_iterator cbegin() const noexcept
Definition json.hpp:22825
reference operator[](typename object_t::key_type key)
access specified object element
Definition json.hpp:22160
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21597
~basic_json() noexcept
destructor
Definition json.hpp:21295
detail::out_of_range out_of_range
Definition json.hpp:20209
const_reverse_iterator crend() const noexcept
Definition json.hpp:22894
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition json.hpp:20924
void swap(typename binary_t::container_type &other)
exchanges the values
Definition json.hpp:23597
binary_t & get_binary()
get a binary value
Definition json.hpp:21945
const_iterator begin() const noexcept
returns an iterator to the first element
Definition json.hpp:22818
constexpr bool is_number() const noexcept
Definition json.hpp:21370
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition json.hpp:23424
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:24482
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition json.hpp:21826
const_reference operator[](T *key) const
Definition json.hpp:22204
data(const value_t v)
Definition json.hpp:24239
reference operator[](size_type idx)
access specified array element
Definition json.hpp:22101
basic_json(const JsonRef &ref)
Definition json.hpp:21163
adl_serializer< T, SFINAE > json_serializer
Definition json.hpp:20183
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
Definition json.hpp:21266
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
Definition json.hpp:22906
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:24361
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition json.hpp:21863
std::int64_t number_integer_t
Definition json.hpp:20370
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21586
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition json.hpp:22063
constexpr bool is_binary() const noexcept
Definition json.hpp:21419
void swap(object_t &other)
exchanges the values
Definition json.hpp:23549
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition json.hpp:24745
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition json.hpp:23404
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition json.hpp:24390
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:21016
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:22924
bool empty() const noexcept
checks whether the container is empty.
Definition json.hpp:22947
void swap(array_t &other)
exchanges the values
Definition json.hpp:23533
void erase(const size_type idx)
remove element from a JSON array given an index
Definition json.hpp:22663
reference operator+=(basic_json &&val)
add an object to an array
Definition json.hpp:23154
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition json.hpp:22786
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition json.hpp:21335
reference emplace_back(Args &&... args)
add an object to an array
Definition json.hpp:23250
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22368
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition json.hpp:21027
detail::bjdata_version_t bjdata_version_t
Definition json.hpp:20189
std::string string_t
Definition json.hpp:20362
friend class ::nlohmann::detail::parser
Definition json.hpp:20124
void push_back(const basic_json &val)
add an object to an array
Definition json.hpp:23162
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:22318
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition json.hpp:22025
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:24605
json_value m_value
Definition json.hpp:24237
const_reverse_iterator crbegin() const noexcept
Definition json.hpp:22887
json_sax< basic_json > json_sax_t
Definition json.hpp:20195
constexpr bool is_boolean() const noexcept
Definition json.hpp:21363
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22752
reference front()
access the first element
Definition json.hpp:22435
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition json.hpp:21342
constexpr bool is_null() const noexcept
Definition json.hpp:21356
void clear() noexcept
clears the contents
Definition json.hpp:23068
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:24353
detail::other_error other_error
Definition json.hpp:20210
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)
Definition json.hpp:24124
basic_json(basic_json &&other) noexcept
move constructor
Definition json.hpp:21240
iter_impl< basic_json > iterator
Definition json.hpp:20245
basic_json(const value_t v)
create an empty value with a given type
Definition json.hpp:20832
const_reference operator[](size_type idx) const
access specified array element
Definition json.hpp:22147
std::ptrdiff_t difference_type
Definition json.hpp:20232
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition json.hpp:23346
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
Definition json.hpp:22880
std::uint64_t number_unsigned_t
Definition json.hpp:20374
friend std::istream & operator>>(std::istream &i, basic_json &j)
Definition json.hpp:24185
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24319
void swap(string_t &other)
exchanges the values
Definition json.hpp:23565
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition json.hpp:20866
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
Definition json.hpp:20249
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition json.hpp:22002
detail::actual_object_comparator_t< basic_json > object_comparator_t
Definition json.hpp:20386
basic_json(const basic_json &other)
copy constructor
Definition json.hpp:21167
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:23194
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition json.hpp:23275
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:24312
constexpr bool is_object() const noexcept
Definition json.hpp:21398
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24328
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:24497
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition json.hpp:23307
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition json.hpp:21054
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition json.hpp:22770
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition json.hpp:24408
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition json.hpp:22738
::nlohmann::json_pointer< std::string > json_pointer
Definition json.hpp:20181
bool operator!=(const byte_container_with_subtype &rhs) const
Definition json.hpp:6234
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition json.hpp:6200
std::uint64_t subtype_type
Definition json.hpp:6197
bool operator==(const byte_container_with_subtype &rhs) const
Definition json.hpp:6228
BinaryType container_type
Definition json.hpp:6196
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:6222
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:6210
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition json.hpp:6249
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition json.hpp:6215
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition json.hpp:6256
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition json.hpp:6205
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition json.hpp:6241
void clear_subtype() noexcept
clears the binary subtype
Definition json.hpp:6263
deserialization of CBOR, MessagePack, and UBJSON values
Definition json.hpp:9846
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
Definition json.hpp:9862
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)
Definition json.hpp:9883
binary_reader & operator=(binary_reader &&)=default
void write_bson(const BasicJsonType &j)
Definition json.hpp:15807
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition json.hpp:17547
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false, const bjdata_version_t bjdata_version=bjdata_version_t::draft2)
Definition json.hpp:16487
static CharType to_char_type(std::uint8_t x) noexcept
Definition json.hpp:17554
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition json.hpp:15798
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition json.hpp:17576
void write_msgpack(const BasicJsonType &j)
Definition json.hpp:16160
void write_cbor(const BasicJsonType &j)
Definition json.hpp:15836
general exception of the basic_json class
Definition json.hpp:4511
exception(int id_, const char *what_arg)
Definition json.hpp:4524
const int id
the id of the exception
Definition json.hpp:4520
static std::string diagnostics(std::nullptr_t)
Definition json.hpp:4531
static std::string name(const std::string &ename, int id_)
Definition json.hpp:4526
const char * what() const noexcept override
returns the explanatory string
Definition json.hpp:4514
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition json.hpp:4537
exception indicating errors with iterators
Definition json.hpp:4680
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4683
iter_impl operator+(difference_type i) const
add to iterator
Definition json.hpp:14189
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition json.hpp:13743
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition json.hpp:14134
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition json.hpp:13733
bool operator<(const iter_impl &other) const
comparison: smaller
Definition json.hpp:14076
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition json.hpp:14116
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition json.hpp:14180
iter_impl & operator--()
pre-decrement (–it)
Definition json.hpp:13986
const object_t::key_type & key() const
return the key of an object iterator
Definition json.hpp:14289
bool operator==(const IterImpl &other) const
comparison: equal
Definition json.hpp:14027
iter_impl operator++(int) &
post-increment (it++)
Definition json.hpp:13924
iter_impl & operator+=(difference_type i)
add to iterator
Definition json.hpp:14143
reference operator[](difference_type n) const
access to successor
Definition json.hpp:14251
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
Definition json.hpp:13638
typename BasicJsonType::difference_type difference_type
Definition json.hpp:13636
pointer operator->() const
dereference the iterator
Definition json.hpp:13882
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
Definition json.hpp:14314
difference_type operator-(const iter_impl &other) const
return difference
Definition json.hpp:14222
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
Definition json.hpp:13631
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition json.hpp:14200
reference value() const
return the value of an iterator
Definition json.hpp:14305
bool operator>(const iter_impl &other) const
comparison: greater than
Definition json.hpp:14125
iter_impl & operator++()
pre-increment (++it)
Definition json.hpp:13935
typename BasicJsonType::value_type value_type
Definition json.hpp:13634
reference operator*() const
return a reference to the value pointed to by the iterator
Definition json.hpp:13838
iter_impl operator-(difference_type i) const
subtract from iterator
Definition json.hpp:14211
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
Definition json.hpp:13642
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition json.hpp:13718
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition json.hpp:14067
iter_impl operator--(int) &
post-decrement (it–)
Definition json.hpp:13975
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition json.hpp:13708
void set_end() noexcept
set the iterator past the last value
Definition json.hpp:13799
iteration_proxy_value operator++(int) &
Definition json.hpp:5518
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition json.hpp:5527
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition json.hpp:5533
std::ptrdiff_t difference_type
Definition json.hpp:5464
value_type & reference
Definition json.hpp:5467
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
Definition json.hpp:5485
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition json.hpp:5510
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
Definition json.hpp:5468
iteration_proxy_value value_type
Definition json.hpp:5465
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
Definition json.hpp:5575
value_type * pointer
Definition json.hpp:5466
const string_type & key() const
return key of the iterator
Definition json.hpp:5539
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
Definition json.hpp:5469
proxy class for the items() function
Definition json.hpp:5583
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition json.hpp:5608
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition json.hpp:5602
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition json.hpp:5592
iteration_proxy & operator=(iteration_proxy const &)=default
Definition json.hpp:15519
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
Definition json.hpp:15527
json_ref(value_type &&value)
Definition json.hpp:15523
value_type const & operator*() const
Definition json.hpp:15558
value_type const * operator->() const
Definition json.hpp:15563
json_ref(std::initializer_list< json_ref > init)
Definition json.hpp:15531
json_ref(Args &&... args)
Definition json.hpp:15538
value_type moved_or_copied() const
Definition json.hpp:15549
BasicJsonType value_type
Definition json.hpp:15521
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition json.hpp:14384
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition json.hpp:14396
json_reverse_iterator & operator++()
pre-increment (++it)
Definition json.hpp:14390
std::ptrdiff_t difference_type
Definition json.hpp:14370
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition json.hpp:14408
reference operator[](difference_type n) const
access to successor
Definition json.hpp:14432
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition json.hpp:14438
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition json.hpp:14426
typename Base::reference reference
the reference type for the pointed-to element
Definition json.hpp:14374
reference value() const
return the value of an iterator
Definition json.hpp:14445
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition json.hpp:14381
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition json.hpp:14402
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition json.hpp:14372
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition json.hpp:14420
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition json.hpp:14377
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition json.hpp:14414
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9564
bool end_object()
Definition json.hpp:9614
bool binary(binary_t &)
Definition json.hpp:9599
bool number_integer(number_integer_t)
Definition json.hpp:9579
bool start_array(std::size_t=detail::unknown_size())
Definition json.hpp:9619
bool boolean(bool)
Definition json.hpp:9574
bool null()
Definition json.hpp:9569
bool end_array()
Definition json.hpp:9624
bool number_unsigned(number_unsigned_t)
Definition json.hpp:9584
bool start_object(std::size_t=detail::unknown_size())
Definition json.hpp:9604
bool string(string_t &)
Definition json.hpp:9594
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9567
bool number_float(number_float_t, const string_t &)
Definition json.hpp:9589
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition json.hpp:9629
bool key(string_t &)
Definition json.hpp:9609
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9563
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9565
typename BasicJsonType::string_t string_t
Definition json.hpp:9566
bool start_array(std::size_t len)
Definition json.hpp:9292
typename BasicJsonType::parser_callback_t parser_callback_t
Definition json.hpp:9131
bool null()
Definition json.hpp:9151
typename BasicJsonType::parse_event_t parse_event_t
Definition json.hpp:9132
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool number_integer(number_integer_t val)
Definition json.hpp:9163
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:9371
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9128
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
lexer< BasicJsonType, InputAdapterType > lexer_t
Definition json.hpp:9133
bool end_object()
Definition json.hpp:9242
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:9169
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:9175
constexpr bool is_errored() const
Definition json.hpp:9383
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition json.hpp:9135
bool binary(binary_t &val)
Definition json.hpp:9187
typename BasicJsonType::string_t string_t
Definition json.hpp:9129
bool boolean(bool val)
Definition json.hpp:9157
bool key(string_t &val)
Definition json.hpp:9225
bool string(string_t &val)
Definition json.hpp:9181
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9127
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9126
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9130
~json_sax_dom_callback_parser()=default
bool end_array()
Definition json.hpp:9324
bool start_object(std::size_t len)
Definition json.hpp:9193
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
SAX implementation to create a JSON value from SAX events.
Definition json.hpp:8818
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:8867
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:8861
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
Definition json.hpp:8879
typename BasicJsonType::binary_t binary_t
Definition json.hpp:8824
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition json.hpp:8832
bool start_object(std::size_t len)
Definition json.hpp:8885
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:8820
bool key(string_t &val)
Definition json.hpp:8908
bool end_object()
Definition json.hpp:8918
typename BasicJsonType::string_t string_t
Definition json.hpp:8823
~json_sax_dom_parser()=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:8821
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:8976
lexer< BasicJsonType, InputAdapterType > lexer_t
Definition json.hpp:8825
bool boolean(bool val)
Definition json.hpp:8849
bool start_array(std::size_t len)
Definition json.hpp:8936
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:8822
bool end_array()
Definition json.hpp:8957
json_sax_dom_parser(json_sax_dom_parser &&)=default
constexpr bool is_errored() const
Definition json.hpp:8988
bool null()
Definition json.hpp:8843
bool string(string_t &val)
Definition json.hpp:8873
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_integer(number_integer_t val)
Definition json.hpp:8855
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition json.hpp:7085
token_type
token types for the parser
Definition json.hpp:7062
@ value_float
an floating point number – use get_number_float() for actual value
Definition json.hpp:7070
@ begin_array
the character for array begin [
Definition json.hpp:7071
@ value_string
a string – use get_string() for actual value
Definition json.hpp:7067
@ end_array
the character for array end ]
Definition json.hpp:7073
@ uninitialized
indicating the scanner is uninitialized
Definition json.hpp:7063
@ parse_error
indicating a parse error
Definition json.hpp:7077
@ value_integer
a signed integer – use get_number_integer() for actual value
Definition json.hpp:7069
@ value_separator
the value separator ,
Definition json.hpp:7076
@ end_object
the character for object end }
Definition json.hpp:7074
@ literal_true
the true literal
Definition json.hpp:7064
@ begin_object
the character for object begin {
Definition json.hpp:7072
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
Definition json.hpp:7068
@ literal_null
the null literal
Definition json.hpp:7066
@ end_of_input
indicating the end of the input buffer
Definition json.hpp:7078
@ name_separator
the name separator :
Definition json.hpp:7075
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
Definition json.hpp:7079
@ literal_false
the false literal
Definition json.hpp:7065
lexical analysis
Definition json.hpp:7135
bool skip_bom()
skip the UTF-8 byte order mark
Definition json.hpp:8517
void skip_whitespace()
Definition json.hpp:8531
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition json.hpp:7146
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition json.hpp:8504
std::string get_token_string() const
Definition json.hpp:8479
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition json.hpp:8438
constexpr position_t get_position() const noexcept
return position of last read token
Definition json.hpp:8471
token_type scan()
Definition json.hpp:8540
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition json.hpp:8444
typename lexer_base< BasicJsonType >::token_type token_type
Definition json.hpp:7144
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)
Definition json.hpp:8456
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition json.hpp:8450
exception indicating other library errors
Definition json.hpp:4732
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4735
exception indicating access out of the defined range
Definition json.hpp:4715
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4718
Definition json.hpp:15738
output_adapter(StringType &s)
Definition json.hpp:15749
output_adapter(std::basic_ostream< CharType > &s)
Definition json.hpp:15745
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition json.hpp:15741
output adapter for output streams
Definition json.hpp:15690
void write_characters(const CharType *s, std::size_t length) override
Definition json.hpp:15702
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition json.hpp:15692
void write_character(CharType c) override
Definition json.hpp:15696
output adapter for basic_string
Definition json.hpp:15715
void write_character(CharType c) override
Definition json.hpp:15721
output_string_adapter(StringType &s) noexcept
Definition json.hpp:15717
void write_characters(const CharType *s, std::size_t length) override
Definition json.hpp:15727
output adapter for byte vectors
Definition json.hpp:15665
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition json.hpp:15667
void write_characters(const CharType *s, std::size_t length) override
Definition json.hpp:15677
void write_character(CharType c) override
Definition json.hpp:15671
exception indicating a parse error
Definition json.hpp:4627
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition json.hpp:4639
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4647
const std::size_t byte
byte index of the parse error
Definition json.hpp:4664
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition json.hpp:12951
bool accept(const bool strict=true)
public accept interface
Definition json.hpp:13011
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
Definition json.hpp:12929
bool sax_parse(SAX *sax, const bool strict=true)
Definition json.hpp:13019
Definition json.hpp:13423
primitive_iterator_t & operator++() noexcept
Definition json.hpp:13485
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition json.hpp:13517
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition json.hpp:13452
primitive_iterator_t & operator--() noexcept
Definition json.hpp:13498
void set_end() noexcept
set iterator to a defined past the end
Definition json.hpp:13446
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13468
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition json.hpp:13458
primitive_iterator_t operator++(int) &noexcept
Definition json.hpp:13491
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition json.hpp:13511
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13463
constexpr difference_type get_value() const noexcept
Definition json.hpp:13434
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13480
primitive_iterator_t operator+(difference_type n) noexcept
Definition json.hpp:13473
void set_begin() noexcept
set iterator to a defined beginning
Definition json.hpp:13440
primitive_iterator_t operator--(int) &noexcept
Definition json.hpp:13504
std::array< char, 512 > string_buffer
string buffer
Definition json.hpp:19697
std::uint8_t state
Definition json.hpp:19115
std::size_t bytes_after_last_accept
Definition json.hpp:19119
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition json.hpp:18788
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition json.hpp:19113
std::size_t undumped_chars
Definition json.hpp:19120
const char thousands_sep
the locale's thousand separator character
Definition json.hpp:19692
const char decimal_point
the locale's decimal point character
Definition json.hpp:19694
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition json.hpp:19705
string_t indent_string
the indentation string
Definition json.hpp:19702
const std::lconv * loc
the locale
Definition json.hpp:19690
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition json.hpp:19687
const char indent_char
the indentation character
Definition json.hpp:19700
std::size_t bytes
Definition json.hpp:19116
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition json.hpp:18828
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
Definition json.hpp:4698
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4701
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition json.hpp:14540
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition json.hpp:14635
typename string_t_helper< RefStringType >::type string_t
Definition json.hpp:14562
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition json.hpp:14642
json_pointer(const string_t &s="")
create JSON pointer
Definition json.hpp:14566
bool empty() const noexcept
return whether pointer points to the root document
Definition json.hpp:14701
void pop_back()
remove last reference token
Definition json.hpp:14663
string_t to_string() const
return a string representation of the JSON pointer
Definition json.hpp:14572
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition json.hpp:14620
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14694
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition json.hpp:14602
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition json.hpp:14627
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition json.hpp:14649
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition json.hpp:14612
friend class json_pointer
Definition json.hpp:14546
const string_t & back() const
return last reference token
Definition json.hpp:14675
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
Definition json.hpp:14593
friend class basic_json
Definition json.hpp:14543
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14687
decltype( get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition json.hpp:5654
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition json.hpp:2619
#define JSON_HEDLEY_CONST
Definition json.hpp:1832
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition json.hpp:1116
#define JSON_INLINE_VARIABLE
Definition json.hpp:2518
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition json.hpp:1462
#define JSON_PRIVATE_UNLESS_TESTED
Definition json.hpp:2578
#define NLOHMANN_JSON_VERSION_PATCH
Definition json.hpp:70
#define JSON_HEDLEY_LIKELY(expr)
Definition json.hpp:1727
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15435
#define JSON_HEDLEY_NON_NULL(...)
Definition json.hpp:1620
#define JSON_INTERNAL_CATCH(exception)
Definition json.hpp:2545
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition json.hpp:25216
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition json.hpp:2061
#define JSON_CATCH(exception)
Definition json.hpp:2544
#define JSON_ASSERT(x)
Definition json.hpp:2571
#define JSON_THROW(exception)
Definition json.hpp:2542
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition json.hpp:81
#define NLOHMANN_JSON_VERSION_MAJOR
Definition json.hpp:68
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15485
#define NLOHMANN_BASIC_JSON_TPL
Definition json.hpp:2629
#define JSON_HEDLEY_UNLIKELY(expr)
Definition json.hpp:1728
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
Definition json.hpp:12808
#define JSON_TRY
Definition json.hpp:2543
#define NLOHMANN_JSON_NAMESPACE_END
Definition json.hpp:155
#define JSON_NO_UNIQUE_ADDRESS
Definition json.hpp:2524
basic_json< nlohmann::ordered_map > ordered_json
specialization that maintains the insertion order of object keys
Definition json.hpp:3558
#define NLOHMANN_JSON_VERSION_MINOR
Definition json.hpp:69
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition json.hpp:2913
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15460
#define NLOHMANN_JSON_NAMESPACE_BEGIN
Definition json.hpp:145
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
Definition json.hpp:12805
basic_json<> json
default specialization
Definition json.hpp:3549
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition json.hpp:1117
#define JSON_EXPLICIT
Definition json.hpp:2950
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition json.hpp:1410
#define JSON_HEDLEY_PURE
Definition json.hpp:1801
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition json.hpp:23622
#define JSON_DIAGNOSTIC_POSITIONS
Definition json.hpp:77
implements the Grisu2 algorithm for binary to decimal floating-point conversion.
Definition json.hpp:17665
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition json.hpp:18112
cached_power get_cached_power_for_binary_exponent(int e)
Definition json.hpp:17948
Target reinterpret_bits(const Source source)
Definition json.hpp:17668
boundaries compute_boundaries(FloatType value)
Definition json.hpp:17809
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition json.hpp:18166
constexpr int kAlpha
Definition json.hpp:17931
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition json.hpp:18448
constexpr int kGamma
Definition json.hpp:17932
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition json.hpp:18207
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition json.hpp:18548
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
Definition json.hpp:18600
constexpr bool is_transparent()
Definition json.hpp:4321
constexpr bool is_c_string()
Definition json.hpp:4293
detail namespace with internal helper functions
Definition json.hpp:263
make_integer_sequence< size_t, N > make_index_sequence
Definition json.hpp:3318
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition json.hpp:4396
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
Definition json.hpp:4203
input_format_t
the supported input formats
Definition json.hpp:6484
@ bson
Definition json.hpp:6484
@ bjdata
Definition json.hpp:6484
@ ubjson
Definition json.hpp:6484
@ json
Definition json.hpp:6484
@ cbor
Definition json.hpp:6484
@ msgpack
Definition json.hpp:6484
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition json.hpp:314
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition json.hpp:6071
static void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:3132
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition json.hpp:3644
detector< Default, void, Op, Args... > detected_or
Definition json.hpp:317
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition json.hpp:9692
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition json.hpp:4137
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition json.hpp:4417
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition json.hpp:9704
OutStringType concat(Args &&... args)
Definition json.hpp:4476
typename T::value_type value_type_t
Definition json.hpp:3629
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
Definition json.hpp:3349
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).
Definition json.hpp:18685
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition json.hpp:9672
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition json.hpp:323
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition json.hpp:4399
typename std::enable_if< B, T >::type enable_if_t
Definition json.hpp:3222
parse_event_t
Definition json.hpp:12893
@ value
the parser finished reading a JSON value
Definition json.hpp:12905
@ key
the parser read a key of a value in an object
Definition json.hpp:12903
@ array_end
the parser read ] and finished processing a JSON array
Definition json.hpp:12901
@ array_start
the parser read [ and started to process a JSON array
Definition json.hpp:12899
@ object_start
the parser read { and started to process a JSON object
Definition json.hpp:12895
@ object_end
the parser read } and finished processing a JSON object
Definition json.hpp:12897
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition json.hpp:4199
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition json.hpp:308
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition json.hpp:4119
typename T::pointer pointer_t
Definition json.hpp:3635
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition json.hpp:5243
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition json.hpp:5048
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition json.hpp:3310
conjunction< std::is_integral< Types >... > all_integral
Definition json.hpp:4189
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition json.hpp:15660
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition json.hpp:320
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition json.hpp:9700
decltype(std::declval< T & >().null()) null_function_t
Definition json.hpp:9669
void int_to_string(StringType &target, std::size_t value)
Definition json.hpp:5436
T conditional_static_cast(U value)
Definition json.hpp:4177
typename T::difference_type difference_type_t
Definition json.hpp:3632
conjunction< std::is_unsigned< Types >... > all_unsigned
Definition json.hpp:4195
constexpr T static_const< T >::value
Definition json.hpp:3345
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition json.hpp:9696
decltype(std::declval< T & >().number_float( std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition json.hpp:9684
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition json.hpp:3098
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition json.hpp:9707
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition json.hpp:4411
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition json.hpp:5618
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition json.hpp:4150
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition json.hpp:3723
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition json.hpp:4146
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition json.hpp:6938
cbor_tag_handler_t
how to treat CBOR tags
Definition json.hpp:9819
@ ignore
ignore tags
Definition json.hpp:9821
@ store
store tags as binary type
Definition json.hpp:9822
@ error
throw a parse_error exception in case of a tag
Definition json.hpp:9820
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition json.hpp:3874
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition json.hpp:3326
void concat_into(OutStringType &)
Definition json.hpp:4392
constexpr bool value_in_range_of(T val)
Definition json.hpp:4277
value_t
the JSON type enumeration
Definition json.hpp:3000
@ null
null value
Definition json.hpp:3001
@ number_integer
number value (signed integer)
Definition json.hpp:3006
@ boolean
boolean value
Definition json.hpp:3005
@ discarded
discarded by the parser callback function
Definition json.hpp:3010
@ binary
binary array (ordered collection of bytes)
Definition json.hpp:3009
@ object
object (unordered set of name/value pairs)
Definition json.hpp:3002
@ string
string value
Definition json.hpp:3004
@ number_float
number value (floating-point)
Definition json.hpp:3008
@ number_unsigned
number value (unsigned integer)
Definition json.hpp:3007
@ array
array (ordered collection of values)
Definition json.hpp:3003
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition json.hpp:3647
conjunction< std::is_signed< Types >... > all_signed
Definition json.hpp:4192
constexpr std::size_t unknown_size()
Definition json.hpp:8798
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition json.hpp:5131
static bool little_endianness(int num=1) noexcept
determine system byte order
Definition json.hpp:9832
StringType to_string(std::size_t value)
Definition json.hpp:5444
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition json.hpp:6325
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition json.hpp:9676
typename make_void< Ts... >::type void_t
Definition json.hpp:269
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition json.hpp:6307
decltype(std::declval< T & >().parse_error( std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition json.hpp:9714
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition json.hpp:3029
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition json.hpp:6874
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition json.hpp:3871
typename T::iterator_category iterator_category_t
Definition json.hpp:3641
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
Definition json.hpp:14490
is_c_string< uncvref_t< T > > is_c_string_uncvref
Definition json.hpp:4311
error_handler_t
how to treat decoding errors
Definition json.hpp:18765
@ strict
throw a type_error exception in case of invalid UTF-8
Definition json.hpp:18766
@ ignore
ignore invalid UTF-8 sequences
Definition json.hpp:18768
@ replace
replace invalid UTF-8 sequences with U+FFFD
Definition json.hpp:18767
std::size_t concat_length()
Definition json.hpp:4361
std::integral_constant< bool, Value > bool_constant
Definition json.hpp:4283
decltype(input_adapter(std::declval< std::string >())) string_input_adapter_type
Definition json.hpp:6914
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition json.hpp:3208
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition json.hpp:4825
typename T::key_compare detect_key_compare
Definition json.hpp:3707
void to_json(BasicJsonType &j, T b) noexcept
Definition json.hpp:5932
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition json.hpp:4857
integer_sequence< size_t, Ints... > index_sequence
Definition json.hpp:3264
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition json.hpp:326
is_specialization_of<::nlohmann::json_pointer, uncvref_t< T > > is_json_pointer
Definition json.hpp:4100
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition json.hpp:4408
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition json.hpp:9711
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition json.hpp:5231
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition json.hpp:4414
typename T::key_type key_type_t
Definition json.hpp:3626
typename T::reference reference_t
Definition json.hpp:3638
typename T::is_transparent detect_is_transparent
Definition json.hpp:4113
bjdata_version_t
how to encode BJData
Definition json.hpp:15773
@ draft3
Definition json.hpp:15775
@ draft2
Definition json.hpp:15774
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition json.hpp:4405
typename T::mapped_type mapped_type_t
Definition json.hpp:3623
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition json.hpp:4402
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:3117
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition json.hpp:9688
decltype(std::declval< T >().template get< U >()) get_template_function
Definition json.hpp:3650
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition json.hpp:9680
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition json.hpp:12909
Definition json.hpp:25224
Definition json.hpp:25222
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:25297
namespace for Niels Lohmann
Definition json.hpp:6136
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition json.hpp:6160
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition json.hpp:6150
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition json.hpp:6140
typename BasicJsonType::object_t object_t
Definition json.hpp:3716
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition json.hpp:3717
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition json.hpp:3718
signed char char_type
Definition json.hpp:3762
static constexpr int_type eof() noexcept
Definition json.hpp:3776
uint64_t int_type
Definition json.hpp:3763
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3771
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3766
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3747
static constexpr int_type eof() noexcept
Definition json.hpp:3752
unsigned char char_type
Definition json.hpp:3738
uint64_t int_type
Definition json.hpp:3739
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3742
std::true_type value_t
Definition json.hpp:303
Op< Args... > type
Definition json.hpp:304
std::false_type value_t
Definition json.hpp:296
Default type
Definition json.hpp:297
Definition json.hpp:17796
diyfp w
Definition json.hpp:17797
diyfp minus
Definition json.hpp:17798
diyfp plus
Definition json.hpp:17799
Definition json.hpp:17935
std::uint64_t f
Definition json.hpp:17936
int e
Definition json.hpp:17937
int k
Definition json.hpp:17938
Definition json.hpp:17678
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition json.hpp:17702
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition json.hpp:17784
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition json.hpp:17767
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition json.hpp:17690
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition json.hpp:17684
static constexpr int kPrecision
Definition json.hpp:17679
std::uint64_t f
Definition json.hpp:17681
int e
Definition json.hpp:17682
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition json.hpp:5841
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition json.hpp:5816
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition json.hpp:5806
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition json.hpp:5828
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition json.hpp:5857
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition json.hpp:5745
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition json.hpp:5754
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition json.hpp:5699
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition json.hpp:5767
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition json.hpp:5793
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition json.hpp:5780
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition json.hpp:5876
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition json.hpp:5897
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition json.hpp:5886
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition json.hpp:5721
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition json.hpp:5732
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition json.hpp:5712
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition json.hpp:5339
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3669
static constexpr bool value
Definition json.hpp:3671
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3684
static constexpr bool value
Definition json.hpp:3686
static constexpr bool value
Definition json.hpp:3701
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3699
T value_type
Definition json.hpp:3251
static constexpr std::size_t size() noexcept
Definition json.hpp:3252
an iterator value
Definition json.hpp:13539
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition json.hpp:13543
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition json.hpp:13545
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition json.hpp:13541
static constexpr bool value
Definition json.hpp:3980
static constexpr auto value
Definition json.hpp:4048
std::numeric_limits< RealIntegerType > RealLimits
Definition json.hpp:4045
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition json.hpp:4046
typename BasicJsonType::object_t object_t
Definition json.hpp:3896
static constexpr bool value
Definition json.hpp:3899
static constexpr auto value
Definition json.hpp:3946
static constexpr bool value
Definition json.hpp:4068
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition json.hpp:4017
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 static constexpr bool value
Definition json.hpp:4019
typename BasicJsonType::object_t object_t
Definition json.hpp:3920
static constexpr bool value
Definition json.hpp:3922
ConstructibleStringType laundered_type
Definition json.hpp:3957
static constexpr auto value
Definition json.hpp:3960
static constexpr bool value
Definition json.hpp:3663
typename std::iterator_traits< T >::value_type value_type
Definition json.hpp:6851
static constexpr auto value
Definition json.hpp:3843
char x[2]
Definition json.hpp:4166
static one test(decltype(&C::capacity))
char one
Definition json.hpp:4162
@ value
Definition json.hpp:4172
static constexpr bool value
Definition json.hpp:3867
static constexpr bool value
Definition json.hpp:9733
T value_type
Definition json.hpp:3431
T * pointer
Definition json.hpp:3433
ptrdiff_t difference_type
Definition json.hpp:3432
T & reference
Definition json.hpp:3434
std::random_access_iterator_tag iterator_category
Definition json.hpp:3430
typename It::iterator_category iterator_category
Definition json.hpp:3411
typename It::difference_type difference_type
Definition json.hpp:3407
typename It::value_type value_type
Definition json.hpp:3408
typename It::reference reference
Definition json.hpp:3410
typename It::pointer pointer
Definition json.hpp:3409
Default base class of the basic_json class.
Definition json.hpp:14487
void type
Definition json.hpp:267
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
Definition json.hpp:15646
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
Definition json.hpp:3163
std::size_t chars_read_current_line
the number of characters read in the current line
Definition json.hpp:3167
std::size_t lines_read
the number of lines read
Definition json.hpp:3169
std::size_t chars_read_total
the total number of characters read
Definition json.hpp:3165
static JSON_INLINE_VARIABLE constexpr T value
Definition json.hpp:3340
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition json.hpp:6105
integer_sequence< T, Ints...,(Ints+SeqSize)... > type
Definition json.hpp:3276
integer_sequence< T, Ints...,(Ints+SeqSize)..., 2 *SeqSize > type
Definition json.hpp:3282
integer_sequence< T > type
Definition json.hpp:3297
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition json.hpp:3290
static constexpr bool test(T val)
Definition json.hpp:4261
static constexpr bool test(T)
Definition json.hpp:4270
static constexpr bool test(T val)
Definition json.hpp:4215
static constexpr bool test(T val)
Definition json.hpp:4235
static constexpr bool test(T val)
Definition json.hpp:4225
static constexpr bool test(T val)
Definition json.hpp:4245
SAX interface.
Definition json.hpp:8683
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:8684
typename BasicJsonType::string_t string_t
Definition json.hpp:8687
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:8686
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:8685
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
Definition json.hpp:8688
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
Definition json.hpp:19747
std::vector< std::pair< const Key, T >, Allocator > Container
Definition json.hpp:19750
std::pair< iterator, bool > insert(value_type &&value)
Definition json.hpp:20041
typename Container::value_type value_type
Definition json.hpp:19754
std::equal_to< Key > key_compare
Definition json.hpp:19758
iterator erase(iterator pos)
Definition json.hpp:19919
T mapped_type
Definition json.hpp:19749
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition json.hpp:19764
T & operator[](KeyType &&key)
Definition json.hpp:19806
typename Container::iterator iterator
Definition json.hpp:19751
const T & at(KeyType &&key) const
Definition json.hpp:19866
T & at(KeyType &&key)
Definition json.hpp:19838
const T & operator[](KeyType &&key) const
Definition json.hpp:19818
iterator find(const key_type &key)
Definition json.hpp:20003
iterator erase(iterator first, iterator last)
Definition json.hpp:19924
const T & at(const key_type &key) const
Definition json.hpp:19851
const_iterator find(const key_type &key) const
Definition json.hpp:20029
T & operator[](const key_type &key)
Definition json.hpp:19799
size_type erase(KeyType &&key)
Definition json.hpp:19900
typename Container::size_type size_type
Definition json.hpp:19753
ordered_map() noexcept(noexcept(Container()))
Definition json.hpp:19763
void insert(InputIt first, InputIt last)
Definition json.hpp:20064
size_type count(const key_type &key) const
Definition json.hpp:19977
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
Definition json.hpp:19786
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition json.hpp:20060
size_type erase(const key_type &key)
Definition json.hpp:19879
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition json.hpp:19768
std::pair< iterator, bool > insert(const value_type &value)
Definition json.hpp:20046
size_type count(KeyType &&key) const
Definition json.hpp:19991
Key key_type
Definition json.hpp:19748
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition json.hpp:19766
const T & operator[](const key_type &key) const
Definition json.hpp:19811
iterator find(KeyType &&key)
Definition json.hpp:20017
T & at(const key_type &key)
Definition json.hpp:19823
typename Container::const_iterator const_iterator
Definition json.hpp:19752
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition json.hpp:19771
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition json.hpp:25266
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition json.hpp:25280