18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
61#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
62 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
63 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2
64 #warning "Already included a different version of the library!"
69#define NLOHMANN_JSON_VERSION_MAJOR 3
70#define NLOHMANN_JSON_VERSION_MINOR 11
71#define NLOHMANN_JSON_VERSION_PATCH 2
73#ifndef JSON_DIAGNOSTICS
74 #define JSON_DIAGNOSTICS 0
77#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
78 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
82 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
84 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
87#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
88 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
90 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
93#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
94 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
98#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
99#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
100 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
102#define NLOHMANN_JSON_ABI_TAGS \
103 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
104 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
105 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
108#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
109 _v ## major ## _ ## minor ## _ ## patch
110#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
111 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
113#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
114#define NLOHMANN_JSON_NAMESPACE_VERSION
116#define NLOHMANN_JSON_NAMESPACE_VERSION \
117 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
118 NLOHMANN_JSON_VERSION_MINOR, \
119 NLOHMANN_JSON_VERSION_PATCH)
123#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
124#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
125 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
127#ifndef NLOHMANN_JSON_NAMESPACE
128#define NLOHMANN_JSON_NAMESPACE \
129 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
130 NLOHMANN_JSON_ABI_TAGS, \
131 NLOHMANN_JSON_NAMESPACE_VERSION)
134#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
135#define NLOHMANN_JSON_NAMESPACE_BEGIN \
138 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
139 NLOHMANN_JSON_ABI_TAGS, \
140 NLOHMANN_JSON_NAMESPACE_VERSION) \
144#ifndef NLOHMANN_JSON_NAMESPACE_END
145#define NLOHMANN_JSON_NAMESPACE_END \
163#include <forward_list>
168#include <type_traits>
169#include <unordered_map>
229#include <type_traits>
274template<
class Default,
276 template<
class...>
class Op,
284template<
class Default,
template<
class...>
class Op,
class... Args>
291template<
template<
class...>
class Op,
class... Args>
294template<
template<
class...>
class Op,
class... Args>
297template<
template<
class...>
class Op,
class... Args>
300template<
class Default,
template<
class...>
class Op,
class... Args>
303template<
class Default,
template<
class...>
class Op,
class... Args>
306template<
class Expected,
template<
class...>
class Op,
class... Args>
309template<
class To,
template<
class...>
class Op,
class... Args>
311 std::is_convertible<
detected_t<Op, Args...>, To>;
332#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
333#if defined(JSON_HEDLEY_VERSION)
334 #undef JSON_HEDLEY_VERSION
336#define JSON_HEDLEY_VERSION 15
338#if defined(JSON_HEDLEY_STRINGIFY_EX)
339 #undef JSON_HEDLEY_STRINGIFY_EX
341#define JSON_HEDLEY_STRINGIFY_EX(x) #x
343#if defined(JSON_HEDLEY_STRINGIFY)
344 #undef JSON_HEDLEY_STRINGIFY
346#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
348#if defined(JSON_HEDLEY_CONCAT_EX)
349 #undef JSON_HEDLEY_CONCAT_EX
351#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
353#if defined(JSON_HEDLEY_CONCAT)
354 #undef JSON_HEDLEY_CONCAT
356#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
358#if defined(JSON_HEDLEY_CONCAT3_EX)
359 #undef JSON_HEDLEY_CONCAT3_EX
361#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
363#if defined(JSON_HEDLEY_CONCAT3)
364 #undef JSON_HEDLEY_CONCAT3
366#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
368#if defined(JSON_HEDLEY_VERSION_ENCODE)
369 #undef JSON_HEDLEY_VERSION_ENCODE
371#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
373#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
374 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
376#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
378#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
379 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
381#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
383#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
384 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
386#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
388#if defined(JSON_HEDLEY_GNUC_VERSION)
389 #undef JSON_HEDLEY_GNUC_VERSION
391#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
392 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
393#elif defined(__GNUC__)
394 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
397#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
398 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
400#if defined(JSON_HEDLEY_GNUC_VERSION)
401 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
403 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
406#if defined(JSON_HEDLEY_MSVC_VERSION)
407 #undef JSON_HEDLEY_MSVC_VERSION
409#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
410 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
411#elif defined(_MSC_FULL_VER) && !defined(__ICL)
412 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
413#elif defined(_MSC_VER) && !defined(__ICL)
414 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
417#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
418 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
420#if !defined(JSON_HEDLEY_MSVC_VERSION)
421 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
422#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
423 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
424#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
425 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
427 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
430#if defined(JSON_HEDLEY_INTEL_VERSION)
431 #undef JSON_HEDLEY_INTEL_VERSION
433#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
434 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
435#elif defined(__INTEL_COMPILER) && !defined(__ICL)
436 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
439#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
440 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
442#if defined(JSON_HEDLEY_INTEL_VERSION)
443 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
445 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
448#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
449 #undef JSON_HEDLEY_INTEL_CL_VERSION
451#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
452 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
455#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
456 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
458#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
459 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
461 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
464#if defined(JSON_HEDLEY_PGI_VERSION)
465 #undef JSON_HEDLEY_PGI_VERSION
467#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
468 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
471#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
472 #undef JSON_HEDLEY_PGI_VERSION_CHECK
474#if defined(JSON_HEDLEY_PGI_VERSION)
475 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
477 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
480#if defined(JSON_HEDLEY_SUNPRO_VERSION)
481 #undef JSON_HEDLEY_SUNPRO_VERSION
483#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
484 #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)
485#elif defined(__SUNPRO_C)
486 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
487#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
488 #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)
489#elif defined(__SUNPRO_CC)
490 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
493#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
494 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
496#if defined(JSON_HEDLEY_SUNPRO_VERSION)
497 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
499 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
502#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
503 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
505#if defined(__EMSCRIPTEN__)
506 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
509#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
510 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
512#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
513 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
515 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
518#if defined(JSON_HEDLEY_ARM_VERSION)
519 #undef JSON_HEDLEY_ARM_VERSION
521#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
522 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
523#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
524 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
527#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
528 #undef JSON_HEDLEY_ARM_VERSION_CHECK
530#if defined(JSON_HEDLEY_ARM_VERSION)
531 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
533 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
536#if defined(JSON_HEDLEY_IBM_VERSION)
537 #undef JSON_HEDLEY_IBM_VERSION
539#if defined(__ibmxl__)
540 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
541#elif defined(__xlC__) && defined(__xlC_ver__)
542 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
543#elif defined(__xlC__)
544 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
547#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
548 #undef JSON_HEDLEY_IBM_VERSION_CHECK
550#if defined(JSON_HEDLEY_IBM_VERSION)
551 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
553 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
556#if defined(JSON_HEDLEY_TI_VERSION)
557 #undef JSON_HEDLEY_TI_VERSION
560 defined(__TI_COMPILER_VERSION__) && \
562 defined(__TMS470__) || defined(__TI_ARM__) || \
563 defined(__MSP430__) || \
564 defined(__TMS320C2000__) \
566#if (__TI_COMPILER_VERSION__ >= 16000000)
567 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
571#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
572 #undef JSON_HEDLEY_TI_VERSION_CHECK
574#if defined(JSON_HEDLEY_TI_VERSION)
575 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
577 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
580#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
581 #undef JSON_HEDLEY_TI_CL2000_VERSION
583#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
584 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
587#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
588 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
590#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
591 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
593 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
596#if defined(JSON_HEDLEY_TI_CL430_VERSION)
597 #undef JSON_HEDLEY_TI_CL430_VERSION
599#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
600 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
603#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
604 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
606#if defined(JSON_HEDLEY_TI_CL430_VERSION)
607 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
609 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
612#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
613 #undef JSON_HEDLEY_TI_ARMCL_VERSION
615#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
616 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
619#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
620 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
622#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
623 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
625 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
628#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
629 #undef JSON_HEDLEY_TI_CL6X_VERSION
631#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
632 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
635#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
636 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
638#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
639 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
641 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
644#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
645 #undef JSON_HEDLEY_TI_CL7X_VERSION
647#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
648 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
651#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
652 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
654#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
655 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
657 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
660#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
661 #undef JSON_HEDLEY_TI_CLPRU_VERSION
663#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
664 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
667#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
668 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
670#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
671 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
673 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
676#if defined(JSON_HEDLEY_CRAY_VERSION)
677 #undef JSON_HEDLEY_CRAY_VERSION
680 #if defined(_RELEASE_PATCHLEVEL)
681 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
683 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
687#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
688 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
690#if defined(JSON_HEDLEY_CRAY_VERSION)
691 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
693 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
696#if defined(JSON_HEDLEY_IAR_VERSION)
697 #undef JSON_HEDLEY_IAR_VERSION
699#if defined(__IAR_SYSTEMS_ICC__)
701 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
703 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
707#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
708 #undef JSON_HEDLEY_IAR_VERSION_CHECK
710#if defined(JSON_HEDLEY_IAR_VERSION)
711 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
713 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
716#if defined(JSON_HEDLEY_TINYC_VERSION)
717 #undef JSON_HEDLEY_TINYC_VERSION
719#if defined(__TINYC__)
720 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
723#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
724 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
726#if defined(JSON_HEDLEY_TINYC_VERSION)
727 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
729 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
732#if defined(JSON_HEDLEY_DMC_VERSION)
733 #undef JSON_HEDLEY_DMC_VERSION
736 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
739#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
740 #undef JSON_HEDLEY_DMC_VERSION_CHECK
742#if defined(JSON_HEDLEY_DMC_VERSION)
743 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
745 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
748#if defined(JSON_HEDLEY_COMPCERT_VERSION)
749 #undef JSON_HEDLEY_COMPCERT_VERSION
751#if defined(__COMPCERT_VERSION__)
752 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
755#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
756 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
758#if defined(JSON_HEDLEY_COMPCERT_VERSION)
759 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
761 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
764#if defined(JSON_HEDLEY_PELLES_VERSION)
765 #undef JSON_HEDLEY_PELLES_VERSION
768 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
771#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
772 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
774#if defined(JSON_HEDLEY_PELLES_VERSION)
775 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
777 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
780#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
781 #undef JSON_HEDLEY_MCST_LCC_VERSION
783#if defined(__LCC__) && defined(__LCC_MINOR__)
784 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
787#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
788 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
790#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
791 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
793 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
796#if defined(JSON_HEDLEY_GCC_VERSION)
797 #undef JSON_HEDLEY_GCC_VERSION
800 defined(JSON_HEDLEY_GNUC_VERSION) && \
801 !defined(__clang__) && \
802 !defined(JSON_HEDLEY_INTEL_VERSION) && \
803 !defined(JSON_HEDLEY_PGI_VERSION) && \
804 !defined(JSON_HEDLEY_ARM_VERSION) && \
805 !defined(JSON_HEDLEY_CRAY_VERSION) && \
806 !defined(JSON_HEDLEY_TI_VERSION) && \
807 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
808 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
809 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
810 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
811 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
812 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
813 !defined(__COMPCERT__) && \
814 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
815 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
818#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
819 #undef JSON_HEDLEY_GCC_VERSION_CHECK
821#if defined(JSON_HEDLEY_GCC_VERSION)
822 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
824 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
827#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
828 #undef JSON_HEDLEY_HAS_ATTRIBUTE
831 defined(__has_attribute) && \
833 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
835# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
837# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
840#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
841 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
843#if defined(__has_attribute)
844 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
846 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
849#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
850 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
852#if defined(__has_attribute)
853 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
855 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
858#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
859 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
862 defined(__has_cpp_attribute) && \
863 defined(__cplusplus) && \
864 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
865 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
867 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
870#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
871 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
873#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
874 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
876 !defined(JSON_HEDLEY_PGI_VERSION) && \
877 !defined(JSON_HEDLEY_IAR_VERSION) && \
878 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
879 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
882 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
885#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
886 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
888#if defined(__has_cpp_attribute) && defined(__cplusplus)
889 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
891 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
894#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
895 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
897#if defined(__has_cpp_attribute) && defined(__cplusplus)
898 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
900 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
903#if defined(JSON_HEDLEY_HAS_BUILTIN)
904 #undef JSON_HEDLEY_HAS_BUILTIN
906#if defined(__has_builtin)
907 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
909 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
912#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
913 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
915#if defined(__has_builtin)
916 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
918 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
921#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
922 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
924#if defined(__has_builtin)
925 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
927 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
930#if defined(JSON_HEDLEY_HAS_FEATURE)
931 #undef JSON_HEDLEY_HAS_FEATURE
933#if defined(__has_feature)
934 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
936 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
939#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
940 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
942#if defined(__has_feature)
943 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
945 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
948#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
949 #undef JSON_HEDLEY_GCC_HAS_FEATURE
951#if defined(__has_feature)
952 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
954 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
957#if defined(JSON_HEDLEY_HAS_EXTENSION)
958 #undef JSON_HEDLEY_HAS_EXTENSION
960#if defined(__has_extension)
961 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
963 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
966#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
967 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
969#if defined(__has_extension)
970 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
972 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
975#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
976 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
978#if defined(__has_extension)
979 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
981 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
984#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
985 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
987#if defined(__has_declspec_attribute)
988 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
990 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
993#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
994 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
996#if defined(__has_declspec_attribute)
997 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
999 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1002#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1003 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1005#if defined(__has_declspec_attribute)
1006 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1008 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1011#if defined(JSON_HEDLEY_HAS_WARNING)
1012 #undef JSON_HEDLEY_HAS_WARNING
1014#if defined(__has_warning)
1015 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1017 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1020#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1021 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1023#if defined(__has_warning)
1024 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1026 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1029#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1030 #undef JSON_HEDLEY_GCC_HAS_WARNING
1032#if defined(__has_warning)
1033 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1035 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1039 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1040 defined(__clang__) || \
1041 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1042 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1043 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1044 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1045 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1046 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1047 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1048 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1049 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1050 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1051 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1052 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1053 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1054 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1055 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1056 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1057 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1058#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1059 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1061 #define JSON_HEDLEY_PRAGMA(value)
1064#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1065 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1067#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1068 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1070#if defined(__clang__)
1071 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1072 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1073#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1074 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1075 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1076#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1077 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1078 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1080 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1081 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1082 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1083 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1084#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1085 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1086 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1088 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1089 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1090 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1091 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1092 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1093 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1094 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1095 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1096#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1097 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1098 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1100 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1101 #define JSON_HEDLEY_DIAGNOSTIC_POP
1106#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1107 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1109#if defined(__cplusplus)
1110# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1111# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1112# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1113# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1114 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1115 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1116 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1117 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1119 JSON_HEDLEY_DIAGNOSTIC_POP
1121# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1122 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1123 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1124 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1126 JSON_HEDLEY_DIAGNOSTIC_POP
1129# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1130 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1131 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1133 JSON_HEDLEY_DIAGNOSTIC_POP
1137#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1138 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1141#if defined(JSON_HEDLEY_CONST_CAST)
1142 #undef JSON_HEDLEY_CONST_CAST
1144#if defined(__cplusplus)
1145# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1147 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1148 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1149 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1150# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1151 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1152 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1154 JSON_HEDLEY_DIAGNOSTIC_POP \
1157# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1160#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1161 #undef JSON_HEDLEY_REINTERPRET_CAST
1163#if defined(__cplusplus)
1164 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1166 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1169#if defined(JSON_HEDLEY_STATIC_CAST)
1170 #undef JSON_HEDLEY_STATIC_CAST
1172#if defined(__cplusplus)
1173 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1175 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1178#if defined(JSON_HEDLEY_CPP_CAST)
1179 #undef JSON_HEDLEY_CPP_CAST
1181#if defined(__cplusplus)
1182# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1183# define JSON_HEDLEY_CPP_CAST(T, expr) \
1184 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1185 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1187 JSON_HEDLEY_DIAGNOSTIC_POP
1188# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1189# define JSON_HEDLEY_CPP_CAST(T, expr) \
1190 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1191 _Pragma("diag_suppress=Pe137") \
1192 JSON_HEDLEY_DIAGNOSTIC_POP
1194# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1197# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1200#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1201 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1203#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1204 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1205#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1206 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1207#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1208 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1209#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1211#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1213#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1215#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1217#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1220 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1221 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1222 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1223 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1225 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1227 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1229 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1230 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1232#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1233 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1234#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1235 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1236#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1238#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1239 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1241 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1244#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1245 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1247#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1248 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1249#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1251#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1253#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1255#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1256 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1257#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1260 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1261 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1262 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1263 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1264 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1265#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1267#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1269#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1275#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1276 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1278#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1280#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1282#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1284#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1286#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1287 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1288#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1289 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1290#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1291 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1292#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1293 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1295 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1296 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1297 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1298 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1299#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1301#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1307#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1308 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1310#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1312#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1314#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1320#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1321 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1323#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1324 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1325#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1327#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1329#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1332 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1335#if defined(JSON_HEDLEY_DEPRECATED)
1336 #undef JSON_HEDLEY_DEPRECATED
1338#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1339 #undef JSON_HEDLEY_DEPRECATED_FOR
1342 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1343 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1344 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1345 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1347 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1348 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1349 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1350 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1351 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1352 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1353 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1354 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1355 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1356 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1357 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1358 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1359 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1360 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1361#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1362 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1363 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1365 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1366 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1367 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1368 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1369 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1370 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1371 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1372 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1373 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1374 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1375 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1376 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1377 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1378 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1379 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1380 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1381 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1382 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1384 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1385 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1386 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1387 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1388 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1389#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1390 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1391 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1393 #define JSON_HEDLEY_DEPRECATED(since)
1394 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1397#if defined(JSON_HEDLEY_UNAVAILABLE)
1398 #undef JSON_HEDLEY_UNAVAILABLE
1401 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1402 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1403 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1404 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1405 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1407 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1410#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1411 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1413#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1414 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1417 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1418 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1419 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1420 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1421 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1422 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1423 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1424 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1425 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1426 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1427 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1428 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1429 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1430 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1431 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1432 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1433 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1434 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1435 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1436#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1437 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1438 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1439#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1440 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1441 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1442#elif defined(_Check_return_)
1443 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1444 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1446 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1447 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1450#if defined(JSON_HEDLEY_SENTINEL)
1451 #undef JSON_HEDLEY_SENTINEL
1454 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1455 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1456 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1457 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1458 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1459 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1461 #define JSON_HEDLEY_SENTINEL(position)
1464#if defined(JSON_HEDLEY_NO_RETURN)
1465 #undef JSON_HEDLEY_NO_RETURN
1467#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1468 #define JSON_HEDLEY_NO_RETURN __noreturn
1470 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1471 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1472 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1473#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1474 #define JSON_HEDLEY_NO_RETURN _Noreturn
1475#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1476 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1478 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1479 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1480 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1481 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1482 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1483 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1484 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1485 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1486 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1487 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1488 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1489 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1490 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1491 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1492 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1493 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1494 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1495 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1496#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1497 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1499 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1500 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1501 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1502#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1503 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1504#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1505 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1506#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1507 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1509 #define JSON_HEDLEY_NO_RETURN
1512#if defined(JSON_HEDLEY_NO_ESCAPE)
1513 #undef JSON_HEDLEY_NO_ESCAPE
1515#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1516 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1518 #define JSON_HEDLEY_NO_ESCAPE
1521#if defined(JSON_HEDLEY_UNREACHABLE)
1522 #undef JSON_HEDLEY_UNREACHABLE
1524#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1525 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1527#if defined(JSON_HEDLEY_ASSUME)
1528 #undef JSON_HEDLEY_ASSUME
1531 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1532 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1533 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1534 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1535#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1536 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1538 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1539 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1540 #if defined(__cplusplus)
1541 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1543 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1547 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1548 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1549 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1550 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1551 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1552 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1553 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1554 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1555#elif defined(JSON_HEDLEY_ASSUME)
1556 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1558#if !defined(JSON_HEDLEY_ASSUME)
1559 #if defined(JSON_HEDLEY_UNREACHABLE)
1560 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1562 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1565#if defined(JSON_HEDLEY_UNREACHABLE)
1567 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1568 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1569 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1571 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1574 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1576#if !defined(JSON_HEDLEY_UNREACHABLE)
1577 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1581#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1582 #pragma clang diagnostic ignored "-Wpedantic"
1584#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1585 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1587#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1588 #if defined(__clang__)
1589 #pragma clang diagnostic ignored "-Wvariadic-macros"
1590 #elif defined(JSON_HEDLEY_GCC_VERSION)
1591 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1594#if defined(JSON_HEDLEY_NON_NULL)
1595 #undef JSON_HEDLEY_NON_NULL
1598 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1599 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1600 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1601 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1602 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1604 #define JSON_HEDLEY_NON_NULL(...)
1608#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1609 #undef JSON_HEDLEY_PRINTF_FORMAT
1611#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1612 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1613#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1614 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1616 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1617 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1618 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1619 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1620 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1621 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1622 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1623 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1624 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1625 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1626 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1627 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1628 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1629 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1630 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1631 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1632 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1633 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1634#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1635 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1637 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1640#if defined(JSON_HEDLEY_CONSTEXPR)
1641 #undef JSON_HEDLEY_CONSTEXPR
1643#if defined(__cplusplus)
1644 #if __cplusplus >= 201103L
1645 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1648#if !defined(JSON_HEDLEY_CONSTEXPR)
1649 #define JSON_HEDLEY_CONSTEXPR
1652#if defined(JSON_HEDLEY_PREDICT)
1653 #undef JSON_HEDLEY_PREDICT
1655#if defined(JSON_HEDLEY_LIKELY)
1656 #undef JSON_HEDLEY_LIKELY
1658#if defined(JSON_HEDLEY_UNLIKELY)
1659 #undef JSON_HEDLEY_UNLIKELY
1661#if defined(JSON_HEDLEY_UNPREDICTABLE)
1662 #undef JSON_HEDLEY_UNPREDICTABLE
1664#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1665 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1668 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1669 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1670 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1671# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1672# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1673# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1674# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1675# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1677 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1678 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1679 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1680 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1681 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1682 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1683 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1684 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1685 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1686 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1687 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1688 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1689 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1690 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1691 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1692 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1693# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1694 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1695# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1697 double hedley_probability_ = (probability); \
1698 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1700# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1702 double hedley_probability_ = (probability); \
1703 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1705# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1706# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1708# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1709# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1710# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1711# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1712# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1714#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1715 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1718#if defined(JSON_HEDLEY_MALLOC)
1719 #undef JSON_HEDLEY_MALLOC
1722 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1723 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1724 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1725 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1726 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1727 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1728 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1729 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1730 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1731 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1732 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1733 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1734 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1735 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1736 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1737 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1738 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1739 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1740 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1741#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1742 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1744 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1745 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1746 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1748 #define JSON_HEDLEY_MALLOC
1751#if defined(JSON_HEDLEY_PURE)
1752 #undef JSON_HEDLEY_PURE
1755 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1756 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1757 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1758 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1759 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1760 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1761 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1762 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1763 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1764 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1765 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1766 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1767 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1768 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1769 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1770 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1771 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1772 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1773 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1774# define JSON_HEDLEY_PURE __attribute__((__pure__))
1775#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1776# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1777#elif defined(__cplusplus) && \
1779 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1780 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1781 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1783# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1785# define JSON_HEDLEY_PURE
1788#if defined(JSON_HEDLEY_CONST)
1789 #undef JSON_HEDLEY_CONST
1792 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1793 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1794 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1795 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1796 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1797 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1798 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1799 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1800 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1801 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1802 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1803 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1804 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1805 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1806 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1807 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1808 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1809 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1810 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1811 #define JSON_HEDLEY_CONST __attribute__((__const__))
1813 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1814 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1816 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1819#if defined(JSON_HEDLEY_RESTRICT)
1820 #undef JSON_HEDLEY_RESTRICT
1822#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1823 #define JSON_HEDLEY_RESTRICT restrict
1825 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1826 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1827 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1828 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1829 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1830 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1831 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1832 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1833 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1834 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1835 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1836 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1837 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1838 defined(__clang__) || \
1839 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1840 #define JSON_HEDLEY_RESTRICT __restrict
1841#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1842 #define JSON_HEDLEY_RESTRICT _Restrict
1844 #define JSON_HEDLEY_RESTRICT
1847#if defined(JSON_HEDLEY_INLINE)
1848 #undef JSON_HEDLEY_INLINE
1851 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1852 (defined(__cplusplus) && (__cplusplus >= 199711L))
1853 #define JSON_HEDLEY_INLINE inline
1855 defined(JSON_HEDLEY_GCC_VERSION) || \
1856 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1857 #define JSON_HEDLEY_INLINE __inline__
1859 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1860 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1861 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1862 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1863 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1864 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1865 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1866 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1867 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1868 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1869 #define JSON_HEDLEY_INLINE __inline
1871 #define JSON_HEDLEY_INLINE
1874#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1875 #undef JSON_HEDLEY_ALWAYS_INLINE
1878 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1879 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1880 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1881 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1882 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1883 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1884 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1885 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1886 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1887 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1888 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1889 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1890 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1891 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1892 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1893 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1894 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1895 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1896 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1897# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1899 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1900 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1901# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1902#elif defined(__cplusplus) && \
1904 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1905 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1906 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1907 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1908 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1909 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1911# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1912#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1913# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1915# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1918#if defined(JSON_HEDLEY_NEVER_INLINE)
1919 #undef JSON_HEDLEY_NEVER_INLINE
1922 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1923 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1924 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1925 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1926 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1927 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1928 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1929 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1930 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1931 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1932 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1933 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1934 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1935 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1936 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1937 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1938 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1939 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1940 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1941 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1943 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1944 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1945 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1946#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1947 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1948#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1949 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1950#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1951 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1952#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1953 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1954#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1955 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1957 #define JSON_HEDLEY_NEVER_INLINE
1960#if defined(JSON_HEDLEY_PRIVATE)
1961 #undef JSON_HEDLEY_PRIVATE
1963#if defined(JSON_HEDLEY_PUBLIC)
1964 #undef JSON_HEDLEY_PUBLIC
1966#if defined(JSON_HEDLEY_IMPORT)
1967 #undef JSON_HEDLEY_IMPORT
1969#if defined(_WIN32) || defined(__CYGWIN__)
1970# define JSON_HEDLEY_PRIVATE
1971# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1972# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1975 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1976 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1977 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1978 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1979 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1980 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1982 defined(__TI_EABI__) && \
1984 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1985 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1988 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1989# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1990# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1992# define JSON_HEDLEY_PRIVATE
1993# define JSON_HEDLEY_PUBLIC
1995# define JSON_HEDLEY_IMPORT extern
1998#if defined(JSON_HEDLEY_NO_THROW)
1999 #undef JSON_HEDLEY_NO_THROW
2002 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2003 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2004 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2005 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2006 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2008 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2009 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2010 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2011 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2013 #define JSON_HEDLEY_NO_THROW
2016#if defined(JSON_HEDLEY_FALL_THROUGH)
2017 #undef JSON_HEDLEY_FALL_THROUGH
2020 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2021 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2022 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2023 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2024#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2025 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2026#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2027 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2028#elif defined(__fallthrough)
2029 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2031 #define JSON_HEDLEY_FALL_THROUGH
2034#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2035 #undef JSON_HEDLEY_RETURNS_NON_NULL
2038 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2039 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2040 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2041 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2042#elif defined(_Ret_notnull_)
2043 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2045 #define JSON_HEDLEY_RETURNS_NON_NULL
2048#if defined(JSON_HEDLEY_ARRAY_PARAM)
2049 #undef JSON_HEDLEY_ARRAY_PARAM
2052 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2053 !defined(__STDC_NO_VLA__) && \
2054 !defined(__cplusplus) && \
2055 !defined(JSON_HEDLEY_PGI_VERSION) && \
2056 !defined(JSON_HEDLEY_TINYC_VERSION)
2057 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2059 #define JSON_HEDLEY_ARRAY_PARAM(name)
2062#if defined(JSON_HEDLEY_IS_CONSTANT)
2063 #undef JSON_HEDLEY_IS_CONSTANT
2065#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2066 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2070#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2071 #undef JSON_HEDLEY_IS_CONSTEXPR_
2074 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2075 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2076 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2077 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2078 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2079 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2080 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2081 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2082 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2083 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2084 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2086#if !defined(__cplusplus)
2088 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2089 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2090 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2091 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2092 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2093 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2094 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2095#if defined(__INTPTR_TYPE__)
2096 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2099 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2103 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2104 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2105 !defined(JSON_HEDLEY_PGI_VERSION) && \
2106 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2107 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2108 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2109 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2110 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2111 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2112#if defined(__INTPTR_TYPE__)
2113 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2116 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2119 defined(JSON_HEDLEY_GCC_VERSION) || \
2120 defined(JSON_HEDLEY_INTEL_VERSION) || \
2121 defined(JSON_HEDLEY_TINYC_VERSION) || \
2122 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2123 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2124 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2125 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2126 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2127 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2129# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2133 ((void*) ((expr) * 0L) ) : \
2134((struct { char v[sizeof(void) * 2]; } *) 1) \
2140#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2141 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2142 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2144 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2146 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2147 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2149 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2152#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2153 #undef JSON_HEDLEY_BEGIN_C_DECLS
2155#if defined(JSON_HEDLEY_END_C_DECLS)
2156 #undef JSON_HEDLEY_END_C_DECLS
2158#if defined(JSON_HEDLEY_C_DECL)
2159 #undef JSON_HEDLEY_C_DECL
2161#if defined(__cplusplus)
2162 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2163 #define JSON_HEDLEY_END_C_DECLS }
2164 #define JSON_HEDLEY_C_DECL extern "C"
2166 #define JSON_HEDLEY_BEGIN_C_DECLS
2167 #define JSON_HEDLEY_END_C_DECLS
2168 #define JSON_HEDLEY_C_DECL
2171#if defined(JSON_HEDLEY_STATIC_ASSERT)
2172 #undef JSON_HEDLEY_STATIC_ASSERT
2175 !defined(__cplusplus) && ( \
2176 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2177 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2178 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2179 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2180 defined(_Static_assert) \
2182# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2184 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2185 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2186 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2187# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2189# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2192#if defined(JSON_HEDLEY_NULL)
2193 #undef JSON_HEDLEY_NULL
2195#if defined(__cplusplus)
2196 #if __cplusplus >= 201103L
2197 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2199 #define JSON_HEDLEY_NULL NULL
2201 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2204 #define JSON_HEDLEY_NULL NULL
2206 #define JSON_HEDLEY_NULL ((void*) 0)
2209#if defined(JSON_HEDLEY_MESSAGE)
2210 #undef JSON_HEDLEY_MESSAGE
2212#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2213# define JSON_HEDLEY_MESSAGE(msg) \
2214 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2215 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2216 JSON_HEDLEY_PRAGMA(message msg) \
2217 JSON_HEDLEY_DIAGNOSTIC_POP
2219 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2220 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2221# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2222#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2223# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2224#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2225# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2226#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2227# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2229# define JSON_HEDLEY_MESSAGE(msg)
2232#if defined(JSON_HEDLEY_WARNING)
2233 #undef JSON_HEDLEY_WARNING
2235#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2236# define JSON_HEDLEY_WARNING(msg) \
2237 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2238 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2239 JSON_HEDLEY_PRAGMA(clang warning msg) \
2240 JSON_HEDLEY_DIAGNOSTIC_POP
2242 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2243 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2244 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2245# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2247 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2248 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2249# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2251# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2254#if defined(JSON_HEDLEY_REQUIRE)
2255 #undef JSON_HEDLEY_REQUIRE
2257#if defined(JSON_HEDLEY_REQUIRE_MSG)
2258 #undef JSON_HEDLEY_REQUIRE_MSG
2260#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2261# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2262# define JSON_HEDLEY_REQUIRE(expr) \
2263 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2264 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2265 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2266 JSON_HEDLEY_DIAGNOSTIC_POP
2267# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2268 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2269 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2270 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2271 JSON_HEDLEY_DIAGNOSTIC_POP
2273# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2274# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2277# define JSON_HEDLEY_REQUIRE(expr)
2278# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2281#if defined(JSON_HEDLEY_FLAGS)
2282 #undef JSON_HEDLEY_FLAGS
2284#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2285 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2287 #define JSON_HEDLEY_FLAGS
2290#if defined(JSON_HEDLEY_FLAGS_CAST)
2291 #undef JSON_HEDLEY_FLAGS_CAST
2293#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2294# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2295 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2296 _Pragma("warning(disable:188)") \
2298 JSON_HEDLEY_DIAGNOSTIC_POP \
2301# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2304#if defined(JSON_HEDLEY_EMPTY_BASES)
2305 #undef JSON_HEDLEY_EMPTY_BASES
2308 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2309 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2310 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2312 #define JSON_HEDLEY_EMPTY_BASES
2317#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2318 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2320#if defined(__clang__)
2321 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2323 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2326#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2327 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2329#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2331#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2332 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2334#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2336#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2337 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2339#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2341#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2342 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2344#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2346#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2347 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2349#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2351#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2352 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2354#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2356#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2357 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2359#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2371#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2372 #if defined(__clang__)
2373 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2374 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2376 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2377 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2378 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2385#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2386 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2387 #define JSON_HAS_CPP_20
2388 #define JSON_HAS_CPP_17
2389 #define JSON_HAS_CPP_14
2390 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2391 #define JSON_HAS_CPP_17
2392 #define JSON_HAS_CPP_14
2393 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2394 #define JSON_HAS_CPP_14
2397 #define JSON_HAS_CPP_11
2401 #if __has_include(<version>)
2406#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2407 #ifdef JSON_HAS_CPP_17
2408 #if defined(__cpp_lib_filesystem)
2409 #define JSON_HAS_FILESYSTEM 1
2410 #elif defined(__cpp_lib_experimental_filesystem)
2411 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2412 #elif !defined(__has_include)
2413 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2414 #elif __has_include(<filesystem>)
2415 #define JSON_HAS_FILESYSTEM 1
2416 #elif __has_include(<experimental/filesystem>)
2417 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2421 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2422 #undef JSON_HAS_FILESYSTEM
2423 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2427 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2428 #undef JSON_HAS_FILESYSTEM
2429 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2433 #if defined(__clang_major__) && __clang_major__ < 7
2434 #undef JSON_HAS_FILESYSTEM
2435 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2439 #if defined(_MSC_VER) && _MSC_VER < 1914
2440 #undef JSON_HAS_FILESYSTEM
2441 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2445 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2446 #undef JSON_HAS_FILESYSTEM
2447 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2451 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2452 #undef JSON_HAS_FILESYSTEM
2453 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2458#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2459 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2462#ifndef JSON_HAS_FILESYSTEM
2463 #define JSON_HAS_FILESYSTEM 0
2466#ifndef JSON_HAS_THREE_WAY_COMPARISON
2467 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2468 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2469 #define JSON_HAS_THREE_WAY_COMPARISON 1
2471 #define JSON_HAS_THREE_WAY_COMPARISON 0
2475#ifndef JSON_HAS_RANGES
2477 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2478 #define JSON_HAS_RANGES 0
2479 #elif defined(__cpp_lib_ranges)
2480 #define JSON_HAS_RANGES 1
2482 #define JSON_HAS_RANGES 0
2486#ifdef JSON_HAS_CPP_17
2487 #define JSON_INLINE_VARIABLE inline
2489 #define JSON_INLINE_VARIABLE
2492#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2493 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2495 #define JSON_NO_UNIQUE_ADDRESS
2499#if defined(__clang__)
2500 #pragma clang diagnostic push
2501 #pragma clang diagnostic ignored "-Wdocumentation"
2502 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2506#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2507 #define JSON_THROW(exception) throw exception
2508 #define JSON_TRY try
2509 #define JSON_CATCH(exception) catch(exception)
2510 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2513 #define JSON_THROW(exception) std::abort()
2514 #define JSON_TRY if(true)
2515 #define JSON_CATCH(exception) if(false)
2516 #define JSON_INTERNAL_CATCH(exception) if(false)
2520#if defined(JSON_THROW_USER)
2522 #define JSON_THROW JSON_THROW_USER
2524#if defined(JSON_TRY_USER)
2526 #define JSON_TRY JSON_TRY_USER
2528#if defined(JSON_CATCH_USER)
2530 #define JSON_CATCH JSON_CATCH_USER
2531 #undef JSON_INTERNAL_CATCH
2532 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2534#if defined(JSON_INTERNAL_CATCH_USER)
2535 #undef JSON_INTERNAL_CATCH
2536 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2540#if !defined(JSON_ASSERT)
2542 #define JSON_ASSERT(x) assert(x)
2546#if defined(JSON_TESTS_PRIVATE)
2547 #define JSON_PRIVATE_UNLESS_TESTED public
2549 #define JSON_PRIVATE_UNLESS_TESTED private
2557#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2558 template<typename BasicJsonType> \
2559 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2561 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2562 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2563 auto it = std::find_if(std::begin(m), std::end(m), \
2564 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2566 return ej_pair.first == e; \
2568 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2570 template<typename BasicJsonType> \
2571 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2573 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2574 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2575 auto it = std::find_if(std::begin(m), std::end(m), \
2576 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2578 return ej_pair.second == j; \
2580 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2586#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2587 template<template<typename, typename, typename...> class ObjectType, \
2588 template<typename, typename...> class ArrayType, \
2589 class StringType, class BooleanType, class NumberIntegerType, \
2590 class NumberUnsignedType, class NumberFloatType, \
2591 template<typename> class AllocatorType, \
2592 template<typename, typename = void> class JSONSerializer, \
2595#define NLOHMANN_BASIC_JSON_TPL \
2596 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2597 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2598 AllocatorType, JSONSerializer, BinaryType>
2602#define NLOHMANN_JSON_EXPAND( x ) x
2603#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
2604#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2605 NLOHMANN_JSON_PASTE64, \
2606 NLOHMANN_JSON_PASTE63, \
2607 NLOHMANN_JSON_PASTE62, \
2608 NLOHMANN_JSON_PASTE61, \
2609 NLOHMANN_JSON_PASTE60, \
2610 NLOHMANN_JSON_PASTE59, \
2611 NLOHMANN_JSON_PASTE58, \
2612 NLOHMANN_JSON_PASTE57, \
2613 NLOHMANN_JSON_PASTE56, \
2614 NLOHMANN_JSON_PASTE55, \
2615 NLOHMANN_JSON_PASTE54, \
2616 NLOHMANN_JSON_PASTE53, \
2617 NLOHMANN_JSON_PASTE52, \
2618 NLOHMANN_JSON_PASTE51, \
2619 NLOHMANN_JSON_PASTE50, \
2620 NLOHMANN_JSON_PASTE49, \
2621 NLOHMANN_JSON_PASTE48, \
2622 NLOHMANN_JSON_PASTE47, \
2623 NLOHMANN_JSON_PASTE46, \
2624 NLOHMANN_JSON_PASTE45, \
2625 NLOHMANN_JSON_PASTE44, \
2626 NLOHMANN_JSON_PASTE43, \
2627 NLOHMANN_JSON_PASTE42, \
2628 NLOHMANN_JSON_PASTE41, \
2629 NLOHMANN_JSON_PASTE40, \
2630 NLOHMANN_JSON_PASTE39, \
2631 NLOHMANN_JSON_PASTE38, \
2632 NLOHMANN_JSON_PASTE37, \
2633 NLOHMANN_JSON_PASTE36, \
2634 NLOHMANN_JSON_PASTE35, \
2635 NLOHMANN_JSON_PASTE34, \
2636 NLOHMANN_JSON_PASTE33, \
2637 NLOHMANN_JSON_PASTE32, \
2638 NLOHMANN_JSON_PASTE31, \
2639 NLOHMANN_JSON_PASTE30, \
2640 NLOHMANN_JSON_PASTE29, \
2641 NLOHMANN_JSON_PASTE28, \
2642 NLOHMANN_JSON_PASTE27, \
2643 NLOHMANN_JSON_PASTE26, \
2644 NLOHMANN_JSON_PASTE25, \
2645 NLOHMANN_JSON_PASTE24, \
2646 NLOHMANN_JSON_PASTE23, \
2647 NLOHMANN_JSON_PASTE22, \
2648 NLOHMANN_JSON_PASTE21, \
2649 NLOHMANN_JSON_PASTE20, \
2650 NLOHMANN_JSON_PASTE19, \
2651 NLOHMANN_JSON_PASTE18, \
2652 NLOHMANN_JSON_PASTE17, \
2653 NLOHMANN_JSON_PASTE16, \
2654 NLOHMANN_JSON_PASTE15, \
2655 NLOHMANN_JSON_PASTE14, \
2656 NLOHMANN_JSON_PASTE13, \
2657 NLOHMANN_JSON_PASTE12, \
2658 NLOHMANN_JSON_PASTE11, \
2659 NLOHMANN_JSON_PASTE10, \
2660 NLOHMANN_JSON_PASTE9, \
2661 NLOHMANN_JSON_PASTE8, \
2662 NLOHMANN_JSON_PASTE7, \
2663 NLOHMANN_JSON_PASTE6, \
2664 NLOHMANN_JSON_PASTE5, \
2665 NLOHMANN_JSON_PASTE4, \
2666 NLOHMANN_JSON_PASTE3, \
2667 NLOHMANN_JSON_PASTE2, \
2668 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2669#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2670#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2671#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2672#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2673#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2674#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)
2675#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)
2676#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)
2677#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)
2678#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)
2679#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)
2680#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)
2681#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)
2682#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)
2683#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)
2684#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)
2685#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)
2686#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)
2687#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)
2688#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)
2689#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)
2690#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)
2691#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)
2692#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)
2693#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)
2694#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)
2695#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)
2696#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)
2697#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)
2698#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)
2699#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)
2700#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)
2701#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)
2702#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)
2703#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)
2704#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)
2705#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)
2706#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)
2707#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)
2708#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)
2709#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)
2710#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)
2711#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)
2712#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)
2713#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)
2714#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)
2715#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)
2716#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)
2717#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)
2718#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)
2719#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)
2720#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)
2721#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)
2722#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)
2723#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)
2724#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)
2725#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)
2726#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)
2727#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)
2728#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)
2729#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)
2730#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)
2731#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)
2733#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2734#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2735#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2742#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2743 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2744 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2746#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2747 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2748 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2755#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2756 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2757 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2759#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2760 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2761 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2770#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2771 namespace detail { \
2772 using std::std_name; \
2774 template<typename... T> \
2775 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2778 namespace detail2 { \
2779 struct std_name##_tag \
2783 template<typename... T> \
2784 std_name##_tag std_name(T&&...); \
2786 template<typename... T> \
2787 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2789 template<typename... T> \
2790 struct would_call_std_##std_name \
2792 static constexpr auto const value = ::nlohmann::detail:: \
2793 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2797 template<typename... T> \
2798 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2802#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2803 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2806#if JSON_USE_IMPLICIT_CONVERSIONS
2807 #define JSON_EXPLICIT
2809 #define JSON_EXPLICIT explicit
2812#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2813 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2816#ifndef JSON_USE_GLOBAL_UDLS
2817 #define JSON_USE_GLOBAL_UDLS 1
2820#if JSON_HAS_THREE_WAY_COMPARISON
2883#if JSON_HAS_THREE_WAY_COMPARISON
2884 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2889 static constexpr std::array<std::uint8_t, 9> order = {{
2896 const auto l_index =
static_cast<std::size_t
>(lhs);
2897 const auto r_index =
static_cast<std::size_t
>(rhs);
2898#if JSON_HAS_THREE_WAY_COMPARISON
2899 if (l_index < order.size() && r_index < order.size())
2901 return order[l_index] <=> order[r_index];
2903 return std::partial_ordering::unordered;
2905 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2913#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2916 return std::is_lt(lhs <=> rhs);
2954template<
typename StringType>
2956 const StringType& t)
2959 for (
auto pos = s.find(f);
2960 pos != StringType::npos;
2961 s.replace(pos, f.size(), t),
2962 pos = s.find(f, pos + t.size()))
2973template<
typename StringType>
2988template<
typename StringType>
3029 constexpr operator size_t()
const
3054#include <type_traits>
3065using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3067#ifdef JSON_HAS_CPP_14
3070using std::enable_if_t;
3071using std::index_sequence;
3072using std::make_index_sequence;
3073using std::index_sequence_for;
3078template<
bool B,
typename T =
void>
3105template <
typename T, T... Ints>
3109 static constexpr std::size_t
size() noexcept
3111 return sizeof...(Ints);
3120template <
size_t... Ints>
3123namespace utility_internal
3126template <
typename Seq,
size_t SeqSize,
size_t Rem>
3130template <
typename T, T... Ints,
size_t SeqSize>
3136template <
typename T, T... Ints,
size_t SeqSize>
3144template <
typename T,
size_t N>
3151template <
typename T>
3166template <
typename T, T N>
3182template <
typename... Ts>
3200#ifndef JSON_HAS_CPP_17
3201 template<
typename T>
3205template<
typename T,
typename... Args>
3206inline constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3208 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3226#include <type_traits>
3254template<
typename It,
typename =
void>
3257template<
typename It>
3261 typename It::reference, typename It::iterator_category >>
3272template<
typename T,
typename =
void>
3351#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3352 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3377 template<
typename T =
void,
typename SFINAE =
void>
3382 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3384 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3385 class StringType = std::string,
class BooleanType =
bool,
3386 class NumberIntegerType = std::int64_t,
3387 class NumberUnsignedType = std::uint64_t,
3388 class NumberFloatType = double,
3389 template<
typename U>
class AllocatorType = std::allocator,
3390 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3392 class BinaryType = std::vector<std::uint8_t>>
3397 template<
typename RefStringType>
3408 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3453template<
typename BasicJsonContext>
3455 std::integral_constant < bool,
3456 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3457 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3498template<
typename T,
typename... Args>
3501template<
typename T,
typename... Args>
3504template<
typename T,
typename U>
3508template<
typename BasicJsonType,
typename T,
typename =
void>
3515template <
typename BasicJsonType,
typename T>
3521template<
typename BasicJsonType,
typename T>
3524 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3526 static constexpr bool value =
3528 const BasicJsonType&, T&>::value;
3533template<
typename BasicJsonType,
typename T,
typename =
void>
3536template<
typename BasicJsonType,
typename T>
3539 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3541 static constexpr bool value =
3543 const BasicJsonType&>::value;
3548template<
typename BasicJsonType,
typename T,
typename =
void>
3551template<
typename BasicJsonType,
typename T>
3554 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3556 static constexpr bool value =
3565struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3568template<
typename BasicJsonType>
3573 using type =
typename std::conditional < has_key_compare<object_t>::value,
3577template<
typename BasicJsonType>
3587template<
class B,
class... Bn>
3589: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3592template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3597template <
typename T>
3600template <
typename T1,
typename T2>
3602 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3604template <
typename T1,
typename T2>
3606 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3608template <
typename... Ts>
3610 :
conjunction<is_default_constructible<Ts>...> {};
3612template <
typename... Ts>
3614 :
conjunction<is_default_constructible<Ts>...> {};
3617template <
typename T,
typename... Args>
3620template <
typename T1,
typename T2>
3623template <
typename T1,
typename T2>
3626template <
typename... Ts>
3629template <
typename... Ts>
3633template<
typename T,
typename =
void>
3643 static constexpr auto value =
3655 using t_ref =
typename std::add_lvalue_reference<T>::type;
3663 static constexpr auto is_iterator_begin =
3667 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3680template<
typename T,
typename =
void>
3686template<
typename BasicJsonType,
typename CompatibleObjectType,
3690template<
typename BasicJsonType,
typename CompatibleObjectType>
3692 BasicJsonType, CompatibleObjectType,
3694 is_detected<key_type_t, CompatibleObjectType>::value >>
3699 static constexpr bool value =
3701 typename CompatibleObjectType::key_type>::value &&
3703 typename CompatibleObjectType::mapped_type>::value;
3706template<
typename BasicJsonType,
typename CompatibleObjectType>
3710template<
typename BasicJsonType,
typename ConstructibleObjectType,
3714template<
typename BasicJsonType,
typename ConstructibleObjectType>
3716 BasicJsonType, ConstructibleObjectType,
3718 is_detected<key_type_t, ConstructibleObjectType>::value >>
3722 static constexpr bool value =
3724 (std::is_move_assignable<ConstructibleObjectType>::value ||
3725 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3727 typename object_t::key_type>::value &&
3729 typename object_t::mapped_type,
3730 typename ConstructibleObjectType::mapped_type >::value)) ||
3732 typename ConstructibleObjectType::mapped_type>::value ||
3735 typename ConstructibleObjectType::mapped_type >::value);
3738template<
typename BasicJsonType,
typename ConstructibleObjectType>
3741 ConstructibleObjectType> {};
3743template<
typename BasicJsonType,
typename CompatibleStringType>
3750template<
typename BasicJsonType,
typename ConstructibleStringType>
3754#ifdef __INTEL_COMPILER
3755 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3767template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3770template<
typename BasicJsonType,
typename CompatibleArrayType>
3772 BasicJsonType, CompatibleArrayType,
3775 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
3778 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3780 static constexpr bool value =
3785template<
typename BasicJsonType,
typename CompatibleArrayType>
3789template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3792template<
typename BasicJsonType,
typename ConstructibleArrayType>
3794 BasicJsonType, ConstructibleArrayType,
3796 typename BasicJsonType::value_type>::value >>
3797 : std::true_type {};
3799template<
typename BasicJsonType,
typename ConstructibleArrayType>
3801 BasicJsonType, ConstructibleArrayType,
3803 typename BasicJsonType::value_type>::value&&
3806(std::is_move_assignable<ConstructibleArrayType>::value ||
3807 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3808is_detected<iterator_t, ConstructibleArrayType>::value&&
3809is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3810is_detected<range_value_t, ConstructibleArrayType>::value&&
3813!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
3815 detected_t<range_value_t, ConstructibleArrayType >>::value >>
3819 static constexpr bool value =
3821 typename BasicJsonType::array_t::value_type>::value ||
3829template<
typename BasicJsonType,
typename ConstructibleArrayType>
3833template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3837template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3839 RealIntegerType, CompatibleNumberIntegerType,
3841 std::is_integral<CompatibleNumberIntegerType>::value&&
3842 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3848 static constexpr auto value =
3850 CompatibleNumberIntegerType>::value &&
3851 CompatibleLimits::is_integer &&
3852 RealLimits::is_signed == CompatibleLimits::is_signed;
3855template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3858 CompatibleNumberIntegerType> {};
3860template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3863template<
typename BasicJsonType,
typename CompatibleType>
3865 BasicJsonType, CompatibleType,
3868 static constexpr bool value =
3872template<
typename BasicJsonType,
typename CompatibleType>
3876template<
typename T1,
typename T2>
3879template<
typename T1,
typename... Args>
3882template<
typename BasicJsonType,
typename T>
3885template<
typename BasicJsonType>
3888template<
typename BasicJsonType>
3893template<
template <
typename...>
class Primary,
typename T>
3896template<
template <
typename...>
class Primary,
typename... Args>
3903template<
typename Compare,
typename A,
typename B,
typename =
void>
3906template<
typename Compare,
typename A,
typename B>
3908decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3909decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3910>> : std::true_type {};
3917template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3921 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3922 ObjectKeyType>::value)
3923 && (!RequireTransparentComparator
3924 || is_detected <detect_is_transparent, Comparator>::value)
3927 std::false_type >::type;
3935template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3939 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3940 RequireTransparentComparator, ExcludeObjectKeyType>::value
3943 std::false_type >::type;
3945template<
typename ObjectType,
typename KeyType>
3949template<
typename BasicJsonType,
typename KeyType>
3953 typename BasicJsonType::object_t, KeyType >::value,
3955 std::false_type >::type;
3959template <
typename T>
3969 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3972 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3976template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3979 return static_cast<T
>(value);
3982template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3988template<
typename... Types>
3991template<
typename... Types>
3994template<
typename... Types>
3998template<
typename... Types>
4002template<
typename OfType,
typename T>
4004 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4007template<
typename OfType,
typename T,
4008 bool OfTypeSigned = std::is_signed<OfType>::value,
4009 bool TSigned = std::is_signed<T>::value>
4012template<
typename OfType,
typename T>
4017 using CommonType =
typename std::common_type<OfType, T>::type;
4018 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4022template<
typename OfType,
typename T>
4027 using CommonType =
typename std::common_type<OfType, T>::type;
4028 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4032template<
typename OfType,
typename T>
4037 using CommonType =
typename std::common_type<OfType, T>::type;
4038 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4043template<
typename OfType,
typename T>
4048 using CommonType =
typename std::common_type<OfType, T>::type;
4049 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4050 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4054template<
typename OfType,
typename T,
4055 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4059template<
typename OfType,
typename T>
4068template<
typename OfType,
typename T>
4077template<
typename OfType,
typename T>
4096 using TUnExt =
typename std::remove_extent<T>::type;
4097 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4098 using TUnPtr =
typename std::remove_pointer<T>::type;
4099 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4101 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4102 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4167template<
typename... Args>
4168inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
4170template<
typename StringType,
typename... Args>
4171inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
4173template<
typename... Args>
4179template<
typename... Args>
4183 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
4186template<
typename StringType,
typename... Args>
4189 return str.size() +
concat_length(std::forward<Args>(rest)...);
4192template<
typename OutStringType>
4196template<
typename StringType,
typename Arg>
4199template<
typename StringType,
typename Arg>
4202template<
typename StringType,
typename Arg>
4205template<
typename StringType,
typename Arg>
4208template<
typename StringType,
typename Arg>
4209using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4211template<
typename StringType,
typename Arg>
4214template<
typename StringType,
typename Arg>
4215using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4217template<
typename StringType,
typename Arg>
4220template <
typename OutStringType,
typename Arg,
typename... Args,
4221 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4223inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4225template <
typename OutStringType,
typename Arg,
typename... Args,
4226 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4229inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4231template <
typename OutStringType,
typename Arg,
typename... Args,
4232 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4236inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4238template<
typename OutStringType,
typename Arg,
typename... Args,
4240inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4242 out.append(std::forward<Arg>(arg));
4246template <
typename OutStringType,
typename Arg,
typename... Args,
4247 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4248 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4249inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4251 out += std::forward<Arg>(arg);
4255template <
typename OutStringType,
typename Arg,
typename... Args,
4256 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4257 && !detect_string_can_append_op<OutStringType, Arg>::value
4258 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4259inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4261 out.append(arg.begin(), arg.end());
4265template <
typename OutStringType,
typename Arg,
typename... Args,
4266 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4267 && !detect_string_can_append_op<OutStringType, Arg>::value
4268 && !detect_string_can_append_iter<OutStringType, Arg>::value
4269 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4270inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4272 out.append(arg.data(), arg.size());
4276template<
typename OutStringType = std::string,
typename... Args>
4304 const char*
what() const noexcept
override
4314 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4316 static std::string
name(
const std::string& ename,
int id_)
4318 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4326 template<
typename BasicJsonType>
4330 std::vector<std::string> tokens;
4331 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4333 switch (current->m_parent->type())
4337 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
4339 if (¤t->m_parent->m_value.array->operator[](i) == current)
4341 tokens.emplace_back(std::to_string(i));
4350 for (
const auto& element : *current->m_parent->m_value.object)
4352 if (&element.second == current)
4354 tokens.emplace_back(element.first.c_str());
4379 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4380 [](
const std::string & a,
const std::string & b)
4382 return concat(a,
'/', detail::escape(b));
4384 return concat(
'(', str,
") ");
4386 static_cast<void>(leaf_element);
4393 std::runtime_error m;
4410 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4418 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4419 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4422 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4424 return {id_, byte_, w.c_str()};
4439 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4442 static std::string position_string(
const position_t& pos)
4454 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4458 return {id_, w.c_str()};
4472 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4476 return {id_, w.c_str()};
4489 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4493 return {id_, w.c_str()};
4506 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4510 return {id_, w.c_str()};
4544template <
class T>
struct identity_tag {};
4563#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4564#include <experimental/filesystem>
4568namespace std_fs = std::experimental::filesystem;
4571#elif JSON_HAS_FILESYSTEM
4572#include <filesystem>
4576namespace std_fs = std::filesystem;
4592template<
typename BasicJsonType>
4593inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4603template <
typename BasicJsonType,
typename ArithmeticType,
4604 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4605 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4607void get_arithmetic_value(
const BasicJsonType& j, ArithmeticType& val)
4609 switch (
static_cast<value_t>(j))
4613 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4618 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4623 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4639template<
typename BasicJsonType>
4640inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4646 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4649template<
typename BasicJsonType>
4650inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4656 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4660 typename BasicJsonType,
typename StringType,
4662 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4663 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4664 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4665 && !is_json_ref<StringType>::value,
int > = 0 >
4666inline void from_json(
const BasicJsonType& j, StringType& s)
4673 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4676template<
typename BasicJsonType>
4677inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4679 get_arithmetic_value(j, val);
4682template<
typename BasicJsonType>
4683inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4685 get_arithmetic_value(j, val);
4688template<
typename BasicJsonType>
4689inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4691 get_arithmetic_value(j, val);
4694#if !JSON_DISABLE_ENUM_SERIALIZATION
4695template<
typename BasicJsonType,
typename EnumType,
4696 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4697inline void from_json(
const BasicJsonType& j, EnumType& e)
4699 typename std::underlying_type<EnumType>::type val;
4700 get_arithmetic_value(j, val);
4701 e =
static_cast<EnumType
>(val);
4706template<
typename BasicJsonType,
typename T,
typename Allocator,
4707 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4708inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4715 std::transform(j.rbegin(), j.rend(),
4716 std::front_inserter(l), [](
const BasicJsonType & i)
4718 return i.template get<T>();
4723template<
typename BasicJsonType,
typename T,
4724 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4725inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4732 std::transform(j.begin(), j.end(), std::begin(l),
4733 [](
const BasicJsonType & elem)
4735 return elem.template get<T>();
4739template<
typename BasicJsonType,
typename T, std::
size_t N>
4740auto from_json(
const BasicJsonType& j, T (&arr)[N])
4741->
decltype(j.template get<T>(), void())
4743 for (std::size_t i = 0; i < N; ++i)
4745 arr[i] = j.at(i).template get<T>();
4749template<
typename BasicJsonType>
4750inline void from_json_array_impl(
const BasicJsonType& j,
typename BasicJsonType::array_t& arr, priority_tag<3> )
4752 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4755template<
typename BasicJsonType,
typename T, std::
size_t N>
4756auto from_json_array_impl(
const BasicJsonType& j, std::array<T, N>& arr,
4758->
decltype(j.template get<T>(), void())
4760 for (std::size_t i = 0; i < N; ++i)
4762 arr[i] = j.at(i).template get<T>();
4766template<
typename BasicJsonType,
typename ConstructibleArrayType,
4768 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4770auto from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> )
4772 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4773 j.template get<typename ConstructibleArrayType::value_type>(),
4778 ConstructibleArrayType ret;
4779 ret.reserve(j.size());
4780 std::transform(j.begin(), j.end(),
4781 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4785 return i.template get<typename ConstructibleArrayType::value_type>();
4787 arr = std::move(ret);
4790template<
typename BasicJsonType,
typename ConstructibleArrayType,
4792 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4794inline void from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr,
4799 ConstructibleArrayType ret;
4801 j.begin(), j.end(), std::inserter(ret, end(ret)),
4802 [](
const BasicJsonType & i)
4806 return i.template get<typename ConstructibleArrayType::value_type>();
4808 arr = std::move(ret);
4811template <
typename BasicJsonType,
typename ConstructibleArrayType,
4813 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4814 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4816 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4817 !is_basic_json<ConstructibleArrayType>::value,
4819auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4820->
decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
4821j.template get<typename ConstructibleArrayType::value_type>(),
4829 from_json_array_impl(j, arr, priority_tag<3> {});
4832template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4833std::array<T,
sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
4834 identity_tag<std::array<T,
sizeof...(Idx)>> ,
index_sequence<Idx...> )
4836 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4839template <
typename BasicJsonType,
typename T, std::
size_t N >
4840auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
4841->
decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
4848 return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
4851template<
typename BasicJsonType>
4852inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4859 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4862template<
typename BasicJsonType,
typename ConstructibleObjectType,
4863 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4864inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4871 ConstructibleObjectType ret;
4872 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4873 using value_type =
typename ConstructibleObjectType::value_type;
4875 inner_object->begin(), inner_object->end(),
4876 std::inserter(ret, ret.begin()),
4877 [](
typename BasicJsonType::object_t::value_type
const & p)
4879 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4881 obj = std::move(ret);
4888template <
typename BasicJsonType,
typename ArithmeticType,
4890 std::is_arithmetic<ArithmeticType>::value&&
4891 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4892 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4893 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4894 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4896inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4898 switch (
static_cast<value_t>(j))
4902 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4907 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4912 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4917 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4932template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4933std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> )
4935 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4938template <
typename BasicJsonType,
class A1,
class A2 >
4939std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> , priority_tag<0> )
4941 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4942 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4945template<
typename BasicJsonType,
typename A1,
typename A2>
4946inline void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> )
4948 p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
4951template<
typename BasicJsonType,
typename... Args>
4952std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> , priority_tag<2> )
4954 return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
index_sequence_for<Args...> {});
4957template<
typename BasicJsonType,
typename... Args>
4958inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> )
4960 t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
index_sequence_for<Args...> {});
4963template<
typename BasicJsonType,
typename TupleRelated>
4964auto from_json(BasicJsonType&& j, TupleRelated&& t)
4965->
decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
4972 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4975template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4977 typename BasicJsonType::string_t, Key >::value >>
4978inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4985 for (
const auto& p : j)
4991 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4995template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4997 typename BasicJsonType::string_t, Key >::value >>
4998inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5005 for (
const auto& p : j)
5011 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5015#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5016template<
typename BasicJsonType>
5017inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5023 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5029 template<
typename BasicJsonType,
typename T>
5030 auto operator()(
const BasicJsonType& j, T&& val)
const
5031 noexcept(
noexcept(from_json(j, std::forward<T>(val))))
5032 ->
decltype(from_json(j, std::forward<T>(val)))
5034 return from_json(j, std::forward<T>(val));
5040#ifndef JSON_HAS_CPP_17
5049#ifndef JSON_HAS_CPP_17
5070#include <type_traits>
5107template<
typename string_type>
5111 using std::to_string;
5122 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5126 IteratorType anchor{};
5128 std::size_t array_index = 0;
5130 mutable std::size_t array_index_last = 0;
5139 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5141 : anchor(
std::move(it))
5142 , array_index(array_index_)
5149 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5152 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5182 return anchor == o.anchor;
5188 return anchor != o.anchor;
5196 switch (anchor.m_object->type())
5201 if (array_index != array_index_last)
5204 array_index_last = array_index;
5206 return array_index_str;
5211 return anchor.key();
5228 typename IteratorType::reference
value()
const
5230 return anchor.value();
5239 typename IteratorType::pointer container =
nullptr;
5246 : container(&cont) {}
5270template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5271auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5278template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5279auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5294#if defined(__clang__)
5296 #pragma clang diagnostic push
5297 #pragma clang diagnostic ignored "-Wmismatched-tags"
5299template<
typename IteratorType>
5300class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5301 :
public std::integral_constant<std::size_t, 2> {};
5303template<std::
size_t N,
typename IteratorType>
5304class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5308 get<N>(std::declval <
5309 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5311#if defined(__clang__)
5312 #pragma clang diagnostic pop
5318 template <
typename IteratorType>
5319 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5353 template<
typename BasicJsonType>
5354 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5356 j.m_value.destroy(j.m_type);
5359 j.assert_invariant();
5366 template<
typename BasicJsonType>
5367 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5369 j.m_value.destroy(j.m_type);
5372 j.assert_invariant();
5375 template<
typename BasicJsonType>
5376 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5378 j.m_value.destroy(j.m_type);
5380 j.m_value = std::move(s);
5381 j.assert_invariant();
5384 template <
typename BasicJsonType,
typename CompatibleStringType,
5385 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5387 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5389 j.m_value.destroy(j.m_type);
5391 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5392 j.assert_invariant();
5399 template<
typename BasicJsonType>
5400 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5402 j.m_value.destroy(j.m_type);
5404 j.m_value =
typename BasicJsonType::binary_t(b);
5405 j.assert_invariant();
5408 template<
typename BasicJsonType>
5409 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5411 j.m_value.destroy(j.m_type);
5413 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
5414 j.assert_invariant();
5421 template<
typename BasicJsonType>
5422 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5424 j.m_value.destroy(j.m_type);
5427 j.assert_invariant();
5434 template<
typename BasicJsonType>
5435 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5437 j.m_value.destroy(j.m_type);
5440 j.assert_invariant();
5447 template<
typename BasicJsonType>
5448 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5450 j.m_value.destroy(j.m_type);
5453 j.assert_invariant();
5460 template<
typename BasicJsonType>
5461 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5463 j.m_value.destroy(j.m_type);
5467 j.assert_invariant();
5470 template<
typename BasicJsonType>
5471 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5473 j.m_value.destroy(j.m_type);
5475 j.m_value = std::move(arr);
5477 j.assert_invariant();
5480 template <
typename BasicJsonType,
typename CompatibleArrayType,
5481 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5483 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5488 j.m_value.destroy(j.m_type);
5490 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5492 j.assert_invariant();
5495 template<
typename BasicJsonType>
5496 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5498 j.m_value.destroy(j.m_type);
5501 j.m_value.array->reserve(arr.size());
5502 for (
const bool x : arr)
5504 j.m_value.array->push_back(x);
5505 j.set_parent(j.m_value.array->back());
5507 j.assert_invariant();
5510 template<
typename BasicJsonType,
typename T,
5512 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5514 j.m_value.destroy(j.m_type);
5517 j.m_value.array->resize(arr.size());
5520 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
5523 j.assert_invariant();
5530 template<
typename BasicJsonType>
5531 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5533 j.m_value.destroy(j.m_type);
5537 j.assert_invariant();
5540 template<
typename BasicJsonType>
5541 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5543 j.m_value.destroy(j.m_type);
5545 j.m_value = std::move(obj);
5547 j.assert_invariant();
5550 template <
typename BasicJsonType,
typename CompatibleObjectType,
5551 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5552 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5557 j.m_value.destroy(j.m_type);
5559 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5561 j.assert_invariant();
5569template<
typename BasicJsonType,
typename T,
5570 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5571inline void to_json(BasicJsonType& j, T b)
noexcept
5576template <
typename BasicJsonType,
typename BoolRef,
5578 ((std::is_same<std::vector<bool>::reference, BoolRef>::value
5579 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>::value)
5580 || (std::is_same<std::vector<bool>::const_reference, BoolRef>::value
5582 typename BasicJsonType::boolean_t >::value))
5583 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5584inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5589template<
typename BasicJsonType,
typename CompatibleString,
5590 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5591inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5596template<
typename BasicJsonType>
5597inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5602template<
typename BasicJsonType,
typename FloatType,
5603 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5604inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5609template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5610 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5611inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5616template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5617 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5618inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5623#if !JSON_DISABLE_ENUM_SERIALIZATION
5624template<
typename BasicJsonType,
typename EnumType,
5625 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5626inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5628 using underlying_type =
typename std::underlying_type<EnumType>::type;
5633template<
typename BasicJsonType>
5634inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5639template <
typename BasicJsonType,
typename CompatibleArrayType,
5640 enable_if_t < is_compatible_array_type<BasicJsonType,
5641 CompatibleArrayType>::value&&
5642 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5644 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5645 !is_basic_json<CompatibleArrayType>::value,
5647inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5652template<
typename BasicJsonType>
5653inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5658template<
typename BasicJsonType,
typename T,
5659 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5660inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5665template<
typename BasicJsonType>
5666inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5671template <
typename BasicJsonType,
typename CompatibleObjectType,
5672 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5673inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5678template<
typename BasicJsonType>
5679inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5685 typename BasicJsonType,
typename T, std::size_t N,
5686 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5687 const T(&)[N]>::value,
5689inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5694template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5695inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5697 j = { p.first, p.second };
5701template<
typename BasicJsonType,
typename T,
5702 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5705 j = { {b.key(), b.value()} };
5708template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5711 j = { std::get<Idx>(t)... };
5714template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5715inline void to_json(BasicJsonType& j,
const T& t)
5720#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5721template<
typename BasicJsonType>
5722inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5730 template<
typename BasicJsonType,
typename T>
5731 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5732 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5734 return to_json(j, std::forward<T>(val));
5739#ifndef JSON_HAS_CPP_17
5748#ifndef JSON_HAS_CPP_17
5760template<
typename ValueType,
typename>
5765 template<
typename BasicJsonType,
typename TargetType = ValueType>
5766 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5767 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5768 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
5770 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5775 template<
typename BasicJsonType,
typename TargetType = ValueType>
5777 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
5778 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
5780 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
5785 template<
typename BasicJsonType,
typename TargetType = ValueType>
5786 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5787 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5788 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
5790 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5818template<
typename BinaryType>
5843 , m_subtype(subtype_)
5844 , m_has_subtype(
true)
5850 , m_subtype(subtype_)
5851 , m_has_subtype(
true)
5856 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5857 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5862 return !(rhs == *
this);
5869 m_subtype = subtype_;
5870 m_has_subtype =
true;
5877 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5884 return m_has_subtype;
5892 m_has_subtype =
false;
5897 bool m_has_subtype =
false;
5921#include <functional>
5933inline std::size_t combine(std::size_t seed, std::size_t h)
noexcept
5935 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5950template<
typename BasicJsonType>
5951std::size_t hash(
const BasicJsonType& j)
5953 using string_t =
typename BasicJsonType::string_t;
5954 using number_integer_t =
typename BasicJsonType::number_integer_t;
5955 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5956 using number_float_t =
typename BasicJsonType::number_float_t;
5958 const auto type =
static_cast<std::size_t
>(j.type());
5961 case BasicJsonType::value_t::null:
5962 case BasicJsonType::value_t::discarded:
5964 return combine(type, 0);
5967 case BasicJsonType::value_t::object:
5969 auto seed = combine(type, j.size());
5970 for (
const auto& element : j.items())
5972 const auto h = std::hash<string_t> {}(element.key());
5973 seed = combine(seed, h);
5974 seed = combine(seed, hash(element.value()));
5979 case BasicJsonType::value_t::array:
5981 auto seed = combine(type, j.size());
5982 for (
const auto& element : j)
5984 seed = combine(seed, hash(element));
5989 case BasicJsonType::value_t::string:
5991 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5992 return combine(type, h);
5995 case BasicJsonType::value_t::boolean:
5997 const auto h = std::hash<bool> {}(j.template get<bool>());
5998 return combine(type, h);
6001 case BasicJsonType::value_t::number_integer:
6003 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6004 return combine(type, h);
6007 case BasicJsonType::value_t::number_unsigned:
6009 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6010 return combine(type, h);
6013 case BasicJsonType::value_t::number_float:
6015 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6016 return combine(type, h);
6019 case BasicJsonType::value_t::binary:
6021 auto seed = combine(type, j.get_binary().size());
6022 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6023 seed = combine(seed, h);
6024 seed = combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6025 for (
const auto byte : j.get_binary())
6027 seed = combine(seed, std::hash<std::uint8_t> {}(byte));
6085#include <type_traits>
6103enum class input_format_t {
json, cbor, msgpack, ubjson, bson, bjdata };
6114class file_input_adapter
6117 using char_type = char;
6120 explicit file_input_adapter(
std::FILE* f) noexcept
6127 file_input_adapter(
const file_input_adapter&) =
delete;
6128 file_input_adapter(file_input_adapter&&) noexcept = default;
6129 file_input_adapter& operator=(const file_input_adapter&) = delete;
6130 file_input_adapter& operator=(file_input_adapter&&) = delete;
6131 ~file_input_adapter() = default;
6133 std::char_traits<
char>::int_type get_character() noexcept
6135 return std::fgetc(m_file);
6153class input_stream_adapter
6156 using char_type = char;
6158 ~input_stream_adapter()
6164 is->clear(is->rdstate() & std::ios::eofbit);
6168 explicit input_stream_adapter(std::istream& i)
6169 : is(&i), sb(i.rdbuf())
6173 input_stream_adapter(
const input_stream_adapter&) =
delete;
6174 input_stream_adapter& operator=(input_stream_adapter&) =
delete;
6175 input_stream_adapter& operator=(input_stream_adapter&&) =
delete;
6177 input_stream_adapter(input_stream_adapter&& rhs) noexcept
6178 : is(rhs.is), sb(rhs.sb)
6187 std::char_traits<char>::int_type get_character()
6189 auto res = sb->sbumpc();
6193 is->clear(is->rdstate() | std::ios::eofbit);
6200 std::istream* is =
nullptr;
6201 std::streambuf* sb =
nullptr;
6207template<
typename IteratorType>
6208class iterator_input_adapter
6211 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6213 iterator_input_adapter(IteratorType first, IteratorType last)
6214 : current(
std::move(first)), end(
std::move(last))
6217 typename std::char_traits<char_type>::int_type get_character()
6221 auto result = std::char_traits<char_type>::to_int_type(*current);
6222 std::advance(current, 1);
6226 return std::char_traits<char_type>::eof();
6230 IteratorType current;
6233 template<
typename BaseInputAdapter,
size_t T>
6234 friend struct wide_string_input_helper;
6238 return current == end;
6243template<
typename BaseInputAdapter,
size_t T>
6244struct wide_string_input_helper;
6246template<
typename BaseInputAdapter>
6247struct wide_string_input_helper<BaseInputAdapter, 4>
6250 static void fill_buffer(BaseInputAdapter& input,
6251 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6252 size_t& utf8_bytes_index,
6253 size_t& utf8_bytes_filled)
6255 utf8_bytes_index = 0;
6259 utf8_bytes[0] = std::char_traits<char>::eof();
6260 utf8_bytes_filled = 1;
6265 const auto wc = input.get_character();
6270 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6271 utf8_bytes_filled = 1;
6273 else if (wc <= 0x7FF)
6275 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6276 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6277 utf8_bytes_filled = 2;
6279 else if (wc <= 0xFFFF)
6281 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6282 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6283 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6284 utf8_bytes_filled = 3;
6286 else if (wc <= 0x10FFFF)
6288 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6289 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6290 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6291 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6292 utf8_bytes_filled = 4;
6297 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6298 utf8_bytes_filled = 1;
6304template<
typename BaseInputAdapter>
6305struct wide_string_input_helper<BaseInputAdapter, 2>
6308 static void fill_buffer(BaseInputAdapter& input,
6309 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6310 size_t& utf8_bytes_index,
6311 size_t& utf8_bytes_filled)
6313 utf8_bytes_index = 0;
6317 utf8_bytes[0] = std::char_traits<char>::eof();
6318 utf8_bytes_filled = 1;
6323 const auto wc = input.get_character();
6328 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6329 utf8_bytes_filled = 1;
6331 else if (wc <= 0x7FF)
6333 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6334 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6335 utf8_bytes_filled = 2;
6337 else if (0xD800 > wc || wc >= 0xE000)
6339 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6340 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6341 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6342 utf8_bytes_filled = 3;
6348 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6349 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6350 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6351 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6352 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6353 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6354 utf8_bytes_filled = 4;
6358 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6359 utf8_bytes_filled = 1;
6367template<
typename BaseInputAdapter,
typename W
ideCharType>
6368class wide_string_input_adapter
6371 using char_type = char;
6373 wide_string_input_adapter(BaseInputAdapter base)
6374 : base_adapter(base) {}
6376 typename std::char_traits<char>::int_type get_character() noexcept
6379 if (utf8_bytes_index == utf8_bytes_filled)
6381 fill_buffer<sizeof(WideCharType)>();
6389 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6390 return utf8_bytes[utf8_bytes_index++];
6394 BaseInputAdapter base_adapter;
6399 wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
6403 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6406 std::size_t utf8_bytes_index = 0;
6408 std::size_t utf8_bytes_filled = 0;
6412template<
typename IteratorType,
typename Enable =
void>
6413struct iterator_input_adapter_factory
6415 using iterator_type = IteratorType;
6416 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6417 using adapter_type = iterator_input_adapter<iterator_type>;
6419 static adapter_type
create(IteratorType first, IteratorType last)
6421 return adapter_type(std::move(first), std::move(last));
6426struct is_iterator_of_multibyte
6428 using value_type =
typename std::iterator_traits<T>::value_type;
6431 value =
sizeof(value_type) > 1
6435template<
typename IteratorType>
6436struct iterator_input_adapter_factory<IteratorType,
enable_if_t<is_iterator_of_multibyte<IteratorType>::value>>
6438 using iterator_type = IteratorType;
6439 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6440 using base_adapter_type = iterator_input_adapter<iterator_type>;
6441 using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
6443 static adapter_type
create(IteratorType first, IteratorType last)
6445 return adapter_type(base_adapter_type(std::move(first), std::move(last)));
6450template<
typename IteratorType>
6451typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
6453 using factory_type = iterator_input_adapter_factory<IteratorType>;
6454 return factory_type::create(first, last);
6461namespace container_input_adapter_factory_impl
6467template<
typename ContainerType,
typename Enable =
void>
6470template<
typename ContainerType>
6472 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6474 using adapter_type =
decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>())));
6478 return input_adapter(begin(container), end(container));
6484template<
typename ContainerType>
6485typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(
const ContainerType& container)
6487 return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
6492inline file_input_adapter input_adapter(std::FILE* file)
6494 return file_input_adapter(file);
6497inline input_stream_adapter input_adapter(std::istream& stream)
6499 return input_stream_adapter(stream);
6502inline input_stream_adapter input_adapter(std::istream&& stream)
6504 return input_stream_adapter(stream);
6508using contiguous_bytes_input_adapter =
decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
6511template <
typename CharT,
6512 typename std::enable_if <
6513 std::is_pointer<CharT>::value&&
6514 !std::is_array<CharT>::value&&
6515 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
6516 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6518contiguous_bytes_input_adapter input_adapter(CharT b)
6520 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6521 const auto* ptr =
reinterpret_cast<const char*
>(b);
6522 return input_adapter(ptr, ptr + length);
6525template<
typename T, std::
size_t N>
6526auto input_adapter(T (&
array)[N]) ->
decltype(input_adapter(
array,
array + N))
6534class span_input_adapter
6537 template <
typename CharT,
6538 typename std::enable_if <
6539 std::is_pointer<CharT>::value&&
6540 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
6541 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6543 span_input_adapter(CharT b, std::size_t l)
6544 : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
6546 template<
class IteratorType,
6547 typename std::enable_if<
6548 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
6550 span_input_adapter(IteratorType first, IteratorType last)
6551 : ia(input_adapter(first, last)) {}
6553 contiguous_bytes_input_adapter&&
get()
6555 return std::move(ia);
6559 contiguous_bytes_input_adapter ia;
6598template<
typename BasicJsonType>
6702 const std::string& last_token,
6729template<
typename BasicJsonType>
6745 : root(r), allow_exceptions(allow_exceptions_)
6757 handle_value(
nullptr);
6793 handle_value(std::move(val));
6799 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6801 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6803 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
6815 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6824 ref_stack.back()->set_parents();
6825 ref_stack.pop_back();
6831 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6833 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6835 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
6846 ref_stack.back()->set_parents();
6847 ref_stack.pop_back();
6851 template<
class Exception>
6853 const Exception& ex)
6856 static_cast<void>(ex);
6857 if (allow_exceptions)
6876 template<
typename Value>
6878 BasicJsonType* handle_value(Value&& v)
6880 if (ref_stack.empty())
6882 root = BasicJsonType(std::forward<Value>(v));
6886 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6888 if (ref_stack.back()->is_array())
6890 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6891 return &(ref_stack.back()->m_value.array->back());
6896 *object_element = BasicJsonType(std::forward<Value>(v));
6897 return object_element;
6901 BasicJsonType& root;
6903 std::vector<BasicJsonType*> ref_stack {};
6905 BasicJsonType* object_element =
nullptr;
6907 bool errored =
false;
6909 const bool allow_exceptions =
true;
6912template<
typename BasicJsonType>
6926 const bool allow_exceptions_ =
true)
6927 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6929 keep_stack.push_back(
true);
6941 handle_value(
nullptr);
6977 handle_value(std::move(val));
6984 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6985 keep_stack.push_back(keep);
6987 auto val = handle_value(BasicJsonType::value_t::object,
true);
6988 ref_stack.push_back(val.second);
6991 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6993 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
7001 BasicJsonType k = BasicJsonType(val);
7004 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
7005 key_keep_stack.push_back(keep);
7008 if (keep && ref_stack.back())
7010 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
7018 if (ref_stack.back())
7020 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7027 ref_stack.back()->set_parents();
7033 ref_stack.pop_back();
7034 keep_stack.pop_back();
7036 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7039 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7041 if (it->is_discarded())
7043 ref_stack.back()->erase(it);
7054 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7055 keep_stack.push_back(keep);
7057 auto val = handle_value(BasicJsonType::value_t::array,
true);
7058 ref_stack.push_back(val.second);
7061 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7063 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7073 if (ref_stack.back())
7075 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7078 ref_stack.back()->set_parents();
7089 ref_stack.pop_back();
7090 keep_stack.pop_back();
7093 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7095 ref_stack.back()->m_value.array->pop_back();
7101 template<
class Exception>
7103 const Exception& ex)
7106 static_cast<void>(ex);
7107 if (allow_exceptions)
7135 template<
typename Value>
7136 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
7142 if (!keep_stack.back())
7144 return {
false,
nullptr};
7148 auto value = BasicJsonType(std::forward<Value>(v));
7151 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
7156 return {
false,
nullptr};
7159 if (ref_stack.empty())
7161 root = std::move(value);
7162 return {
true, &root};
7167 if (!ref_stack.back())
7169 return {
false,
nullptr};
7173 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7176 if (ref_stack.back()->is_array())
7178 ref_stack.back()->m_value.array->emplace_back(std::move(value));
7179 return {
true, &(ref_stack.back()->m_value.array->back())};
7186 const bool store_element = key_keep_stack.back();
7187 key_keep_stack.pop_back();
7191 return {
false,
nullptr};
7195 *object_element = std::move(value);
7196 return {
true, object_element};
7200 BasicJsonType& root;
7202 std::vector<BasicJsonType*> ref_stack {};
7204 std::vector<bool> keep_stack {};
7206 std::vector<bool> key_keep_stack {};
7208 BasicJsonType* object_element =
nullptr;
7210 bool errored =
false;
7212 const parser_callback_t callback =
nullptr;
7214 const bool allow_exceptions =
true;
7216 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7219template<
typename BasicJsonType>
7314#include <initializer_list>
7334template<
typename BasicJsonType>
7367 case token_type::uninitialized:
7368 return "<uninitialized>";
7369 case token_type::literal_true:
7370 return "true literal";
7371 case token_type::literal_false:
7372 return "false literal";
7373 case token_type::literal_null:
7374 return "null literal";
7375 case token_type::value_string:
7376 return "string literal";
7377 case token_type::value_unsigned:
7378 case token_type::value_integer:
7379 case token_type::value_float:
7380 return "number literal";
7381 case token_type::begin_array:
7383 case token_type::begin_object:
7385 case token_type::end_array:
7387 case token_type::end_object:
7389 case token_type::name_separator:
7391 case token_type::value_separator:
7393 case token_type::parse_error:
7394 return "<parse error>";
7395 case token_type::end_of_input:
7396 return "end of input";
7397 case token_type::literal_or_value:
7398 return "'[', '{', or a literal";
7401 return "unknown token";
7411template<
typename BasicJsonType,
typename InputAdapterType>
7414 using number_integer_t =
typename BasicJsonType::number_integer_t;
7415 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7416 using number_float_t =
typename BasicJsonType::number_float_t;
7417 using string_t =
typename BasicJsonType::string_t;
7418 using char_type =
typename InputAdapterType::char_type;
7419 using char_int_type =
typename std::char_traits<char_type>::int_type;
7424 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7425 : ia(
std::move(adapter))
7426 , ignore_comments(ignore_comments_)
7427 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7444 static char get_decimal_point() noexcept
7446 const auto* loc = localeconv();
7448 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7476 const auto factors = { 12u, 8u, 4u, 0u };
7477 for (
const auto factor : factors)
7481 if (current >=
'0' && current <=
'9')
7483 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7485 else if (current >=
'A' && current <=
'F')
7487 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7489 else if (current >=
'a' && current <=
'f')
7491 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7499 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7518 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7520 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7523 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7532 error_message =
"invalid string: ill-formed UTF-8 byte";
7555 token_type scan_string()
7569 case std::char_traits<char_type>::eof():
7571 error_message =
"invalid string: missing closing quote";
7572 return token_type::parse_error;
7578 return token_type::value_string;
7622 const int codepoint1 = get_codepoint();
7623 int codepoint = codepoint1;
7627 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7628 return token_type::parse_error;
7632 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7637 const int codepoint2 = get_codepoint();
7641 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7642 return token_type::parse_error;
7649 codepoint =
static_cast<int>(
7651 (
static_cast<unsigned int>(codepoint1) << 10u)
7653 +
static_cast<unsigned int>(codepoint2)
7661 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7662 return token_type::parse_error;
7667 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7668 return token_type::parse_error;
7675 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7676 return token_type::parse_error;
7681 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7684 if (codepoint < 0x80)
7687 add(
static_cast<char_int_type
>(codepoint));
7689 else if (codepoint <= 0x7FF)
7692 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7693 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7695 else if (codepoint <= 0xFFFF)
7698 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7699 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7700 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7705 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7706 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7707 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7708 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7716 error_message =
"invalid string: forbidden character after backslash";
7717 return token_type::parse_error;
7726 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7727 return token_type::parse_error;
7732 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7733 return token_type::parse_error;
7738 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7739 return token_type::parse_error;
7744 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7745 return token_type::parse_error;
7750 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7751 return token_type::parse_error;
7756 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7757 return token_type::parse_error;
7762 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7763 return token_type::parse_error;
7768 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7769 return token_type::parse_error;
7774 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7775 return token_type::parse_error;
7780 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7781 return token_type::parse_error;
7786 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7787 return token_type::parse_error;
7792 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7793 return token_type::parse_error;
7798 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7799 return token_type::parse_error;
7804 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7805 return token_type::parse_error;
7810 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7811 return token_type::parse_error;
7816 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7817 return token_type::parse_error;
7822 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7823 return token_type::parse_error;
7828 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7829 return token_type::parse_error;
7834 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7835 return token_type::parse_error;
7840 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7841 return token_type::parse_error;
7846 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7847 return token_type::parse_error;
7852 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7853 return token_type::parse_error;
7858 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7859 return token_type::parse_error;
7864 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7865 return token_type::parse_error;
7870 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7871 return token_type::parse_error;
7876 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7877 return token_type::parse_error;
7882 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7883 return token_type::parse_error;
7888 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7889 return token_type::parse_error;
7894 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7895 return token_type::parse_error;
7900 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7901 return token_type::parse_error;
7906 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7907 return token_type::parse_error;
7912 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7913 return token_type::parse_error;
8050 return token_type::parse_error;
8060 return token_type::parse_error;
8084 return token_type::parse_error;
8094 return token_type::parse_error;
8104 return token_type::parse_error;
8116 return token_type::parse_error;
8126 return token_type::parse_error;
8134 error_message =
"invalid string: ill-formed UTF-8 byte";
8135 return token_type::parse_error;
8158 case std::char_traits<char_type>::eof():
8175 case std::char_traits<char_type>::eof():
8178 error_message =
"invalid comment; missing closing '*/'";
8206 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8213 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
8215 f = std::strtof(str, endptr);
8219 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
8221 f = std::strtod(str, endptr);
8225 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
8227 f = std::strtold(str, endptr);
8270 token_type scan_number()
8277 token_type number_type = token_type::value_unsigned;
8285 goto scan_number_minus;
8291 goto scan_number_zero;
8305 goto scan_number_any1;
8315 number_type = token_type::value_integer;
8321 goto scan_number_zero;
8335 goto scan_number_any1;
8340 error_message =
"invalid number; expected digit after '-'";
8341 return token_type::parse_error;
8351 add(decimal_point_char);
8352 goto scan_number_decimal1;
8359 goto scan_number_exponent;
8363 goto scan_number_done;
8382 goto scan_number_any1;
8387 add(decimal_point_char);
8388 goto scan_number_decimal1;
8395 goto scan_number_exponent;
8399 goto scan_number_done;
8402scan_number_decimal1:
8404 number_type = token_type::value_float;
8419 goto scan_number_decimal2;
8424 error_message =
"invalid number; expected digit after '.'";
8425 return token_type::parse_error;
8429scan_number_decimal2:
8445 goto scan_number_decimal2;
8452 goto scan_number_exponent;
8456 goto scan_number_done;
8459scan_number_exponent:
8461 number_type = token_type::value_float;
8468 goto scan_number_sign;
8483 goto scan_number_any2;
8489 "invalid number; expected '+', '-', or digit after exponent";
8490 return token_type::parse_error;
8510 goto scan_number_any2;
8515 error_message =
"invalid number; expected digit after exponent sign";
8516 return token_type::parse_error;
8536 goto scan_number_any2;
8540 goto scan_number_done;
8548 char* endptr =
nullptr;
8552 if (number_type == token_type::value_unsigned)
8554 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8557 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8561 value_unsigned =
static_cast<number_unsigned_t
>(x);
8562 if (value_unsigned == x)
8564 return token_type::value_unsigned;
8568 else if (number_type == token_type::value_integer)
8570 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8573 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8577 value_integer =
static_cast<number_integer_t
>(x);
8578 if (value_integer == x)
8580 return token_type::value_integer;
8587 strtof(value_float, token_buffer.data(), &endptr);
8590 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8592 return token_type::value_float;
8601 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8602 token_type return_type)
8604 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8605 for (std::size_t i = 1; i < length; ++i)
8609 error_message =
"invalid literal";
8610 return token_type::parse_error;
8621 void reset() noexcept
8623 token_buffer.clear();
8624 token_string.clear();
8625 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8640 ++position.chars_read_total;
8641 ++position.chars_read_current_line;
8650 current = ia.get_character();
8655 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8658 if (current ==
'\n')
8660 ++position.lines_read;
8661 position.chars_read_current_line = 0;
8679 --position.chars_read_total;
8682 if (position.chars_read_current_line == 0)
8684 if (position.lines_read > 0)
8686 --position.lines_read;
8691 --position.chars_read_current_line;
8697 token_string.pop_back();
8702 void add(char_int_type c)
8704 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8715 return value_integer;
8721 return value_unsigned;
8733 return token_buffer;
8753 for (
const auto c : token_string)
8755 if (
static_cast<unsigned char>(c) <=
'\x1F')
8758 std::array<char, 9> cs{{}};
8759 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8760 result += cs.data();
8765 result.push_back(
static_cast<std::string::value_type
>(c));
8776 return error_message;
8792 return get() == 0xBB &&
get() == 0xBF;
8807 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8813 if (position.chars_read_total == 0 && !skip_bom())
8815 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8816 return token_type::parse_error;
8823 while (ignore_comments && current ==
'/')
8825 if (!scan_comment())
8827 return token_type::parse_error;
8838 return token_type::begin_array;
8840 return token_type::end_array;
8842 return token_type::begin_object;
8844 return token_type::end_object;
8846 return token_type::name_separator;
8848 return token_type::value_separator;
8853 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')}};
8854 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8858 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')}};
8859 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8863 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')}};
8864 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8869 return scan_string();
8883 return scan_number();
8888 case std::char_traits<char_type>::eof():
8889 return token_type::end_of_input;
8893 error_message =
"invalid literal";
8894 return token_type::parse_error;
8900 InputAdapterType ia;
8903 const bool ignore_comments =
false;
8906 char_int_type current = std::char_traits<char_type>::eof();
8909 bool next_unget =
false;
8915 std::vector<char_type> token_string {};
8918 string_t token_buffer {};
8921 const char* error_message =
"";
8924 number_integer_t value_integer = 0;
8925 number_unsigned_t value_unsigned = 0;
8926 number_float_t value_float = 0;
8929 const char_int_type decimal_point_char =
'.';
8964using null_function_t =
decltype(std::declval<T&>().null());
8967using boolean_function_t =
8968 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8970template<
typename T,
typename Integer>
8971using number_integer_function_t =
8972 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8974template<
typename T,
typename Un
signed>
8975using number_unsigned_function_t =
8976 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8978template<
typename T,
typename Float,
typename String>
8979using number_float_function_t =
decltype(std::declval<T&>().number_float(
8980 std::declval<Float>(), std::declval<const String&>()));
8982template<
typename T,
typename String>
8983using string_function_t =
8984 decltype(std::declval<T&>().string(std::declval<String&>()));
8986template<
typename T,
typename Binary>
8987using binary_function_t =
8988 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8991using start_object_function_t =
8992 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8994template<
typename T,
typename String>
8995using key_function_t =
8996 decltype(std::declval<T&>().key(std::declval<String&>()));
8999using end_object_function_t =
decltype(std::declval<T&>().end_object());
9002using start_array_function_t =
9003 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9006using end_array_function_t =
decltype(std::declval<T&>().end_array());
9008template<
typename T,
typename Exception>
9009using parse_error_function_t =
decltype(std::declval<T&>().parse_error(
9010 std::declval<std::size_t>(), std::declval<const std::string&>(),
9011 std::declval<const Exception&>()));
9013template<
typename SAX,
typename BasicJsonType>
9017 static_assert(is_basic_json<BasicJsonType>::value,
9018 "BasicJsonType must be of type basic_json<...>");
9020 using number_integer_t =
typename BasicJsonType::number_integer_t;
9021 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9022 using number_float_t =
typename BasicJsonType::number_float_t;
9023 using string_t =
typename BasicJsonType::string_t;
9024 using binary_t =
typename BasicJsonType::binary_t;
9025 using exception_t =
typename BasicJsonType::exception;
9028 static constexpr bool value =
9029 is_detected_exact<bool, null_function_t, SAX>::value &&
9030 is_detected_exact<bool, boolean_function_t, SAX>::value &&
9031 is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value &&
9032 is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value &&
9033 is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value &&
9034 is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
9035 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value &&
9036 is_detected_exact<bool, start_object_function_t, SAX>::value &&
9037 is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
9038 is_detected_exact<bool, end_object_function_t, SAX>::value &&
9039 is_detected_exact<bool, start_array_function_t, SAX>::value &&
9040 is_detected_exact<bool, end_array_function_t, SAX>::value &&
9041 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
9044template<
typename SAX,
typename BasicJsonType>
9045struct is_sax_static_asserts
9048 static_assert(is_basic_json<BasicJsonType>::value,
9049 "BasicJsonType must be of type basic_json<...>");
9051 using number_integer_t =
typename BasicJsonType::number_integer_t;
9052 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9053 using number_float_t =
typename BasicJsonType::number_float_t;
9054 using string_t =
typename BasicJsonType::string_t;
9055 using binary_t =
typename BasicJsonType::binary_t;
9056 using exception_t =
typename BasicJsonType::exception;
9059 static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
9060 "Missing/invalid function: bool null()");
9061 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
9062 "Missing/invalid function: bool boolean(bool)");
9063 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
9064 "Missing/invalid function: bool boolean(bool)");
9067 number_integer_t>::value,
9068 "Missing/invalid function: bool number_integer(number_integer_t)");
9071 number_unsigned_t>::value,
9072 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9074 number_float_t, string_t>::value,
9075 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9077 is_detected_exact<bool, string_function_t, SAX, string_t>::value,
9078 "Missing/invalid function: bool string(string_t&)");
9080 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value,
9081 "Missing/invalid function: bool binary(binary_t&)");
9082 static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
9083 "Missing/invalid function: bool start_object(std::size_t)");
9084 static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
9085 "Missing/invalid function: bool key(string_t&)");
9086 static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
9087 "Missing/invalid function: bool end_object()");
9088 static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
9089 "Missing/invalid function: bool start_array(std::size_t)");
9090 static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
9091 "Missing/invalid function: bool end_array()");
9093 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
9094 "Missing/invalid function: bool parse_error(std::size_t, const "
9095 "std::string&, const exception&)");
9129 return *
reinterpret_cast<char*
>(&num) == 1;
9140template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9143 using number_integer_t =
typename BasicJsonType::number_integer_t;
9144 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9145 using number_float_t =
typename BasicJsonType::number_float_t;
9146 using string_t =
typename BasicJsonType::string_t;
9147 using binary_t =
typename BasicJsonType::binary_t;
9148 using json_sax_t = SAX;
9149 using char_type =
typename InputAdapterType::char_type;
9150 using char_int_type =
typename std::char_traits<char_type>::int_type;
9158 explicit binary_reader(InputAdapterType&& adapter,
const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format)
9160 (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
9181 const
bool strict = true,
9185 bool result =
false;
9189 case input_format_t::bson:
9190 result = parse_bson_internal();
9193 case input_format_t::cbor:
9194 result = parse_cbor_internal(
true, tag_handler);
9197 case input_format_t::msgpack:
9198 result = parse_msgpack_internal();
9201 case input_format_t::ubjson:
9202 case input_format_t::bjdata:
9203 result = parse_ubjson_internal();
9206 case input_format_t::json:
9214 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9225 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9226 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9242 bool parse_bson_internal()
9244 std::int32_t document_size{};
9245 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9257 return sax->end_object();
9267 bool get_bson_cstr(string_t& result)
9269 auto out = std::back_inserter(result);
9277 if (current == 0x00)
9281 *out++ =
static_cast<typename string_t::value_type
>(current);
9296 template<
typename NumberType>
9297 bool get_bson_string(
const NumberType len, string_t& result)
9301 auto last_token = get_token_string();
9303 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
9306 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != std::char_traits<char_type>::eof();
9318 template<
typename NumberType>
9319 bool get_bson_binary(
const NumberType len, binary_t& result)
9323 auto last_token = get_token_string();
9325 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
9329 std::uint8_t subtype{};
9330 get_number<std::uint8_t>(input_format_t::bson, subtype);
9331 result.set_subtype(subtype);
9333 return get_binary(input_format_t::bson, len, result);
9346 bool parse_bson_element_internal(
const char_int_type element_type,
9347 const std::size_t element_type_parse_position)
9349 switch (element_type)
9354 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9361 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
9366 return parse_bson_internal();
9371 return parse_bson_array();
9378 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
9383 return sax->boolean(get() != 0);
9393 std::int32_t value{};
9394 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
9399 std::int64_t value{};
9400 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
9405 std::array<char, 3> cr{{}};
9406 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9407 std::string cr_str{cr.data()};
9408 return sax->parse_error(element_type_parse_position, cr_str,
9426 bool parse_bson_element_list(
const bool is_array)
9430 while (
auto element_type = get())
9437 const std::size_t element_type_parse_position = chars_read;
9443 if (!is_array && !sax->key(key))
9448 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9464 bool parse_bson_array()
9466 std::int32_t document_size{};
9467 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9479 return sax->end_array();
9494 bool parse_cbor_internal(
const bool get_char,
9497 switch (get_char ? get() : current)
9500 case std::char_traits<char_type>::eof():
9501 return unexpect_eof(input_format_t::cbor,
"value");
9528 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9533 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9539 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9545 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9551 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9579 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9584 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9590 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9596 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9602 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
9603 -
static_cast<number_integer_t
>(number));
9638 return get_cbor_binary(b) && sax->binary(b);
9673 return get_cbor_string(s) && sax->string(s);
9701 return get_cbor_array(
9702 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9707 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9712 std::uint16_t len{};
9713 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9718 std::uint32_t len{};
9719 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9724 std::uint64_t len{};
9725 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9729 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9756 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9761 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9766 std::uint16_t len{};
9767 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9772 std::uint32_t len{};
9773 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9778 std::uint64_t len{};
9779 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9783 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9805 switch (tag_handler)
9809 auto last_token = get_token_string();
9811 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9821 std::uint8_t subtype_to_ignore{};
9822 get_number(input_format_t::cbor, subtype_to_ignore);
9827 std::uint16_t subtype_to_ignore{};
9828 get_number(input_format_t::cbor, subtype_to_ignore);
9833 std::uint32_t subtype_to_ignore{};
9834 get_number(input_format_t::cbor, subtype_to_ignore);
9839 std::uint64_t subtype_to_ignore{};
9840 get_number(input_format_t::cbor, subtype_to_ignore);
9846 return parse_cbor_internal(
true, tag_handler);
9857 std::uint8_t subtype{};
9858 get_number(input_format_t::cbor, subtype);
9859 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9864 std::uint16_t subtype{};
9865 get_number(input_format_t::cbor, subtype);
9866 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9871 std::uint32_t subtype{};
9872 get_number(input_format_t::cbor, subtype);
9873 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9878 std::uint64_t subtype{};
9879 get_number(input_format_t::cbor, subtype);
9880 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9884 return parse_cbor_internal(
true, tag_handler);
9887 return get_cbor_binary(b) && sax->binary(b);
9897 return sax->boolean(
false);
9900 return sax->boolean(
true);
9907 const auto byte1_raw = get();
9912 const auto byte2_raw = get();
9918 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9919 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9929 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9930 const double val = [&half]
9932 const int exp = (half >> 10u) & 0x1Fu;
9933 const unsigned int mant = half & 0x3FFu;
9939 return std::ldexp(mant, -24);
9942 ? std::numeric_limits<double>::infinity()
9943 :
std::numeric_limits<double>::quiet_NaN();
9945 return std::ldexp(mant + 1024, exp - 25);
9948 return sax->number_float((half & 0x8000u) != 0
9949 ?
static_cast<number_float_t
>(-val)
9950 : static_cast<number_float_t>(val),
"");
9956 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9962 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9967 auto last_token = get_token_string();
9969 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9985 bool get_cbor_string(string_t& result)
10020 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10025 std::uint8_t len{};
10026 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10031 std::uint16_t len{};
10032 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10037 std::uint32_t len{};
10038 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10043 std::uint64_t len{};
10044 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10049 while (get() != 0xFF)
10052 if (!get_cbor_string(chunk))
10056 result.append(chunk);
10063 auto last_token = get_token_string();
10065 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10081 bool get_cbor_binary(binary_t& result)
10116 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10121 std::uint8_t len{};
10122 return get_number(input_format_t::cbor, len) &&
10123 get_binary(input_format_t::cbor, len, result);
10128 std::uint16_t len{};
10129 return get_number(input_format_t::cbor, len) &&
10130 get_binary(input_format_t::cbor, len, result);
10135 std::uint32_t len{};
10136 return get_number(input_format_t::cbor, len) &&
10137 get_binary(input_format_t::cbor, len, result);
10142 std::uint64_t len{};
10143 return get_number(input_format_t::cbor, len) &&
10144 get_binary(input_format_t::cbor, len, result);
10149 while (get() != 0xFF)
10152 if (!get_cbor_binary(chunk))
10156 result.insert(result.end(), chunk.begin(), chunk.end());
10163 auto last_token = get_token_string();
10165 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));
10176 bool get_cbor_array(
const std::size_t len,
10184 if (len !=
static_cast<std::size_t
>(-1))
10186 for (std::size_t i = 0; i < len; ++i)
10196 while (get() != 0xFF)
10205 return sax->end_array();
10214 bool get_cbor_object(
const std::size_t len,
10225 if (len !=
static_cast<std::size_t
>(-1))
10227 for (std::size_t i = 0; i < len; ++i)
10244 while (get() != 0xFF)
10260 return sax->end_object();
10270 bool parse_msgpack_internal()
10275 case std::char_traits<char_type>::eof():
10276 return unexpect_eof(input_format_t::msgpack,
"value");
10407 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10426 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10445 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10485 return get_msgpack_string(s) && sax->string(s);
10489 return sax->null();
10492 return sax->boolean(
false);
10495 return sax->boolean(
true);
10510 return get_msgpack_binary(b) && sax->binary(b);
10516 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10522 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10528 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10534 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10540 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10546 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10552 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10558 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10564 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10570 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10575 std::uint16_t len{};
10576 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
10581 std::uint32_t len{};
10582 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10587 std::uint16_t len{};
10588 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
10593 std::uint32_t len{};
10594 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10630 return sax->number_integer(
static_cast<std::int8_t
>(current));
10634 auto last_token = get_token_string();
10636 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10651 bool get_msgpack_string(string_t& result)
10694 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
10699 std::uint8_t len{};
10700 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10705 std::uint16_t len{};
10706 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10711 std::uint32_t len{};
10712 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10717 auto last_token = get_token_string();
10719 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10734 bool get_msgpack_binary(binary_t& result)
10737 auto assign_and_return_true = [&result](std::int8_t subtype)
10739 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10747 std::uint8_t len{};
10748 return get_number(input_format_t::msgpack, len) &&
10749 get_binary(input_format_t::msgpack, len, result);
10754 std::uint16_t len{};
10755 return get_number(input_format_t::msgpack, len) &&
10756 get_binary(input_format_t::msgpack, len, result);
10761 std::uint32_t len{};
10762 return get_number(input_format_t::msgpack, len) &&
10763 get_binary(input_format_t::msgpack, len, result);
10768 std::uint8_t len{};
10769 std::int8_t subtype{};
10770 return get_number(input_format_t::msgpack, len) &&
10771 get_number(input_format_t::msgpack, subtype) &&
10772 get_binary(input_format_t::msgpack, len, result) &&
10773 assign_and_return_true(subtype);
10778 std::uint16_t len{};
10779 std::int8_t subtype{};
10780 return get_number(input_format_t::msgpack, len) &&
10781 get_number(input_format_t::msgpack, subtype) &&
10782 get_binary(input_format_t::msgpack, len, result) &&
10783 assign_and_return_true(subtype);
10788 std::uint32_t len{};
10789 std::int8_t subtype{};
10790 return get_number(input_format_t::msgpack, len) &&
10791 get_number(input_format_t::msgpack, subtype) &&
10792 get_binary(input_format_t::msgpack, len, result) &&
10793 assign_and_return_true(subtype);
10798 std::int8_t subtype{};
10799 return get_number(input_format_t::msgpack, subtype) &&
10800 get_binary(input_format_t::msgpack, 1, result) &&
10801 assign_and_return_true(subtype);
10806 std::int8_t subtype{};
10807 return get_number(input_format_t::msgpack, subtype) &&
10808 get_binary(input_format_t::msgpack, 2, result) &&
10809 assign_and_return_true(subtype);
10814 std::int8_t subtype{};
10815 return get_number(input_format_t::msgpack, subtype) &&
10816 get_binary(input_format_t::msgpack, 4, result) &&
10817 assign_and_return_true(subtype);
10822 std::int8_t subtype{};
10823 return get_number(input_format_t::msgpack, subtype) &&
10824 get_binary(input_format_t::msgpack, 8, result) &&
10825 assign_and_return_true(subtype);
10830 std::int8_t subtype{};
10831 return get_number(input_format_t::msgpack, subtype) &&
10832 get_binary(input_format_t::msgpack, 16, result) &&
10833 assign_and_return_true(subtype);
10845 bool get_msgpack_array(
const std::size_t len)
10852 for (std::size_t i = 0; i < len; ++i)
10860 return sax->end_array();
10867 bool get_msgpack_object(
const std::size_t len)
10875 for (std::size_t i = 0; i < len; ++i)
10890 return sax->end_object();
10904 bool parse_ubjson_internal(
const bool get_char =
true)
10906 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10923 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
10939 std::uint8_t len{};
10940 return get_number(input_format, len) && get_string(input_format, len, result);
10946 return get_number(input_format, len) && get_string(input_format, len, result);
10951 std::int16_t len{};
10952 return get_number(input_format, len) && get_string(input_format, len, result);
10957 std::int32_t len{};
10958 return get_number(input_format, len) && get_string(input_format, len, result);
10963 std::int64_t len{};
10964 return get_number(input_format, len) && get_string(input_format, len, result);
10969 if (input_format != input_format_t::bjdata)
10973 std::uint16_t len{};
10974 return get_number(input_format, len) && get_string(input_format, len, result);
10979 if (input_format != input_format_t::bjdata)
10983 std::uint32_t len{};
10984 return get_number(input_format, len) && get_string(input_format, len, result);
10989 if (input_format != input_format_t::bjdata)
10993 std::uint64_t len{};
10994 return get_number(input_format, len) && get_string(input_format, len, result);
11000 auto last_token = get_token_string();
11001 std::string message;
11003 if (input_format != input_format_t::bjdata)
11005 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11009 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11011 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11018 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11020 std::pair<std::size_t, char_int_type> size_and_type;
11022 bool no_ndarray =
true;
11029 if (size_and_type.first != npos)
11031 if (size_and_type.second != 0)
11033 if (size_and_type.second !=
'N')
11035 for (std::size_t i = 0; i < size_and_type.first; ++i)
11041 dim.push_back(dimlen);
11047 for (std::size_t i = 0; i < size_and_type.first; ++i)
11053 dim.push_back(dimlen);
11059 while (current !=
']')
11065 dim.push_back(dimlen);
11083 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11087 prefix = get_ignore_noop();
11099 result =
static_cast<std::size_t
>(
number);
11112 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11113 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11115 result =
static_cast<std::size_t
>(
number);
11128 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11129 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11131 result =
static_cast<std::size_t
>(
number);
11144 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11145 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11147 result =
static_cast<std::size_t
>(
number);
11160 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11161 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11163 if (!value_in_range_of<std::size_t>(number))
11166 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11168 result =
static_cast<std::size_t
>(
number);
11174 if (input_format != input_format_t::bjdata)
11183 result =
static_cast<std::size_t
>(
number);
11189 if (input_format != input_format_t::bjdata)
11198 result = conditional_static_cast<std::size_t>(number);
11204 if (input_format != input_format_t::bjdata)
11213 if (!value_in_range_of<std::size_t>(number))
11216 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11218 result = detail::conditional_static_cast<std::size_t>(number);
11224 if (input_format != input_format_t::bjdata)
11230 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimentional vector is not allowed",
"size"),
nullptr));
11232 std::vector<size_t> dim;
11237 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11239 result = dim.at(dim.size() - 1);
11253 string_t key =
"_ArraySize_";
11254 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
11262 if (result == 0 || result == npos)
11264 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));
11272 return sax->end_array();
11281 auto last_token = get_token_string();
11282 std::string message;
11284 if (input_format != input_format_t::bjdata)
11286 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11290 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11292 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11306 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
11308 result.first = npos;
11310 bool is_ndarray =
false;
11314 if (current ==
'$')
11316 result.second = get();
11317 if (input_format == input_format_t::bjdata
11318 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
11320 auto last_token = get_token_string();
11322 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11337 auto last_token = get_token_string();
11339 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11342 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11343 if (input_format == input_format_t::bjdata && is_ndarray)
11345 if (inside_ndarray)
11347 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11348 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11350 result.second |= (1 << 8);
11355 if (current ==
'#')
11357 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11358 if (input_format == input_format_t::bjdata && is_ndarray)
11360 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11361 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11373 bool get_ubjson_value(
const char_int_type prefix)
11377 case std::char_traits<char_type>::eof():
11378 return unexpect_eof(input_format,
"value");
11381 return sax->boolean(
true);
11383 return sax->boolean(
false);
11386 return sax->null();
11391 return get_number(input_format, number) && sax->number_unsigned(number);
11397 return get_number(input_format, number) && sax->number_integer(number);
11403 return get_number(input_format, number) && sax->number_integer(number);
11409 return get_number(input_format, number) && sax->number_integer(number);
11415 return get_number(input_format, number) && sax->number_integer(number);
11420 if (input_format != input_format_t::bjdata)
11425 return get_number(input_format, number) && sax->number_unsigned(number);
11430 if (input_format != input_format_t::bjdata)
11435 return get_number(input_format, number) && sax->number_unsigned(number);
11440 if (input_format != input_format_t::bjdata)
11445 return get_number(input_format, number) && sax->number_unsigned(number);
11450 if (input_format != input_format_t::bjdata)
11454 const auto byte1_raw = get();
11459 const auto byte2_raw = get();
11465 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11466 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11476 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11477 const double val = [&half]
11479 const int exp = (half >> 10u) & 0x1Fu;
11480 const unsigned int mant = half & 0x3FFu;
11486 return std::ldexp(mant, -24);
11489 ? std::numeric_limits<double>::infinity()
11490 :
std::numeric_limits<double>::quiet_NaN();
11492 return std::ldexp(mant + 1024, exp - 25);
11495 return sax->number_float((half & 0x8000u) != 0
11496 ?
static_cast<number_float_t
>(-val)
11497 : static_cast<number_float_t>(val),
"");
11503 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11509 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11514 return get_ubjson_high_precision_number();
11526 auto last_token = get_token_string();
11528 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11530 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11531 return sax->string(s);
11537 return get_ubjson_string(s) && sax->string(s);
11541 return get_ubjson_array();
11544 return get_ubjson_object();
11549 auto last_token = get_token_string();
11550 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));
11556 bool get_ubjson_array()
11558 std::pair<std::size_t, char_int_type> size_and_type;
11567 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11569 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
11570 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)
11572 return p.first < t;
11574 string_t key =
"_ArrayType_";
11577 auto last_token = get_token_string();
11579 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11582 string_t
type = it->second;
11588 if (size_and_type.second ==
'C')
11590 size_and_type.second =
'U';
11593 key =
"_ArrayData_";
11599 for (std::size_t i = 0; i < size_and_type.first; ++i)
11607 return (sax->end_array() && sax->end_object());
11610 if (size_and_type.first != npos)
11617 if (size_and_type.second != 0)
11619 if (size_and_type.second !=
'N')
11621 for (std::size_t i = 0; i < size_and_type.first; ++i)
11632 for (std::size_t i = 0; i < size_and_type.first; ++i)
11648 while (current !=
']')
11658 return sax->end_array();
11664 bool get_ubjson_object()
11666 std::pair<std::size_t, char_int_type> size_and_type;
11673 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11675 auto last_token = get_token_string();
11677 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11681 if (size_and_type.first != npos)
11688 if (size_and_type.second != 0)
11690 for (std::size_t i = 0; i < size_and_type.first; ++i)
11705 for (std::size_t i = 0; i < size_and_type.first; ++i)
11726 while (current !=
'}')
11741 return sax->end_object();
11747 bool get_ubjson_high_precision_number()
11750 std::size_t size{};
11751 bool no_ndarray =
true;
11752 auto res = get_ubjson_size_value(size, no_ndarray);
11759 std::vector<char> number_vector;
11760 for (std::size_t i = 0; i < size; ++i)
11767 number_vector.push_back(
static_cast<char>(current));
11771 using ia_type =
decltype(detail::input_adapter(number_vector));
11773 const auto result_number = number_lexer.scan();
11774 const auto number_string = number_lexer.get_token_string();
11775 const auto result_remainder = number_lexer.scan();
11782 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11785 switch (result_number)
11787 case token_type::value_integer:
11788 return sax->number_integer(number_lexer.get_number_integer());
11789 case token_type::value_unsigned:
11790 return sax->number_unsigned(number_lexer.get_number_unsigned());
11791 case token_type::value_float:
11792 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11793 case token_type::uninitialized:
11794 case token_type::literal_true:
11795 case token_type::literal_false:
11796 case token_type::literal_null:
11797 case token_type::value_string:
11798 case token_type::begin_array:
11799 case token_type::begin_object:
11800 case token_type::end_array:
11801 case token_type::end_object:
11802 case token_type::name_separator:
11803 case token_type::value_separator:
11804 case token_type::parse_error:
11805 case token_type::end_of_input:
11806 case token_type::literal_or_value:
11809 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11826 char_int_type get()
11829 return current = ia.get_character();
11835 char_int_type get_ignore_noop()
11841 while (current ==
'N');
11861 template<
typename NumberType,
bool InputIsLittleEndian = false>
11862 bool get_number(
const input_format_t format, NumberType& result)
11865 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11866 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11875 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
11877 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11881 vec[i] =
static_cast<std::uint8_t
>(current);
11886 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11904 template<
typename NumberType>
11905 bool get_string(
const input_format_t format,
11906 const NumberType len,
11909 bool success =
true;
11910 for (NumberType i = 0; i < len; i++)
11918 result.push_back(
static_cast<typename string_t::value_type
>(current));
11937 template<
typename NumberType>
11938 bool get_binary(
const input_format_t format,
11939 const NumberType len,
11942 bool success =
true;
11943 for (NumberType i = 0; i < len; i++)
11951 result.push_back(
static_cast<std::uint8_t
>(current));
11962 bool unexpect_eof(const input_format_t format, const
char* context)
const
11966 return sax->parse_error(chars_read,
"<end of file>",
11967 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11975 std::string get_token_string()
const
11977 std::array<char, 3> cr{{}};
11978 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11979 return std::string{cr.data()};
11988 std::string exception_message(
const input_format_t format,
11989 const std::string&
detail,
11990 const std::string& context)
const
11992 std::string error_msg =
"syntax error while parsing ";
11996 case input_format_t::cbor:
11997 error_msg +=
"CBOR";
12000 case input_format_t::msgpack:
12001 error_msg +=
"MessagePack";
12004 case input_format_t::ubjson:
12005 error_msg +=
"UBJSON";
12008 case input_format_t::bson:
12009 error_msg +=
"BSON";
12012 case input_format_t::bjdata:
12013 error_msg +=
"BJData";
12016 case input_format_t::json:
12028 InputAdapterType ia;
12031 char_int_type current = std::char_traits<char_type>::eof();
12034 std::size_t chars_read = 0;
12040 const input_format_t input_format = input_format_t::json;
12043 json_sax_t* sax =
nullptr;
12046#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12047 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12049#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12050 make_array<bjd_type>( \
12051 bjd_type{'C', "char"}, \
12052 bjd_type{'D', "double"}, \
12053 bjd_type{'I', "int16"}, \
12054 bjd_type{'L', "int64"}, \
12055 bjd_type{'M', "uint64"}, \
12056 bjd_type{'U', "uint8"}, \
12057 bjd_type{'d', "single"}, \
12058 bjd_type{'i', "int8"}, \
12059 bjd_type{'l', "int32"}, \
12060 bjd_type{'m', "uint32"}, \
12061 bjd_type{'u', "uint16"})
12069 using bjd_type = std::pair<char_int_type, string_t>;
12074#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12075#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12078#ifndef JSON_HAS_CPP_17
12079 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12080 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12103#include <functional>
12132enum class parse_event_t : std::uint8_t
12148template<
typename BasicJsonType>
12149using parser_callback_t =
12150 std::function<
bool(
int , parse_event_t , BasicJsonType& )>;
12157template<
typename BasicJsonType,
typename InputAdapterType>
12160 using number_integer_t =
typename BasicJsonType::number_integer_t;
12161 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12162 using number_float_t =
typename BasicJsonType::number_float_t;
12163 using string_t =
typename BasicJsonType::string_t;
12164 using lexer_t = lexer<BasicJsonType, InputAdapterType>;
12165 using token_type =
typename lexer_t::token_type;
12169 explicit parser(InputAdapterType&& adapter,
12170 const parser_callback_t<BasicJsonType> cb =
nullptr,
12171 const bool allow_exceptions_ =
true,
12172 const bool skip_comments =
false)
12174 , m_lexer(
std::move(adapter), skip_comments)
12175 , allow_exceptions(allow_exceptions_)
12191 void parse(
const bool strict, BasicJsonType& result)
12195 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
12196 sax_parse_internal(&sdp);
12199 if (
strict && (get_token() != token_type::end_of_input))
12201 sdp.parse_error(m_lexer.get_position(),
12202 m_lexer.get_token_string(),
12204 exception_message(token_type::end_of_input,
"value"),
nullptr));
12208 if (sdp.is_errored())
12216 if (result.is_discarded())
12223 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
12224 sax_parse_internal(&sdp);
12227 if (
strict && (get_token() != token_type::end_of_input))
12229 sdp.parse_error(m_lexer.get_position(),
12230 m_lexer.get_token_string(),
12231 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12235 if (sdp.is_errored())
12242 result.assert_invariant();
12251 bool accept(
const bool strict =
true)
12253 json_sax_acceptor<BasicJsonType> sax_acceptor;
12254 return sax_parse(&sax_acceptor,
strict);
12257 template<
typename SAX>
12259 bool sax_parse(SAX* sax, const
bool strict = true)
12261 (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
12262 const bool result = sax_parse_internal(sax);
12265 if (result &&
strict && (get_token() != token_type::end_of_input))
12267 return sax->parse_error(m_lexer.get_position(),
12268 m_lexer.get_token_string(),
12269 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12276 template<
typename SAX>
12278 bool sax_parse_internal(SAX* sax)
12282 std::vector<bool> states;
12284 bool skip_to_state_evaluation =
false;
12288 if (!skip_to_state_evaluation)
12291 switch (last_token)
12293 case token_type::begin_object:
12301 if (get_token() == token_type::end_object)
12313 return sax->parse_error(m_lexer.get_position(),
12314 m_lexer.get_token_string(),
12315 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12325 return sax->parse_error(m_lexer.get_position(),
12326 m_lexer.get_token_string(),
12327 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12331 states.push_back(
false);
12338 case token_type::begin_array:
12346 if (get_token() == token_type::end_array)
12356 states.push_back(
true);
12362 case token_type::value_float:
12364 const auto res = m_lexer.get_number_float();
12368 return sax->parse_error(m_lexer.get_position(),
12369 m_lexer.get_token_string(),
12381 case token_type::literal_false:
12390 case token_type::literal_null:
12399 case token_type::literal_true:
12408 case token_type::value_integer:
12417 case token_type::value_string:
12426 case token_type::value_unsigned:
12435 case token_type::parse_error:
12438 return sax->parse_error(m_lexer.get_position(),
12439 m_lexer.get_token_string(),
12440 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12443 case token_type::uninitialized:
12444 case token_type::end_array:
12445 case token_type::end_object:
12446 case token_type::name_separator:
12447 case token_type::value_separator:
12448 case token_type::end_of_input:
12449 case token_type::literal_or_value:
12452 return sax->parse_error(m_lexer.get_position(),
12453 m_lexer.get_token_string(),
12454 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12460 skip_to_state_evaluation =
false;
12464 if (states.empty())
12473 if (get_token() == token_type::value_separator)
12494 skip_to_state_evaluation =
true;
12498 return sax->parse_error(m_lexer.get_position(),
12499 m_lexer.get_token_string(),
12500 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12506 if (get_token() == token_type::value_separator)
12511 return sax->parse_error(m_lexer.get_position(),
12512 m_lexer.get_token_string(),
12513 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12524 return sax->parse_error(m_lexer.get_position(),
12525 m_lexer.get_token_string(),
12526 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12548 skip_to_state_evaluation =
true;
12552 return sax->parse_error(m_lexer.get_position(),
12553 m_lexer.get_token_string(),
12554 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12559 token_type get_token()
12561 return last_token = m_lexer.scan();
12564 std::string exception_message(
const token_type expected,
const std::string& context)
12566 std::string error_msg =
"syntax error ";
12568 if (!context.empty())
12570 error_msg +=
concat(
"while parsing ", context,
' ');
12575 if (last_token == token_type::parse_error)
12577 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12578 m_lexer.get_token_string(),
'\'');
12582 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
12585 if (expected != token_type::uninitialized)
12587 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
12595 const parser_callback_t<BasicJsonType> callback =
nullptr;
12597 token_type last_token = token_type::uninitialized;
12601 const bool allow_exceptions =
true;
12650class primitive_iterator_t
12653 using difference_type = std::ptrdiff_t;
12654 static constexpr difference_type begin_value = 0;
12655 static constexpr difference_type end_value = begin_value + 1;
12659 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
12662 constexpr difference_type get_value() const noexcept
12668 void set_begin() noexcept
12670 m_it = begin_value;
12674 void set_end() noexcept
12680 constexpr bool is_begin() const noexcept
12682 return m_it == begin_value;
12686 constexpr bool is_end() const noexcept
12688 return m_it == end_value;
12691 friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
12693 return lhs.m_it == rhs.m_it;
12696 friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
12698 return lhs.m_it < rhs.m_it;
12701 primitive_iterator_t operator+(difference_type n)
noexcept
12703 auto result = *
this;
12708 friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
12710 return lhs.m_it - rhs.m_it;
12713 primitive_iterator_t& operator++() noexcept
12719 primitive_iterator_t operator++(
int)&
noexcept
12721 auto result = *
this;
12726 primitive_iterator_t& operator--() noexcept
12732 primitive_iterator_t operator--(
int)&
noexcept
12734 auto result = *
this;
12739 primitive_iterator_t& operator+=(difference_type n)
noexcept
12745 primitive_iterator_t& operator-=(difference_type n)
noexcept
12791#include <type_traits>
12813template<
typename IteratorType>
class iteration_proxy;
12814template<
typename IteratorType>
class iteration_proxy_value;
12832template<
typename BasicJsonType>
12839 friend BasicJsonType;
12843 using object_t =
typename BasicJsonType::object_t;
12844 using array_t =
typename BasicJsonType::array_t;
12847 "iter_impl only accepts (const) basic_json");
12849 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12850 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
12851 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12866 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12867 typename BasicJsonType::const_pointer,
12868 typename BasicJsonType::pointer>::type;
12871 typename std::conditional<std::is_const<BasicJsonType>::value,
12872 typename BasicJsonType::const_reference,
12873 typename BasicJsonType::reference>::type;
12890 switch (m_object->m_type)
12937 : m_object(other.m_object),
m_it(other.m_it)
12948 if (&other !=
this)
12950 m_object = other.m_object;
12962 : m_object(other.m_object),
m_it(other.m_it)
12973 m_object = other.m_object;
12983 void set_begin() noexcept
12987 switch (m_object->m_type)
13031 switch (m_object->m_type)
13070 switch (m_object->m_type)
13114 switch (m_object->m_type)
13154 auto result = *
this;
13167 switch (m_object->m_type)
13205 auto result = *
this;
13218 switch (m_object->m_type)
13254 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 >
13265 switch (m_object->m_type)
13290 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 >
13310 switch (m_object->m_type)
13337 return !other.operator < (*this);
13366 switch (m_object->m_type)
13410 auto result = *
this;
13432 auto result = *
this;
13445 switch (m_object->m_type)
13474 switch (m_object->m_type)
13508 const typename object_t::key_type&
key()
const
13585template<
typename Base>
13659 auto it = --this->base();
13666 auto it = --this->base();
13667 return it.operator * ();
13687#include <algorithm>
13715template<
typename RefStringType>
13725 template<
typename T>
13726 struct string_t_helper
13734 using type = StringType;
13739 using string_t =
typename string_t_helper<RefStringType>::type;
13744 : reference_tokens(split(s))
13751 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13755 return detail::concat(a,
'/', detail::escape(b));
13781 reference_tokens.insert(reference_tokens.end(),
13782 ptr.reference_tokens.begin(),
13783 ptr.reference_tokens.end());
13799 return *
this /= std::to_string(array_idx);
13847 reference_tokens.pop_back();
13859 return reference_tokens.back();
13866 reference_tokens.push_back(token);
13873 reference_tokens.push_back(std::move(token));
13880 return reference_tokens.empty();
13894 template<
typename BasicJsonType>
13895 static typename BasicJsonType::size_type array_index(
const string_t& s)
13897 using size_type =
typename BasicJsonType::size_type;
13911 const char* p = s.c_str();
13912 char* p_end =
nullptr;
13914 unsigned long long res = std::strtoull(p, &p_end, 10);
13924 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13929 return static_cast<size_type
>(res);
13941 result.reference_tokens = {reference_tokens[0]};
13954 template<
typename BasicJsonType>
13955 BasicJsonType& get_and_create(BasicJsonType& j)
const
13961 for (
const auto& reference_token : reference_tokens)
13963 switch (result->type())
13967 if (reference_token ==
"0")
13970 result = &result->operator[](0);
13975 result = &result->operator[](reference_token);
13983 result = &result->operator[](reference_token);
13990 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14034 template<
typename BasicJsonType>
14035 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14037 for (
const auto& reference_token : reference_tokens)
14040 if (ptr->is_null())
14044 std::all_of(reference_token.begin(), reference_token.end(),
14045 [](
const unsigned char x)
14047 return std::isdigit(x);
14051 *ptr = (nums || reference_token ==
"-")
14056 switch (ptr->type())
14061 ptr = &ptr->operator[](reference_token);
14067 if (reference_token ==
"-")
14070 ptr = &ptr->operator[](ptr->m_value.array->size());
14075 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14102 template<
typename BasicJsonType>
14103 BasicJsonType& get_checked(BasicJsonType* ptr)
const
14105 for (
const auto& reference_token : reference_tokens)
14107 switch (ptr->type())
14112 ptr = &ptr->at(reference_token);
14122 "array index '-' (", std::to_string(ptr->m_value.array->size()),
14123 ") is out of range"), ptr));
14127 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14160 template<
typename BasicJsonType>
14161 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
14163 for (
const auto& reference_token : reference_tokens)
14165 switch (ptr->type())
14170 ptr = &ptr->operator[](reference_token);
14183 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14209 template<
typename BasicJsonType>
14210 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
14212 for (
const auto& reference_token : reference_tokens)
14214 switch (ptr->type())
14219 ptr = &ptr->at(reference_token);
14229 "array index '-' (", std::to_string(ptr->m_value.array->size()),
14230 ") is out of range"), ptr));
14234 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14258 template<
typename BasicJsonType>
14259 bool contains(
const BasicJsonType* ptr)
const
14261 for (
const auto& reference_token : reference_tokens)
14263 switch (ptr->type())
14267 if (!ptr->contains(reference_token))
14273 ptr = &ptr->operator[](reference_token);
14284 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14296 for (std::size_t i = 1; i < reference_token.size(); i++)
14306 const auto idx = array_index<BasicJsonType>(reference_token);
14307 if (idx >= ptr->size())
14313 ptr = &ptr->operator[](idx);
14347 static std::vector<string_t> split(
const string_t& reference_string)
14349 std::vector<string_t> result;
14352 if (reference_string.empty())
14368 std::size_t slash = reference_string.find_first_of(
'/', 1),
14375 start = (slash == string_t::npos) ? 0 : slash + 1,
14377 slash = reference_string.find_first_of(
'/', start))
14381 auto reference_token = reference_string.substr(start, slash - start);
14384 for (std::size_t pos = reference_token.find_first_of(
'~');
14385 pos != string_t::npos;
14386 pos = reference_token.find_first_of(
'~', pos + 1))
14392 (reference_token[pos + 1] !=
'0' &&
14393 reference_token[pos + 1] !=
'1')))
14401 result.push_back(reference_token);
14415 template<
typename BasicJsonType>
14416 static void flatten(
const string_t& reference_string,
14417 const BasicJsonType& value,
14418 BasicJsonType& result)
14420 switch (value.type())
14424 if (value.m_value.array->empty())
14427 result[reference_string] =
nullptr;
14432 for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
14434 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
14435 value.m_value.array->operator[](i), result);
14443 if (value.m_value.object->empty())
14446 result[reference_string] =
nullptr;
14451 for (
const auto& element : *value.m_value.
object)
14470 result[reference_string] = value;
14486 template<
typename BasicJsonType>
14487 static BasicJsonType
14488 unflatten(
const BasicJsonType& value)
14495 BasicJsonType result;
14498 for (
const auto& element : *value.m_value.
object)
14509 json_pointer(element.first).get_and_create(result) = element.second;
14519 result.reference_tokens = reference_tokens;
14526 result.reference_tokens = std::move(reference_tokens);
14531#if JSON_HAS_THREE_WAY_COMPARISON
14534 template<
typename RefStringTypeRhs>
14537 return reference_tokens == rhs.reference_tokens;
14549 template<
typename RefStringTypeRhs>
14552 return reference_tokens <=> rhs.reference_tokens;
14557 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14564 template<
typename RefStringTypeLhs,
typename StringType>
14567 const StringType& rhs);
14571 template<
typename RefStringTypeRhs,
typename StringType>
14573 friend bool operator==(
const StringType& lhs,
14578 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14585 template<
typename RefStringTypeLhs,
typename StringType>
14588 const StringType& rhs);
14592 template<
typename RefStringTypeRhs,
typename StringType>
14594 friend bool operator!=(
const StringType& lhs,
14598 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14606 std::vector<string_t> reference_tokens;
14609#if !JSON_HAS_THREE_WAY_COMPARISON
14611template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14615 return lhs.reference_tokens == rhs.reference_tokens;
14618template<
typename RefStringTypeLhs,
14622 const StringType& rhs)
14627template<
typename RefStringTypeRhs,
14630inline
bool operator==(const StringType& lhs,
14636template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14640 return !(lhs == rhs);
14643template<
typename RefStringTypeLhs,
14647 const StringType& rhs)
14649 return !(lhs == rhs);
14652template<
typename RefStringTypeRhs,
14655inline
bool operator!=(const StringType& lhs,
14658 return !(lhs == rhs);
14661template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14665 return lhs.reference_tokens < rhs.reference_tokens;
14682#include <initializer_list>
14694template<
typename BasicJsonType>
14701 : owned_value(
std::move(value))
14705 : value_ref(&value)
14709 : owned_value(init)
14716 : owned_value(
std::forward<Args>(args)...)
14728 if (value_ref ==
nullptr)
14730 return std::move(owned_value);
14737 return value_ref ? *value_ref : owned_value;
14774#include <algorithm>
14800#include <algorithm>
14820template<
typename CharType>
struct output_adapter_protocol
14822 virtual void write_character(CharType c) = 0;
14823 virtual void write_characters(
const CharType* s, std::size_t length) = 0;
14824 virtual ~output_adapter_protocol() =
default;
14826 output_adapter_protocol() =
default;
14827 output_adapter_protocol(
const output_adapter_protocol&) =
default;
14828 output_adapter_protocol(output_adapter_protocol&&) noexcept = default;
14829 output_adapter_protocol& operator=(const output_adapter_protocol&) = default;
14830 output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default;
14834template<typename CharType>
14835using output_adapter_t =
std::shared_ptr<output_adapter_protocol<CharType>>;
14838template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
14839class output_vector_adapter : public output_adapter_protocol<CharType>
14842 explicit output_vector_adapter(std::vector<CharType, AllocatorType>& vec) noexcept
14846 void write_character(CharType c)
override
14852 void write_characters(const CharType* s,
std::
size_t length)
override
14854 v.insert(v.end(), s, s + length);
14858 std::vector<CharType, AllocatorType>& v;
14863template<
typename CharType>
14864class output_stream_adapter :
public output_adapter_protocol<CharType>
14867 explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept
14871 void write_character(CharType c)
override
14877 void write_characters(const CharType* s,
std::
size_t length)
override
14879 stream.write(s,
static_cast<std::streamsize
>(length));
14883 std::basic_ostream<CharType>& stream;
14888template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14889class output_string_adapter :
public output_adapter_protocol<CharType>
14892 explicit output_string_adapter(StringType& s) noexcept
14896 void write_character(CharType c)
override
14902 void write_characters(const CharType* s,
std::
size_t length)
override
14904 str.append(s, length);
14911template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14912class output_adapter
14915 template<
typename AllocatorType = std::allocator<CharType>>
14916 output_adapter(std::vector<CharType, AllocatorType>& vec)
14917 : oa(
std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
14920 output_adapter(std::basic_ostream<CharType>& s)
14921 : oa(
std::make_shared<output_stream_adapter<CharType>>(s)) {}
14924 output_adapter(StringType& s)
14925 : oa(
std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
14927 operator output_adapter_t<CharType>()
14933 output_adapter_t<CharType> oa =
nullptr;
14953template<
typename BasicJsonType,
typename CharType>
14956 using string_t =
typename BasicJsonType::string_t;
14957 using binary_t =
typename BasicJsonType::binary_t;
14958 using number_float_t =
typename BasicJsonType::number_float_t;
14966 explicit binary_writer(output_adapter_t<CharType> adapter) : oa(
std::move(adapter))
14975 void write_bson(
const BasicJsonType& j)
14979 case value_t::object:
14981 write_bson_object(*j.m_value.object);
14985 case value_t::null:
14986 case value_t::array:
14987 case value_t::string:
14988 case value_t::boolean:
14989 case value_t::number_integer:
14990 case value_t::number_unsigned:
14991 case value_t::number_float:
14992 case value_t::binary:
14993 case value_t::discarded:
14996 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15004 void write_cbor(
const BasicJsonType& j)
15008 case value_t::null:
15010 oa->write_character(to_char_type(0xF6));
15014 case value_t::boolean:
15016 oa->write_character(j.m_value.boolean
15017 ? to_char_type(0xF5)
15018 : to_char_type(0xF4));
15022 case value_t::number_integer:
15024 if (j.m_value.number_integer >= 0)
15029 if (j.m_value.number_integer <= 0x17)
15031 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15033 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15035 oa->write_character(to_char_type(0x18));
15036 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15038 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15040 oa->write_character(to_char_type(0x19));
15041 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15043 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15045 oa->write_character(to_char_type(0x1A));
15046 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15050 oa->write_character(to_char_type(0x1B));
15051 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15058 const auto positive_number = -1 - j.m_value.number_integer;
15059 if (j.m_value.number_integer >= -24)
15061 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15063 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15065 oa->write_character(to_char_type(0x38));
15066 write_number(
static_cast<std::uint8_t
>(positive_number));
15068 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15070 oa->write_character(to_char_type(0x39));
15071 write_number(
static_cast<std::uint16_t
>(positive_number));
15073 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15075 oa->write_character(to_char_type(0x3A));
15076 write_number(
static_cast<std::uint32_t
>(positive_number));
15080 oa->write_character(to_char_type(0x3B));
15081 write_number(
static_cast<std::uint64_t
>(positive_number));
15087 case value_t::number_unsigned:
15089 if (j.m_value.number_unsigned <= 0x17)
15091 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
15093 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15095 oa->write_character(to_char_type(0x18));
15096 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
15098 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15100 oa->write_character(to_char_type(0x19));
15101 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
15103 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15105 oa->write_character(to_char_type(0x1A));
15106 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
15110 oa->write_character(to_char_type(0x1B));
15111 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
15116 case value_t::number_float:
15118 if (std::isnan(j.m_value.number_float))
15121 oa->write_character(to_char_type(0xF9));
15122 oa->write_character(to_char_type(0x7E));
15123 oa->write_character(to_char_type(0x00));
15125 else if (std::isinf(j.m_value.number_float))
15128 oa->write_character(to_char_type(0xf9));
15129 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15130 oa->write_character(to_char_type(0x00));
15134 write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
15139 case value_t::string:
15142 const auto N = j.m_value.string->size();
15145 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15147 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15149 oa->write_character(to_char_type(0x78));
15150 write_number(
static_cast<std::uint8_t
>(N));
15152 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15154 oa->write_character(to_char_type(0x79));
15155 write_number(
static_cast<std::uint16_t
>(N));
15157 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15159 oa->write_character(to_char_type(0x7A));
15160 write_number(
static_cast<std::uint32_t
>(N));
15163 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15165 oa->write_character(to_char_type(0x7B));
15166 write_number(
static_cast<std::uint64_t
>(N));
15171 oa->write_characters(
15172 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15173 j.m_value.string->size());
15177 case value_t::array:
15180 const auto N = j.m_value.array->size();
15183 write_number(
static_cast<std::uint8_t
>(0x80 + N));
15185 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15187 oa->write_character(to_char_type(0x98));
15188 write_number(
static_cast<std::uint8_t
>(N));
15190 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15192 oa->write_character(to_char_type(0x99));
15193 write_number(
static_cast<std::uint16_t
>(N));
15195 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15197 oa->write_character(to_char_type(0x9A));
15198 write_number(
static_cast<std::uint32_t
>(N));
15201 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15203 oa->write_character(to_char_type(0x9B));
15204 write_number(
static_cast<std::uint64_t
>(N));
15209 for (
const auto& el : *j.m_value.
array)
15216 case value_t::binary:
15218 if (j.m_value.binary->has_subtype())
15220 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15222 write_number(
static_cast<std::uint8_t
>(0xd8));
15223 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
15225 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15227 write_number(
static_cast<std::uint8_t
>(0xd9));
15228 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
15230 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15232 write_number(
static_cast<std::uint8_t
>(0xda));
15233 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
15235 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15237 write_number(
static_cast<std::uint8_t
>(0xdb));
15238 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
15243 const auto N = j.m_value.binary->size();
15246 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15248 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15250 oa->write_character(to_char_type(0x58));
15251 write_number(
static_cast<std::uint8_t
>(N));
15253 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15255 oa->write_character(to_char_type(0x59));
15256 write_number(
static_cast<std::uint16_t
>(N));
15258 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15260 oa->write_character(to_char_type(0x5A));
15261 write_number(
static_cast<std::uint32_t
>(N));
15264 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15266 oa->write_character(to_char_type(0x5B));
15267 write_number(
static_cast<std::uint64_t
>(N));
15272 oa->write_characters(
15273 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15279 case value_t::object:
15282 const auto N = j.m_value.object->size();
15285 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15287 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15289 oa->write_character(to_char_type(0xB8));
15290 write_number(
static_cast<std::uint8_t
>(N));
15292 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15294 oa->write_character(to_char_type(0xB9));
15295 write_number(
static_cast<std::uint16_t
>(N));
15297 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15299 oa->write_character(to_char_type(0xBA));
15300 write_number(
static_cast<std::uint32_t
>(N));
15303 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15305 oa->write_character(to_char_type(0xBB));
15306 write_number(
static_cast<std::uint64_t
>(N));
15311 for (
const auto& el : *j.m_value.
object)
15313 write_cbor(el.first);
15314 write_cbor(el.second);
15319 case value_t::discarded:
15328 void write_msgpack(
const BasicJsonType& j)
15332 case value_t::null:
15334 oa->write_character(to_char_type(0xC0));
15338 case value_t::boolean:
15340 oa->write_character(j.m_value.boolean
15341 ? to_char_type(0xC3)
15342 : to_char_type(0xC2));
15346 case value_t::number_integer:
15348 if (j.m_value.number_integer >= 0)
15353 if (j.m_value.number_unsigned < 128)
15356 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15358 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15361 oa->write_character(to_char_type(0xCC));
15362 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15364 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15367 oa->write_character(to_char_type(0xCD));
15368 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15370 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15373 oa->write_character(to_char_type(0xCE));
15374 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15376 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15379 oa->write_character(to_char_type(0xCF));
15380 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15385 if (j.m_value.number_integer >= -32)
15388 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15390 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15391 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15394 oa->write_character(to_char_type(0xD0));
15395 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15397 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15398 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15401 oa->write_character(to_char_type(0xD1));
15402 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
15404 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15405 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15408 oa->write_character(to_char_type(0xD2));
15409 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
15411 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15412 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15415 oa->write_character(to_char_type(0xD3));
15416 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
15422 case value_t::number_unsigned:
15424 if (j.m_value.number_unsigned < 128)
15427 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15429 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15432 oa->write_character(to_char_type(0xCC));
15433 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15435 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15438 oa->write_character(to_char_type(0xCD));
15439 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15441 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15444 oa->write_character(to_char_type(0xCE));
15445 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15447 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15450 oa->write_character(to_char_type(0xCF));
15451 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15456 case value_t::number_float:
15458 write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
15462 case value_t::string:
15465 const auto N = j.m_value.string->size();
15469 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15471 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15474 oa->write_character(to_char_type(0xD9));
15475 write_number(
static_cast<std::uint8_t
>(N));
15477 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15480 oa->write_character(to_char_type(0xDA));
15481 write_number(
static_cast<std::uint16_t
>(N));
15483 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15486 oa->write_character(to_char_type(0xDB));
15487 write_number(
static_cast<std::uint32_t
>(N));
15491 oa->write_characters(
15492 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15493 j.m_value.string->size());
15497 case value_t::array:
15500 const auto N = j.m_value.array->size();
15504 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15506 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15509 oa->write_character(to_char_type(0xDC));
15510 write_number(
static_cast<std::uint16_t
>(N));
15512 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15515 oa->write_character(to_char_type(0xDD));
15516 write_number(
static_cast<std::uint32_t
>(N));
15520 for (
const auto& el : *j.m_value.
array)
15527 case value_t::binary:
15531 const bool use_ext = j.m_value.binary->has_subtype();
15534 const auto N = j.m_value.binary->size();
15535 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15537 std::uint8_t output_type{};
15544 output_type = 0xD4;
15547 output_type = 0xD5;
15550 output_type = 0xD6;
15553 output_type = 0xD7;
15556 output_type = 0xD8;
15559 output_type = 0xC7;
15567 output_type = 0xC4;
15571 oa->write_character(to_char_type(output_type));
15574 write_number(
static_cast<std::uint8_t
>(N));
15577 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15579 std::uint8_t output_type = use_ext
15583 oa->write_character(to_char_type(output_type));
15584 write_number(
static_cast<std::uint16_t
>(N));
15586 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15588 std::uint8_t output_type = use_ext
15592 oa->write_character(to_char_type(output_type));
15593 write_number(
static_cast<std::uint32_t
>(N));
15599 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
15603 oa->write_characters(
15604 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15610 case value_t::object:
15613 const auto N = j.m_value.object->size();
15617 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15619 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15622 oa->write_character(to_char_type(0xDE));
15623 write_number(
static_cast<std::uint16_t
>(N));
15625 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15628 oa->write_character(to_char_type(0xDF));
15629 write_number(
static_cast<std::uint32_t
>(N));
15633 for (
const auto& el : *j.m_value.
object)
15635 write_msgpack(el.first);
15636 write_msgpack(el.second);
15641 case value_t::discarded:
15654 void write_ubjson(
const BasicJsonType& j,
const bool use_count,
15655 const bool use_type,
const bool add_prefix =
true,
15656 const bool use_bjdata =
false)
15660 case value_t::null:
15664 oa->write_character(to_char_type(
'Z'));
15669 case value_t::boolean:
15673 oa->write_character(j.m_value.boolean
15674 ? to_char_type(
'T')
15675 : to_char_type(
'F'));
15680 case value_t::number_integer:
15682 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
15686 case value_t::number_unsigned:
15688 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
15692 case value_t::number_float:
15694 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
15698 case value_t::string:
15702 oa->write_character(to_char_type(
'S'));
15704 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
15705 oa->write_characters(
15706 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15707 j.m_value.string->size());
15711 case value_t::array:
15715 oa->write_character(to_char_type(
'['));
15718 bool prefix_required =
true;
15719 if (use_type && !j.m_value.array->empty())
15722 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15723 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15724 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15726 return ubjson_prefix(v, use_bjdata) == first_prefix;
15729 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15731 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15733 prefix_required =
false;
15734 oa->write_character(to_char_type(
'$'));
15735 oa->write_character(first_prefix);
15741 oa->write_character(to_char_type(
'#'));
15742 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
15745 for (
const auto& el : *j.m_value.
array)
15747 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15752 oa->write_character(to_char_type(
']'));
15758 case value_t::binary:
15762 oa->write_character(to_char_type(
'['));
15765 if (use_type && !j.m_value.binary->empty())
15768 oa->write_character(to_char_type(
'$'));
15769 oa->write_character(
'U');
15774 oa->write_character(to_char_type(
'#'));
15775 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
15780 oa->write_characters(
15781 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15782 j.m_value.binary->size());
15786 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
15788 oa->write_character(to_char_type(
'U'));
15789 oa->write_character(j.m_value.binary->data()[i]);
15795 oa->write_character(to_char_type(
']'));
15801 case value_t::object:
15803 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
15805 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
15813 oa->write_character(to_char_type(
'{'));
15816 bool prefix_required =
true;
15817 if (use_type && !j.m_value.object->empty())
15820 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15821 const bool same_prefix = std::all_of(j.begin(), j.end(),
15822 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15824 return ubjson_prefix(v, use_bjdata) == first_prefix;
15827 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15829 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15831 prefix_required =
false;
15832 oa->write_character(to_char_type(
'$'));
15833 oa->write_character(first_prefix);
15839 oa->write_character(to_char_type(
'#'));
15840 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
15843 for (
const auto& el : *j.m_value.
object)
15845 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15846 oa->write_characters(
15847 reinterpret_cast<const CharType*
>(el.first.c_str()),
15849 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15854 oa->write_character(to_char_type(
'}'));
15860 case value_t::discarded:
15875 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
15877 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
15880 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
15881 static_cast<void>(j);
15884 return 1ul + name.size() + 1u;
15890 void write_bson_entry_header(
const string_t& name,
15891 const std::uint8_t element_type)
15893 oa->write_character(to_char_type(element_type));
15894 oa->write_characters(
15895 reinterpret_cast<const CharType*
>(name.c_str()),
15902 void write_bson_boolean(
const string_t& name,
15905 write_bson_entry_header(name, 0x08);
15906 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
15912 void write_bson_double(
const string_t& name,
15913 const double value)
15915 write_bson_entry_header(name, 0x01);
15916 write_number<double>(value,
true);
15922 static std::size_t calc_bson_string_size(
const string_t& value)
15924 return sizeof(std::int32_t) + value.size() + 1ul;
15930 void write_bson_string(
const string_t& name,
15931 const string_t& value)
15933 write_bson_entry_header(name, 0x02);
15935 write_number<std::int32_t>(
static_cast<std::int32_t
>(value.size() + 1ul),
true);
15936 oa->write_characters(
15937 reinterpret_cast<const CharType*
>(value.c_str()),
15944 void write_bson_null(
const string_t& name)
15946 write_bson_entry_header(name, 0x0A);
15952 static std::size_t calc_bson_integer_size(
const std::int64_t value)
15954 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
15955 ?
sizeof(std::int32_t)
15956 :
sizeof(std::int64_t);
15962 void write_bson_integer(
const string_t& name,
15963 const std::int64_t value)
15965 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
15967 write_bson_entry_header(name, 0x10);
15968 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
15972 write_bson_entry_header(name, 0x12);
15973 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
15980 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
15982 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15983 ?
sizeof(std::int32_t)
15984 : sizeof(
std::int64_t);
15990 void write_bson_unsigned(
const string_t& name,
15991 const BasicJsonType& j)
15993 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15995 write_bson_entry_header(name, 0x10 );
15996 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
15998 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16000 write_bson_entry_header(name, 0x12 );
16001 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
16005 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
16012 void write_bson_object_entry(
const string_t& name,
16013 const typename BasicJsonType::object_t& value)
16015 write_bson_entry_header(name, 0x03);
16016 write_bson_object(value);
16022 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16024 std::size_t array_index = 0ul;
16026 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)
16028 return result + calc_bson_element_size(std::to_string(array_index++), el);
16031 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16037 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16039 return sizeof(std::int32_t) + value.size() + 1ul;
16045 void write_bson_array(
const string_t& name,
16046 const typename BasicJsonType::array_t& value)
16048 write_bson_entry_header(name, 0x04);
16049 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16051 std::size_t array_index = 0ul;
16053 for (
const auto& el : value)
16055 write_bson_element(std::to_string(array_index++), el);
16058 oa->write_character(to_char_type(0x00));
16064 void write_bson_binary(
const string_t& name,
16065 const binary_t& value)
16067 write_bson_entry_header(name, 0x05);
16069 write_number<std::int32_t>(
static_cast<std::int32_t
>(value.size()),
true);
16070 write_number(value.has_subtype() ?
static_cast<std::uint8_t
>(value.subtype()) : static_cast<
std::uint8_t>(0x00));
16072 oa->write_characters(
reinterpret_cast<const CharType*
>(value.data()), value.size());
16079 static std::size_t calc_bson_element_size(
const string_t& name,
16080 const BasicJsonType& j)
16082 const auto header_size = calc_bson_entry_header_size(name, j);
16085 case value_t::object:
16086 return header_size + calc_bson_object_size(*j.m_value.object);
16088 case value_t::array:
16089 return header_size + calc_bson_array_size(*j.m_value.array);
16091 case value_t::binary:
16092 return header_size + calc_bson_binary_size(*j.m_value.binary);
16094 case value_t::boolean:
16095 return header_size + 1ul;
16097 case value_t::number_float:
16098 return header_size + 8ul;
16100 case value_t::number_integer:
16101 return header_size + calc_bson_integer_size(j.m_value.number_integer);
16103 case value_t::number_unsigned:
16104 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
16106 case value_t::string:
16107 return header_size + calc_bson_string_size(*j.m_value.string);
16109 case value_t::null:
16110 return header_size + 0ul;
16113 case value_t::discarded:
16127 void write_bson_element(
const string_t& name,
16128 const BasicJsonType& j)
16132 case value_t::object:
16133 return write_bson_object_entry(name, *j.m_value.object);
16135 case value_t::array:
16136 return write_bson_array(name, *j.m_value.array);
16138 case value_t::binary:
16139 return write_bson_binary(name, *j.m_value.binary);
16141 case value_t::boolean:
16142 return write_bson_boolean(name, j.m_value.boolean);
16144 case value_t::number_float:
16145 return write_bson_double(name, j.m_value.number_float);
16147 case value_t::number_integer:
16148 return write_bson_integer(name, j.m_value.number_integer);
16150 case value_t::number_unsigned:
16151 return write_bson_unsigned(name, j);
16153 case value_t::string:
16154 return write_bson_string(name, *j.m_value.string);
16156 case value_t::null:
16157 return write_bson_null(name);
16160 case value_t::discarded:
16174 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
16176 std::size_t document_size = std::accumulate(value.begin(), value.end(),
static_cast<std::size_t
>(0),
16177 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
16179 return result += calc_bson_element_size(el.first, el.second);
16182 return sizeof(std::int32_t) + document_size + 1ul;
16189 void write_bson_object(
const typename BasicJsonType::object_t& value)
16191 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
16193 for (
const auto& el : value)
16195 write_bson_element(el.first, el.second);
16198 oa->write_character(to_char_type(0x00));
16205 static constexpr CharType get_cbor_float_prefix(
float )
16207 return to_char_type(0xFA);
16210 static constexpr CharType get_cbor_float_prefix(
double )
16212 return to_char_type(0xFB);
16219 static constexpr CharType get_msgpack_float_prefix(
float )
16221 return to_char_type(0xCA);
16224 static constexpr CharType get_msgpack_float_prefix(
double )
16226 return to_char_type(0xCB);
16234 template<
typename NumberType,
typename std::enable_if<
16235 std::is_floating_point<NumberType>::value,
int>::type = 0>
16236 void write_number_with_ubjson_prefix(
const NumberType n,
16237 const bool add_prefix,
16238 const bool use_bjdata)
16242 oa->write_character(get_ubjson_float_prefix(n));
16244 write_number(n, use_bjdata);
16248 template<
typename NumberType,
typename std::enable_if<
16249 std::is_unsigned<NumberType>::value,
int>::type = 0>
16250 void write_number_with_ubjson_prefix(
const NumberType n,
16251 const bool add_prefix,
16252 const bool use_bjdata)
16254 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16258 oa->write_character(to_char_type(
'i'));
16260 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16262 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16266 oa->write_character(to_char_type(
'U'));
16268 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16270 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16274 oa->write_character(to_char_type(
'I'));
16276 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16278 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
16282 oa->write_character(to_char_type(
'u'));
16284 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
16286 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16290 oa->write_character(to_char_type(
'l'));
16292 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16294 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
16298 oa->write_character(to_char_type(
'm'));
16300 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
16302 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16306 oa->write_character(to_char_type(
'L'));
16308 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16310 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16314 oa->write_character(to_char_type(
'M'));
16316 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
16322 oa->write_character(to_char_type(
'H'));
16325 const auto number = BasicJsonType(n).dump();
16326 write_number_with_ubjson_prefix(
number.size(),
true, use_bjdata);
16327 for (std::size_t i = 0; i <
number.size(); ++i)
16329 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16335 template <
typename NumberType,
typename std::enable_if <
16336 std::is_signed<NumberType>::value&&
16337 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
16338 void write_number_with_ubjson_prefix(
const NumberType n,
16339 const bool add_prefix,
16340 const bool use_bjdata)
16342 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16346 oa->write_character(to_char_type(
'i'));
16348 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
16350 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)()))
16354 oa->write_character(to_char_type(
'U'));
16356 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16358 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16362 oa->write_character(to_char_type(
'I'));
16364 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16366 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)())))
16370 oa->write_character(to_char_type(
'u'));
16372 write_number(
static_cast<uint16_t
>(n), use_bjdata);
16374 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16378 oa->write_character(to_char_type(
'l'));
16380 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16382 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)())))
16386 oa->write_character(to_char_type(
'm'));
16388 write_number(
static_cast<uint32_t
>(n), use_bjdata);
16390 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16394 oa->write_character(to_char_type(
'L'));
16396 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16403 oa->write_character(to_char_type(
'H'));
16406 const auto number = BasicJsonType(n).dump();
16407 write_number_with_ubjson_prefix(
number.size(),
true, use_bjdata);
16408 for (std::size_t i = 0; i <
number.size(); ++i)
16410 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16419 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16423 case value_t::null:
16426 case value_t::boolean:
16427 return j.m_value.boolean ?
'T' :
'F';
16429 case value_t::number_integer:
16431 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16435 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16439 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16443 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
16447 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16451 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
16455 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16463 case value_t::number_unsigned:
16465 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16469 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16473 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16477 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16481 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16485 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16489 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16493 if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16501 case value_t::number_float:
16502 return get_ubjson_float_prefix(j.m_value.number_float);
16504 case value_t::string:
16507 case value_t::array:
16508 case value_t::binary:
16511 case value_t::object:
16514 case value_t::discarded:
16520 static constexpr CharType get_ubjson_float_prefix(
float )
16525 static constexpr CharType get_ubjson_float_prefix(
double )
16533 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type)
16535 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16536 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16539 string_t key =
"_ArrayType_";
16540 auto it = bjdtype.find(
static_cast<string_t
>(value.at(key)));
16541 if (it == bjdtype.end())
16545 CharType dtype = it->second;
16547 key =
"_ArraySize_";
16548 std::size_t len = (value.at(key).empty() ? 0 : 1);
16549 for (
const auto& el : value.at(key))
16551 len *=
static_cast<std::size_t
>(el.m_value.number_unsigned);
16554 key =
"_ArrayData_";
16555 if (value.at(key).size() != len)
16560 oa->write_character(
'[');
16561 oa->write_character(
'$');
16562 oa->write_character(dtype);
16563 oa->write_character(
'#');
16565 key =
"_ArraySize_";
16566 write_ubjson(value.at(key), use_count, use_type,
true,
true);
16568 key =
"_ArrayData_";
16569 if (dtype ==
'U' || dtype ==
'C')
16571 for (
const auto& el : value.at(key))
16573 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
16576 else if (dtype ==
'i')
16578 for (
const auto& el : value.at(key))
16580 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
16583 else if (dtype ==
'u')
16585 for (
const auto& el : value.at(key))
16587 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
16590 else if (dtype ==
'I')
16592 for (
const auto& el : value.at(key))
16594 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
16597 else if (dtype ==
'm')
16599 for (
const auto& el : value.at(key))
16601 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
16604 else if (dtype ==
'l')
16606 for (
const auto& el : value.at(key))
16608 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
16611 else if (dtype ==
'M')
16613 for (
const auto& el : value.at(key))
16615 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
16618 else if (dtype ==
'L')
16620 for (
const auto& el : value.at(key))
16622 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
16625 else if (dtype ==
'd')
16627 for (
const auto& el : value.at(key))
16629 write_number(
static_cast<float>(el.m_value.number_float),
true);
16632 else if (dtype ==
'D')
16634 for (
const auto& el : value.at(key))
16636 write_number(
static_cast<double>(el.m_value.number_float),
true);
16659 template<
typename NumberType>
16660 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
16663 std::array<CharType,
sizeof(NumberType)> vec{};
16664 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16667 if (is_little_endian != OutputIsLittleEndian)
16670 std::reverse(vec.begin(), vec.end());
16673 oa->write_characters(vec.data(),
sizeof(NumberType));
16676 void write_compact_float(
const number_float_t n, detail::input_format_t format)
16679#pragma GCC diagnostic push
16680#pragma GCC diagnostic ignored "-Wfloat-equal"
16682 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16683 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16684 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
16686 oa->write_character(format == detail::input_format_t::cbor
16687 ? get_cbor_float_prefix(
static_cast<float>(n))
16688 : get_msgpack_float_prefix(static_cast<float>(n)));
16689 write_number(
static_cast<float>(n));
16693 oa->write_character(format == detail::input_format_t::cbor
16694 ? get_cbor_float_prefix(n)
16695 : get_msgpack_float_prefix(n));
16699#pragma GCC diagnostic pop
16708 template <
typename C = CharType,
16709 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
16710 static constexpr CharType to_char_type(std::uint8_t x)
noexcept
16712 return *
reinterpret_cast<char*
>(&x);
16715 template <
typename C = CharType,
16716 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
16717 static CharType to_char_type(std::uint8_t x)
noexcept
16719 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16720 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16722 std::memcpy(&result, &x,
sizeof(x));
16726 template<
typename C = CharType,
16727 enable_if_t<std::is_unsigned<C>::value>* =
nullptr>
16728 static constexpr CharType to_char_type(std::uint8_t x)
noexcept
16733 template <
typename InputCharType,
typename C = CharType,
16735 std::is_signed<C>::value &&
16736 std::is_signed<char>::value &&
16737 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
16739 static constexpr CharType to_char_type(InputCharType x)
noexcept
16749 output_adapter_t<CharType> oa =
nullptr;
16769#include <algorithm>
16779#include <type_traits>
16799#include <type_traits>
16830template<
typename Target,
typename Source>
16831Target reinterpret_bits(
const Source source)
16833 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16836 std::memcpy(&target, &source,
sizeof(Source));
16842 static constexpr int kPrecision = 64;
16844 std::uint64_t f = 0;
16847 constexpr diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
16853 static diyfp sub(
const diyfp& x,
const diyfp& y)
noexcept
16858 return {x.f - y.f, x.e};
16865 static diyfp mul(
const diyfp& x,
const diyfp& y)
noexcept
16867 static_assert(kPrecision == 64,
"internal error");
16892 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
16893 const std::uint64_t u_hi = x.f >> 32u;
16894 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
16895 const std::uint64_t v_hi = y.f >> 32u;
16897 const std::uint64_t p0 = u_lo * v_lo;
16898 const std::uint64_t p1 = u_lo * v_hi;
16899 const std::uint64_t p2 = u_hi * v_lo;
16900 const std::uint64_t p3 = u_hi * v_hi;
16902 const std::uint64_t p0_hi = p0 >> 32u;
16903 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
16904 const std::uint64_t p1_hi = p1 >> 32u;
16905 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
16906 const std::uint64_t p2_hi = p2 >> 32u;
16908 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16919 Q += std::uint64_t{1} << (64u - 32u - 1u);
16921 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16923 return {h, x.e + y.e + 64};
16930 static diyfp normalize(diyfp x)
noexcept
16934 while ((x.f >> 63u) == 0)
16947 static diyfp normalize_to(
const diyfp& x,
const int target_exponent)
noexcept
16949 const int delta = x.e - target_exponent;
16954 return {x.f << delta, target_exponent};
16971template<
typename FloatType>
16972boundaries compute_boundaries(FloatType value)
16984 static_assert(std::numeric_limits<FloatType>::is_iec559,
16985 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
16987 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
16988 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
16989 constexpr int kMinExp = 1 - kBias;
16990 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
16992 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
16994 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(value));
16995 const std::uint64_t E = bits >> (kPrecision - 1);
16996 const std::uint64_t F = bits & (kHiddenBit - 1);
16998 const bool is_denormal = E == 0;
16999 const diyfp v = is_denormal
17000 ? diyfp(F, kMinExp)
17001 : diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17024 const bool lower_boundary_is_closer = F == 0 && E > 1;
17025 const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
17026 const diyfp m_minus = lower_boundary_is_closer
17027 ? diyfp(4 * v.f - 1, v.e - 2)
17028 : diyfp(2 * v.f - 1, v.e - 1);
17031 const diyfp w_plus = diyfp::normalize(m_plus);
17034 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
17036 return {diyfp::normalize(v), w_minus, w_plus};
17094constexpr int kAlpha = -60;
17095constexpr int kGamma = -32;
17111inline cached_power get_cached_power_for_binary_exponent(
int e)
17163 constexpr int kCachedPowersMinDecExp = -300;
17164 constexpr int kCachedPowersDecStep = 8;
17166 static constexpr std::array<cached_power, 79> kCachedPowers =
17169 { 0xAB70FE17C79AC6CA, -1060, -300 },
17170 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17171 { 0xBE5691EF416BD60C, -1007, -284 },
17172 { 0x8DD01FAD907FFC3C, -980, -276 },
17173 { 0xD3515C2831559A83, -954, -268 },
17174 { 0x9D71AC8FADA6C9B5, -927, -260 },
17175 { 0xEA9C227723EE8BCB, -901, -252 },
17176 { 0xAECC49914078536D, -874, -244 },
17177 { 0x823C12795DB6CE57, -847, -236 },
17178 { 0xC21094364DFB5637, -821, -228 },
17179 { 0x9096EA6F3848984F, -794, -220 },
17180 { 0xD77485CB25823AC7, -768, -212 },
17181 { 0xA086CFCD97BF97F4, -741, -204 },
17182 { 0xEF340A98172AACE5, -715, -196 },
17183 { 0xB23867FB2A35B28E, -688, -188 },
17184 { 0x84C8D4DFD2C63F3B, -661, -180 },
17185 { 0xC5DD44271AD3CDBA, -635, -172 },
17186 { 0x936B9FCEBB25C996, -608, -164 },
17187 { 0xDBAC6C247D62A584, -582, -156 },
17188 { 0xA3AB66580D5FDAF6, -555, -148 },
17189 { 0xF3E2F893DEC3F126, -529, -140 },
17190 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17191 { 0x87625F056C7C4A8B, -475, -124 },
17192 { 0xC9BCFF6034C13053, -449, -116 },
17193 { 0x964E858C91BA2655, -422, -108 },
17194 { 0xDFF9772470297EBD, -396, -100 },
17195 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17196 { 0xF8A95FCF88747D94, -343, -84 },
17197 { 0xB94470938FA89BCF, -316, -76 },
17198 { 0x8A08F0F8BF0F156B, -289, -68 },
17199 { 0xCDB02555653131B6, -263, -60 },
17200 { 0x993FE2C6D07B7FAC, -236, -52 },
17201 { 0xE45C10C42A2B3B06, -210, -44 },
17202 { 0xAA242499697392D3, -183, -36 },
17203 { 0xFD87B5F28300CA0E, -157, -28 },
17204 { 0xBCE5086492111AEB, -130, -20 },
17205 { 0x8CBCCC096F5088CC, -103, -12 },
17206 { 0xD1B71758E219652C, -77, -4 },
17207 { 0x9C40000000000000, -50, 4 },
17208 { 0xE8D4A51000000000, -24, 12 },
17209 { 0xAD78EBC5AC620000, 3, 20 },
17210 { 0x813F3978F8940984, 30, 28 },
17211 { 0xC097CE7BC90715B3, 56, 36 },
17212 { 0x8F7E32CE7BEA5C70, 83, 44 },
17213 { 0xD5D238A4ABE98068, 109, 52 },
17214 { 0x9F4F2726179A2245, 136, 60 },
17215 { 0xED63A231D4C4FB27, 162, 68 },
17216 { 0xB0DE65388CC8ADA8, 189, 76 },
17217 { 0x83C7088E1AAB65DB, 216, 84 },
17218 { 0xC45D1DF942711D9A, 242, 92 },
17219 { 0x924D692CA61BE758, 269, 100 },
17220 { 0xDA01EE641A708DEA, 295, 108 },
17221 { 0xA26DA3999AEF774A, 322, 116 },
17222 { 0xF209787BB47D6B85, 348, 124 },
17223 { 0xB454E4A179DD1877, 375, 132 },
17224 { 0x865B86925B9BC5C2, 402, 140 },
17225 { 0xC83553C5C8965D3D, 428, 148 },
17226 { 0x952AB45CFA97A0B3, 455, 156 },
17227 { 0xDE469FBD99A05FE3, 481, 164 },
17228 { 0xA59BC234DB398C25, 508, 172 },
17229 { 0xF6C69A72A3989F5C, 534, 180 },
17230 { 0xB7DCBF5354E9BECE, 561, 188 },
17231 { 0x88FCF317F22241E2, 588, 196 },
17232 { 0xCC20CE9BD35C78A5, 614, 204 },
17233 { 0x98165AF37B2153DF, 641, 212 },
17234 { 0xE2A0B5DC971F303A, 667, 220 },
17235 { 0xA8D9D1535CE3B396, 694, 228 },
17236 { 0xFB9B7CD9A4A7443C, 720, 236 },
17237 { 0xBB764C4CA7A44410, 747, 244 },
17238 { 0x8BAB8EEFB6409C1A, 774, 252 },
17239 { 0xD01FEF10A657842C, 800, 260 },
17240 { 0x9B10A4E5E9913129, 827, 268 },
17241 { 0xE7109BFBA19C0C9D, 853, 276 },
17242 { 0xAC2820D9623BF429, 880, 284 },
17243 { 0x80444B5E7AA7CF85, 907, 292 },
17244 { 0xBF21E44003ACDD2D, 933, 300 },
17245 { 0x8E679C2F5E44FF8F, 960, 308 },
17246 { 0xD433179D9C8CB841, 986, 316 },
17247 { 0x9E19DB92B4E31BA9, 1013, 324 },
17257 const int f = kAlpha - e - 1;
17258 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
17260 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17262 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
17264 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
17275inline int find_largest_pow10(
const std::uint32_t n, std::uint32_t& pow10)
17278 if (n >= 1000000000)
17280 pow10 = 1000000000;
17284 if (n >= 100000000)
17329inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17330 std::uint64_t rest, std::uint64_t ten_k)
17357 && delta - rest >= ten_k
17358 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17370inline void grisu2_digit_gen(
char* buffer,
int& length,
int& decimal_exponent,
17371 diyfp M_minus, diyfp w, diyfp M_plus)
17373 static_assert(kAlpha >= -60,
"internal error");
17374 static_assert(kGamma <= -32,
"internal error");
17391 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
17392 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
17401 const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
17403 auto p1 =
static_cast<std::uint32_t
>(M_plus.f >> -one.e);
17404 std::uint64_t p2 = M_plus.f & (one.f - 1);
17412 std::uint32_t pow10{};
17413 const int k = find_largest_pow10(p1, pow10);
17440 const std::uint32_t d = p1 / pow10;
17441 const std::uint32_t r = p1 % pow10;
17447 buffer[length++] =
static_cast<char>(
'0' + d);
17466 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17471 decimal_exponent += n;
17482 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17483 grisu2_round(buffer, length, dist, delta, rest, ten_n);
17544 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17546 const std::uint64_t d = p2 >> -one.e;
17547 const std::uint64_t r = p2 & (one.f - 1);
17554 buffer[length++] =
static_cast<char>(
'0' + d);
17579 decimal_exponent -= m;
17587 const std::uint64_t ten_m = one.f;
17588 grisu2_round(buffer, length, dist, delta, p2, ten_m);
17611inline void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17612 diyfp m_minus, diyfp v, diyfp m_plus)
17626 const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);
17628 const diyfp c_minus_k(cached.f, cached.e);
17631 const diyfp w = diyfp::mul(v, c_minus_k);
17632 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
17633 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
17656 const diyfp M_minus(w_minus.f + 1, w_minus.e);
17657 const diyfp M_plus (w_plus.f - 1, w_plus.e );
17659 decimal_exponent = -cached.k;
17661 grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus);
17669template<
typename FloatType>
17671void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
17673 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
17674 "internal error: not enough precision");
17696 const boundaries w = compute_boundaries(
static_cast<double>(value));
17698 const boundaries w = compute_boundaries(value);
17701 grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
17711inline char* append_exponent(
char* buf,
int e)
17726 auto k =
static_cast<std::uint32_t
>(e);
17732 *buf++ =
static_cast<char>(
'0' + k);
17736 *buf++ =
static_cast<char>(
'0' + k / 10);
17738 *buf++ =
static_cast<char>(
'0' + k);
17742 *buf++ =
static_cast<char>(
'0' + k / 100);
17744 *buf++ =
static_cast<char>(
'0' + k / 10);
17746 *buf++ =
static_cast<char>(
'0' + k);
17763inline char* format_buffer(
char* buf,
int len,
int decimal_exponent,
17764 int min_exp,
int max_exp)
17770 const int n = len + decimal_exponent;
17776 if (k <= n && n <= max_exp)
17781 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
17785 return buf + (
static_cast<size_t>(n) + 2);
17788 if (0 < n && n <= max_exp)
17795 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
17797 return buf + (
static_cast<size_t>(k) + 1U);
17800 if (min_exp < n && n <= 0)
17805 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
17808 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
17809 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
17824 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17826 buf += 1 +
static_cast<size_t>(k);
17830 return append_exponent(buf, n - 1);
17845template<
typename FloatType>
17848char* to_chars(
char* first, const
char* last, FloatType value)
17850 static_cast<void>(last);
17854 if (std::signbit(value))
17861#pragma GCC diagnostic push
17862#pragma GCC diagnostic ignored "-Wfloat-equal"
17873#pragma GCC diagnostic pop
17876 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
17883 int decimal_exponent = 0;
17884 dtoa_impl::grisu2(first, len, decimal_exponent, value);
17886 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
17889 constexpr int kMinExp = -4;
17891 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
17894 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17895 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17897 return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
17934template<
typename BasicJsonType>
17937 using string_t =
typename BasicJsonType::string_t;
17938 using number_float_t =
typename BasicJsonType::number_float_t;
17939 using number_integer_t =
typename BasicJsonType::number_integer_t;
17940 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
17941 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
17942 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17943 static constexpr std::uint8_t UTF8_REJECT = 1;
17954 ,
loc(
std::localeconv())
17992 const bool pretty_print,
17994 const unsigned int indent_step,
17995 const unsigned int current_indent = 0)
17997 switch (val.m_type)
18001 if (val.m_value.object->empty())
18003 o->write_characters(
"{}", 2);
18009 o->write_characters(
"{\n", 2);
18012 const auto new_indent = current_indent + indent_step;
18019 auto i = val.m_value.object->cbegin();
18020 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
18023 o->write_character(
'\"');
18025 o->write_characters(
"\": ", 3);
18027 o->write_characters(
",\n", 2);
18032 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
18034 o->write_character(
'\"');
18036 o->write_characters(
"\": ", 3);
18039 o->write_character(
'\n');
18040 o->write_characters(
indent_string.c_str(), current_indent);
18041 o->write_character(
'}');
18045 o->write_character(
'{');
18048 auto i = val.m_value.object->cbegin();
18049 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
18051 o->write_character(
'\"');
18053 o->write_characters(
"\":", 2);
18055 o->write_character(
',');
18060 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
18061 o->write_character(
'\"');
18063 o->write_characters(
"\":", 2);
18066 o->write_character(
'}');
18074 if (val.m_value.array->empty())
18076 o->write_characters(
"[]", 2);
18082 o->write_characters(
"[\n", 2);
18085 const auto new_indent = current_indent + indent_step;
18092 for (
auto i = val.m_value.array->cbegin();
18093 i != val.m_value.array->cend() - 1; ++i)
18097 o->write_characters(
",\n", 2);
18103 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
18105 o->write_character(
'\n');
18106 o->write_characters(
indent_string.c_str(), current_indent);
18107 o->write_character(
']');
18111 o->write_character(
'[');
18114 for (
auto i = val.m_value.array->cbegin();
18115 i != val.m_value.array->cend() - 1; ++i)
18118 o->write_character(
',');
18123 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
18125 o->write_character(
']');
18133 o->write_character(
'\"');
18135 o->write_character(
'\"');
18143 o->write_characters(
"{\n", 2);
18146 const auto new_indent = current_indent + indent_step;
18154 o->write_characters(
"\"bytes\": [", 10);
18156 if (!val.m_value.binary->empty())
18158 for (
auto i = val.m_value.binary->cbegin();
18159 i != val.m_value.binary->cend() - 1; ++i)
18162 o->write_characters(
", ", 2);
18164 dump_integer(val.m_value.binary->back());
18167 o->write_characters(
"],\n", 3);
18170 o->write_characters(
"\"subtype\": ", 11);
18171 if (val.m_value.binary->has_subtype())
18173 dump_integer(val.m_value.binary->subtype());
18177 o->write_characters(
"null", 4);
18179 o->write_character(
'\n');
18180 o->write_characters(
indent_string.c_str(), current_indent);
18181 o->write_character(
'}');
18185 o->write_characters(
"{\"bytes\":[", 10);
18187 if (!val.m_value.binary->empty())
18189 for (
auto i = val.m_value.binary->cbegin();
18190 i != val.m_value.binary->cend() - 1; ++i)
18193 o->write_character(
',');
18195 dump_integer(val.m_value.binary->back());
18198 o->write_characters(
"],\"subtype\":", 12);
18199 if (val.m_value.binary->has_subtype())
18201 dump_integer(val.m_value.binary->subtype());
18202 o->write_character(
'}');
18206 o->write_characters(
"null}", 5);
18214 if (val.m_value.boolean)
18216 o->write_characters(
"true", 4);
18220 o->write_characters(
"false", 5);
18227 dump_integer(val.m_value.number_integer);
18233 dump_integer(val.m_value.number_unsigned);
18239 dump_float(val.m_value.number_float);
18245 o->write_characters(
"<discarded>", 11);
18251 o->write_characters(
"null", 4);
18277 std::uint32_t codepoint{};
18285 for (std::size_t i = 0; i < s.size(); ++i)
18287 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18289 switch (decode(
state, codepoint,
byte))
18348 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
18350 if (codepoint <= 0xFFFF)
18354 static_cast<std::uint16_t
>(codepoint)));
18360 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
18361 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18362 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18430 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xEF');
18431 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBF');
18432 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBD');
18450 state = UTF8_ACCEPT;
18506 o->write_characters(
"\\ufffd", 6);
18510 o->write_characters(
"\xEF\xBF\xBD", 3);
18530 inline unsigned int count_digits(number_unsigned_t x)
noexcept
18532 unsigned int n_digits = 1;
18541 return n_digits + 1;
18545 return n_digits + 2;
18549 return n_digits + 3;
18561 static std::string hex_bytes(std::uint8_t
byte)
18563 std::string result =
"FF";
18564 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
18565 result[0] = nibble_to_hex[
byte / 16];
18566 result[1] = nibble_to_hex[
byte % 16];
18571 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18572 bool is_negative_number(NumberType x)
18577 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18578 bool is_negative_number(NumberType )
18593 std::is_integral<NumberType>::value ||
18594 std::is_same<NumberType, number_unsigned_t>::value ||
18595 std::is_same<NumberType, number_integer_t>::value ||
18596 std::is_same<NumberType, binary_char_t>::value,
18598 void dump_integer(NumberType x)
18600 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18603 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18604 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18605 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18606 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18607 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18608 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18609 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18610 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18611 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18612 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18619 o->write_character(
'0');
18626 number_unsigned_t abs_value;
18628 unsigned int n_chars{};
18630 if (is_negative_number(x))
18633 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
18636 n_chars = 1 + count_digits(abs_value);
18640 abs_value =
static_cast<number_unsigned_t
>(x);
18641 n_chars = count_digits(abs_value);
18649 buffer_ptr += n_chars;
18653 while (abs_value >= 100)
18655 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18657 *(--buffer_ptr) = digits_to_99[digits_index][1];
18658 *(--buffer_ptr) = digits_to_99[digits_index][0];
18661 if (abs_value >= 10)
18663 const auto digits_index =
static_cast<unsigned>(abs_value);
18664 *(--buffer_ptr) = digits_to_99[digits_index][1];
18665 *(--buffer_ptr) = digits_to_99[digits_index][0];
18669 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18683 void dump_float(number_float_t x)
18686 if (!std::isfinite(x))
18688 o->write_characters(
"null", 4);
18697 static constexpr bool is_ieee_single_or_double
18698 = (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) ||
18699 (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);
18701 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18704 void dump_float(number_float_t x, std::true_type )
18707 auto* end = ::nlohmann::detail::to_chars(begin, begin +
number_buffer.size(), x);
18709 o->write_characters(begin,
static_cast<size_t>(end - begin));
18712 void dump_float(number_float_t x, std::false_type )
18715 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
18747 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
18750 const bool value_is_int_like =
18754 return c ==
'.' || c ==
'e';
18757 if (value_is_int_like)
18759 o->write_characters(
".0", 2);
18784 static std::uint8_t
decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
18786 static const std::array<std::uint8_t, 400> utf8d =
18789 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,
18790 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,
18791 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,
18792 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,
18793 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,
18794 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,
18795 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,
18796 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18797 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18798 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18799 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,
18800 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,
18801 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,
18802 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
18807 const std::uint8_t
type = utf8d[byte];
18809 codep = (
state != UTF8_ACCEPT)
18810 ? (
byte & 0x3fu) | (codep << 6u)
18811 : (0xFFu >>
type) & (byte);
18813 std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
18815 state = utf8d[index];
18824 number_unsigned_t remove_sign(number_unsigned_t x)
18839 inline number_unsigned_t remove_sign(number_integer_t x)
noexcept
18841 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18842 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
18847 output_adapter_t<char> o =
nullptr;
18889#include <functional>
18890#include <initializer_list>
18893#include <stdexcept>
18894#include <type_traits>
18907template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18908 class Allocator = std::allocator<std::pair<const Key, T>>>
18913 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18918#ifdef JSON_HAS_CPP_14
18928 template <
class It>
18931 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
18936 for (
auto it = this->begin(); it != this->end(); ++it)
18938 if (m_compare(it->first, key))
18940 return {it,
false};
18943 Container::emplace_back(key, std::forward<T>(t));
18944 return {std::prev(this->end()),
true};
18949 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
18951 for (
auto it = this->begin(); it != this->end(); ++it)
18953 if (m_compare(it->first, key))
18955 return {it,
false};
18958 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
18959 return {std::prev(this->end()),
true};
18964 return emplace(key, T{}).first->second;
18971 return emplace(std::forward<KeyType>(key), T{}).first->second;
18983 return at(std::forward<KeyType>(key));
18988 for (
auto it = this->begin(); it != this->end(); ++it)
18990 if (m_compare(it->first, key))
18996 JSON_THROW(std::out_of_range(
"key not found"));
19003 for (
auto it = this->begin(); it != this->end(); ++it)
19005 if (m_compare(it->first, key))
19011 JSON_THROW(std::out_of_range(
"key not found"));
19016 for (
auto it = this->begin(); it != this->end(); ++it)
19018 if (m_compare(it->first, key))
19024 JSON_THROW(std::out_of_range(
"key not found"));
19029 const T &
at(KeyType && key)
const
19031 for (
auto it = this->begin(); it != this->end(); ++it)
19033 if (m_compare(it->first, key))
19039 JSON_THROW(std::out_of_range(
"key not found"));
19044 for (
auto it = this->begin(); it != this->end(); ++it)
19046 if (m_compare(it->first, key))
19049 for (
auto next = it; ++next != this->end(); ++it)
19054 Container::pop_back();
19065 for (
auto it = this->begin(); it != this->end(); ++it)
19067 if (m_compare(it->first, key))
19070 for (
auto next = it; ++next != this->end(); ++it)
19075 Container::pop_back();
19084 return erase(pos, std::next(pos));
19094 const auto elements_affected = std::distance(first, last);
19095 const auto offset = std::distance(Container::begin(), first);
19117 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
19120 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19128 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
19137 return Container::begin() + offset;
19142 for (
auto it = this->begin(); it != this->end(); ++it)
19144 if (m_compare(it->first, key))
19156 for (
auto it = this->begin(); it != this->end(); ++it)
19158 if (m_compare(it->first, key))
19168 for (
auto it = this->begin(); it != this->end(); ++it)
19170 if (m_compare(it->first, key))
19175 return Container::end();
19182 for (
auto it = this->begin(); it != this->end(); ++it)
19184 if (m_compare(it->first, key))
19189 return Container::end();
19194 for (
auto it = this->begin(); it != this->end(); ++it)
19196 if (m_compare(it->first, key))
19201 return Container::end();
19206 return emplace(value.first, std::move(value.second));
19211 for (
auto it = this->begin(); it != this->end(); ++it)
19213 if (m_compare(it->first, value.first))
19215 return {it,
false};
19218 Container::push_back(value);
19219 return {--this->end(),
true};
19222 template<
typename InputIt>
19223 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19224 std::input_iterator_tag>::value>::type;
19226 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19229 for (
auto it = first; it != last; ++it)
19242#if defined(JSON_HAS_CPP_17)
19244 #include <string_view>
19279 friend class ::nlohmann::json_pointer;
19283 template<
typename BasicJsonType,
typename InputType>
19284 friend class ::nlohmann::detail::parser;
19285 friend ::nlohmann::detail::serializer<basic_json>;
19286 template<
typename BasicJsonType>
19287 friend class ::nlohmann::detail::iter_impl;
19288 template<
typename BasicJsonType,
typename CharType>
19289 friend class ::nlohmann::detail::binary_writer;
19290 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19291 friend class ::nlohmann::detail::binary_reader;
19292 template<
typename BasicJsonType>
19293 friend class ::nlohmann::detail::json_sax_dom_parser;
19294 template<
typename BasicJsonType>
19295 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19296 friend class ::nlohmann::detail::exception;
19303 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19305 template<
typename InputAdapterType>
19306 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19307 InputAdapterType adapter,
19308 detail::parser_callback_t<basic_json>cb =
nullptr,
19309 const bool allow_exceptions =
true,
19310 const bool ignore_comments =
false
19313 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19314 std::move(cb), allow_exceptions, ignore_comments);
19318 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
19319 template<
typename BasicJsonType>
19320 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
19321 template<
typename BasicJsonType>
19322 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
19323 template<
typename Iterator>
19324 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
19325 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
19327 template<
typename CharType>
19328 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
19330 template<
typename InputType>
19331 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
19332 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19335 using serializer = ::nlohmann::detail::serializer<basic_json>;
19341 template<
typename T,
typename SFINAE>
19350 using input_format_t = detail::input_format_t;
19398 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19400 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19428 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
19429 result[
"name"] =
"JSON for Modern C++";
19430 result[
"url"] =
"https://github.com/nlohmann/json";
19431 result[
"version"][
"string"] =
19440 result[
"platform"] =
"win32";
19441#elif defined __linux__
19442 result[
"platform"] =
"linux";
19443#elif defined __APPLE__
19444 result[
"platform"] =
"apple";
19445#elif defined __unix__
19446 result[
"platform"] =
"unix";
19448 result[
"platform"] =
"unknown";
19451#if defined(__ICC) || defined(__INTEL_COMPILER)
19452 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19453#elif defined(__clang__)
19454 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19455#elif defined(__GNUC__) || defined(__GNUG__)
19456 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19457 std::to_string(__GNUC__),
'.',
19458 std::to_string(__GNUC_MINOR__),
'.',
19459 std::to_string(__GNUC_PATCHLEVEL__))
19462#elif defined(__HP_cc) || defined(__HP_aCC)
19463 result[
"compiler"] =
"hp"
19464#elif defined(__IBMCPP__)
19465 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19466#elif defined(_MSC_VER)
19467 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19468#elif defined(__PGI)
19469 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19470#elif defined(__SUNPRO_CC)
19471 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19473 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19477#if defined(_MSVC_LANG)
19478 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
19479#elif defined(__cplusplus)
19480 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
19482 result[
"compiler"][
"c++"] =
"unknown";
19501#if defined(JSON_HAS_CPP_14)
19514 AllocatorType<std::pair<
const StringType,
19519 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19543 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19554 template<
typename T,
typename... Args>
19556 static T* create(Args&& ... args)
19558 AllocatorType<T> alloc;
19559 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19561 auto deleter = [&](T * obj)
19563 AllocatorTraits::deallocate(alloc, obj, 1);
19565 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19566 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19568 return obj.release();
19621 json_value() =
default;
19623 json_value(
boolean_t v) noexcept : boolean(v) {}
19635 case value_t::object:
19637 object = create<object_t>();
19641 case value_t::array:
19643 array = create<array_t>();
19647 case value_t::string:
19649 string = create<string_t>(
"");
19653 case value_t::binary:
19655 binary = create<binary_t>();
19659 case value_t::boolean:
19661 boolean =
static_cast<boolean_t>(
false);
19665 case value_t::number_integer:
19671 case value_t::number_unsigned:
19677 case value_t::number_float:
19683 case value_t::null:
19689 case value_t::discarded:
19734 if (t == value_t::array || t == value_t::object)
19737 std::vector<basic_json> stack;
19740 if (t == value_t::array)
19742 stack.reserve(
array->size());
19743 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
19748 for (
auto&& it : *
object)
19750 stack.push_back(std::move(it.second));
19754 while (!stack.empty())
19757 basic_json current_item(std::move(stack.back()));
19762 if (current_item.is_array())
19764 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
19766 current_item.m_value.array->clear();
19768 else if (current_item.is_object())
19772 stack.push_back(std::move(it.second));
19775 current_item.m_value.object->clear();
19785 case value_t::object:
19787 AllocatorType<object_t> alloc;
19788 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
19789 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
19793 case value_t::array:
19795 AllocatorType<array_t> alloc;
19796 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
19797 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
19801 case value_t::string:
19803 AllocatorType<string_t> alloc;
19804 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
19805 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
19809 case value_t::binary:
19811 AllocatorType<binary_t> alloc;
19812 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
19813 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
19817 case value_t::null:
19818 case value_t::boolean:
19819 case value_t::number_integer:
19820 case value_t::number_unsigned:
19821 case value_t::number_float:
19822 case value_t::discarded:
19850 void assert_invariant(
bool check_parents =
true) const noexcept
19857#if JSON_DIAGNOSTICS
19863 return j.m_parent ==
this;
19868 static_cast<void>(check_parents);
19873#if JSON_DIAGNOSTICS
19876 case value_t::array:
19880 element.m_parent =
this;
19885 case value_t::object:
19889 element.second.m_parent =
this;
19894 case value_t::null:
19895 case value_t::string:
19896 case value_t::boolean:
19897 case value_t::number_integer:
19898 case value_t::number_unsigned:
19899 case value_t::number_float:
19900 case value_t::binary:
19901 case value_t::discarded:
19908 iterator set_parents(
iterator it,
typename iterator::difference_type count_set_parents)
19910#if JSON_DIAGNOSTICS
19911 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
19913 (it + i)->m_parent =
this;
19916 static_cast<void>(count_set_parents);
19921 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
19923#if JSON_DIAGNOSTICS
19924 if (old_capacity !=
static_cast<std::size_t
>(-1))
19938#ifdef JSON_HEDLEY_MSVC_VERSION
19939#pragma warning(push )
19940#pragma warning(disable : 4127)
19947#ifdef JSON_HEDLEY_MSVC_VERSION
19948#pragma warning( pop )
19953 static_cast<void>(j);
19954 static_cast<void>(old_capacity);
19966 using parse_event_t = detail::parse_event_t;
19986 assert_invariant();
19994 assert_invariant();
19999 template <
typename CompatibleType,
20004 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20005 std::forward<CompatibleType>(val))))
20007 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20009 assert_invariant();
20014 template <
typename BasicJsonType,
20019 using other_boolean_t =
typename BasicJsonType::boolean_t;
20020 using other_number_float_t =
typename BasicJsonType::number_float_t;
20021 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20022 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20023 using other_string_t =
typename BasicJsonType::string_t;
20024 using other_object_t =
typename BasicJsonType::object_t;
20025 using other_array_t =
typename BasicJsonType::array_t;
20026 using other_binary_t =
typename BasicJsonType::binary_t;
20028 switch (val.type())
20030 case value_t::boolean:
20031 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
20033 case value_t::number_float:
20034 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
20036 case value_t::number_integer:
20037 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
20039 case value_t::number_unsigned:
20040 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
20042 case value_t::string:
20043 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
20045 case value_t::object:
20046 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
20048 case value_t::array:
20049 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
20051 case value_t::binary:
20052 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
20054 case value_t::null:
20057 case value_t::discarded:
20058 m_type = value_t::discarded;
20065 assert_invariant();
20071 bool type_deduction =
true,
20072 value_t manual_type = value_t::array)
20076 bool is_an_object = std::all_of(init.begin(), init.end(),
20079 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
20083 if (!type_deduction)
20086 if (manual_type == value_t::array)
20088 is_an_object =
false;
20101 m_type = value_t::object;
20104 for (
auto& element_ref : init)
20108 std::move(*((*element.m_value.array)[0].m_value.string)),
20109 std::move((*element.m_value.array)[1]));
20115 m_type = value_t::array;
20116 m_value.array = create<array_t>(init.begin(), init.end());
20120 assert_invariant();
20129 res.m_type = value_t::binary;
20130 res.m_value = init;
20137 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20140 res.m_type = value_t::binary;
20141 res.m_value =
binary_t(init, subtype);
20151 res.m_type = value_t::binary;
20152 res.m_value = std::move(init);
20159 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
20162 res.m_type = value_t::binary;
20163 res.m_value =
binary_t(std::move(init), subtype);
20172 return basic_json(init,
false, value_t::array);
20180 return basic_json(init,
false, value_t::object);
20188 m_value.array = create<array_t>(cnt, val);
20190 assert_invariant();
20195 template <
class InputIT,
typename std::enable_if <
20196 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
20197 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
20210 m_type = first.m_object->m_type;
20215 case value_t::boolean:
20216 case value_t::number_float:
20217 case value_t::number_integer:
20218 case value_t::number_unsigned:
20219 case value_t::string:
20222 || !last.m_it.primitive_iterator.is_end()))
20229 case value_t::null:
20230 case value_t::object:
20231 case value_t::array:
20232 case value_t::binary:
20233 case value_t::discarded:
20240 case value_t::number_integer:
20242 m_value.number_integer = first.m_object->m_value.number_integer;
20246 case value_t::number_unsigned:
20248 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
20252 case value_t::number_float:
20254 m_value.number_float = first.m_object->m_value.number_float;
20258 case value_t::boolean:
20260 m_value.boolean = first.m_object->m_value.boolean;
20264 case value_t::string:
20266 m_value = *first.m_object->m_value.string;
20270 case value_t::object:
20272 m_value.object = create<object_t>(first.m_it.object_iterator,
20273 last.m_it.object_iterator);
20277 case value_t::array:
20279 m_value.array = create<array_t>(first.m_it.array_iterator,
20280 last.m_it.array_iterator);
20284 case value_t::binary:
20286 m_value = *first.m_object->m_value.binary;
20290 case value_t::null:
20291 case value_t::discarded:
20297 assert_invariant();
20305 template<
typename JsonRef,
20307 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
20313 : m_type(other.m_type)
20316 other.assert_invariant();
20320 case value_t::object:
20326 case value_t::array:
20332 case value_t::string:
20338 case value_t::boolean:
20344 case value_t::number_integer:
20350 case value_t::number_unsigned:
20356 case value_t::number_float:
20362 case value_t::binary:
20368 case value_t::null:
20369 case value_t::discarded:
20375 assert_invariant();
20381 : m_type(std::move(other.m_type)),
20382 m_value(std::move(other.m_value))
20385 other.assert_invariant(
false);
20388 other.m_type = value_t::null;
20389 other.m_value = {};
20392 assert_invariant();
20398 std::is_nothrow_move_constructible<value_t>::value&&
20399 std::is_nothrow_move_assignable<value_t>::value&&
20400 std::is_nothrow_move_constructible<json_value>::value&&
20401 std::is_nothrow_move_assignable<json_value>::value
20405 other.assert_invariant();
20408 swap(m_type, other.m_type);
20412 assert_invariant();
20420 assert_invariant(
false);
20438 const char indent_char =
' ',
20439 const bool ensure_ascii =
false,
20443 serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler);
20447 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20451 s.dump(*
this,
false, ensure_ascii, 0);
20482 return m_type == value_t::null;
20489 return m_type == value_t::boolean;
20503 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
20510 return m_type == value_t::number_unsigned;
20517 return m_type == value_t::number_float;
20524 return m_type == value_t::object;
20531 return m_type == value_t::array;
20538 return m_type == value_t::string;
20545 return m_type == value_t::binary;
20552 return m_type == value_t::discarded;
20599 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
20687 template<
typename ReferenceType,
typename ThisType>
20688 static ReferenceType get_ref_impl(ThisType& obj)
20691 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20708 template<
typename PointerType,
typename std::enable_if<
20709 std::is_pointer<PointerType>::value,
int>
::type = 0>
20710 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20713 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20718 template <
typename PointerType,
typename std::enable_if <
20719 std::is_pointer<PointerType>::value&&
20720 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
20721 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20724 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20766 template <
typename ValueType,
20772 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
20774 auto ret = ValueType();
20775 JSONSerializer<ValueType>::from_json(*
this, ret);
20809 template <
typename ValueType,
20814 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
20816 return JSONSerializer<ValueType>::from_json(*
this);
20834 template <
typename BasicJsonType,
20857 template<
typename BasicJsonType,
20859 std::is_same<BasicJsonType, basic_json_t>::value,
20870 template<
typename PointerType,
20872 std::is_pointer<PointerType>::value,
20875 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20878 return get_ptr<PointerType>();
20905 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20906#if defined(JSON_HAS_CPP_14)
20910 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
20916 static_assert(!std::is_reference<ValueTypeCV>::value,
20917 "get() cannot be used with reference types, you might want to use get_ref()");
20948 template<
typename PointerType,
typename std::enable_if<
20949 std::is_pointer<PointerType>::value,
int>
::type = 0>
20950 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
20953 return get_ptr<PointerType>();
20958 template <
typename ValueType,
20963 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
20964 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
20966 JSONSerializer<ValueType>::from_json(*
this, v);
20972 template<
typename ValueType,
20983 typename T, std::size_t N,
20984 typename Array = T (&)[N],
20988 noexcept(
noexcept(JSONSerializer<Array>::from_json(
20989 std::declval<const basic_json_t&>(), v)))
20991 JSONSerializer<Array>::from_json(*
this, v);
20997 template<
typename ReferenceType,
typename std::enable_if<
20998 std::is_reference<ReferenceType>::value,
int>
::type = 0>
21002 return get_ref_impl<ReferenceType>(*
this);
21007 template <
typename ReferenceType,
typename std::enable_if <
21008 std::is_reference<ReferenceType>::value&&
21009 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
21013 return get_ref_impl<ReferenceType>(*
this);
21045 template <
typename ValueType,
typename std::enable_if <
21053#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21056#if defined(JSON_HAS_CPP_17)
21064 return get<ValueType>();
21076 return *get_ptr<binary_t*>();
21088 return *get_ptr<const binary_t*>();
21111 return set_parent(
m_value.array->at(idx));
21134 return m_value.array->at(idx);
21158 auto it =
m_value.object->find(key);
21159 if (it ==
m_value.object->end())
21163 return set_parent(it->second);
21178 auto it =
m_value.object->find(std::forward<KeyType>(key));
21179 if (it ==
m_value.object->end())
21183 return set_parent(it->second);
21196 auto it =
m_value.object->find(key);
21197 if (it ==
m_value.object->end())
21216 auto it =
m_value.object->find(std::forward<KeyType>(key));
21217 if (it ==
m_value.object->end())
21231 m_type = value_t::array;
21232 m_value.array = create<array_t>();
21233 assert_invariant();
21240 if (idx >=
m_value.array->size())
21242#if JSON_DIAGNOSTICS
21244 const auto old_size =
m_value.array->size();
21245 const auto old_capacity =
m_value.array->capacity();
21247 m_value.array->resize(idx + 1);
21249#if JSON_DIAGNOSTICS
21258 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21261 assert_invariant();
21264 return m_value.array->operator[](idx);
21277 return m_value.array->operator[](idx);
21290 m_type = value_t::object;
21292 assert_invariant();
21298 auto result =
m_value.object->emplace(std::move(key),
nullptr);
21299 return set_parent(result.first->second);
21322 template<
typename T>
21325 return operator[](
typename object_t::key_type(key));
21328 template<
typename T>
21331 return operator[](
typename object_t::key_type(key));
21343 m_type = value_t::object;
21345 assert_invariant();
21351 auto result =
m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
21352 return set_parent(result.first->second);
21376 template<
typename KeyType>
21380 template<
typename ValueType>
21381 using value_return_type = std::conditional <
21383 string_t,
typename std::decay<ValueType>::type >;
21391 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21392 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
21398 const auto it =
find(key);
21401 return it->template get<ValueType>();
21404 return default_value;
21412 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21416 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21417 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
21423 const auto it =
find(key);
21426 return it->template get<ReturnType>();
21429 return std::forward<ValueType>(default_value);
21440 && is_comparable_with_object_key<KeyType>::value
21442 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21443 ValueType
value(KeyType && key,
const ValueType& default_value)
const
21449 const auto it =
find(std::forward<KeyType>(key));
21452 return it->template get<ValueType>();
21455 return default_value;
21463 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
21467 && is_comparable_with_object_key<KeyType>::value
21469 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21470 ReturnType
value(KeyType && key, ValueType && default_value)
const
21476 const auto it =
find(std::forward<KeyType>(key));
21479 return it->template get<ReturnType>();
21482 return std::forward<ValueType>(default_value);
21492 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21501 return ptr.get_checked(
this).template get<ValueType>();
21505 return default_value;
21514 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21517 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21526 return ptr.get_checked(
this).template get<ReturnType>();
21530 return std::forward<ValueType>(default_value);
21540 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21542 ValueType
value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
21544 return value(ptr.convert(), default_value);
21547 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
21551 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21555 return value(ptr.convert(), std::forward<ValueType>(default_value));
21593 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21594 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21603 IteratorType result =
end();
21607 case value_t::boolean:
21608 case value_t::number_float:
21609 case value_t::number_integer:
21610 case value_t::number_unsigned:
21611 case value_t::string:
21612 case value_t::binary:
21621 AllocatorType<string_t> alloc;
21622 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
21623 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
21628 AllocatorType<binary_t> alloc;
21629 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
21630 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
21634 m_type = value_t::null;
21635 assert_invariant();
21639 case value_t::object:
21641 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
21645 case value_t::array:
21647 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
21651 case value_t::null:
21652 case value_t::discarded:
21663 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21664 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21665 IteratorType
erase(IteratorType first, IteratorType last)
21673 IteratorType result =
end();
21677 case value_t::boolean:
21678 case value_t::number_float:
21679 case value_t::number_integer:
21680 case value_t::number_unsigned:
21681 case value_t::string:
21682 case value_t::binary:
21685 || !last.m_it.primitive_iterator.is_end()))
21692 AllocatorType<string_t> alloc;
21693 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
21694 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
21699 AllocatorType<binary_t> alloc;
21700 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
21701 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
21705 m_type = value_t::null;
21706 assert_invariant();
21710 case value_t::object:
21712 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
21713 last.m_it.object_iterator);
21717 case value_t::array:
21719 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
21720 last.m_it.array_iterator);
21724 case value_t::null:
21725 case value_t::discarded:
21736 size_type erase_internal(KeyType && key)
21744 return m_value.object->erase(std::forward<KeyType>(key));
21749 size_type erase_internal(KeyType && key)
21757 const auto it =
m_value.object->find(std::forward<KeyType>(key));
21758 if (it !=
m_value.object->end())
21774 return erase_internal(key);
21783 return erase_internal(std::forward<KeyType>(key));
21820 auto result =
end();
21824 result.m_it.object_iterator =
m_value.object->find(key);
21834 auto result =
cend();
21838 result.m_it.object_iterator =
m_value.object->find(key);
21850 auto result =
end();
21854 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
21866 auto result =
cend();
21870 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
21891 return is_object() ?
m_value.object->count(std::forward<KeyType>(key)) : 0;
21896 bool contains(
const typename object_t::key_type& key)
const
21914 return ptr.contains(
this);
21917 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
21921 return ptr.contains(
this);
21939 result.set_begin();
21955 result.set_begin();
22035 return ref.items();
22046 return ref.items();
22053 return iteration_proxy<iterator>(*
this);
22058 iteration_proxy<const_iterator>
items() const noexcept
22060 return iteration_proxy<const_iterator>(*
this);
22079 case value_t::null:
22085 case value_t::array:
22088 return m_value.array->empty();
22091 case value_t::object:
22094 return m_value.object->empty();
22097 case value_t::string:
22098 case value_t::boolean:
22099 case value_t::number_integer:
22100 case value_t::number_unsigned:
22101 case value_t::number_float:
22102 case value_t::binary:
22103 case value_t::discarded:
22118 case value_t::null:
22124 case value_t::array:
22127 return m_value.array->size();
22130 case value_t::object:
22133 return m_value.object->size();
22136 case value_t::string:
22137 case value_t::boolean:
22138 case value_t::number_integer:
22139 case value_t::number_unsigned:
22140 case value_t::number_float:
22141 case value_t::binary:
22142 case value_t::discarded:
22157 case value_t::array:
22160 return m_value.array->max_size();
22163 case value_t::object:
22166 return m_value.object->max_size();
22169 case value_t::null:
22170 case value_t::string:
22171 case value_t::boolean:
22172 case value_t::number_integer:
22173 case value_t::number_unsigned:
22174 case value_t::number_float:
22175 case value_t::binary:
22176 case value_t::discarded:
22201 case value_t::number_integer:
22207 case value_t::number_unsigned:
22213 case value_t::number_float:
22219 case value_t::boolean:
22225 case value_t::string:
22231 case value_t::binary:
22237 case value_t::array:
22243 case value_t::object:
22249 case value_t::null:
22250 case value_t::discarded:
22269 m_type = value_t::array;
22271 assert_invariant();
22275 const auto old_capacity =
m_value.array->capacity();
22276 m_value.array->push_back(std::move(val));
22277 set_parent(
m_value.array->back(), old_capacity);
22302 m_type = value_t::array;
22304 assert_invariant();
22308 const auto old_capacity =
m_value.array->capacity();
22309 m_value.array->push_back(val);
22310 set_parent(
m_value.array->back(), old_capacity);
22334 m_type = value_t::object;
22336 assert_invariant();
22340 auto res =
m_value.object->insert(val);
22341 set_parent(res.first->second);
22356 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
22358 basic_json&& key = init.begin()->moved_or_copied();
22359 push_back(
typename object_t::value_type(
22360 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22378 template<
class... Args>
22390 m_type = value_t::array;
22392 assert_invariant();
22396 const auto old_capacity =
m_value.array->capacity();
22397 m_value.array->emplace_back(std::forward<Args>(args)...);
22398 return set_parent(
m_value.array->back(), old_capacity);
22403 template<
class... Args>
22415 m_type = value_t::object;
22417 assert_invariant();
22421 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
22422 set_parent(res.first->second);
22426 it.m_it.object_iterator = res.first;
22429 return {it, res.second};
22435 template<
typename... Args>
22441 auto insert_pos = std::distance(
m_value.array->begin(), pos.m_it.array_iterator);
22442 m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22443 result.m_it.array_iterator =
m_value.array->begin() + insert_pos;
22477 return insert(pos, val);
22528 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22573 m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22590 m_type = value_t::object;
22591 m_value.object = create<object_t>();
22592 assert_invariant();
22612 for (
auto it = first; it != last; ++it)
22614 if (merge_objects && it.value().is_object())
22616 auto it2 =
m_value.object->find(it.key());
22617 if (it2 !=
m_value.object->end())
22619 it2->second.update(it.value(),
true);
22623 m_value.object->operator[](it.key()) = it.value();
22624#if JSON_DIAGNOSTICS
22625 m_value.object->operator[](it.key()).m_parent =
this;
22633 std::is_nothrow_move_constructible<value_t>::value&&
22634 std::is_nothrow_move_assignable<value_t>::value&&
22635 std::is_nothrow_move_constructible<json_value>::value&&
22636 std::is_nothrow_move_assignable<json_value>::value
22643 other.set_parents();
22644 assert_invariant();
22650 std::is_nothrow_move_constructible<value_t>::value&&
22651 std::is_nothrow_move_assignable<value_t>::value&&
22652 std::is_nothrow_move_constructible<json_value>::value&&
22653 std::is_nothrow_move_assignable<json_value>::value
22725 void swap(
typename binary_t::container_type& other)
22750#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22751 const auto lhs_type = lhs.type(); \
22752 const auto rhs_type = rhs.type(); \
22754 if (lhs_type == rhs_type) \
22756 switch (lhs_type) \
22758 case value_t::array: \
22759 return (*lhs.m_value.array) op (*rhs.m_value.array); \
22761 case value_t::object: \
22762 return (*lhs.m_value.object) op (*rhs.m_value.object); \
22764 case value_t::null: \
22765 return (null_result); \
22767 case value_t::string: \
22768 return (*lhs.m_value.string) op (*rhs.m_value.string); \
22770 case value_t::boolean: \
22771 return (lhs.m_value.boolean) op (rhs.m_value.boolean); \
22773 case value_t::number_integer: \
22774 return (lhs.m_value.number_integer) op (rhs.m_value.number_integer); \
22776 case value_t::number_unsigned: \
22777 return (lhs.m_value.number_unsigned) op (rhs.m_value.number_unsigned); \
22779 case value_t::number_float: \
22780 return (lhs.m_value.number_float) op (rhs.m_value.number_float); \
22782 case value_t::binary: \
22783 return (*lhs.m_value.binary) op (*rhs.m_value.binary); \
22785 case value_t::discarded: \
22787 return (unordered_result); \
22790 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22792 return static_cast<number_float_t>(lhs.m_value.number_integer) op rhs.m_value.number_float; \
22794 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22796 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_integer); \
22798 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22800 return static_cast<number_float_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_float; \
22802 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22804 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_unsigned); \
22806 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22808 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_integer; \
22810 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22812 return lhs.m_value.number_integer op static_cast<number_integer_t>(rhs.m_value.number_unsigned); \
22814 else if(compares_unordered(lhs, rhs))\
22816 return (unordered_result);\
22819 return (default_result);
22834#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22845 return compares_unordered(*
this,
rhs,
inverse);
22849#if JSON_HAS_THREE_WAY_COMPARISON
22855#pragma GCC diagnostic push
22856#pragma GCC diagnostic ignored "-Wfloat-equal"
22861#pragma GCC diagnostic pop
22867 template<
typename ScalarType>
22868 requires std::is_scalar_v<ScalarType>
22878 if (compares_unordered(
rhs,
true))
22893 std::partial_ordering::equivalent,
22894 std::partial_ordering::unordered,
22895 lhs_type <=> rhs_type)
22900 template<
typename ScalarType>
22901 requires std::is_scalar_v<ScalarType>
22902 std::partial_ordering operator<=>(ScalarType
rhs)
const noexcept
22907#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22916 if (compares_unordered(
rhs,
true))
22920 return !(
rhs < *
this);
22925 template<
typename ScalarType>
22926 requires std::is_scalar_v<ScalarType>
22927 bool operator<=(ScalarType
rhs)
const noexcept
22937 if (compares_unordered(
rhs,
true))
22941 return !(*
this <
rhs);
22946 template<
typename ScalarType>
22947 requires std::is_scalar_v<ScalarType>
22948 bool operator>=(ScalarType
rhs)
const noexcept
22959#pragma GCC diagnostic push
22960#pragma GCC diagnostic ignored "-Wfloat-equal"
22964#pragma GCC diagnostic pop
22970 template<
typename ScalarType,
typename std::enable_if<
22971 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22979 template<
typename ScalarType,
typename std::enable_if<
22980 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22990 if (compares_unordered(lhs,
rhs,
true))
22994 return !(lhs ==
rhs);
22999 template<
typename ScalarType,
typename std::enable_if<
23000 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23008 template<
typename ScalarType,
typename std::enable_if<
23009 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23027 template<
typename ScalarType,
typename std::enable_if<
23028 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23036 template<
typename ScalarType,
typename std::enable_if<
23037 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23047 if (compares_unordered(lhs,
rhs,
true))
23051 return !(
rhs < lhs);
23056 template<
typename ScalarType,
typename std::enable_if<
23057 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23065 template<
typename ScalarType,
typename std::enable_if<
23066 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23077 if (compares_unordered(lhs,
rhs))
23081 return !(lhs <=
rhs);
23086 template<
typename ScalarType,
typename std::enable_if<
23087 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23095 template<
typename ScalarType,
typename std::enable_if<
23096 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23106 if (compares_unordered(lhs,
rhs,
true))
23110 return !(lhs <
rhs);
23115 template<
typename ScalarType,
typename std::enable_if<
23116 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23124 template<
typename ScalarType,
typename std::enable_if<
23125 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23132#undef JSON_IMPLEMENT_OPERATOR
23148 const bool pretty_print = o.width() > 0;
23149 const auto indentation = pretty_print ? o.width() : 0;
23155 serializer s(detail::output_adapter<char>(o), o.fill());
23156 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23184 template<
typename InputType>
23188 const bool allow_exceptions =
true,
23189 const bool ignore_comments =
false)
23192 parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23198 template<
typename IteratorType>
23203 const bool allow_exceptions =
true,
23204 const bool ignore_comments =
false)
23207 parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23213 static basic_json parse(detail::span_input_adapter&& i,
23215 const bool allow_exceptions =
true,
23216 const bool ignore_comments =
false)
23219 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23225 template<
typename InputType>
23226 static bool accept(InputType&& i,
23227 const bool ignore_comments =
false)
23229 return parser(detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
23234 template<
typename IteratorType>
23235 static bool accept(IteratorType first, IteratorType last,
23236 const bool ignore_comments =
false)
23238 return parser(detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
23243 static bool accept(detail::span_input_adapter&& i,
23244 const bool ignore_comments =
false)
23246 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23251 template <
typename InputType,
typename SAX>
23254 input_format_t format = input_format_t::
json,
23255 const
bool strict = true,
23256 const
bool ignore_comments = false)
23258 auto ia = detail::input_adapter(std::forward<InputType>(i));
23259 return format == input_format_t::json
23260 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23266 template<
class IteratorType,
class SAX>
23268 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23269 input_format_t format = input_format_t::
json,
23270 const
bool strict = true,
23271 const
bool ignore_comments = false)
23273 auto ia = detail::input_adapter(std::move(first), std::move(last));
23274 return format == input_format_t::json
23275 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23284 template <
typename SAX>
23288 input_format_t format = input_format_t::
json,
23289 const
bool strict = true,
23290 const
bool ignore_comments = false)
23293 return format == input_format_t::json
23295 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23316 parser(detail::input_adapter(i)).parse(
false, j);
23333 case value_t::null:
23335 case value_t::object:
23337 case value_t::array:
23339 case value_t::string:
23341 case value_t::boolean:
23343 case value_t::binary:
23345 case value_t::discarded:
23346 return "discarded";
23347 case value_t::number_integer:
23348 case value_t::number_unsigned:
23349 case value_t::number_float:
23362 value_t m_type = value_t::null;
23367#if JSON_DIAGNOSTICS
23384 std::vector<std::uint8_t> result;
23393 binary_writer<std::uint8_t>(o).write_cbor(j);
23400 binary_writer<char>(o).write_cbor(j);
23407 std::vector<std::uint8_t> result;
23416 binary_writer<std::uint8_t>(o).write_msgpack(j);
23423 binary_writer<char>(o).write_msgpack(j);
23429 const bool use_size =
false,
23430 const bool use_type =
false)
23432 std::vector<std::uint8_t> result;
23433 to_ubjson(j, result, use_size, use_type);
23440 const bool use_size =
false,
const bool use_type =
false)
23442 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
23448 const bool use_size =
false,
const bool use_type =
false)
23450 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
23456 const bool use_size =
false,
23457 const bool use_type =
false)
23459 std::vector<std::uint8_t> result;
23460 to_bjdata(j, result, use_size, use_type);
23467 const bool use_size =
false,
const bool use_type =
false)
23469 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
23475 const bool use_size =
false,
const bool use_type =
false)
23477 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
23484 std::vector<std::uint8_t> result;
23493 binary_writer<std::uint8_t>(o).write_bson(j);
23500 binary_writer<char>(o).write_bson(j);
23505 template<
typename InputType>
23508 const bool strict =
true,
23509 const bool allow_exceptions =
true,
23514 auto ia = detail::input_adapter(std::forward<InputType>(i));
23515 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23516 return res ? result :
basic_json(value_t::discarded);
23521 template<
typename IteratorType>
23524 const bool strict =
true,
23525 const bool allow_exceptions =
true,
23530 auto ia = detail::input_adapter(std::move(first), std::move(last));
23531 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23532 return res ? result :
basic_json(value_t::discarded);
23535 template<
typename T>
23539 const
bool strict = true,
23540 const
bool allow_exceptions = true,
23543 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23550 const
bool strict = true,
23551 const
bool allow_exceptions = true,
23558 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23559 return res ? result :
basic_json(value_t::discarded);
23564 template<
typename InputType>
23567 const bool strict =
true,
23568 const bool allow_exceptions =
true)
23572 auto ia = detail::input_adapter(std::forward<InputType>(i));
23573 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23574 return res ? result :
basic_json(value_t::discarded);
23579 template<
typename IteratorType>
23582 const bool strict =
true,
23583 const bool allow_exceptions =
true)
23587 auto ia = detail::input_adapter(std::move(first), std::move(last));
23588 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23589 return res ? result :
basic_json(value_t::discarded);
23592 template<
typename T>
23596 const
bool strict = true,
23597 const
bool allow_exceptions = true)
23599 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23605 const
bool strict = true,
23606 const
bool allow_exceptions = true)
23612 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23613 return res ? result :
basic_json(value_t::discarded);
23618 template<
typename InputType>
23621 const bool strict =
true,
23622 const bool allow_exceptions =
true)
23626 auto ia = detail::input_adapter(std::forward<InputType>(i));
23627 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23628 return res ? result :
basic_json(value_t::discarded);
23633 template<
typename IteratorType>
23636 const bool strict =
true,
23637 const bool allow_exceptions =
true)
23641 auto ia = detail::input_adapter(std::move(first), std::move(last));
23642 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23643 return res ? result :
basic_json(value_t::discarded);
23646 template<
typename T>
23650 const
bool strict = true,
23651 const
bool allow_exceptions = true)
23653 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23659 const
bool strict = true,
23660 const
bool allow_exceptions = true)
23666 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23667 return res ? result :
basic_json(value_t::discarded);
23673 template<
typename InputType>
23676 const bool strict =
true,
23677 const bool allow_exceptions =
true)
23681 auto ia = detail::input_adapter(std::forward<InputType>(i));
23682 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23683 return res ? result :
basic_json(value_t::discarded);
23688 template<
typename IteratorType>
23691 const bool strict =
true,
23692 const bool allow_exceptions =
true)
23696 auto ia = detail::input_adapter(std::move(first), std::move(last));
23697 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23698 return res ? result :
basic_json(value_t::discarded);
23703 template<
typename InputType>
23706 const bool strict =
true,
23707 const bool allow_exceptions =
true)
23711 auto ia = detail::input_adapter(std::forward<InputType>(i));
23712 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23713 return res ? result :
basic_json(value_t::discarded);
23718 template<
typename IteratorType>
23721 const bool strict =
true,
23722 const bool allow_exceptions =
true)
23726 auto ia = detail::input_adapter(std::move(first), std::move(last));
23727 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23728 return res ? result :
basic_json(value_t::discarded);
23731 template<
typename T>
23735 const
bool strict = true,
23736 const
bool allow_exceptions = true)
23738 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23744 const
bool strict = true,
23745 const
bool allow_exceptions = true)
23751 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23752 return res ? result :
basic_json(value_t::discarded);
23767 return ptr.get_unchecked(
this);
23770 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23774 return ptr.get_unchecked(
this);
23781 return ptr.get_unchecked(
this);
23784 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23788 return ptr.get_unchecked(
this);
23795 return ptr.get_checked(
this);
23798 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23802 return ptr.get_checked(
this);
23809 return ptr.get_checked(
this);
23812 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23816 return ptr.get_checked(
this);
23824 json_pointer::flatten(
"", *
this, result);
23832 return json_pointer::unflatten(*
this);
23850 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
23852 const auto get_op = [](
const std::string & op)
23856 return patch_operations::add;
23858 if (op ==
"remove")
23860 return patch_operations::remove;
23862 if (op ==
"replace")
23864 return patch_operations::replace;
23868 return patch_operations::move;
23872 return patch_operations::copy;
23876 return patch_operations::test;
23879 return patch_operations::invalid;
23894 if (top_pointer != ptr)
23896 result.
at(top_pointer);
23900 const auto last_path = ptr.
back();
23905 switch (parent.m_type)
23907 case value_t::null:
23908 case value_t::object:
23911 parent[last_path] = val;
23915 case value_t::array:
23917 if (last_path ==
"-")
23924 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
23938 case value_t::string:
23939 case value_t::boolean:
23940 case value_t::number_integer:
23941 case value_t::number_unsigned:
23942 case value_t::number_float:
23943 case value_t::binary:
23944 case value_t::discarded:
23951 const auto operation_remove = [
this, &result](
json_pointer & ptr)
23954 const auto last_path = ptr.
back();
23962 auto it = parent.
find(last_path);
23975 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
23986 for (
const auto& val : json_patch)
23989 const auto get_value = [&val](
const std::string & op,
23990 const std::string & member,
23994 auto it = val.
m_value.object->find(member);
23997 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24024 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24025 const auto path = get_value(op,
"path",
true).template get<std::string>();
24028 switch (get_op(op))
24030 case patch_operations::add:
24032 operation_add(ptr, get_value(
"add",
"value",
false));
24036 case patch_operations::remove:
24038 operation_remove(ptr);
24042 case patch_operations::replace:
24045 result.
at(ptr) = get_value(
"replace",
"value",
false);
24049 case patch_operations::move:
24051 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24061 operation_remove(from_ptr);
24062 operation_add(ptr, v);
24066 case patch_operations::copy:
24068 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24077 operation_add(ptr, v);
24081 case patch_operations::test:
24083 bool success =
false;
24088 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24104 case patch_operations::invalid:
24128 const std::string& path =
"")
24134 if (source == target)
24139 if (source.
type() != target.
type())
24144 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24149 switch (source.
type())
24151 case value_t::array:
24155 while (i < source.
size() && i < target.
size())
24158 auto temp_diff =
diff(source[i], target[i],
detail::concat(path,
'/', std::to_string(i)));
24159 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24168 while (i < source.
size())
24181 while (i < target.
size())
24187 {
"value", target[i]}
24195 case value_t::object:
24198 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
24203 if (target.
find(it.key()) != target.
end())
24206 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
24207 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24214 {
"op",
"remove"}, {
"path", path_key}
24220 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
24222 if (source.
find(it.key()) == source.
end())
24228 {
"op",
"add"}, {
"path", path_key},
24229 {
"value", it.value()}
24237 case value_t::null:
24238 case value_t::string:
24239 case value_t::boolean:
24240 case value_t::number_integer:
24241 case value_t::number_unsigned:
24242 case value_t::number_float:
24243 case value_t::binary:
24244 case value_t::discarded:
24250 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24277 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
24279 if (it.value().is_null())
24291 *
this = apply_patch;
24308inline namespace json_literals
24314inline nlohmann::
json operator "" _json(const
char* s,
std::
size_t n)
24316 return nlohmann::json::parse(s, s + n);
24324 return nlohmann::json::json_pointer(std::string(s, n));
24343 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
24345 return nlohmann::detail::hash(j);
24351struct less< ::nlohmann::detail::value_t>
24358 ::nlohmann::detail::value_t rhs)
const noexcept
24360#if JSON_HAS_THREE_WAY_COMPARISON
24361 return std::is_lt(lhs <=> rhs);
24363 return ::nlohmann::detail::operator<(lhs, rhs);
24369#ifndef JSON_HAS_CPP_20
24374inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
24375 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24376 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24385#if JSON_USE_GLOBAL_UDLS
24386 using nlohmann::literals::json_literals::operator
"" _json;
24387 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24402#if defined(__clang__)
24403 #pragma clang diagnostic pop
24408#undef JSON_INTERNAL_CATCH
24410#undef JSON_PRIVATE_UNLESS_TESTED
24411#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24412#undef NLOHMANN_BASIC_JSON_TPL
24413#undef JSON_EXPLICIT
24414#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24415#undef JSON_INLINE_VARIABLE
24416#undef JSON_NO_UNIQUE_ADDRESS
24417#undef JSON_DISABLE_ENUM_SERIALIZATION
24418#undef JSON_USE_GLOBAL_UDLS
24420#ifndef JSON_TEST_KEEP_MACROS
24423 #undef JSON_HAS_CPP_11
24424 #undef JSON_HAS_CPP_14
24425 #undef JSON_HAS_CPP_17
24426 #undef JSON_HAS_CPP_20
24427 #undef JSON_HAS_FILESYSTEM
24428 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24429 #undef JSON_HAS_THREE_WAY_COMPARISON
24430 #undef JSON_HAS_RANGES
24431 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24445#undef JSON_HEDLEY_ALWAYS_INLINE
24446#undef JSON_HEDLEY_ARM_VERSION
24447#undef JSON_HEDLEY_ARM_VERSION_CHECK
24448#undef JSON_HEDLEY_ARRAY_PARAM
24449#undef JSON_HEDLEY_ASSUME
24450#undef JSON_HEDLEY_BEGIN_C_DECLS
24451#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24452#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24453#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24454#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24455#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24456#undef JSON_HEDLEY_CLANG_HAS_FEATURE
24457#undef JSON_HEDLEY_CLANG_HAS_WARNING
24458#undef JSON_HEDLEY_COMPCERT_VERSION
24459#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24460#undef JSON_HEDLEY_CONCAT
24461#undef JSON_HEDLEY_CONCAT3
24462#undef JSON_HEDLEY_CONCAT3_EX
24463#undef JSON_HEDLEY_CONCAT_EX
24464#undef JSON_HEDLEY_CONST
24465#undef JSON_HEDLEY_CONSTEXPR
24466#undef JSON_HEDLEY_CONST_CAST
24467#undef JSON_HEDLEY_CPP_CAST
24468#undef JSON_HEDLEY_CRAY_VERSION
24469#undef JSON_HEDLEY_CRAY_VERSION_CHECK
24470#undef JSON_HEDLEY_C_DECL
24471#undef JSON_HEDLEY_DEPRECATED
24472#undef JSON_HEDLEY_DEPRECATED_FOR
24473#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24474#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24475#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24476#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24477#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24478#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24479#undef JSON_HEDLEY_DIAGNOSTIC_POP
24480#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24481#undef JSON_HEDLEY_DMC_VERSION
24482#undef JSON_HEDLEY_DMC_VERSION_CHECK
24483#undef JSON_HEDLEY_EMPTY_BASES
24484#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24485#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24486#undef JSON_HEDLEY_END_C_DECLS
24487#undef JSON_HEDLEY_FLAGS
24488#undef JSON_HEDLEY_FLAGS_CAST
24489#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24490#undef JSON_HEDLEY_GCC_HAS_BUILTIN
24491#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24492#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24493#undef JSON_HEDLEY_GCC_HAS_EXTENSION
24494#undef JSON_HEDLEY_GCC_HAS_FEATURE
24495#undef JSON_HEDLEY_GCC_HAS_WARNING
24496#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24497#undef JSON_HEDLEY_GCC_VERSION
24498#undef JSON_HEDLEY_GCC_VERSION_CHECK
24499#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24500#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24501#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24502#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24503#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24504#undef JSON_HEDLEY_GNUC_HAS_FEATURE
24505#undef JSON_HEDLEY_GNUC_HAS_WARNING
24506#undef JSON_HEDLEY_GNUC_VERSION
24507#undef JSON_HEDLEY_GNUC_VERSION_CHECK
24508#undef JSON_HEDLEY_HAS_ATTRIBUTE
24509#undef JSON_HEDLEY_HAS_BUILTIN
24510#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24511#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24512#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24513#undef JSON_HEDLEY_HAS_EXTENSION
24514#undef JSON_HEDLEY_HAS_FEATURE
24515#undef JSON_HEDLEY_HAS_WARNING
24516#undef JSON_HEDLEY_IAR_VERSION
24517#undef JSON_HEDLEY_IAR_VERSION_CHECK
24518#undef JSON_HEDLEY_IBM_VERSION
24519#undef JSON_HEDLEY_IBM_VERSION_CHECK
24520#undef JSON_HEDLEY_IMPORT
24521#undef JSON_HEDLEY_INLINE
24522#undef JSON_HEDLEY_INTEL_CL_VERSION
24523#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24524#undef JSON_HEDLEY_INTEL_VERSION
24525#undef JSON_HEDLEY_INTEL_VERSION_CHECK
24526#undef JSON_HEDLEY_IS_CONSTANT
24527#undef JSON_HEDLEY_IS_CONSTEXPR_
24528#undef JSON_HEDLEY_LIKELY
24529#undef JSON_HEDLEY_MALLOC
24530#undef JSON_HEDLEY_MCST_LCC_VERSION
24531#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24532#undef JSON_HEDLEY_MESSAGE
24533#undef JSON_HEDLEY_MSVC_VERSION
24534#undef JSON_HEDLEY_MSVC_VERSION_CHECK
24535#undef JSON_HEDLEY_NEVER_INLINE
24536#undef JSON_HEDLEY_NON_NULL
24537#undef JSON_HEDLEY_NO_ESCAPE
24538#undef JSON_HEDLEY_NO_RETURN
24539#undef JSON_HEDLEY_NO_THROW
24540#undef JSON_HEDLEY_NULL
24541#undef JSON_HEDLEY_PELLES_VERSION
24542#undef JSON_HEDLEY_PELLES_VERSION_CHECK
24543#undef JSON_HEDLEY_PGI_VERSION
24544#undef JSON_HEDLEY_PGI_VERSION_CHECK
24545#undef JSON_HEDLEY_PREDICT
24546#undef JSON_HEDLEY_PRINTF_FORMAT
24547#undef JSON_HEDLEY_PRIVATE
24548#undef JSON_HEDLEY_PUBLIC
24549#undef JSON_HEDLEY_PURE
24550#undef JSON_HEDLEY_REINTERPRET_CAST
24551#undef JSON_HEDLEY_REQUIRE
24552#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24553#undef JSON_HEDLEY_REQUIRE_MSG
24554#undef JSON_HEDLEY_RESTRICT
24555#undef JSON_HEDLEY_RETURNS_NON_NULL
24556#undef JSON_HEDLEY_SENTINEL
24557#undef JSON_HEDLEY_STATIC_ASSERT
24558#undef JSON_HEDLEY_STATIC_CAST
24559#undef JSON_HEDLEY_STRINGIFY
24560#undef JSON_HEDLEY_STRINGIFY_EX
24561#undef JSON_HEDLEY_SUNPRO_VERSION
24562#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24563#undef JSON_HEDLEY_TINYC_VERSION
24564#undef JSON_HEDLEY_TINYC_VERSION_CHECK
24565#undef JSON_HEDLEY_TI_ARMCL_VERSION
24566#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24567#undef JSON_HEDLEY_TI_CL2000_VERSION
24568#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24569#undef JSON_HEDLEY_TI_CL430_VERSION
24570#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24571#undef JSON_HEDLEY_TI_CL6X_VERSION
24572#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24573#undef JSON_HEDLEY_TI_CL7X_VERSION
24574#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24575#undef JSON_HEDLEY_TI_CLPRU_VERSION
24576#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24577#undef JSON_HEDLEY_TI_VERSION
24578#undef JSON_HEDLEY_TI_VERSION_CHECK
24579#undef JSON_HEDLEY_UNAVAILABLE
24580#undef JSON_HEDLEY_UNLIKELY
24581#undef JSON_HEDLEY_UNPREDICTABLE
24582#undef JSON_HEDLEY_UNREACHABLE
24583#undef JSON_HEDLEY_UNREACHABLE_RETURN
24584#undef JSON_HEDLEY_VERSION
24585#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24586#undef JSON_HEDLEY_VERSION_DECODE_MINOR
24587#undef JSON_HEDLEY_VERSION_DECODE_REVISION
24588#undef JSON_HEDLEY_VERSION_ENCODE
24589#undef JSON_HEDLEY_WARNING
24590#undef JSON_HEDLEY_WARN_UNUSED_RESULT
24591#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24592#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
reference operator+=(const typename object_t::value_type &val)
add an object to an object
const_iterator end() const noexcept
returns an iterator to one past the last element
reference operator+=(basic_json &&val)
add an object to an array
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
iterator end() noexcept
returns an iterator to one past the last element
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
void erase(const size_type idx)
remove element from a JSON array given an index
void push_back(const basic_json &val)
add an object to an array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
const_reference operator[](T *key) const
static allocator_type get_allocator()
returns the allocator associated with the container
const_reference back() const
access the last element
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
NumberFloatType number_float_t
a type for a number (floating-point)
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
void swap(object_t &other)
exchanges the values
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
void swap(binary_t &other)
exchanges the values
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
reference operator[](typename object_t::key_type key)
access specified object element
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
iter_impl< basic_json > iterator
an iterator for a basic_json container
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
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)
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
std::ptrdiff_t difference_type
a type to represent differences between iterators
size_type erase(KeyType &&key)
remove element from a JSON object given a key
basic_json(const JsonRef &ref)
const_iterator cbegin() const noexcept
returns a const iterator to the first element
json_value m_value
the value of the current element
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
constexpr bool is_string() const noexcept
return whether value is a string
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
const_iterator find(KeyType &&key) const
find an element in a JSON object
ReferenceType get_ref() const
get a reference value (implicit)
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
const binary_t & get_binary() const
get a binary value
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
AllocatorType< basic_json > allocator_type
the allocator type
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
void push_back(const typename object_t::value_type &val)
add an object to an object
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
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 &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
reference operator[](KeyType &&key)
access specified object element
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
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
JSONSerializer< T, SFINAE > json_serializer
reference at(size_type idx)
access specified array element with bounds checking
const_reference operator[](size_type idx) const
access specified array element
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
void swap(typename binary_t::container_type &other)
exchanges the values
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
iterator insert_iterator(const_iterator pos, Args &&... args)
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)
size_type max_size() const noexcept
returns the maximum possible number of elements
constexpr bool is_null() const noexcept
return whether value is null
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
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
size_type size() const noexcept
returns the number of elements
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
IteratorType erase(IteratorType pos)
remove element given an iterator
reference emplace_back(Args &&... args)
add an object to an array
ReferenceType get_ref()
get a reference value (implicit)
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
constexpr bool is_primitive() const noexcept
return whether type is primitive
StringType string_t
a type for a string
constexpr bool is_boolean() const noexcept
return whether value is a boolean
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
iterator find(KeyType &&key)
find an element in a JSON object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
const_reference front() const
access the first element
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
std::size_t size_type
a type to represent container sizes
constexpr bool is_array() const noexcept
return whether value is an array
NumberIntegerType number_integer_t
a type for a number (integer)
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)
copy assignment
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
basic_json unflatten() const
unflatten a previously flattened JSON value
basic_json flatten() const
return flattened JSON value
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
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
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
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
const_reference at(size_type idx) const
access specified array element with bounds checking
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)
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
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
ValueType & get_to(ValueType &v) const
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
constexpr bool is_binary() const noexcept
return whether value is a binary array
basic_json(basic_json &&other) noexcept
move constructor
reference operator[](size_type idx)
access specified array element
binary_t & get_binary()
get a binary value
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
void swap(string_t &other)
exchanges the values
value_type & reference
the type of an element reference
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
const_iterator cend() const noexcept
returns an iterator to one past the last element
constexpr bool is_number() const noexcept
return whether value is a number
reference operator[](T *key)
constexpr bool is_discarded() const noexcept
return whether value is discarded
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
void clear() noexcept
clears the contents
basic_json(const basic_json &other)
copy constructor
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
friend class ::nlohmann::detail::parser
const value_type & const_reference
the type of an element const reference
~basic_json() noexcept
destructor
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
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
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
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
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
void push_back(initializer_list_t init)
add an object to an object
reference back()
access the last element
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
constexpr bool is_structured() const noexcept
return whether type is structured
reference operator+=(initializer_list_t init)
add an object to an object
void push_back(basic_json &&val)
add an object to an array
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
reference front()
access the first element
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
bool empty() const noexcept
checks whether the container is empty.
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
const_iterator begin() const noexcept
returns an iterator to the first element
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
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 &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
basic_json(const value_t v)
create an empty value with a given type
const_reference at(KeyType &&key) const
access specified object element with bounds checking
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
void swap(array_t &other)
exchanges the values
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
BooleanType boolean_t
a type for a boolean
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
constexpr bool is_object() const noexcept
return whether value is an object
iterator begin() noexcept
returns an iterator to the first element
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
const_reference operator[](KeyType &&key) const
access specified object element
reference operator+=(const basic_json &val)
add an object to an array
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
reference at(KeyType &&key)
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
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
an internal type for a backed binary type
bool operator!=(const byte_container_with_subtype &rhs) const
byte_container_with_subtype() noexcept(noexcept(container_type()))
std::uint64_t subtype_type
bool operator==(const byte_container_with_subtype &rhs) const
BinaryType container_type
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
constexpr subtype_type subtype() const noexcept
return the binary subtype
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
void clear_subtype() noexcept
clears the binary subtype
deserialization of CBOR, MessagePack, and UBJSON values
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
binary_reader & operator=(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
binary_reader & operator=(binary_reader &&)=default
general exception of the basic_json class
const int id
the id of the exception
static std::string diagnostics(std::nullptr_t)
static std::string name(const std::string &ename, int id_)
const char * what() const noexcept override
returns the explanatory string
static std::string diagnostics(const BasicJsonType *leaf_element)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
iter_impl operator+(difference_type i) const
add to iterator
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
bool operator<(const iter_impl &other) const
comparison: smaller
bool operator<=(const iter_impl &other) const
comparison: less than or equal
iter_impl & operator-=(difference_type i)
subtract from iterator
iter_impl & operator--()
pre-decrement (–it)
const object_t::key_type & key() const
return the key of an object iterator
bool operator==(const IterImpl &other) const
comparison: equal
iter_impl operator++(int) &
post-increment (it++)
iter_impl & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
pointer operator->() const
dereference the iterator
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
difference_type operator-(const iter_impl &other) const
return difference
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
reference value() const
return the value of an iterator
bool operator>(const iter_impl &other) const
comparison: greater than
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
iter_impl & operator++()
pre-increment (++it)
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl operator-(difference_type i) const
subtract from iterator
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
bool operator!=(const IterImpl &other) const
comparison: not equal
iter_impl operator--(int) &
post-decrement (it–)
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
void set_end() noexcept
set the iterator past the last value
iteration_proxy_value operator++(int) &
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
std::ptrdiff_t difference_type
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
iteration_proxy_value()=default
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
const string_type & key() const
return key of the iterator
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
std::input_iterator_tag iterator_category
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
proxy class for the items() function
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
iteration_proxy & operator=(iteration_proxy const &)=default
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
json_ref(value_type &&value)
value_type const & operator*() const
value_type const * operator->() const
json_ref(std::initializer_list< json_ref > init)
json_ref(Args &&... args)
value_type moved_or_copied() const
a template for a reverse iterator class
json_reverse_iterator operator++(int) &
post-increment (it++)
json_reverse_iterator operator--(int) &
post-decrement (it–)
json_reverse_iterator & operator++()
pre-increment (++it)
std::ptrdiff_t difference_type
json_reverse_iterator & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
difference_type operator-(const json_reverse_iterator &other) const
return difference
typename Base::reference reference
the reference type for the pointed-to element
reference value() const
return the value of an iterator
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
json_reverse_iterator & operator--()
pre-decrement (–it)
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator operator+(difference_type i) const
add to iterator
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool start_object(std::size_t=static_cast< std::size_t >(-1))
bool number_integer(number_integer_t)
bool start_array(std::size_t=static_cast< std::size_t >(-1))
bool number_unsigned(number_unsigned_t)
typename BasicJsonType::binary_t binary_t
bool number_float(number_float_t, const string_t &)
bool parse_error(std::size_t, const std::string &, const detail::exception &)
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::string_t string_t
bool parse_error(std::size_t, const std::string &, const Exception &ex)
typename BasicJsonType::string_t string_t
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
bool string(string_t &val)
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::binary_t binary_t
bool start_object(std::size_t len)
bool start_array(std::size_t len)
typename BasicJsonType::number_integer_t number_integer_t
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
~json_sax_dom_callback_parser()=default
typename BasicJsonType::parse_event_t parse_event_t
typename BasicJsonType::parser_callback_t parser_callback_t
bool number_unsigned(number_unsigned_t val)
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
typename BasicJsonType::number_float_t number_float_t
bool number_integer(number_integer_t val)
bool binary(binary_t &val)
SAX implementation to create a JSON value from SAX events.
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool string(string_t &val)
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
bool parse_error(std::size_t, const std::string &, const Exception &ex)
~json_sax_dom_parser()=default
typename BasicJsonType::string_t string_t
bool start_object(std::size_t len)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_unsigned(number_unsigned_t val)
bool number_integer(number_integer_t val)
typename BasicJsonType::number_integer_t number_integer_t
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
json_sax_dom_parser(json_sax_dom_parser &&)=default
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::number_float_t number_float_t
bool start_array(std::size_t len)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
bool skip_bom()
skip the UTF-8 byte order mark
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
std::string get_token_string() const
constexpr number_integer_t get_number_integer() const noexcept
return integer value
constexpr position_t get_position() const noexcept
return position of last read token
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
typename lexer_base< BasicJsonType >::token_type token_type
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
exception indicating a parse error
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
const std::size_t byte
byte index of the parse error
std::array< char, 512 > string_buffer
string buffer
std::size_t bytes_after_last_accept
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
std::size_t undumped_chars
const char thousands_sep
the locale's thousand separator character
const char decimal_point
the locale's decimal point character
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
string_t indent_string
the indentation string
const std::lconv * loc
the locale
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
const char indent_char
the indentation character
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
typename string_t_helper< RefStringType >::type string_t
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
json_pointer(const string_t &s="")
create JSON pointer
bool empty() const noexcept
return whether pointer points to the root document
friend bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for equality
void pop_back()
remove last reference token
string_t to_string() const
return a string representation of the JSON pointer
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
json_pointer parent_pointer() const
returns the parent of this JSON pointer
friend bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for inequality
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
friend class json_pointer
const string_t & back() const
return last reference token
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
friend bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointer for less-than
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_INLINE_VARIABLE
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_PRIVATE_UNLESS_TESTED
#define NLOHMANN_JSON_VERSION_PATCH
#define JSON_HEDLEY_LIKELY(expr)
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
#define JSON_HEDLEY_RETURNS_NON_NULL
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
#define NLOHMANN_JSON_NAMESPACE_END
#define JSON_NO_UNIQUE_ADDRESS
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
#define NLOHMANN_JSON_NAMESPACE_BEGIN
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
constexpr bool is_transparent()
constexpr bool is_c_string()
detail namespace with internal helper functions
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
static void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
typename make_void< Ts... >::type void_t
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
OutStringType concat(Args &&... args)
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
decltype(T::to_json(std::declval< Args >()...)) to_json_function
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
decltype(std::declval< T >().template get< U >()) get_template_function
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
typename T::pointer pointer_t
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
integer_sequence< size_t, Ints... > index_sequence
typename utility_internal::Gen< T, N >::type make_integer_sequence
typename T::value_type value_type_t
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
T conditional_static_cast(U value)
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
typename std::enable_if< B, T >::type enable_if_t
typename T::mapped_type mapped_type_t
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
cbor_tag_handler_t
how to treat CBOR tags
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(T::from_json(std::declval< Args >()...)) from_json_function
make_integer_sequence< size_t, N > make_index_sequence
std::integral_constant< bool, Value > bool_constant
void concat_into(OutStringType &)
typename T::key_type key_type_t
constexpr bool value_in_range_of(T val)
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
static bool little_endianness(int num=1) noexcept
determine system byte order
typename detector< nonesuch, void, Op, Args... >::type detected_t
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
typename T::iterator_category iterator_category_t
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
void to_json(BasicJsonType &j, T b) noexcept
make_index_sequence< sizeof...(Ts)> index_sequence_for
typename T::difference_type difference_type_t
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
typename T::is_transparent detect_is_transparent
typename T::reference reference_t
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
typename T::key_compare detect_key_compare
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
void int_to_string(string_type &target, std::size_t value)
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
is_detected< string_can_append, StringType, Arg > detect_string_can_append
bool operator<(const TCPEndPoint &ep_a, const TCPEndPoint &ep_b)
std::string str(TimeType value=SystemClock::now< TimeType >())
Returns the provided time (or current time if omitted) as a human-readable string.
type
Generic JSON types used in JWTs.
decoded_jwt< json_traits > decode(const typename json_traits::string_type &token, Decode decode)
builder< json_traits > create()
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) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
namespace for Niels Lohmann
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
typename BasicJsonType::object_t object_t
typename BasicJsonType::default_object_comparator_t object_comparator_t
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
primitive_iterator_t primitive_iterator
generic iterator for all other types
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
std::numeric_limits< RealIntegerType > RealLimits
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
typename BasicJsonType::object_t object_t
static constexpr auto value
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
typename BasicJsonType::object_t object_t
ConstructibleStringType laundered_type
static constexpr auto value
static constexpr bool value
static one test(decltype(&C::capacity))
static constexpr bool value
ptrdiff_t difference_type
std::random_access_iterator_tag iterator_category
typename It::iterator_category iterator_category
typename It::difference_type difference_type
typename It::value_type value_type
typename It::reference reference
typename It::pointer pointer
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
struct to capture the start position of the current token
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t lines_read
the number of lines read
std::size_t chars_read_total
the total number of characters read
static JSON_INLINE_VARIABLE constexpr T value
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
static constexpr bool test(T val)
static constexpr bool test(T)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
std::vector< std::pair< const Key, T >, Allocator > Container
std::pair< iterator, bool > insert(value_type &&value)
typename Container::value_type value_type
std::equal_to< Key > key_compare
iterator erase(iterator pos)
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
T & operator[](KeyType &&key)
typename Container::iterator iterator
const T & at(KeyType &&key) const
const T & operator[](KeyType &&key) const
iterator find(const key_type &key)
iterator erase(iterator first, iterator last)
const T & at(const key_type &key) const
const_iterator find(const key_type &key) const
T & operator[](const key_type &key)
size_type erase(KeyType &&key)
typename Container::size_type size_type
ordered_map() noexcept(noexcept(Container()))
void insert(InputIt first, InputIt last)
size_type count(const key_type &key) const
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
size_type erase(const key_type &key)
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
std::pair< iterator, bool > insert(const value_type &value)
size_type count(KeyType &&key) const
ordered_map(It first, It last, const Allocator &alloc=Allocator())
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
const T & operator[](const key_type &key) const
iterator find(KeyType &&key)
T & at(const key_type &key)
typename Container::const_iterator const_iterator
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values