18 #ifndef INCLUDE_NLOHMANN_JSON_HPP_
19 #define INCLUDE_NLOHMANN_JSON_HPP_
24 #include <initializer_list>
60 #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
63 #warning "Already included a different version of the library!"
68 #define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
69 #define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum)
70 #define NLOHMANN_JSON_VERSION_PATCH 3 // NOLINT(modernize-macro-to-enum)
72 #ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76 #ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
77 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
81 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
83 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
86 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
87 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
89 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
92 #ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
93 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
97 #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
98 #define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
99 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
101 #define NLOHMANN_JSON_ABI_TAGS \
102 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
103 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
104 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
107 #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
108 _v ## major ## _ ## minor ## _ ## patch
109 #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
110 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
112 #if NLOHMANN_JSON_NAMESPACE_NO_VERSION
113 #define NLOHMANN_JSON_NAMESPACE_VERSION
115 #define NLOHMANN_JSON_NAMESPACE_VERSION \
116 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
117 NLOHMANN_JSON_VERSION_MINOR, \
118 NLOHMANN_JSON_VERSION_PATCH)
122 #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
123 #define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
124 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
126 #ifndef NLOHMANN_JSON_NAMESPACE
127 #define NLOHMANN_JSON_NAMESPACE \
128 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
129 NLOHMANN_JSON_ABI_TAGS, \
130 NLOHMANN_JSON_NAMESPACE_VERSION)
133 #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
134 #define NLOHMANN_JSON_NAMESPACE_BEGIN \
137 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
138 NLOHMANN_JSON_ABI_TAGS, \
139 NLOHMANN_JSON_NAMESPACE_VERSION) \
143 #ifndef NLOHMANN_JSON_NAMESPACE_END
144 #define NLOHMANN_JSON_NAMESPACE_END \
146 } // namespace nlohmann
162 #include <forward_list>
167 #include <type_traits>
168 #include <unordered_map>
231 #include <type_traits>
276 template<
class Default,
278 template<
class...>
class Op,
286 template<
class Default,
template<
class...>
class Op,
class... Args>
293 template<
template<
class...>
class Op,
class... Args>
296 template<
template<
class...>
class Op,
class... Args>
299 template<
template<
class...>
class Op,
class... Args>
302 template<
class Default,
template<
class...>
class Op,
class... Args>
305 template<
class Default,
template<
class...>
class Op,
class... Args>
308 template<
class Expected,
template<
class...>
class Op,
class... Args>
311 template<
class To,
template<
class...>
class Op,
class... Args>
334 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
335 #if defined(JSON_HEDLEY_VERSION)
336 #undef JSON_HEDLEY_VERSION
338 #define JSON_HEDLEY_VERSION 15
340 #if defined(JSON_HEDLEY_STRINGIFY_EX)
341 #undef JSON_HEDLEY_STRINGIFY_EX
343 #define JSON_HEDLEY_STRINGIFY_EX(x) #x
345 #if defined(JSON_HEDLEY_STRINGIFY)
346 #undef JSON_HEDLEY_STRINGIFY
348 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
350 #if defined(JSON_HEDLEY_CONCAT_EX)
351 #undef JSON_HEDLEY_CONCAT_EX
353 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b
355 #if defined(JSON_HEDLEY_CONCAT)
356 #undef JSON_HEDLEY_CONCAT
358 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
360 #if defined(JSON_HEDLEY_CONCAT3_EX)
361 #undef JSON_HEDLEY_CONCAT3_EX
363 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
365 #if defined(JSON_HEDLEY_CONCAT3)
366 #undef JSON_HEDLEY_CONCAT3
368 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
370 #if defined(JSON_HEDLEY_VERSION_ENCODE)
371 #undef JSON_HEDLEY_VERSION_ENCODE
373 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
375 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
376 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
378 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
380 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
381 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
383 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
385 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
386 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
388 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
390 #if defined(JSON_HEDLEY_GNUC_VERSION)
391 #undef JSON_HEDLEY_GNUC_VERSION
393 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
394 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
395 #elif defined(__GNUC__)
396 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
399 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
400 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
402 #if defined(JSON_HEDLEY_GNUC_VERSION)
403 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
405 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
408 #if defined(JSON_HEDLEY_MSVC_VERSION)
409 #undef JSON_HEDLEY_MSVC_VERSION
411 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
412 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
413 #elif defined(_MSC_FULL_VER) && !defined(__ICL)
414 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
415 #elif defined(_MSC_VER) && !defined(__ICL)
416 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
419 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
420 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
422 #if !defined(JSON_HEDLEY_MSVC_VERSION)
423 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
424 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
425 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
426 #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
427 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
429 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
432 #if defined(JSON_HEDLEY_INTEL_VERSION)
433 #undef JSON_HEDLEY_INTEL_VERSION
435 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
436 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
437 #elif defined(__INTEL_COMPILER) && !defined(__ICL)
438 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
441 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
442 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
444 #if defined(JSON_HEDLEY_INTEL_VERSION)
445 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
447 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
450 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
451 #undef JSON_HEDLEY_INTEL_CL_VERSION
453 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
454 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
457 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
458 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
460 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
461 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
463 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
466 #if defined(JSON_HEDLEY_PGI_VERSION)
467 #undef JSON_HEDLEY_PGI_VERSION
469 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
470 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
473 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
474 #undef JSON_HEDLEY_PGI_VERSION_CHECK
476 #if defined(JSON_HEDLEY_PGI_VERSION)
477 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
479 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
482 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
483 #undef JSON_HEDLEY_SUNPRO_VERSION
485 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
486 #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)
487 #elif defined(__SUNPRO_C)
488 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
489 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
490 #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)
491 #elif defined(__SUNPRO_CC)
492 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
495 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
496 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
498 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
499 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
501 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
504 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
505 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
507 #if defined(__EMSCRIPTEN__)
508 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
511 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
512 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
514 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
515 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
517 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
520 #if defined(JSON_HEDLEY_ARM_VERSION)
521 #undef JSON_HEDLEY_ARM_VERSION
523 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
524 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
525 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
526 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
529 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
530 #undef JSON_HEDLEY_ARM_VERSION_CHECK
532 #if defined(JSON_HEDLEY_ARM_VERSION)
533 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
535 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
538 #if defined(JSON_HEDLEY_IBM_VERSION)
539 #undef JSON_HEDLEY_IBM_VERSION
541 #if defined(__ibmxl__)
542 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
543 #elif defined(__xlC__) && defined(__xlC_ver__)
544 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
545 #elif defined(__xlC__)
546 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
549 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
550 #undef JSON_HEDLEY_IBM_VERSION_CHECK
552 #if defined(JSON_HEDLEY_IBM_VERSION)
553 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
555 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
558 #if defined(JSON_HEDLEY_TI_VERSION)
559 #undef JSON_HEDLEY_TI_VERSION
562 defined(__TI_COMPILER_VERSION__) && \
564 defined(__TMS470__) || defined(__TI_ARM__) || \
565 defined(__MSP430__) || \
566 defined(__TMS320C2000__) \
568 #if (__TI_COMPILER_VERSION__ >= 16000000)
569 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
573 #if defined(JSON_HEDLEY_TI_VERSION_CHECK)
574 #undef JSON_HEDLEY_TI_VERSION_CHECK
576 #if defined(JSON_HEDLEY_TI_VERSION)
577 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
579 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
582 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
583 #undef JSON_HEDLEY_TI_CL2000_VERSION
585 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
586 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
589 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
590 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
592 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
593 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
595 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
598 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
599 #undef JSON_HEDLEY_TI_CL430_VERSION
601 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
602 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
605 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
606 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
608 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
609 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
611 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
614 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
615 #undef JSON_HEDLEY_TI_ARMCL_VERSION
617 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
618 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
621 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
622 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
624 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
625 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
627 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
630 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
631 #undef JSON_HEDLEY_TI_CL6X_VERSION
633 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
634 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
637 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
638 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
640 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
641 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
643 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
646 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
647 #undef JSON_HEDLEY_TI_CL7X_VERSION
649 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
650 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
653 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
654 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
656 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
657 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
659 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
662 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
663 #undef JSON_HEDLEY_TI_CLPRU_VERSION
665 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
666 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
669 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
670 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
672 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
673 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
675 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
678 #if defined(JSON_HEDLEY_CRAY_VERSION)
679 #undef JSON_HEDLEY_CRAY_VERSION
682 #if defined(_RELEASE_PATCHLEVEL)
683 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
685 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
689 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
690 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
692 #if defined(JSON_HEDLEY_CRAY_VERSION)
693 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
695 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
698 #if defined(JSON_HEDLEY_IAR_VERSION)
699 #undef JSON_HEDLEY_IAR_VERSION
701 #if defined(__IAR_SYSTEMS_ICC__)
703 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
705 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
709 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
710 #undef JSON_HEDLEY_IAR_VERSION_CHECK
712 #if defined(JSON_HEDLEY_IAR_VERSION)
713 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
715 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
718 #if defined(JSON_HEDLEY_TINYC_VERSION)
719 #undef JSON_HEDLEY_TINYC_VERSION
721 #if defined(__TINYC__)
722 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
725 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
726 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
728 #if defined(JSON_HEDLEY_TINYC_VERSION)
729 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
731 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
734 #if defined(JSON_HEDLEY_DMC_VERSION)
735 #undef JSON_HEDLEY_DMC_VERSION
738 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
741 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
742 #undef JSON_HEDLEY_DMC_VERSION_CHECK
744 #if defined(JSON_HEDLEY_DMC_VERSION)
745 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
747 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
750 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
751 #undef JSON_HEDLEY_COMPCERT_VERSION
753 #if defined(__COMPCERT_VERSION__)
754 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
757 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
758 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
760 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
761 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
763 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
766 #if defined(JSON_HEDLEY_PELLES_VERSION)
767 #undef JSON_HEDLEY_PELLES_VERSION
769 #if defined(__POCC__)
770 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
773 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
774 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
776 #if defined(JSON_HEDLEY_PELLES_VERSION)
777 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
779 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
782 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
783 #undef JSON_HEDLEY_MCST_LCC_VERSION
785 #if defined(__LCC__) && defined(__LCC_MINOR__)
786 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
789 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
790 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
792 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
793 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
795 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
798 #if defined(JSON_HEDLEY_GCC_VERSION)
799 #undef JSON_HEDLEY_GCC_VERSION
802 defined(JSON_HEDLEY_GNUC_VERSION) && \
803 !defined(__clang__) && \
804 !defined(JSON_HEDLEY_INTEL_VERSION) && \
805 !defined(JSON_HEDLEY_PGI_VERSION) && \
806 !defined(JSON_HEDLEY_ARM_VERSION) && \
807 !defined(JSON_HEDLEY_CRAY_VERSION) && \
808 !defined(JSON_HEDLEY_TI_VERSION) && \
809 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
810 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
811 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
812 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
813 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
814 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
815 !defined(__COMPCERT__) && \
816 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
817 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
820 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
821 #undef JSON_HEDLEY_GCC_VERSION_CHECK
823 #if defined(JSON_HEDLEY_GCC_VERSION)
824 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
826 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
829 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
830 #undef JSON_HEDLEY_HAS_ATTRIBUTE
833 defined(__has_attribute) && \
835 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
837 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
839 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
842 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
843 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
845 #if defined(__has_attribute)
846 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
848 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
851 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
852 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
854 #if defined(__has_attribute)
855 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
857 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
860 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
861 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
864 defined(__has_cpp_attribute) && \
865 defined(__cplusplus) && \
866 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
867 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
869 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
872 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
873 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
875 #if !defined(__cplusplus) || !defined(__has_cpp_attribute)
876 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
878 !defined(JSON_HEDLEY_PGI_VERSION) && \
879 !defined(JSON_HEDLEY_IAR_VERSION) && \
880 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
881 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
882 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
884 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
887 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
888 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
890 #if defined(__has_cpp_attribute) && defined(__cplusplus)
891 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
893 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
896 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
897 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
899 #if defined(__has_cpp_attribute) && defined(__cplusplus)
900 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
902 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
905 #if defined(JSON_HEDLEY_HAS_BUILTIN)
906 #undef JSON_HEDLEY_HAS_BUILTIN
908 #if defined(__has_builtin)
909 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
911 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
914 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
915 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
917 #if defined(__has_builtin)
918 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
920 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
923 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
924 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
926 #if defined(__has_builtin)
927 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
929 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
932 #if defined(JSON_HEDLEY_HAS_FEATURE)
933 #undef JSON_HEDLEY_HAS_FEATURE
935 #if defined(__has_feature)
936 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
938 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
941 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
942 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
944 #if defined(__has_feature)
945 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
947 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
950 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
951 #undef JSON_HEDLEY_GCC_HAS_FEATURE
953 #if defined(__has_feature)
954 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
956 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
959 #if defined(JSON_HEDLEY_HAS_EXTENSION)
960 #undef JSON_HEDLEY_HAS_EXTENSION
962 #if defined(__has_extension)
963 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
965 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
968 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
969 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
971 #if defined(__has_extension)
972 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
974 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
977 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
978 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
980 #if defined(__has_extension)
981 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
983 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
986 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
987 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
989 #if defined(__has_declspec_attribute)
990 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
992 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
995 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
996 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
998 #if defined(__has_declspec_attribute)
999 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1001 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1004 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1005 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1007 #if defined(__has_declspec_attribute)
1008 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1010 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1013 #if defined(JSON_HEDLEY_HAS_WARNING)
1014 #undef JSON_HEDLEY_HAS_WARNING
1016 #if defined(__has_warning)
1017 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1019 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1022 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1023 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1025 #if defined(__has_warning)
1026 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1028 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1031 #if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1032 #undef JSON_HEDLEY_GCC_HAS_WARNING
1034 #if defined(__has_warning)
1035 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1037 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1041 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1042 defined(__clang__) || \
1043 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1044 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1045 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1046 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1047 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1048 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1049 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1050 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1051 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1052 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1053 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1054 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1055 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1056 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1057 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1058 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1059 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1060 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1061 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1063 #define JSON_HEDLEY_PRAGMA(value)
1066 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1067 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1069 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1070 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1072 #if defined(__clang__)
1073 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1074 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1075 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1076 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1077 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1078 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1079 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1080 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1082 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1083 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1084 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1085 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1086 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1090 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1091 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1092 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1094 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1095 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1096 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1097 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1098 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1099 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1100 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1102 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1103 #define JSON_HEDLEY_DIAGNOSTIC_POP
1108 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1109 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1111 #if defined(__cplusplus)
1112 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1113 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1114 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1115 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1116 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1117 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1118 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1119 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1121 JSON_HEDLEY_DIAGNOSTIC_POP
1123 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1124 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1125 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1126 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1128 JSON_HEDLEY_DIAGNOSTIC_POP
1131 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1132 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1133 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1135 JSON_HEDLEY_DIAGNOSTIC_POP
1139 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1140 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1143 #if defined(JSON_HEDLEY_CONST_CAST)
1144 #undef JSON_HEDLEY_CONST_CAST
1146 #if defined(__cplusplus)
1147 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1149 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1150 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1151 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1152 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1153 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1154 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1156 JSON_HEDLEY_DIAGNOSTIC_POP \
1159 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1162 #if defined(JSON_HEDLEY_REINTERPRET_CAST)
1163 #undef JSON_HEDLEY_REINTERPRET_CAST
1165 #if defined(__cplusplus)
1166 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1168 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1171 #if defined(JSON_HEDLEY_STATIC_CAST)
1172 #undef JSON_HEDLEY_STATIC_CAST
1174 #if defined(__cplusplus)
1175 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1177 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1180 #if defined(JSON_HEDLEY_CPP_CAST)
1181 #undef JSON_HEDLEY_CPP_CAST
1183 #if defined(__cplusplus)
1184 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1185 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1186 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1187 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1189 JSON_HEDLEY_DIAGNOSTIC_POP
1190 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1191 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1192 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1193 _Pragma("diag_suppress=Pe137") \
1194 JSON_HEDLEY_DIAGNOSTIC_POP
1196 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1199 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1202 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1203 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1205 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1206 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1207 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1208 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1209 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1211 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1213 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1215 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1217 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1219 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1222 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1223 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1225 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1227 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1229 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1231 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1232 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1233 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1234 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1235 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1236 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1238 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1239 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1240 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1241 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1243 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1246 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1247 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1249 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1251 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1253 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1255 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1256 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1257 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1259 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1260 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1262 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1263 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1264 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1265 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1267 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1269 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1271 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1274 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1277 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1278 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1280 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1282 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1284 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1286 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1287 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1288 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1289 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1290 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1291 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1292 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1293 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1294 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1295 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1297 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1298 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1299 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1301 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1303 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1309 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1310 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1312 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1314 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1316 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1319 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1322 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1323 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1325 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1327 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1329 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1331 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1332 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1334 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1337 #if defined(JSON_HEDLEY_DEPRECATED)
1338 #undef JSON_HEDLEY_DEPRECATED
1340 #if defined(JSON_HEDLEY_DEPRECATED_FOR)
1341 #undef JSON_HEDLEY_DEPRECATED_FOR
1344 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1345 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1346 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1347 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1349 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1350 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1351 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1352 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1353 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1354 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1355 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1356 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1357 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1358 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1359 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1360 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1361 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1362 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1363 #elif defined(__cplusplus) && (__cplusplus >= 201402L)
1364 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1365 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1367 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1368 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1369 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1370 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1371 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1372 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1373 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1374 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1375 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1376 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1377 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1378 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1379 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1380 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1381 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1382 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1383 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1384 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1386 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1387 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1388 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1389 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1390 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1391 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1392 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1393 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1395 #define JSON_HEDLEY_DEPRECATED(since)
1396 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1399 #if defined(JSON_HEDLEY_UNAVAILABLE)
1400 #undef JSON_HEDLEY_UNAVAILABLE
1403 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1404 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1405 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1406 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1407 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1409 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1412 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1413 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1415 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1416 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1419 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1420 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1421 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1422 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1423 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1424 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1425 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1426 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1427 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1428 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1429 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1430 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1431 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1432 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1433 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1434 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1435 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1436 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1437 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1438 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1439 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1440 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1441 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1442 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1443 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1444 #elif defined(_Check_return_)
1445 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1446 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1449 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1452 #if defined(JSON_HEDLEY_SENTINEL)
1453 #undef JSON_HEDLEY_SENTINEL
1456 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1457 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1458 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1459 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1460 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1461 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1463 #define JSON_HEDLEY_SENTINEL(position)
1466 #if defined(JSON_HEDLEY_NO_RETURN)
1467 #undef JSON_HEDLEY_NO_RETURN
1469 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1470 #define JSON_HEDLEY_NO_RETURN __noreturn
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1474 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1475 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1476 #define JSON_HEDLEY_NO_RETURN _Noreturn
1477 #elif defined(__cplusplus) && (__cplusplus >= 201103L)
1478 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1480 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1481 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1482 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1483 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1484 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1485 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1486 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1487 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1488 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1489 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1490 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1491 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1492 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1493 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1494 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1495 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1496 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1497 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1498 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1499 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1501 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1502 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1503 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1504 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1505 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1506 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1507 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1508 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1509 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1511 #define JSON_HEDLEY_NO_RETURN
1514 #if defined(JSON_HEDLEY_NO_ESCAPE)
1515 #undef JSON_HEDLEY_NO_ESCAPE
1517 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1518 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1520 #define JSON_HEDLEY_NO_ESCAPE
1523 #if defined(JSON_HEDLEY_UNREACHABLE)
1524 #undef JSON_HEDLEY_UNREACHABLE
1526 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1527 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1529 #if defined(JSON_HEDLEY_ASSUME)
1530 #undef JSON_HEDLEY_ASSUME
1533 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1534 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1535 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1536 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1537 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1538 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1540 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1541 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1542 #if defined(__cplusplus)
1543 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1545 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1549 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1550 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1551 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1552 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1553 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1554 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1555 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1556 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1557 #elif defined(JSON_HEDLEY_ASSUME)
1558 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1560 #if !defined(JSON_HEDLEY_ASSUME)
1561 #if defined(JSON_HEDLEY_UNREACHABLE)
1562 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1564 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1567 #if defined(JSON_HEDLEY_UNREACHABLE)
1569 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1570 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1571 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1573 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1576 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1578 #if !defined(JSON_HEDLEY_UNREACHABLE)
1579 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1583 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1584 #pragma clang diagnostic ignored "-Wpedantic"
1586 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1587 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1589 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1590 #if defined(__clang__)
1591 #pragma clang diagnostic ignored "-Wvariadic-macros"
1592 #elif defined(JSON_HEDLEY_GCC_VERSION)
1593 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1596 #if defined(JSON_HEDLEY_NON_NULL)
1597 #undef JSON_HEDLEY_NON_NULL
1600 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1601 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1602 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1603 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1604 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1606 #define JSON_HEDLEY_NON_NULL(...)
1610 #if defined(JSON_HEDLEY_PRINTF_FORMAT)
1611 #undef JSON_HEDLEY_PRINTF_FORMAT
1613 #if 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__(ms_printf, string_idx, first_to_check)))
1615 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1616 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1618 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1619 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1621 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1622 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1623 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1624 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1625 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1626 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1627 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1628 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1629 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1630 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1631 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1632 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1633 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1634 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1635 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1636 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1637 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1639 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1642 #if defined(JSON_HEDLEY_CONSTEXPR)
1643 #undef JSON_HEDLEY_CONSTEXPR
1645 #if defined(__cplusplus)
1646 #if __cplusplus >= 201103L
1647 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1650 #if !defined(JSON_HEDLEY_CONSTEXPR)
1651 #define JSON_HEDLEY_CONSTEXPR
1654 #if defined(JSON_HEDLEY_PREDICT)
1655 #undef JSON_HEDLEY_PREDICT
1657 #if defined(JSON_HEDLEY_LIKELY)
1658 #undef JSON_HEDLEY_LIKELY
1660 #if defined(JSON_HEDLEY_UNLIKELY)
1661 #undef JSON_HEDLEY_UNLIKELY
1663 #if defined(JSON_HEDLEY_UNPREDICTABLE)
1664 #undef JSON_HEDLEY_UNPREDICTABLE
1666 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1667 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1670 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1671 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1672 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1673 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1674 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1675 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1676 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1677 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1679 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1680 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1681 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1682 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1683 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1684 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1685 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1686 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1687 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1688 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1689 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1690 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1691 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1692 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1693 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1694 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1695 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1696 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1697 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1699 double hedley_probability_ = (probability); \
1700 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1702 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1704 double hedley_probability_ = (probability); \
1705 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1707 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1708 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1710 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1711 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1712 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1713 # define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1714 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1716 #if !defined(JSON_HEDLEY_UNPREDICTABLE)
1717 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1720 #if defined(JSON_HEDLEY_MALLOC)
1721 #undef JSON_HEDLEY_MALLOC
1724 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1725 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1726 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1727 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1728 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1729 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1730 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1731 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1732 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1733 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1734 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1735 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1736 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1737 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1738 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1739 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1740 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1741 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1742 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1743 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1744 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1746 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1747 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1748 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1750 #define JSON_HEDLEY_MALLOC
1753 #if defined(JSON_HEDLEY_PURE)
1754 #undef JSON_HEDLEY_PURE
1757 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1758 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1759 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1760 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1761 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1762 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1763 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1764 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1765 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1766 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1767 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1768 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1769 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1770 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1771 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1772 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1773 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1774 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1775 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1776 # define JSON_HEDLEY_PURE __attribute__((__pure__))
1777 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1778 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1779 #elif defined(__cplusplus) && \
1781 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1785 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1787 # define JSON_HEDLEY_PURE
1790 #if defined(JSON_HEDLEY_CONST)
1791 #undef JSON_HEDLEY_CONST
1794 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1795 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1796 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1797 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1798 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1799 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1800 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1801 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1802 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1803 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1804 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1805 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1806 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1807 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1808 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1809 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1810 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1811 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1812 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1813 #define JSON_HEDLEY_CONST __attribute__((__const__))
1815 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1816 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1818 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1821 #if defined(JSON_HEDLEY_RESTRICT)
1822 #undef JSON_HEDLEY_RESTRICT
1824 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1825 #define JSON_HEDLEY_RESTRICT restrict
1827 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1828 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1829 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1830 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1831 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1832 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1833 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1834 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1835 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1836 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1837 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1838 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1839 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1840 defined(__clang__) || \
1841 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1842 #define JSON_HEDLEY_RESTRICT __restrict
1843 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1844 #define JSON_HEDLEY_RESTRICT _Restrict
1846 #define JSON_HEDLEY_RESTRICT
1849 #if defined(JSON_HEDLEY_INLINE)
1850 #undef JSON_HEDLEY_INLINE
1853 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1854 (defined(__cplusplus) && (__cplusplus >= 199711L))
1855 #define JSON_HEDLEY_INLINE inline
1857 defined(JSON_HEDLEY_GCC_VERSION) || \
1858 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1859 #define JSON_HEDLEY_INLINE __inline__
1861 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1862 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1863 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1864 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1865 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1866 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1867 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1868 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1869 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1870 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1871 #define JSON_HEDLEY_INLINE __inline
1873 #define JSON_HEDLEY_INLINE
1876 #if defined(JSON_HEDLEY_ALWAYS_INLINE)
1877 #undef JSON_HEDLEY_ALWAYS_INLINE
1880 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1881 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1882 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1883 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1884 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1885 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1886 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1887 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1888 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1889 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1890 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1891 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1892 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1893 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1894 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1895 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1896 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1897 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1898 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1899 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1901 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1902 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1903 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1904 #elif defined(__cplusplus) && \
1906 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1907 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1908 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1909 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1910 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1911 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1913 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1914 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1915 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1917 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1920 #if defined(JSON_HEDLEY_NEVER_INLINE)
1921 #undef JSON_HEDLEY_NEVER_INLINE
1924 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1925 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1926 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1927 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1928 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1929 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1930 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1931 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1932 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1933 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1934 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1935 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1936 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1937 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1938 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1939 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1940 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1941 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1942 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1943 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1945 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1946 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1947 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1948 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1949 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1950 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1951 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1952 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1953 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1954 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1955 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1956 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1957 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1959 #define JSON_HEDLEY_NEVER_INLINE
1962 #if defined(JSON_HEDLEY_PRIVATE)
1963 #undef JSON_HEDLEY_PRIVATE
1965 #if defined(JSON_HEDLEY_PUBLIC)
1966 #undef JSON_HEDLEY_PUBLIC
1968 #if defined(JSON_HEDLEY_IMPORT)
1969 #undef JSON_HEDLEY_IMPORT
1971 #if defined(_WIN32) || defined(__CYGWIN__)
1972 # define JSON_HEDLEY_PRIVATE
1973 # define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1974 # define JSON_HEDLEY_IMPORT __declspec(dllimport)
1977 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1978 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1979 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1980 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1981 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1982 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1984 defined(__TI_EABI__) && \
1986 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1987 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1990 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1991 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1992 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1994 # define JSON_HEDLEY_PRIVATE
1995 # define JSON_HEDLEY_PUBLIC
1997 # define JSON_HEDLEY_IMPORT extern
2000 #if defined(JSON_HEDLEY_NO_THROW)
2001 #undef JSON_HEDLEY_NO_THROW
2004 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2005 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2006 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2007 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2008 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2010 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2011 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2012 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2013 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2015 #define JSON_HEDLEY_NO_THROW
2018 #if defined(JSON_HEDLEY_FALL_THROUGH)
2019 #undef JSON_HEDLEY_FALL_THROUGH
2022 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2023 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2024 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2025 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2026 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2027 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2028 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2029 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2030 #elif defined(__fallthrough)
2031 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2033 #define JSON_HEDLEY_FALL_THROUGH
2036 #if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2037 #undef JSON_HEDLEY_RETURNS_NON_NULL
2040 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2041 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2042 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2043 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2044 #elif defined(_Ret_notnull_)
2045 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2047 #define JSON_HEDLEY_RETURNS_NON_NULL
2050 #if defined(JSON_HEDLEY_ARRAY_PARAM)
2051 #undef JSON_HEDLEY_ARRAY_PARAM
2054 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2055 !defined(__STDC_NO_VLA__) && \
2056 !defined(__cplusplus) && \
2057 !defined(JSON_HEDLEY_PGI_VERSION) && \
2058 !defined(JSON_HEDLEY_TINYC_VERSION)
2059 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2061 #define JSON_HEDLEY_ARRAY_PARAM(name)
2064 #if defined(JSON_HEDLEY_IS_CONSTANT)
2065 #undef JSON_HEDLEY_IS_CONSTANT
2067 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2068 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2072 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2073 #undef JSON_HEDLEY_IS_CONSTEXPR_
2076 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2077 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2078 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2079 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2080 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2081 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2082 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2083 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2084 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2085 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2086 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2088 #if !defined(__cplusplus)
2090 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2091 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2092 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2093 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2094 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2095 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2096 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2097 #if defined(__INTPTR_TYPE__)
2098 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2101 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2105 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2106 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2107 !defined(JSON_HEDLEY_PGI_VERSION) && \
2108 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2109 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2110 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2111 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2112 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2113 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2114 #if defined(__INTPTR_TYPE__)
2115 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2118 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2121 defined(JSON_HEDLEY_GCC_VERSION) || \
2122 defined(JSON_HEDLEY_INTEL_VERSION) || \
2123 defined(JSON_HEDLEY_TINYC_VERSION) || \
2124 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2125 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2126 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2127 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2128 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2129 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2131 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2135 ((void*) ((expr) * 0L) ) : \
2136 ((struct { char v[sizeof(void) * 2]; } *) 1) \
2142 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2143 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2144 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2146 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2148 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2149 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2151 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2154 #if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2155 #undef JSON_HEDLEY_BEGIN_C_DECLS
2157 #if defined(JSON_HEDLEY_END_C_DECLS)
2158 #undef JSON_HEDLEY_END_C_DECLS
2160 #if defined(JSON_HEDLEY_C_DECL)
2161 #undef JSON_HEDLEY_C_DECL
2163 #if defined(__cplusplus)
2164 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2165 #define JSON_HEDLEY_END_C_DECLS }
2166 #define JSON_HEDLEY_C_DECL extern "C"
2168 #define JSON_HEDLEY_BEGIN_C_DECLS
2169 #define JSON_HEDLEY_END_C_DECLS
2170 #define JSON_HEDLEY_C_DECL
2173 #if defined(JSON_HEDLEY_STATIC_ASSERT)
2174 #undef JSON_HEDLEY_STATIC_ASSERT
2177 !defined(__cplusplus) && ( \
2178 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2179 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2180 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2181 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2182 defined(_Static_assert) \
2184 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2186 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2187 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2188 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2189 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2191 # define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2194 #if defined(JSON_HEDLEY_NULL)
2195 #undef JSON_HEDLEY_NULL
2197 #if defined(__cplusplus)
2198 #if __cplusplus >= 201103L
2199 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2201 #define JSON_HEDLEY_NULL NULL
2203 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2206 #define JSON_HEDLEY_NULL NULL
2208 #define JSON_HEDLEY_NULL ((void*) 0)
2211 #if defined(JSON_HEDLEY_MESSAGE)
2212 #undef JSON_HEDLEY_MESSAGE
2214 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2215 # define JSON_HEDLEY_MESSAGE(msg) \
2216 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2217 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2218 JSON_HEDLEY_PRAGMA(message msg) \
2219 JSON_HEDLEY_DIAGNOSTIC_POP
2221 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2222 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2223 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2224 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2225 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2226 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2227 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2228 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2229 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2231 # define JSON_HEDLEY_MESSAGE(msg)
2234 #if defined(JSON_HEDLEY_WARNING)
2235 #undef JSON_HEDLEY_WARNING
2237 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2238 # define JSON_HEDLEY_WARNING(msg) \
2239 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2240 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2241 JSON_HEDLEY_PRAGMA(clang warning msg) \
2242 JSON_HEDLEY_DIAGNOSTIC_POP
2244 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2245 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2246 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2247 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2249 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2250 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2251 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2253 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2256 #if defined(JSON_HEDLEY_REQUIRE)
2257 #undef JSON_HEDLEY_REQUIRE
2259 #if defined(JSON_HEDLEY_REQUIRE_MSG)
2260 #undef JSON_HEDLEY_REQUIRE_MSG
2262 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2263 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2264 # define JSON_HEDLEY_REQUIRE(expr) \
2265 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2266 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2267 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2268 JSON_HEDLEY_DIAGNOSTIC_POP
2269 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2270 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2271 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2272 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2273 JSON_HEDLEY_DIAGNOSTIC_POP
2275 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2276 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2279 # define JSON_HEDLEY_REQUIRE(expr)
2280 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2283 #if defined(JSON_HEDLEY_FLAGS)
2284 #undef JSON_HEDLEY_FLAGS
2286 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2287 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2289 #define JSON_HEDLEY_FLAGS
2292 #if defined(JSON_HEDLEY_FLAGS_CAST)
2293 #undef JSON_HEDLEY_FLAGS_CAST
2295 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2296 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2297 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2298 _Pragma("warning(disable:188)") \
2300 JSON_HEDLEY_DIAGNOSTIC_POP \
2303 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2306 #if defined(JSON_HEDLEY_EMPTY_BASES)
2307 #undef JSON_HEDLEY_EMPTY_BASES
2310 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2311 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2312 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2314 #define JSON_HEDLEY_EMPTY_BASES
2319 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2320 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2322 #if defined(__clang__)
2323 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2325 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2328 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2329 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2331 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2333 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2334 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2336 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2338 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2339 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2341 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2343 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2344 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2346 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2348 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2349 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2351 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2353 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2354 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2356 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2358 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2359 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2361 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2373 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2374 #if defined(__clang__)
2375 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2376 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2378 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2379 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2380 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2387 #if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2388 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2389 #define JSON_HAS_CPP_20
2390 #define JSON_HAS_CPP_17
2391 #define JSON_HAS_CPP_14
2392 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
2393 #define JSON_HAS_CPP_17
2394 #define JSON_HAS_CPP_14
2395 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2396 #define JSON_HAS_CPP_14
2399 #define JSON_HAS_CPP_11
2402 #ifdef __has_include
2403 #if __has_include(<version>)
2408 #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2409 #ifdef JSON_HAS_CPP_17
2410 #if defined(__cpp_lib_filesystem)
2411 #define JSON_HAS_FILESYSTEM 1
2412 #elif defined(__cpp_lib_experimental_filesystem)
2413 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2414 #elif !defined(__has_include)
2415 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2416 #elif __has_include(<filesystem>)
2417 #define JSON_HAS_FILESYSTEM 1
2418 #elif __has_include(<experimental/filesystem>)
2419 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2423 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2424 #undef JSON_HAS_FILESYSTEM
2425 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2429 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2430 #undef JSON_HAS_FILESYSTEM
2431 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2435 #if defined(__clang_major__) && __clang_major__ < 7
2436 #undef JSON_HAS_FILESYSTEM
2437 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2441 #if defined(_MSC_VER) && _MSC_VER < 1914
2442 #undef JSON_HAS_FILESYSTEM
2443 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2447 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2448 #undef JSON_HAS_FILESYSTEM
2449 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2453 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2454 #undef JSON_HAS_FILESYSTEM
2455 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2460 #ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2461 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2464 #ifndef JSON_HAS_FILESYSTEM
2465 #define JSON_HAS_FILESYSTEM 0
2468 #ifndef JSON_HAS_THREE_WAY_COMPARISON
2469 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2470 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2471 #define JSON_HAS_THREE_WAY_COMPARISON 1
2473 #define JSON_HAS_THREE_WAY_COMPARISON 0
2477 #ifndef JSON_HAS_RANGES
2479 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2480 #define JSON_HAS_RANGES 0
2481 #elif defined(__cpp_lib_ranges)
2482 #define JSON_HAS_RANGES 1
2484 #define JSON_HAS_RANGES 0
2488 #ifndef JSON_HAS_STATIC_RTTI
2489 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2490 #define JSON_HAS_STATIC_RTTI 1
2492 #define JSON_HAS_STATIC_RTTI 0
2496 #ifdef JSON_HAS_CPP_17
2497 #define JSON_INLINE_VARIABLE inline
2499 #define JSON_INLINE_VARIABLE
2502 #if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2503 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2505 #define JSON_NO_UNIQUE_ADDRESS
2509 #if defined(__clang__)
2510 #pragma clang diagnostic push
2511 #pragma clang diagnostic ignored "-Wdocumentation"
2512 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2516 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2517 #define JSON_THROW(exception) throw exception
2518 #define JSON_TRY try
2519 #define JSON_CATCH(exception) catch(exception)
2520 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2523 #define JSON_THROW(exception) std::abort()
2524 #define JSON_TRY if(true)
2525 #define JSON_CATCH(exception) if(false)
2526 #define JSON_INTERNAL_CATCH(exception) if(false)
2530 #if defined(JSON_THROW_USER)
2532 #define JSON_THROW JSON_THROW_USER
2534 #if defined(JSON_TRY_USER)
2536 #define JSON_TRY JSON_TRY_USER
2538 #if defined(JSON_CATCH_USER)
2540 #define JSON_CATCH JSON_CATCH_USER
2541 #undef JSON_INTERNAL_CATCH
2542 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2544 #if defined(JSON_INTERNAL_CATCH_USER)
2545 #undef JSON_INTERNAL_CATCH
2546 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2550 #if !defined(JSON_ASSERT)
2552 #define JSON_ASSERT(x) assert(x)
2556 #if defined(JSON_TESTS_PRIVATE)
2557 #define JSON_PRIVATE_UNLESS_TESTED public
2559 #define JSON_PRIVATE_UNLESS_TESTED private
2567 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2568 template<typename BasicJsonType> \
2569 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2571 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2572 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2573 auto it = std::find_if(std::begin(m), std::end(m), \
2574 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2576 return ej_pair.first == e; \
2578 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2580 template<typename BasicJsonType> \
2581 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2583 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2584 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2585 auto it = std::find_if(std::begin(m), std::end(m), \
2586 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2588 return ej_pair.second == j; \
2590 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2596 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2597 template<template<typename, typename, typename...> class ObjectType, \
2598 template<typename, typename...> class ArrayType, \
2599 class StringType, class BooleanType, class NumberIntegerType, \
2600 class NumberUnsignedType, class NumberFloatType, \
2601 template<typename> class AllocatorType, \
2602 template<typename, typename = void> class JSONSerializer, \
2604 class CustomBaseClass>
2606 #define NLOHMANN_BASIC_JSON_TPL \
2607 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2608 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2609 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2613 #define NLOHMANN_JSON_EXPAND( x ) x
2614 #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
2615 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2616 NLOHMANN_JSON_PASTE64, \
2617 NLOHMANN_JSON_PASTE63, \
2618 NLOHMANN_JSON_PASTE62, \
2619 NLOHMANN_JSON_PASTE61, \
2620 NLOHMANN_JSON_PASTE60, \
2621 NLOHMANN_JSON_PASTE59, \
2622 NLOHMANN_JSON_PASTE58, \
2623 NLOHMANN_JSON_PASTE57, \
2624 NLOHMANN_JSON_PASTE56, \
2625 NLOHMANN_JSON_PASTE55, \
2626 NLOHMANN_JSON_PASTE54, \
2627 NLOHMANN_JSON_PASTE53, \
2628 NLOHMANN_JSON_PASTE52, \
2629 NLOHMANN_JSON_PASTE51, \
2630 NLOHMANN_JSON_PASTE50, \
2631 NLOHMANN_JSON_PASTE49, \
2632 NLOHMANN_JSON_PASTE48, \
2633 NLOHMANN_JSON_PASTE47, \
2634 NLOHMANN_JSON_PASTE46, \
2635 NLOHMANN_JSON_PASTE45, \
2636 NLOHMANN_JSON_PASTE44, \
2637 NLOHMANN_JSON_PASTE43, \
2638 NLOHMANN_JSON_PASTE42, \
2639 NLOHMANN_JSON_PASTE41, \
2640 NLOHMANN_JSON_PASTE40, \
2641 NLOHMANN_JSON_PASTE39, \
2642 NLOHMANN_JSON_PASTE38, \
2643 NLOHMANN_JSON_PASTE37, \
2644 NLOHMANN_JSON_PASTE36, \
2645 NLOHMANN_JSON_PASTE35, \
2646 NLOHMANN_JSON_PASTE34, \
2647 NLOHMANN_JSON_PASTE33, \
2648 NLOHMANN_JSON_PASTE32, \
2649 NLOHMANN_JSON_PASTE31, \
2650 NLOHMANN_JSON_PASTE30, \
2651 NLOHMANN_JSON_PASTE29, \
2652 NLOHMANN_JSON_PASTE28, \
2653 NLOHMANN_JSON_PASTE27, \
2654 NLOHMANN_JSON_PASTE26, \
2655 NLOHMANN_JSON_PASTE25, \
2656 NLOHMANN_JSON_PASTE24, \
2657 NLOHMANN_JSON_PASTE23, \
2658 NLOHMANN_JSON_PASTE22, \
2659 NLOHMANN_JSON_PASTE21, \
2660 NLOHMANN_JSON_PASTE20, \
2661 NLOHMANN_JSON_PASTE19, \
2662 NLOHMANN_JSON_PASTE18, \
2663 NLOHMANN_JSON_PASTE17, \
2664 NLOHMANN_JSON_PASTE16, \
2665 NLOHMANN_JSON_PASTE15, \
2666 NLOHMANN_JSON_PASTE14, \
2667 NLOHMANN_JSON_PASTE13, \
2668 NLOHMANN_JSON_PASTE12, \
2669 NLOHMANN_JSON_PASTE11, \
2670 NLOHMANN_JSON_PASTE10, \
2671 NLOHMANN_JSON_PASTE9, \
2672 NLOHMANN_JSON_PASTE8, \
2673 NLOHMANN_JSON_PASTE7, \
2674 NLOHMANN_JSON_PASTE6, \
2675 NLOHMANN_JSON_PASTE5, \
2676 NLOHMANN_JSON_PASTE4, \
2677 NLOHMANN_JSON_PASTE3, \
2678 NLOHMANN_JSON_PASTE2, \
2679 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2680 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2681 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2682 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2683 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2684 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2685 #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)
2686 #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)
2687 #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)
2688 #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)
2689 #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)
2690 #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)
2691 #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)
2692 #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)
2693 #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)
2694 #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)
2695 #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)
2696 #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)
2697 #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)
2698 #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)
2699 #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)
2700 #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)
2701 #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)
2702 #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)
2703 #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)
2704 #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)
2705 #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)
2706 #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)
2707 #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)
2708 #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)
2709 #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)
2710 #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)
2711 #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)
2712 #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)
2713 #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)
2714 #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)
2715 #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)
2716 #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)
2717 #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)
2718 #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)
2719 #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)
2720 #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)
2721 #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)
2722 #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)
2723 #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)
2724 #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)
2725 #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)
2726 #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)
2727 #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)
2728 #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)
2729 #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)
2730 #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)
2731 #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)
2732 #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)
2733 #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)
2734 #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)
2735 #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)
2736 #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)
2737 #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)
2738 #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)
2739 #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)
2740 #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)
2741 #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)
2742 #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)
2744 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2745 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2746 #define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2753 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2754 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__)) } \
2755 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__)) }
2757 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2758 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__)) } \
2759 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2761 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2762 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2769 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2770 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__)) } \
2771 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__)) }
2773 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2774 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__)) }
2776 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2777 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__)) } \
2778 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2786 #define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2787 namespace detail { \
2788 using std::std_name; \
2790 template<typename... T> \
2791 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2794 namespace detail2 { \
2795 struct std_name##_tag \
2799 template<typename... T> \
2800 std_name##_tag std_name(T&&...); \
2802 template<typename... T> \
2803 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2805 template<typename... T> \
2806 struct would_call_std_##std_name \
2808 static constexpr auto const value = ::nlohmann::detail:: \
2809 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2813 template<typename... T> \
2814 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2818 #ifndef JSON_USE_IMPLICIT_CONVERSIONS
2819 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2822 #if JSON_USE_IMPLICIT_CONVERSIONS
2823 #define JSON_EXPLICIT
2825 #define JSON_EXPLICIT explicit
2828 #ifndef JSON_DISABLE_ENUM_SERIALIZATION
2829 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2832 #ifndef JSON_USE_GLOBAL_UDLS
2833 #define JSON_USE_GLOBAL_UDLS 1
2836 #if JSON_HAS_THREE_WAY_COMPARISON
2899 #if JSON_HAS_THREE_WAY_COMPARISON
2900 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs) noexcept
2905 static constexpr std::array<std::uint8_t, 9> order = {{
2912 const auto l_index =
static_cast<std::size_t
>(lhs);
2913 const auto r_index =
static_cast<std::size_t
>(rhs);
2914 #if JSON_HAS_THREE_WAY_COMPARISON
2915 if (l_index < order.size() && r_index < order.size())
2917 return order[l_index] <=> order[r_index];
2919 return std::partial_ordering::unordered;
2921 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2929 #if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2932 return std::is_lt(lhs <=> rhs);
2970 template<
typename StringType>
2972 const StringType& t)
2975 for (
auto pos = s.find(
f);
2976 pos != StringType::npos;
2977 s.replace(pos,
f.size(), t),
2978 pos = s.find(
f, pos + t.size()))
2989 template<
typename StringType>
3004 template<
typename StringType>
3045 constexpr
operator size_t()
const
3070 #include <type_traits>
3080 template<
typename T>
3081 using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3083 #ifdef JSON_HAS_CPP_14
3094 template<
bool B,
typename T =
void>
3121 template <
typename T, T... Ints>
3125 static constexpr std::size_t
size() noexcept
3127 return sizeof...(Ints);
3136 template <
size_t... Ints>
3139 namespace utility_internal
3142 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3146 template <
typename T, T... Ints,
size_t SeqSize>
3152 template <
typename T, T... Ints,
size_t SeqSize>
3160 template <
typename T,
size_t N>
3167 template <
typename T>
3182 template <
typename T, T N>
3198 template <
typename... Ts>
3210 template<
typename T>
3216 #ifndef JSON_HAS_CPP_17
3217 template<
typename T>
3221 template<
typename T,
typename... Args>
3222 inline constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3224 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3242 #include <type_traits>
3271 template<
typename It,
typename =
void>
3274 template<
typename It>
3278 typename It::reference, typename It::iterator_category >>
3289 template<
typename T,
typename =
void>
3294 template<
typename T>
3300 template<
typename T>
3368 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3369 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3394 template<
typename T =
void,
typename SFINAE =
void>
3399 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3401 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3402 class StringType = std::string,
class BooleanType = bool,
3403 class NumberIntegerType = std::int64_t,
3404 class NumberUnsignedType = std::uint64_t,
3405 class NumberFloatType = double,
3406 template<
typename U>
class AllocatorType = std::allocator,
3407 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3409 class BinaryType = std::vector<std::uint8_t>,
3410 class CustomBaseClass =
void>
3415 template<
typename RefStringType>
3426 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3435 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
3471 template<
typename BasicJsonContext>
3473 std::integral_constant < bool,
3474 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3475 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3488 template<
typename T>
3495 template<
typename T>
3498 template<
typename T>
3501 template<
typename T>
3504 template<
typename T>
3507 template<
typename T>
3510 template<
typename T>
3513 template<
typename T>
3516 template<
typename T,
typename... Args>
3519 template<
typename T,
typename... Args>
3522 template<
typename T,
typename U>
3526 template<
typename BasicJsonType,
typename T,
typename =
void>
3533 template <
typename BasicJsonType,
typename T>
3539 template<
typename BasicJsonType,
typename T>
3542 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3544 static constexpr
bool value =
3546 const BasicJsonType&, T&>::value;
3551 template<
typename BasicJsonType,
typename T,
typename =
void>
3554 template<
typename BasicJsonType,
typename T>
3557 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3559 static constexpr
bool value =
3561 const BasicJsonType&>::value;
3566 template<
typename BasicJsonType,
typename T,
typename =
void>
3569 template<
typename BasicJsonType,
typename T>
3572 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3574 static constexpr
bool value =
3579 template<
typename T>
3582 template<
typename T>
3583 struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3586 template<
typename BasicJsonType>
3595 template<
typename BasicJsonType>
3603 template<
typename T>
3662 template<
class B,
class... Bn>
3664 : std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3667 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3672 template <
typename T>
3675 template <
typename T1,
typename T2>
3677 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3679 template <
typename T1,
typename T2>
3681 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3683 template <
typename... Ts>
3685 :
conjunction<is_default_constructible<Ts>...> {};
3687 template <
typename... Ts>
3689 :
conjunction<is_default_constructible<Ts>...> {};
3691 template <
typename T,
typename... Args>
3694 template <
typename T1,
typename T2>
3697 template <
typename T1,
typename T2>
3700 template <
typename... Ts>
3703 template <
typename... Ts>
3706 template<
typename T,
typename =
void>
3709 template<
typename T>
3716 static constexpr
auto value =
3724 template<
typename T>
3728 using t_ref =
typename std::add_lvalue_reference<T>::type;
3743 template<
typename R>
3746 template<
typename T>
3753 template<
typename T,
typename =
void>
3756 template<
typename T>
3759 template<
typename BasicJsonType,
typename CompatibleObjectType,
3763 template<
typename BasicJsonType,
typename CompatibleObjectType>
3765 BasicJsonType, CompatibleObjectType,
3772 static constexpr
bool value =
3774 typename CompatibleObjectType::key_type>::value &&
3776 typename CompatibleObjectType::mapped_type>::value;
3779 template<
typename BasicJsonType,
typename CompatibleObjectType>
3783 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3787 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3789 BasicJsonType, ConstructibleObjectType,
3795 static constexpr
bool value =
3800 typename object_t::key_type>::value &&
3802 typename object_t::mapped_type,
3803 typename ConstructibleObjectType::mapped_type >::value)) ||
3805 typename ConstructibleObjectType::mapped_type>::value ||
3808 typename ConstructibleObjectType::mapped_type >::value);
3811 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3814 ConstructibleObjectType> {};
3816 template<
typename BasicJsonType,
typename CompatibleStringType>
3823 template<
typename BasicJsonType,
typename ConstructibleStringType>
3827 #ifdef __INTEL_COMPILER
3828 using laundered_type = decltype(std::declval<ConstructibleStringType>());
3840 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3843 template<
typename BasicJsonType,
typename CompatibleArrayType>
3845 BasicJsonType, CompatibleArrayType,
3851 !
std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3853 static constexpr
bool value =
3858 template<
typename BasicJsonType,
typename CompatibleArrayType>
3862 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3865 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3867 BasicJsonType, ConstructibleArrayType,
3869 typename BasicJsonType::value_type>
::value >>
3870 : std::true_type {};
3872 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3874 BasicJsonType, ConstructibleArrayType,
3876 typename BasicJsonType::value_type>
::value&&
3879 (std::is_move_assignable<ConstructibleArrayType>::value ||
3880 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3886 !
std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3888 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3892 static constexpr
bool value =
3894 typename BasicJsonType::array_t::value_type>::value ||
3902 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3906 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3910 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3912 RealIntegerType, CompatibleNumberIntegerType,
3914 std::is_integral<CompatibleNumberIntegerType>
::value&&
3921 static constexpr
auto value =
3923 CompatibleNumberIntegerType>::value &&
3928 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3931 CompatibleNumberIntegerType> {};
3933 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3936 template<
typename BasicJsonType,
typename CompatibleType>
3938 BasicJsonType, CompatibleType,
3941 static constexpr
bool value =
3945 template<
typename BasicJsonType,
typename CompatibleType>
3949 template<
typename T1,
typename T2>
3952 template<
typename T1,
typename... Args>
3955 template<
typename BasicJsonType,
typename T>
3958 template<
typename BasicJsonType>
3961 template<
typename BasicJsonType>
3966 template<
template <
typename...>
class Primary,
typename T>
3969 template<
template <
typename...>
class Primary,
typename... Args>
3972 template<
typename T>
3976 template<
typename Compare,
typename A,
typename B,
typename =
void>
3979 template<
typename Compare,
typename A,
typename B>
3981 decltype(
std::
declval<Compare>()(std::declval<A>(), std::declval<B>())),
3982 decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3983 >> : std::true_type {};
3985 template<
typename T>
3990 template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3995 ObjectKeyType>::value)
3996 && (!RequireTransparentComparator
4000 std::false_type >::type;
4008 template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4012 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4013 RequireTransparentComparator, ExcludeObjectKeyType>::value
4016 std::false_type >::type;
4018 template<
typename ObjectType,
typename KeyType>
4022 template<
typename BasicJsonType,
typename KeyType>
4026 typename BasicJsonType::object_t, KeyType >::value,
4028 std::false_type >::type;
4032 template <
typename T>
4042 template <
typename C>
static one test( decltype(&C::capacity) ) ;
4043 template <
typename C>
static two test(...);
4045 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
4052 return static_cast<T
>(value);
4061 template<
typename... Types>
4064 template<
typename... Types>
4067 template<
typename... Types>
4071 template<
typename... Types>
4072 using same_sign = std::integral_constant < bool,
4075 template<
typename OfType,
typename T>
4080 template<
typename OfType,
typename T,
4085 template<
typename OfType,
typename T>
4090 using CommonType =
typename std::common_type<OfType, T>::type;
4091 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4095 template<
typename OfType,
typename T>
4100 using CommonType =
typename std::common_type<OfType, T>::type;
4101 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4105 template<
typename OfType,
typename T>
4110 using CommonType =
typename std::common_type<OfType, T>::type;
4111 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4115 template<
typename OfType,
typename T>
4120 using CommonType =
typename std::common_type<OfType, T>::type;
4121 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4122 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4126 template<
typename OfType,
typename T,
4131 template<
typename OfType,
typename T>
4140 template<
typename OfType,
typename T>
4149 template<
typename OfType,
typename T>
4155 template<
bool Value>
4165 template<
typename T>
4168 using TUnExt =
typename std::remove_extent<T>::type;
4169 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4170 using TUnPtr =
typename std::remove_pointer<T>::type;
4171 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4180 template<
typename T>
4183 template<
typename T>
4193 template<
typename T>
4202 template<
typename T>
4239 template<
typename... Args>
4240 inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4242 template<
typename StringType,
typename... Args>
4243 inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4245 template<
typename... Args>
4251 template<
typename... Args>
4258 template<
typename StringType,
typename... Args>
4264 template<
typename OutStringType>
4268 template<
typename StringType,
typename Arg>
4271 template<
typename StringType,
typename Arg>
4274 template<
typename StringType,
typename Arg>
4277 template<
typename StringType,
typename Arg>
4280 template<
typename StringType,
typename Arg>
4283 template<
typename StringType,
typename Arg>
4286 template<
typename StringType,
typename Arg>
4287 using string_can_append_data = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().
size()));
4289 template<
typename StringType,
typename Arg>
4292 template <
typename OutStringType,
typename Arg,
typename... Args,
4295 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4297 template <
typename OutStringType,
typename Arg,
typename... Args,
4301 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4303 template <
typename OutStringType,
typename Arg,
typename... Args,
4308 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4310 template<
typename OutStringType,
typename Arg,
typename... Args,
4312 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4314 out.append(std::forward<Arg>(arg));
4318 template <
typename OutStringType,
typename Arg,
typename... Args,
4321 inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4323 out += std::forward<Arg>(arg);
4327 template <
typename OutStringType,
typename Arg,
typename... Args,
4331 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4333 out.append(arg.begin(), arg.end());
4337 template <
typename OutStringType,
typename Arg,
typename... Args,
4342 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4344 out.append(arg.data(), arg.size());
4348 template<
typename OutStringType = std::string,
typename... Args>
4349 inline OutStringType
concat(Args && ... args)
4375 const char*
what() const noexcept
override
4385 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
4387 static std::string
name(
const std::string& ename,
int id_)
4397 template<
typename BasicJsonType>
4400 #if JSON_DIAGNOSTICS
4401 std::vector<std::string>
tokens;
4402 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4404 switch (current->m_parent->type())
4408 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4410 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4421 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4423 if (&element.second == current)
4425 tokens.emplace_back(element.first.c_str());
4450 auto str = std::accumulate(
tokens.rbegin(),
tokens.rend(), std::string{},
4451 [](
const std::string & a,
const std::string & b)
4453 return concat(a,
'/', detail::escape(b));
4455 return concat(
'(', str,
") ");
4457 static_cast<void>(leaf_element);
4464 std::runtime_error
m;
4490 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4495 return {id_, byte_, w.c_str()};
4529 return {id_, w.c_str()};
4547 return {id_, w.c_str()};
4564 return {id_, w.c_str()};
4581 return {id_, w.c_str()};
4634 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4635 #include <experimental/filesystem>
4639 namespace std_fs = std::experimental::filesystem;
4642 #elif JSON_HAS_FILESYSTEM
4643 #include <filesystem>
4647 namespace std_fs = std::filesystem;
4663 template<
typename BasicJsonType>
4664 inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t&
n)
4674 template <
typename BasicJsonType,
typename ArithmeticType,
4680 switch (
static_cast<value_t>(j))
4684 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4689 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4694 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4710 template<
typename BasicJsonType>
4711 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4717 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4720 template<
typename BasicJsonType>
4721 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4727 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4731 typename BasicJsonType,
typename StringType,
4737 inline void from_json(
const BasicJsonType& j, StringType& s)
4744 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4747 template<
typename BasicJsonType>
4748 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4753 template<
typename BasicJsonType>
4754 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4759 template<
typename BasicJsonType>
4760 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4765 #if !JSON_DISABLE_ENUM_SERIALIZATION
4766 template<
typename BasicJsonType,
typename EnumType,
4770 typename std::underlying_type<EnumType>::type val;
4772 e =
static_cast<EnumType
>(val);
4774 #endif // JSON_DISABLE_ENUM_SERIALIZATION
4777 template<
typename BasicJsonType,
typename T,
typename Allocator,
4779 inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4786 std::transform(j.rbegin(), j.rend(),
4787 std::front_inserter(l), [](
const BasicJsonType & i)
4789 return i.template get<T>();
4794 template<
typename BasicJsonType,
typename T,
4796 inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4803 std::transform(j.begin(), j.end(),
std::begin(l),
4804 [](
const BasicJsonType & elem)
4806 return elem.template get<T>();
4810 template<
typename BasicJsonType,
typename T, std::
size_t N>
4812 -> decltype(j.template get<T>(),
void())
4814 for (std::size_t i = 0; i < N; ++i)
4816 arr[i] = j.at(i).template get<T>();
4820 template<
typename BasicJsonType>
4823 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4826 template<
typename BasicJsonType,
typename T, std::
size_t N>
4829 -> decltype(j.template get<T>(),
void())
4831 for (std::size_t i = 0; i < N; ++i)
4833 arr[i] = j.at(i).template get<T>();
4837 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4843 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4844 j.template get<typename ConstructibleArrayType::value_type>(),
4849 ConstructibleArrayType ret;
4850 ret.reserve(j.size());
4851 std::transform(j.begin(), j.end(),
4852 std::inserter(ret,
end(ret)), [](
const BasicJsonType & i)
4856 return i.template get<typename ConstructibleArrayType::value_type>();
4858 arr = std::move(ret);
4861 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4870 ConstructibleArrayType ret;
4872 j.begin(), j.end(), std::inserter(ret,
end(ret)),
4873 [](
const BasicJsonType & i)
4877 return i.template get<typename ConstructibleArrayType::value_type>();
4879 arr = std::move(ret);
4882 template <
typename BasicJsonType,
typename ConstructibleArrayType,
4890 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4892 j.template get<typename ConstructibleArrayType::value_type>(),
4903 template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4907 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4910 template <
typename BasicJsonType,
typename T, std::
size_t N >
4922 template<
typename BasicJsonType>
4923 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4930 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4933 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4935 inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4942 ConstructibleObjectType ret;
4943 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4944 using value_type =
typename ConstructibleObjectType::value_type;
4946 inner_object->begin(), inner_object->end(),
4947 std::inserter(ret, ret.begin()),
4948 [](
typename BasicJsonType::object_t::value_type
const &
p)
4950 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4952 obj = std::move(ret);
4959 template <
typename BasicJsonType,
typename ArithmeticType,
4967 inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4969 switch (
static_cast<value_t>(j))
4973 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4978 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4983 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4988 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5003 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5006 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5009 template <
typename BasicJsonType,
class A1,
class A2 >
5012 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
5013 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
5016 template<
typename BasicJsonType,
typename A1,
typename A2>
5022 template<
typename BasicJsonType,
typename... Args>
5028 template<
typename BasicJsonType,
typename... Args>
5034 template<
typename BasicJsonType,
typename TupleRelated>
5043 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5046 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5048 typename BasicJsonType::string_t, Key >::value >>
5049 inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5056 for (
const auto&
p : j)
5062 m.emplace(
p.at(0).template get<Key>(),
p.at(1).template get<Value>());
5066 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5068 typename BasicJsonType::string_t, Key >::value >>
5069 inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5076 for (
const auto&
p : j)
5082 m.emplace(
p.at(0).template get<Key>(),
p.at(1).template get<Value>());
5086 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5087 template<
typename BasicJsonType>
5088 inline void from_json(
const BasicJsonType& j, std_fs::path&
p)
5094 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5100 template<
typename BasicJsonType,
typename T>
5102 noexcept(noexcept(
from_json(j, std::forward<T>(val))))
5103 -> decltype(
from_json(j, std::forward<T>(val)))
5105 return from_json(j, std::forward<T>(val));
5111 #ifndef JSON_HAS_CPP_17
5120 #ifndef JSON_HAS_CPP_17
5137 #include <algorithm>
5141 #include <type_traits>
5178 template<
typename string_type>
5193 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5210 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5220 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5223 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5267 switch (
anchor.m_object->type())
5299 typename IteratorType::reference
value()
const
5341 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5342 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key())
5349 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5350 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
5365 #if defined(__clang__)
5367 #pragma clang diagnostic push
5368 #pragma clang diagnostic ignored "-Wmismatched-tags"
5370 template<
typename IteratorType>
5371 class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5372 :
public std::integral_constant<std::size_t, 2> {};
5374 template<std::
size_t N,
typename IteratorType>
5375 class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5378 using type = decltype(
5380 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5382 #if defined(__clang__)
5383 #pragma clang diagnostic pop
5389 template <
typename IteratorType>
5390 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5424 template<
typename BasicJsonType>
5425 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b) noexcept
5427 j.m_data.m_value.destroy(j.m_data.m_type);
5429 j.m_data.m_value = b;
5430 j.assert_invariant();
5437 template<
typename BasicJsonType>
5438 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5440 j.m_data.m_value.destroy(j.m_data.m_type);
5442 j.m_data.m_value = s;
5443 j.assert_invariant();
5446 template<
typename BasicJsonType>
5447 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5449 j.m_data.m_value.destroy(j.m_data.m_type);
5451 j.m_data.m_value = std::move(s);
5452 j.assert_invariant();
5455 template <
typename BasicJsonType,
typename CompatibleStringType,
5458 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5460 j.m_data.m_value.destroy(j.m_data.m_type);
5462 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5463 j.assert_invariant();
5470 template<
typename BasicJsonType>
5471 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5473 j.m_data.m_value.destroy(j.m_data.m_type);
5475 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5476 j.assert_invariant();
5479 template<
typename BasicJsonType>
5480 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5482 j.m_data.m_value.destroy(j.m_data.m_type);
5484 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5485 j.assert_invariant();
5492 template<
typename BasicJsonType>
5493 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val) noexcept
5495 j.m_data.m_value.destroy(j.m_data.m_type);
5497 j.m_data.m_value = val;
5498 j.assert_invariant();
5505 template<
typename BasicJsonType>
5506 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val) noexcept
5508 j.m_data.m_value.destroy(j.m_data.m_type);
5510 j.m_data.m_value = val;
5511 j.assert_invariant();
5518 template<
typename BasicJsonType>
5519 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val) noexcept
5521 j.m_data.m_value.destroy(j.m_data.m_type);
5523 j.m_data.m_value = val;
5524 j.assert_invariant();
5531 template<
typename BasicJsonType>
5532 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5534 j.m_data.m_value.destroy(j.m_data.m_type);
5536 j.m_data.m_value = arr;
5538 j.assert_invariant();
5541 template<
typename BasicJsonType>
5542 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5544 j.m_data.m_value.destroy(j.m_data.m_type);
5546 j.m_data.m_value = std::move(arr);
5548 j.assert_invariant();
5551 template <
typename BasicJsonType,
typename CompatibleArrayType,
5554 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5559 j.m_data.m_value.destroy(j.m_data.m_type);
5561 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(
begin(arr),
end(arr));
5563 j.assert_invariant();
5566 template<
typename BasicJsonType>
5567 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5569 j.m_data.m_value.destroy(j.m_data.m_type);
5572 j.m_data.m_value.array->reserve(arr.size());
5573 for (
const bool x : arr)
5575 j.m_data.m_value.array->push_back(x);
5576 j.set_parent(j.m_data.m_value.array->back());
5578 j.assert_invariant();
5581 template<
typename BasicJsonType,
typename T,
5583 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5585 j.m_data.m_value.destroy(j.m_data.m_type);
5588 j.m_data.m_value.array->resize(arr.size());
5594 j.assert_invariant();
5601 template<
typename BasicJsonType>
5602 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5604 j.m_data.m_value.destroy(j.m_data.m_type);
5606 j.m_data.m_value = obj;
5608 j.assert_invariant();
5611 template<
typename BasicJsonType>
5612 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5614 j.m_data.m_value.destroy(j.m_data.m_type);
5616 j.m_data.m_value = std::move(obj);
5618 j.assert_invariant();
5621 template <
typename BasicJsonType,
typename CompatibleObjectType,
5623 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5628 j.m_data.m_value.destroy(j.m_data.m_type);
5630 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(
begin(obj),
end(obj));
5632 j.assert_invariant();
5640 template<
typename BasicJsonType,
typename T,
5642 inline void to_json(BasicJsonType& j, T b) noexcept
5647 template <
typename BasicJsonType,
typename BoolRef,
5649 ((std::is_same<std::vector<bool>::reference, BoolRef>::value
5650 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>::value)
5651 || (
std::is_same<std::vector<bool>::const_reference, BoolRef>::value
5653 typename BasicJsonType::boolean_t >::value))
5655 inline void to_json(BasicJsonType& j,
const BoolRef& b) noexcept
5660 template<
typename BasicJsonType,
typename CompatibleString,
5662 inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5667 template<
typename BasicJsonType>
5668 inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5673 template<
typename BasicJsonType,
typename FloatType,
5675 inline void to_json(BasicJsonType& j, FloatType val) noexcept
5680 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5682 inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
5687 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5689 inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
5694 #if !JSON_DISABLE_ENUM_SERIALIZATION
5695 template<
typename BasicJsonType,
typename EnumType,
5697 inline void to_json(BasicJsonType& j, EnumType e) noexcept
5699 using underlying_type =
typename std::underlying_type<EnumType>::type;
5702 #endif // JSON_DISABLE_ENUM_SERIALIZATION
5704 template<
typename BasicJsonType>
5705 inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5710 template <
typename BasicJsonType,
typename CompatibleArrayType,
5711 enable_if_t < is_compatible_array_type<BasicJsonType,
5712 CompatibleArrayType>::value&&
5718 inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5723 template<
typename BasicJsonType>
5724 inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5729 template<
typename BasicJsonType,
typename T,
5731 inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5736 template<
typename BasicJsonType>
5737 inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5742 template <
typename BasicJsonType,
typename CompatibleObjectType,
5744 inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5749 template<
typename BasicJsonType>
5750 inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5756 typename BasicJsonType,
typename T, std::size_t N,
5758 const T(&)[N]>::value,
5760 inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5766 inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>&
p)
5768 j = {
p.first,
p.second };
5772 template<
typename BasicJsonType,
typename T,
5773 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5776 j = { {b.key(), b.value()} };
5779 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5782 j = { std::get<Idx>(t)... };
5786 inline void to_json(BasicJsonType& j,
const T& t)
5791 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5792 template<
typename BasicJsonType>
5793 inline void to_json(BasicJsonType& j,
const std_fs::path&
p)
5801 template<
typename BasicJsonType,
typename T>
5802 auto operator()(BasicJsonType& j, T&& val)
const noexcept(noexcept(
to_json(j, std::forward<T>(val))))
5803 -> decltype(
to_json(j, std::forward<T>(val)),
void())
5805 return to_json(j, std::forward<T>(val));
5810 #ifndef JSON_HAS_CPP_17
5819 #ifndef JSON_HAS_CPP_17
5831 template<
typename ValueType,
typename>
5836 template<
typename BasicJsonType,
typename TargetType = ValueType>
5837 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
5846 template<
typename BasicJsonType,
typename TargetType = ValueType>
5856 template<
typename BasicJsonType,
typename TargetType = ValueType>
5857 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
5889 template<
typename BinaryType>
5933 return !(rhs == *
this);
5992 #include <functional>
6004 inline std::size_t
combine(std::size_t seed, std::size_t h) noexcept
6006 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6021 template<
typename BasicJsonType>
6022 std::size_t
hash(
const BasicJsonType& j)
6024 using string_t =
typename BasicJsonType::string_t;
6025 using number_integer_t =
typename BasicJsonType::number_integer_t;
6026 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6027 using number_float_t =
typename BasicJsonType::number_float_t;
6029 const auto type =
static_cast<std::size_t
>(j.type());
6032 case BasicJsonType::value_t::null:
6033 case BasicJsonType::value_t::discarded:
6038 case BasicJsonType::value_t::object:
6040 auto seed =
combine(type, j.size());
6041 for (
const auto& element : j.items())
6043 const auto h = std::hash<string_t> {}(element.key());
6050 case BasicJsonType::value_t::array:
6052 auto seed =
combine(type, j.size());
6053 for (
const auto& element : j)
6060 case BasicJsonType::value_t::string:
6062 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6066 case BasicJsonType::value_t::boolean:
6068 const auto h = std::hash<bool> {}(j.template get<bool>());
6072 case BasicJsonType::value_t::number_integer:
6074 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6078 case BasicJsonType::value_t::number_unsigned:
6080 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6084 case BasicJsonType::value_t::number_float:
6086 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6092 auto seed =
combine(type, j.get_binary().size());
6093 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6095 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6096 for (
const auto byte : j.get_binary())
6098 seed =
combine(seed, std::hash<std::uint8_t> {}(
byte));
6123 #include <algorithm>
6156 #include <type_traits>
6162 #endif // JSON_NO_IO
6208 return std::fgetc(
m_file);
6236 is->clear(
is->rdstate() & std::ios::eofbit);
6241 :
is(&i),
sb(i.rdbuf())
6250 :
is(rhs.is),
sb(rhs.sb)
6261 auto res =
sb->sbumpc();
6265 is->clear(
is->rdstate() | std::ios::eofbit);
6272 std::istream*
is =
nullptr;
6273 std::streambuf*
sb =
nullptr;
6275 #endif // JSON_NO_IO
6279 template<
typename IteratorType>
6283 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6305 template<
typename BaseInputAdapter,
size_t T>
6314 template<
typename BaseInputAdapter,
size_t T>
6317 template<
typename BaseInputAdapter>
6322 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6323 size_t& utf8_bytes_index,
6324 size_t& utf8_bytes_filled)
6326 utf8_bytes_index = 0;
6331 utf8_bytes_filled = 1;
6336 const auto wc = input.get_character();
6341 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6342 utf8_bytes_filled = 1;
6344 else if (wc <= 0x7FF)
6346 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6347 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6348 utf8_bytes_filled = 2;
6350 else if (wc <= 0xFFFF)
6352 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6353 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6354 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6355 utf8_bytes_filled = 3;
6357 else if (wc <= 0x10FFFF)
6359 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6360 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6361 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6362 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6363 utf8_bytes_filled = 4;
6368 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6369 utf8_bytes_filled = 1;
6375 template<
typename BaseInputAdapter>
6380 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6381 size_t& utf8_bytes_index,
6382 size_t& utf8_bytes_filled)
6384 utf8_bytes_index = 0;
6389 utf8_bytes_filled = 1;
6394 const auto wc = input.get_character();
6399 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6400 utf8_bytes_filled = 1;
6402 else if (wc <= 0x7FF)
6404 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6405 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6406 utf8_bytes_filled = 2;
6408 else if (0xD800 > wc || wc >= 0xE000)
6410 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6411 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6412 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6413 utf8_bytes_filled = 3;
6419 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6420 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6421 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6422 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6423 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6424 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6425 utf8_bytes_filled = 4;
6429 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6430 utf8_bytes_filled = 1;
6438 template<
typename BaseInputAdapter,
typename W
ideCharType>
6452 fill_buffer<sizeof(WideCharType)>();
6474 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
6482 template<
typename IteratorType,
typename Enable =
void>
6486 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6491 return adapter_type(std::move(first), std::move(last));
6495 template<
typename T>
6505 template<
typename IteratorType>
6509 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6520 template<
typename IteratorType>
6524 return factory_type::create(first, last);
6531 namespace container_input_adapter_factory_impl
6537 template<
typename ContainerType,
typename Enable =
void>
6540 template<
typename ContainerType>
6554 template<
typename ContainerType>
6576 #endif // JSON_NO_IO
6581 template <
typename CharT,
6585 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
6586 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6590 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6591 const auto* ptr =
reinterpret_cast<const char*
>(b);
6595 template<
typename T, std::
size_t N>
6607 template <
typename CharT,
6610 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
6611 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6614 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6616 template<
class IteratorType,
6618 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
6625 return std::move(ia);
6668 template<
typename BasicJsonType>
6681 virtual bool null() = 0;
6688 virtual bool boolean(
bool val) = 0;
6756 virtual bool start_array(std::size_t elements) = 0;
6772 const std::string& last_token,
6798 template<
typename BasicJsonType>
6814 : root(r), allow_exceptions(allow_exceptions_)
6826 handle_value(
nullptr);
6862 handle_value(std::move(val));
6868 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6870 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6884 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
6893 ref_stack.back()->set_parents();
6894 ref_stack.pop_back();
6900 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6902 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6915 ref_stack.back()->set_parents();
6916 ref_stack.pop_back();
6920 template<
class Exception>
6922 const Exception& ex)
6925 static_cast<void>(ex);
6926 if (allow_exceptions)
6945 template<
typename Value>
6949 if (ref_stack.empty())
6951 root = BasicJsonType(std::forward<Value>(v));
6955 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6957 if (ref_stack.back()->is_array())
6959 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
6960 return &(ref_stack.back()->m_data.m_value.array->back());
6965 *object_element = BasicJsonType(std::forward<Value>(v));
6966 return object_element;
6972 std::vector<BasicJsonType*> ref_stack {};
6974 BasicJsonType* object_element =
nullptr;
6976 bool errored =
false;
6978 const bool allow_exceptions =
true;
6981 template<
typename BasicJsonType>
6995 const bool allow_exceptions_ =
true)
6996 : root(r),
callback(cb), allow_exceptions(allow_exceptions_)
6998 keep_stack.push_back(
true);
7010 handle_value(
nullptr);
7046 handle_value(std::move(val));
7053 const bool keep =
callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
7054 keep_stack.push_back(keep);
7056 auto val = handle_value(BasicJsonType::value_t::object,
true);
7057 ref_stack.push_back(val.second);
7060 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7070 BasicJsonType k = BasicJsonType(val);
7073 const bool keep =
callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
7074 key_keep_stack.push_back(keep);
7077 if (keep && ref_stack.back())
7079 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
7087 if (ref_stack.back())
7089 if (!
callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7096 ref_stack.back()->set_parents();
7102 ref_stack.pop_back();
7103 keep_stack.pop_back();
7105 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7108 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7110 if (it->is_discarded())
7112 ref_stack.back()->erase(it);
7123 const bool keep =
callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7124 keep_stack.push_back(keep);
7126 auto val = handle_value(BasicJsonType::value_t::array,
true);
7127 ref_stack.push_back(val.second);
7130 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7142 if (ref_stack.back())
7144 keep =
callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7147 ref_stack.back()->set_parents();
7158 ref_stack.pop_back();
7159 keep_stack.pop_back();
7162 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7164 ref_stack.back()->m_data.m_value.array->pop_back();
7170 template<
class Exception>
7172 const Exception& ex)
7175 static_cast<void>(ex);
7176 if (allow_exceptions)
7204 template<
typename Value>
7205 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
7211 if (!keep_stack.back())
7213 return {
false,
nullptr};
7217 auto value = BasicJsonType(std::forward<Value>(v));
7225 return {
false,
nullptr};
7228 if (ref_stack.empty())
7230 root = std::move(
value);
7231 return {
true, & root};
7236 if (!ref_stack.back())
7238 return {
false,
nullptr};
7242 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7245 if (ref_stack.back()->is_array())
7247 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(
value));
7248 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
7255 const bool store_element = key_keep_stack.back();
7256 key_keep_stack.pop_back();
7260 return {
false,
nullptr};
7264 *object_element = std::move(
value);
7265 return {
true, object_element};
7271 std::vector<BasicJsonType*> ref_stack {};
7273 std::vector<bool> keep_stack {};
7275 std::vector<bool> key_keep_stack {};
7277 BasicJsonType* object_element =
nullptr;
7279 bool errored =
false;
7283 const bool allow_exceptions =
true;
7285 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7288 template<
typename BasicJsonType>
7383 #include <initializer_list>
7405 template<
typename BasicJsonType>
7438 case token_type::uninitialized:
7439 return "<uninitialized>";
7440 case token_type::literal_true:
7441 return "true literal";
7442 case token_type::literal_false:
7443 return "false literal";
7444 case token_type::literal_null:
7445 return "null literal";
7446 case token_type::value_string:
7447 return "string literal";
7448 case token_type::value_unsigned:
7449 case token_type::value_integer:
7450 case token_type::value_float:
7451 return "number literal";
7452 case token_type::begin_array:
7454 case token_type::begin_object:
7456 case token_type::end_array:
7458 case token_type::end_object:
7460 case token_type::name_separator:
7462 case token_type::value_separator:
7464 case token_type::parse_error:
7465 return "<parse error>";
7466 case token_type::end_of_input:
7467 return "end of input";
7468 case token_type::literal_or_value:
7469 return "'[', '{', or a literal";
7472 return "unknown token";
7482 template<
typename BasicJsonType,
typename InputAdapterType>
7495 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7496 : ia(
std::move(adapter))
7497 , ignore_comments(ignore_comments_)
7498 , decimal_point_char(static_cast<
char_int_type>(get_decimal_point()))
7517 const auto* loc = localeconv();
7519 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7547 const auto factors = { 12u, 8u, 4u, 0u };
7548 for (
const auto factor : factors)
7552 if (current >=
'0' && current <=
'9')
7554 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7556 else if (current >=
'A' && current <=
'F')
7558 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7560 else if (current >=
'a' && current <=
'f')
7562 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7570 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7591 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7594 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7603 error_message =
"invalid string: ill-formed UTF-8 byte";
7642 error_message =
"invalid string: missing closing quote";
7643 return token_type::parse_error;
7649 return token_type::value_string;
7693 const int codepoint1 = get_codepoint();
7694 int codepoint = codepoint1;
7698 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7699 return token_type::parse_error;
7703 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7708 const int codepoint2 = get_codepoint();
7712 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7713 return token_type::parse_error;
7720 codepoint =
static_cast<int>(
7722 (
static_cast<unsigned int>(codepoint1) << 10u)
7724 +
static_cast<unsigned int>(codepoint2)
7732 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7733 return token_type::parse_error;
7738 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7739 return token_type::parse_error;
7746 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7747 return token_type::parse_error;
7752 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7755 if (codepoint < 0x80)
7760 else if (codepoint <= 0x7FF)
7763 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7764 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7766 else if (codepoint <= 0xFFFF)
7769 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7770 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7771 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7776 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7777 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7778 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7779 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7787 error_message =
"invalid string: forbidden character after backslash";
7788 return token_type::parse_error;
7797 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7798 return token_type::parse_error;
7803 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7804 return token_type::parse_error;
7809 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7810 return token_type::parse_error;
7815 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7816 return token_type::parse_error;
7821 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7822 return token_type::parse_error;
7827 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7828 return token_type::parse_error;
7833 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7834 return token_type::parse_error;
7839 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7840 return token_type::parse_error;
7845 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7846 return token_type::parse_error;
7851 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7852 return token_type::parse_error;
7857 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7858 return token_type::parse_error;
7863 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7864 return token_type::parse_error;
7869 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7870 return token_type::parse_error;
7875 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7876 return token_type::parse_error;
7881 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7882 return token_type::parse_error;
7887 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7888 return token_type::parse_error;
7893 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7894 return token_type::parse_error;
7899 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7900 return token_type::parse_error;
7905 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7906 return token_type::parse_error;
7911 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7912 return token_type::parse_error;
7917 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7918 return token_type::parse_error;
7923 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7924 return token_type::parse_error;
7929 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7930 return token_type::parse_error;
7935 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7936 return token_type::parse_error;
7941 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7942 return token_type::parse_error;
7947 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7948 return token_type::parse_error;
7953 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7954 return token_type::parse_error;
7959 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7960 return token_type::parse_error;
7965 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7966 return token_type::parse_error;
7971 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7972 return token_type::parse_error;
7977 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7978 return token_type::parse_error;
7983 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7984 return token_type::parse_error;
8121 return token_type::parse_error;
8131 return token_type::parse_error;
8155 return token_type::parse_error;
8165 return token_type::parse_error;
8175 return token_type::parse_error;
8187 return token_type::parse_error;
8197 return token_type::parse_error;
8205 error_message =
"invalid string: ill-formed UTF-8 byte";
8206 return token_type::parse_error;
8249 error_message =
"invalid comment; missing closing '*/'";
8277 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8284 static
void strtof(
float&
f, const
char* str,
char** endptr) noexcept
8286 f = std::strtof(str, endptr);
8290 static
void strtof(
double&
f, const
char* str,
char** endptr) noexcept
8292 f = std::strtod(str, endptr);
8296 static
void strtof(
long double&
f, const
char* str,
char** endptr) noexcept
8298 f = std::strtold(str, endptr);
8348 token_type number_type = token_type::value_unsigned;
8356 goto scan_number_minus;
8362 goto scan_number_zero;
8376 goto scan_number_any1;
8386 number_type = token_type::value_integer;
8392 goto scan_number_zero;
8406 goto scan_number_any1;
8411 error_message =
"invalid number; expected digit after '-'";
8412 return token_type::parse_error;
8422 add(decimal_point_char);
8423 goto scan_number_decimal1;
8430 goto scan_number_exponent;
8434 goto scan_number_done;
8453 goto scan_number_any1;
8458 add(decimal_point_char);
8459 goto scan_number_decimal1;
8466 goto scan_number_exponent;
8470 goto scan_number_done;
8473 scan_number_decimal1:
8475 number_type = token_type::value_float;
8490 goto scan_number_decimal2;
8495 error_message =
"invalid number; expected digit after '.'";
8496 return token_type::parse_error;
8500 scan_number_decimal2:
8516 goto scan_number_decimal2;
8523 goto scan_number_exponent;
8527 goto scan_number_done;
8530 scan_number_exponent:
8532 number_type = token_type::value_float;
8539 goto scan_number_sign;
8554 goto scan_number_any2;
8560 "invalid number; expected '+', '-', or digit after exponent";
8561 return token_type::parse_error;
8581 goto scan_number_any2;
8586 error_message =
"invalid number; expected digit after exponent sign";
8587 return token_type::parse_error;
8607 goto scan_number_any2;
8611 goto scan_number_done;
8619 char* endptr =
nullptr;
8623 if (number_type == token_type::value_unsigned)
8625 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8628 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8633 if (value_unsigned == x)
8635 return token_type::value_unsigned;
8639 else if (number_type == token_type::value_integer)
8641 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8644 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8649 if (value_integer == x)
8651 return token_type::value_integer;
8658 strtof(value_float, token_buffer.data(), &endptr);
8661 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8663 return token_type::value_float;
8676 for (std::size_t i = 1; i < length; ++i)
8680 error_message =
"invalid literal";
8681 return token_type::parse_error;
8694 token_buffer.clear();
8695 token_string.clear();
8712 ++
position.chars_read_current_line;
8721 current = ia.get_character();
8729 if (current ==
'\n')
8732 position.chars_read_current_line = 0;
8753 if (
position.chars_read_current_line == 0)
8762 --
position.chars_read_current_line;
8768 token_string.pop_back();
8775 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8786 return value_integer;
8792 return value_unsigned;
8804 return token_buffer;
8824 for (
const auto c : token_string)
8826 if (
static_cast<unsigned char>(c) <=
'\x1F')
8829 std::array<char, 9> cs{{}};
8830 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8831 result += cs.data();
8836 result.push_back(
static_cast<std::string::value_type
>(c));
8847 return error_message;
8863 return get() == 0xBB &&
get() == 0xBF;
8878 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8884 if (
position.chars_read_total == 0 && !skip_bom())
8886 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8887 return token_type::parse_error;
8894 while (ignore_comments && current ==
'/')
8896 if (!scan_comment())
8898 return token_type::parse_error;
8909 return token_type::begin_array;
8911 return token_type::end_array;
8913 return token_type::begin_object;
8915 return token_type::end_object;
8917 return token_type::name_separator;
8919 return token_type::value_separator;
8925 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8930 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8935 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8940 return scan_string();
8954 return scan_number();
8960 return token_type::end_of_input;
8964 error_message =
"invalid literal";
8965 return token_type::parse_error;
8974 const bool ignore_comments =
false;
8980 bool next_unget =
false;
8986 std::vector<char_type> token_string {};
8992 const char* error_message =
"";
9034 template<
typename T>
9037 template<
typename T>
9039 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
9041 template<
typename T,
typename Integer>
9045 template<
typename T,
typename Un
signed>
9049 template<
typename T,
typename Float,
typename String>
9051 std::declval<Float>(), std::declval<const String&>()));
9053 template<
typename T,
typename String>
9055 decltype(std::declval<T&>().
string(std::declval<String&>()));
9057 template<
typename T,
typename Binary>
9059 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
9061 template<
typename T>
9065 template<
typename T,
typename String>
9067 decltype(std::declval<T&>().
key(std::declval<String&>()));
9069 template<
typename T>
9072 template<
typename T>
9074 decltype(std::declval<T&>().
start_array(std::declval<std::size_t>()));
9076 template<
typename T>
9079 template<
typename T,
typename Exception>
9081 std::declval<std::size_t>(), std::declval<const std::string&>(),
9082 std::declval<const Exception&>()));
9084 template<
typename SAX,
typename BasicJsonType>
9089 "BasicJsonType must be of type basic_json<...>");
9115 template<
typename SAX,
typename BasicJsonType>
9120 "BasicJsonType must be of type basic_json<...>");
9131 "Missing/invalid function: bool null()");
9133 "Missing/invalid function: bool boolean(bool)");
9135 "Missing/invalid function: bool boolean(bool)");
9139 "Missing/invalid function: bool number_integer(number_integer_t)");
9143 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9146 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9149 "Missing/invalid function: bool string(string_t&)");
9152 "Missing/invalid function: bool binary(binary_t&)");
9154 "Missing/invalid function: bool start_object(std::size_t)");
9156 "Missing/invalid function: bool key(string_t&)");
9158 "Missing/invalid function: bool end_object()");
9160 "Missing/invalid function: bool start_array(std::size_t)");
9162 "Missing/invalid function: bool end_array()");
9165 "Missing/invalid function: bool parse_error(std::size_t, const "
9166 "std::string&, const exception&)");
9200 return *
reinterpret_cast<char*
>(&num) == 1;
9210 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9251 const
bool strict = true,
9255 bool result =
false;
9259 case input_format_t::bson:
9260 result = parse_bson_internal();
9263 case input_format_t::cbor:
9264 result = parse_cbor_internal(
true, tag_handler);
9267 case input_format_t::msgpack:
9268 result = parse_msgpack_internal();
9271 case input_format_t::ubjson:
9272 case input_format_t::bjdata:
9273 result = parse_ubjson_internal();
9284 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9295 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
9296 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9314 std::int32_t document_size{};
9315 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9327 return sax->end_object();
9339 auto out = std::back_inserter(result);
9347 if (current == 0x00)
9351 *out++ =
static_cast<typename string_t::value_type
>(current);
9366 template<
typename NumberType>
9371 auto last_token = get_token_string();
9372 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9373 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ",
std::to_string(len)),
"string"),
nullptr));
9388 template<
typename NumberType>
9393 auto last_token = get_token_string();
9394 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9395 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ",
std::to_string(len)),
"binary"),
nullptr));
9400 get_number<std::uint8_t>(input_format_t::bson,
subtype);
9403 return get_binary(input_format_t::bson, len, result);
9417 const std::size_t element_type_parse_position)
9419 switch (element_type)
9424 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9431 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len,
value) && sax->string(
value);
9436 return parse_bson_internal();
9441 return parse_bson_array();
9448 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len,
value) && sax->binary(
value);
9453 return sax->boolean(
get() != 0);
9463 std::int32_t
value{};
9464 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9469 std::int64_t
value{};
9470 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9475 std::array<char, 3> cr{{}};
9476 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9477 const std::string cr_str{cr.data()};
9478 return sax->parse_error(element_type_parse_position, cr_str,
9479 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
9500 while (
auto element_type =
get())
9507 const std::size_t element_type_parse_position = chars_read;
9513 if (!is_array && !sax->key(
key))
9518 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9536 std::int32_t document_size{};
9537 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9549 return sax->end_array();
9567 switch (get_char ?
get() : current)
9571 return unexpect_eof(input_format_t::cbor,
"value");
9602 std::uint8_t number{};
9603 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9608 std::uint16_t number{};
9609 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9614 std::uint32_t number{};
9615 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9620 std::uint64_t number{};
9621 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9649 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9653 std::uint8_t number{};
9654 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9659 std::uint16_t number{};
9660 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9665 std::uint32_t number{};
9666 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9671 std::uint64_t number{};
9672 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1)
9708 return get_cbor_binary(b) && sax->binary(b);
9743 return get_cbor_string(s) && sax->string(s);
9771 return get_cbor_array(
9772 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9777 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9782 std::uint16_t len{};
9783 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9788 std::uint32_t len{};
9789 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9794 std::uint64_t len{};
9795 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9799 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9826 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9831 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9836 std::uint16_t len{};
9837 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9842 std::uint32_t len{};
9843 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9848 std::uint64_t len{};
9849 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9853 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9875 switch (tag_handler)
9879 auto last_token = get_token_string();
9880 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9881 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9884 case cbor_tag_handler_t::ignore:
9891 std::uint8_t subtype_to_ignore{};
9892 get_number(input_format_t::cbor, subtype_to_ignore);
9897 std::uint16_t subtype_to_ignore{};
9898 get_number(input_format_t::cbor, subtype_to_ignore);
9903 std::uint32_t subtype_to_ignore{};
9904 get_number(input_format_t::cbor, subtype_to_ignore);
9909 std::uint64_t subtype_to_ignore{};
9910 get_number(input_format_t::cbor, subtype_to_ignore);
9916 return parse_cbor_internal(
true, tag_handler);
9919 case cbor_tag_handler_t::store:
9928 get_number(input_format_t::cbor,
subtype);
9929 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(
subtype));
9935 get_number(input_format_t::cbor,
subtype);
9936 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(
subtype));
9942 get_number(input_format_t::cbor,
subtype);
9943 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(
subtype));
9949 get_number(input_format_t::cbor,
subtype);
9950 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(
subtype));
9954 return parse_cbor_internal(
true, tag_handler);
9957 return get_cbor_binary(b) && sax->binary(b);
9967 return sax->boolean(
false);
9970 return sax->boolean(
true);
9977 const auto byte1_raw =
get();
9982 const auto byte2_raw =
get();
9988 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9989 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9999 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10000 const double val = [&half]
10002 const int exp = (half >> 10u) & 0x1Fu;
10003 const unsigned int mant = half & 0x3FFu;
10009 return std::ldexp(mant, -24);
10012 ? std::numeric_limits<double>::infinity()
10013 : std::numeric_limits<double>::quiet_NaN();
10015 return std::ldexp(mant + 1024, exp - 25);
10018 return sax->number_float((half & 0x8000u) != 0
10026 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10032 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10037 auto last_token = get_token_string();
10038 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10039 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10090 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10095 std::uint8_t len{};
10096 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10101 std::uint16_t len{};
10102 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10107 std::uint32_t len{};
10108 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10113 std::uint64_t len{};
10114 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10119 while (
get() != 0xFF)
10122 if (!get_cbor_string(chunk))
10126 result.append(chunk);
10133 auto last_token = get_token_string();
10134 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10135 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10186 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10191 std::uint8_t len{};
10192 return get_number(input_format_t::cbor, len) &&
10193 get_binary(input_format_t::cbor, len, result);
10198 std::uint16_t len{};
10199 return get_number(input_format_t::cbor, len) &&
10200 get_binary(input_format_t::cbor, len, result);
10205 std::uint32_t len{};
10206 return get_number(input_format_t::cbor, len) &&
10207 get_binary(input_format_t::cbor, len, result);
10212 std::uint64_t len{};
10213 return get_number(input_format_t::cbor, len) &&
10214 get_binary(input_format_t::cbor, len, result);
10219 while (
get() != 0xFF)
10222 if (!get_cbor_binary(chunk))
10226 result.insert(result.end(), chunk.begin(), chunk.end());
10233 auto last_token = get_token_string();
10234 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10235 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));
10254 if (len !=
static_cast<std::size_t
>(-1))
10256 for (std::size_t i = 0; i < len; ++i)
10266 while (
get() != 0xFF)
10275 return sax->end_array();
10295 if (len !=
static_cast<std::size_t
>(-1))
10297 for (std::size_t i = 0; i < len; ++i)
10314 while (
get() != 0xFF)
10330 return sax->end_object();
10346 return unexpect_eof(input_format_t::msgpack,
"value");
10496 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10515 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10555 return get_msgpack_string(s) && sax->string(s);
10559 return sax->null();
10562 return sax->boolean(
false);
10565 return sax->boolean(
true);
10580 return get_msgpack_binary(b) && sax->binary(b);
10586 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10592 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10597 std::uint8_t number{};
10598 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10603 std::uint16_t number{};
10604 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10609 std::uint32_t number{};
10610 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10615 std::uint64_t number{};
10616 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10621 std::int8_t number{};
10622 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10627 std::int16_t number{};
10628 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10633 std::int32_t number{};
10634 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10639 std::int64_t number{};
10640 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10645 std::uint16_t len{};
10646 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
10651 std::uint32_t len{};
10652 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10657 std::uint16_t len{};
10658 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
10663 std::uint32_t len{};
10664 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10700 return sax->number_integer(
static_cast<std::int8_t
>(current));
10704 auto last_token = get_token_string();
10705 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10706 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10764 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
10769 std::uint8_t len{};
10770 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10775 std::uint16_t len{};
10776 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10781 std::uint32_t len{};
10782 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10787 auto last_token = get_token_string();
10788 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10789 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10807 auto assign_and_return_true = [&result](std::int8_t
subtype)
10809 result.set_subtype(
static_cast<std::uint8_t
>(
subtype));
10817 std::uint8_t len{};
10818 return get_number(input_format_t::msgpack, len) &&
10819 get_binary(input_format_t::msgpack, len, result);
10824 std::uint16_t len{};
10825 return get_number(input_format_t::msgpack, len) &&
10826 get_binary(input_format_t::msgpack, len, result);
10831 std::uint32_t len{};
10832 return get_number(input_format_t::msgpack, len) &&
10833 get_binary(input_format_t::msgpack, len, result);
10838 std::uint8_t len{};
10840 return get_number(input_format_t::msgpack, len) &&
10841 get_number(input_format_t::msgpack,
subtype) &&
10842 get_binary(input_format_t::msgpack, len, result) &&
10843 assign_and_return_true(
subtype);
10848 std::uint16_t len{};
10850 return get_number(input_format_t::msgpack, len) &&
10851 get_number(input_format_t::msgpack,
subtype) &&
10852 get_binary(input_format_t::msgpack, len, result) &&
10853 assign_and_return_true(
subtype);
10858 std::uint32_t len{};
10860 return get_number(input_format_t::msgpack, len) &&
10861 get_number(input_format_t::msgpack,
subtype) &&
10862 get_binary(input_format_t::msgpack, len, result) &&
10863 assign_and_return_true(
subtype);
10869 return get_number(input_format_t::msgpack,
subtype) &&
10870 get_binary(input_format_t::msgpack, 1, result) &&
10871 assign_and_return_true(
subtype);
10877 return get_number(input_format_t::msgpack,
subtype) &&
10878 get_binary(input_format_t::msgpack, 2, result) &&
10879 assign_and_return_true(
subtype);
10885 return get_number(input_format_t::msgpack,
subtype) &&
10886 get_binary(input_format_t::msgpack, 4, result) &&
10887 assign_and_return_true(
subtype);
10893 return get_number(input_format_t::msgpack,
subtype) &&
10894 get_binary(input_format_t::msgpack, 8, result) &&
10895 assign_and_return_true(
subtype);
10901 return get_number(input_format_t::msgpack,
subtype) &&
10902 get_binary(input_format_t::msgpack, 16, result) &&
10903 assign_and_return_true(
subtype);
10922 for (std::size_t i = 0; i < len; ++i)
10930 return sax->end_array();
10945 for (std::size_t i = 0; i < len; ++i)
10960 return sax->end_object();
10976 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11009 std::uint8_t len{};
11010 return get_number(input_format, len) && get_string(input_format, len, result);
11016 return get_number(input_format, len) && get_string(input_format, len, result);
11021 std::int16_t len{};
11022 return get_number(input_format, len) && get_string(input_format, len, result);
11027 std::int32_t len{};
11028 return get_number(input_format, len) && get_string(input_format, len, result);
11033 std::int64_t len{};
11034 return get_number(input_format, len) && get_string(input_format, len, result);
11039 if (input_format != input_format_t::bjdata)
11043 std::uint16_t len{};
11044 return get_number(input_format, len) && get_string(input_format, len, result);
11049 if (input_format != input_format_t::bjdata)
11053 std::uint32_t len{};
11054 return get_number(input_format, len) && get_string(input_format, len, result);
11059 if (input_format != input_format_t::bjdata)
11063 std::uint64_t len{};
11064 return get_number(input_format, len) && get_string(input_format, len, result);
11070 auto last_token = get_token_string();
11071 std::string message;
11073 if (input_format != input_format_t::bjdata)
11075 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11079 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11081 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11090 std::pair<std::size_t, char_int_type> size_and_type;
11092 bool no_ndarray =
true;
11099 if (size_and_type.first != npos)
11101 if (size_and_type.second != 0)
11103 if (size_and_type.second !=
'N')
11105 for (std::size_t i = 0; i < size_and_type.first; ++i)
11111 dim.push_back(dimlen);
11117 for (std::size_t i = 0; i < size_and_type.first; ++i)
11123 dim.push_back(dimlen);
11129 while (current !=
']')
11135 dim.push_back(dimlen);
11157 prefix = get_ignore_noop();
11164 std::uint8_t number{};
11169 result =
static_cast<std::size_t
>(number);
11175 std::int8_t number{};
11182 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11183 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11185 result =
static_cast<std::size_t
>(number);
11191 std::int16_t number{};
11198 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11199 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11201 result =
static_cast<std::size_t
>(number);
11207 std::int32_t number{};
11214 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11215 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11217 result =
static_cast<std::size_t
>(number);
11223 std::int64_t number{};
11230 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11231 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11233 if (!value_in_range_of<std::size_t>(number))
11235 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11236 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11238 result =
static_cast<std::size_t
>(number);
11244 if (input_format != input_format_t::bjdata)
11248 std::uint16_t number{};
11253 result =
static_cast<std::size_t
>(number);
11259 if (input_format != input_format_t::bjdata)
11263 std::uint32_t number{};
11268 result = conditional_static_cast<std::size_t>(number);
11274 if (input_format != input_format_t::bjdata)
11278 std::uint64_t number{};
11283 if (!value_in_range_of<std::size_t>(number))
11285 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11286 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11288 result = detail::conditional_static_cast<std::size_t>(number);
11294 if (input_format != input_format_t::bjdata)
11300 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11302 std::vector<size_t> dim;
11307 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11309 result = dim.at(dim.size() - 1);
11332 if (result == 0 || result == npos)
11334 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));
11342 return sax->end_array();
11351 auto last_token = get_token_string();
11352 std::string message;
11354 if (input_format != input_format_t::bjdata)
11356 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11360 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11362 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11378 result.first = npos;
11380 bool is_ndarray =
false;
11384 if (current ==
'$')
11386 result.second =
get();
11387 if (input_format == input_format_t::bjdata
11388 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
11390 auto last_token = get_token_string();
11391 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11392 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11407 auto last_token = get_token_string();
11408 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11409 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11412 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11413 if (input_format == input_format_t::bjdata && is_ndarray)
11415 if (inside_ndarray)
11417 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11418 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11420 result.second |= (1 << 8);
11425 if (current ==
'#')
11427 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11428 if (input_format == input_format_t::bjdata && is_ndarray)
11430 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11431 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11448 return unexpect_eof(input_format,
"value");
11451 return sax->boolean(
true);
11453 return sax->boolean(
false);
11456 return sax->null();
11460 std::uint8_t number{};
11461 return get_number(input_format, number) && sax->number_unsigned(number);
11466 std::int8_t number{};
11467 return get_number(input_format, number) && sax->number_integer(number);
11472 std::int16_t number{};
11473 return get_number(input_format, number) && sax->number_integer(number);
11478 std::int32_t number{};
11479 return get_number(input_format, number) && sax->number_integer(number);
11484 std::int64_t number{};
11485 return get_number(input_format, number) && sax->number_integer(number);
11490 if (input_format != input_format_t::bjdata)
11494 std::uint16_t number{};
11495 return get_number(input_format, number) && sax->number_unsigned(number);
11500 if (input_format != input_format_t::bjdata)
11504 std::uint32_t number{};
11505 return get_number(input_format, number) && sax->number_unsigned(number);
11510 if (input_format != input_format_t::bjdata)
11514 std::uint64_t number{};
11515 return get_number(input_format, number) && sax->number_unsigned(number);
11520 if (input_format != input_format_t::bjdata)
11524 const auto byte1_raw =
get();
11529 const auto byte2_raw =
get();
11535 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11536 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11546 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11547 const double val = [&half]
11549 const int exp = (half >> 10u) & 0x1Fu;
11550 const unsigned int mant = half & 0x3FFu;
11556 return std::ldexp(mant, -24);
11559 ? std::numeric_limits<double>::infinity()
11560 : std::numeric_limits<double>::quiet_NaN();
11562 return std::ldexp(mant + 1024, exp - 25);
11565 return sax->number_float((half & 0x8000u) != 0
11573 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11579 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11584 return get_ubjson_high_precision_number();
11596 auto last_token = get_token_string();
11597 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11598 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11600 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11601 return sax->string(s);
11607 return get_ubjson_string(s) && sax->string(s);
11611 return get_ubjson_array();
11614 return get_ubjson_object();
11619 auto last_token = get_token_string();
11620 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));
11628 std::pair<std::size_t, char_int_type> size_and_type;
11637 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11639 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
11640 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)
11642 return p.first < t;
11647 auto last_token = get_token_string();
11648 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11649 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11658 if (size_and_type.second ==
'C')
11660 size_and_type.second =
'U';
11663 key =
"_ArrayData_";
11669 for (std::size_t i = 0; i < size_and_type.first; ++i)
11677 return (sax->end_array() && sax->end_object());
11680 if (size_and_type.first != npos)
11687 if (size_and_type.second != 0)
11689 if (size_and_type.second !=
'N')
11691 for (std::size_t i = 0; i < size_and_type.first; ++i)
11702 for (std::size_t i = 0; i < size_and_type.first; ++i)
11718 while (current !=
']')
11728 return sax->end_array();
11736 std::pair<std::size_t, char_int_type> size_and_type;
11743 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11745 auto last_token = get_token_string();
11746 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11747 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11751 if (size_and_type.first != npos)
11758 if (size_and_type.second != 0)
11760 for (std::size_t i = 0; i < size_and_type.first; ++i)
11775 for (std::size_t i = 0; i < size_and_type.first; ++i)
11796 while (current !=
'}')
11811 return sax->end_object();
11820 std::size_t
size{};
11821 bool no_ndarray =
true;
11822 auto res = get_ubjson_size_value(
size, no_ndarray);
11829 std::vector<char> number_vector;
11830 for (std::size_t i = 0; i <
size; ++i)
11837 number_vector.push_back(
static_cast<char>(current));
11843 const auto result_number = number_lexer.scan();
11844 const auto number_string = number_lexer.get_token_string();
11845 const auto result_remainder = number_lexer.scan();
11851 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11852 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11855 switch (result_number)
11857 case token_type::value_integer:
11858 return sax->number_integer(number_lexer.get_number_integer());
11859 case token_type::value_unsigned:
11860 return sax->number_unsigned(number_lexer.get_number_unsigned());
11861 case token_type::value_float:
11862 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11863 case token_type::uninitialized:
11864 case token_type::literal_true:
11865 case token_type::literal_false:
11866 case token_type::literal_null:
11867 case token_type::value_string:
11868 case token_type::begin_array:
11869 case token_type::begin_object:
11870 case token_type::end_array:
11871 case token_type::end_object:
11872 case token_type::name_separator:
11873 case token_type::value_separator:
11874 case token_type::parse_error:
11875 case token_type::end_of_input:
11876 case token_type::literal_or_value:
11878 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11879 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11899 return current = ia.get_character();
11911 while (current ==
'N');
11931 template<
typename NumberType,
bool InputIsLittleEndian = false>
11935 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11936 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11945 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
11947 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11951 vec[i] =
static_cast<std::uint8_t
>(current);
11956 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11974 template<
typename NumberType>
11976 const NumberType len,
11979 bool success =
true;
11980 for (NumberType i = 0; i < len; i++)
11988 result.push_back(
static_cast<typename string_t::value_type
>(current));
12007 template<
typename NumberType>
12009 const NumberType len,
12012 bool success =
true;
12013 for (NumberType i = 0; i < len; i++)
12021 result.push_back(
static_cast<std::uint8_t
>(current));
12036 return sax->parse_error(chars_read,
"<end of file>",
12037 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12047 std::array<char, 3> cr{{}};
12048 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12049 return std::string{cr.data()};
12059 const std::string&
detail,
12060 const std::string& context)
const
12062 std::string error_msg =
"syntax error while parsing ";
12066 case input_format_t::cbor:
12067 error_msg +=
"CBOR";
12070 case input_format_t::msgpack:
12071 error_msg +=
"MessagePack";
12074 case input_format_t::ubjson:
12075 error_msg +=
"UBJSON";
12078 case input_format_t::bson:
12079 error_msg +=
"BSON";
12082 case input_format_t::bjdata:
12083 error_msg +=
"BJData";
12104 std::size_t chars_read = 0;
12116 #define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12117 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12119 #define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12120 make_array<bjd_type>( \
12121 bjd_type{'C', "char"}, \
12122 bjd_type{'D', "double"}, \
12123 bjd_type{'I', "int16"}, \
12124 bjd_type{'L', "int64"}, \
12125 bjd_type{'M', "uint64"}, \
12126 bjd_type{'U', "uint8"}, \
12127 bjd_type{'d', "single"}, \
12128 bjd_type{'i', "int8"}, \
12129 bjd_type{'l', "int32"}, \
12130 bjd_type{'m', "uint32"}, \
12131 bjd_type{'u', "uint16"})
12144 #undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12145 #undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12148 #ifndef JSON_HAS_CPP_17
12149 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12173 #include <functional>
12218 template<
typename BasicJsonType>
12227 template<
typename BasicJsonType,
typename InputAdapterType>
12241 const bool allow_exceptions_ =
true,
12242 const bool skip_comments =
false)
12244 , m_lexer(
std::move(adapter), skip_comments)
12245 , allow_exceptions(allow_exceptions_)
12261 void parse(
const bool strict, BasicJsonType& result)
12266 sax_parse_internal(&sdp);
12269 if (
strict && (get_token() != token_type::end_of_input))
12272 m_lexer.get_token_string(),
12273 parse_error::create(101, m_lexer.get_position(),
12274 exception_message(token_type::end_of_input,
"value"),
nullptr));
12280 result = value_t::discarded;
12286 if (result.is_discarded())
12294 sax_parse_internal(&sdp);
12297 if (
strict && (get_token() != token_type::end_of_input))
12300 m_lexer.get_token_string(),
12301 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12307 result = value_t::discarded;
12312 result.assert_invariant();
12324 return sax_parse(&sax_acceptor,
strict);
12327 template<
typename SAX>
12329 bool sax_parse(SAX* sax, const
bool strict = true)
12332 const bool result = sax_parse_internal(sax);
12335 if (result &&
strict && (get_token() != token_type::end_of_input))
12337 return sax->parse_error(m_lexer.get_position(),
12338 m_lexer.get_token_string(),
12339 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12346 template<
typename SAX>
12348 bool sax_parse_internal(SAX* sax)
12352 std::vector<bool> states;
12354 bool skip_to_state_evaluation =
false;
12358 if (!skip_to_state_evaluation)
12361 switch (last_token)
12363 case token_type::begin_object:
12371 if (get_token() == token_type::end_object)
12383 return sax->parse_error(m_lexer.get_position(),
12384 m_lexer.get_token_string(),
12385 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12395 return sax->parse_error(m_lexer.get_position(),
12396 m_lexer.get_token_string(),
12397 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12401 states.push_back(
false);
12408 case token_type::begin_array:
12416 if (get_token() == token_type::end_array)
12426 states.push_back(
true);
12432 case token_type::value_float:
12434 const auto res = m_lexer.get_number_float();
12438 return sax->parse_error(m_lexer.get_position(),
12439 m_lexer.get_token_string(),
12440 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
12451 case token_type::literal_false:
12460 case token_type::literal_null:
12469 case token_type::literal_true:
12478 case token_type::value_integer:
12487 case token_type::value_string:
12496 case token_type::value_unsigned:
12505 case token_type::parse_error:
12508 return sax->parse_error(m_lexer.get_position(),
12509 m_lexer.get_token_string(),
12510 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12512 case token_type::end_of_input:
12516 return sax->parse_error(m_lexer.get_position(),
12517 m_lexer.get_token_string(),
12518 parse_error::create(101, m_lexer.get_position(),
12519 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
12522 return sax->parse_error(m_lexer.get_position(),
12523 m_lexer.get_token_string(),
12524 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12526 case token_type::uninitialized:
12527 case token_type::end_array:
12528 case token_type::end_object:
12529 case token_type::name_separator:
12530 case token_type::value_separator:
12531 case token_type::literal_or_value:
12534 return sax->parse_error(m_lexer.get_position(),
12535 m_lexer.get_token_string(),
12536 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12542 skip_to_state_evaluation =
false;
12546 if (states.empty())
12555 if (get_token() == token_type::value_separator)
12576 skip_to_state_evaluation =
true;
12580 return sax->parse_error(m_lexer.get_position(),
12581 m_lexer.get_token_string(),
12582 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12588 if (get_token() == token_type::value_separator)
12593 return sax->parse_error(m_lexer.get_position(),
12594 m_lexer.get_token_string(),
12595 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12606 return sax->parse_error(m_lexer.get_position(),
12607 m_lexer.get_token_string(),
12608 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12630 skip_to_state_evaluation =
true;
12634 return sax->parse_error(m_lexer.get_position(),
12635 m_lexer.get_token_string(),
12636 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12643 return last_token = m_lexer.scan();
12648 std::string error_msg =
"syntax error ";
12650 if (!context.empty())
12652 error_msg +=
concat(
"while parsing ", context,
' ');
12657 if (last_token == token_type::parse_error)
12659 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12660 m_lexer.get_token_string(),
'\'');
12664 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
12667 if (expected != token_type::uninitialized)
12669 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
12683 const bool allow_exceptions =
true;
12752 m_it = begin_value;
12764 return m_it == begin_value;
12770 return m_it == end_value;
12775 return lhs.m_it == rhs.m_it;
12780 return lhs.m_it < rhs.m_it;
12785 auto result = *
this;
12792 return lhs.m_it - rhs.m_it;
12803 auto result = *
this;
12816 auto result = *
this;
12851 typename BasicJsonType::object_t::iterator object_iterator {};
12853 typename BasicJsonType::array_t::iterator array_iterator {};
12872 #include <iterator>
12873 #include <type_traits>
12895 template<
typename IteratorType>
class iteration_proxy;
12896 template<
typename IteratorType>
class iteration_proxy_value;
12914 template<
typename BasicJsonType>
12928 static_assert(
is_basic_json<
typename std::remove_const<BasicJsonType>::type>::
value,
12929 "iter_impl only accepts (const) basic_json");
12932 && std::is_base_of<std::bidirectional_iterator_tag,
typename std::iterator_traits<typename array_t::iterator>::iterator_category>::
value,
12933 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12949 typename BasicJsonType::const_pointer,
12950 typename BasicJsonType::pointer>::type;
12954 typename BasicJsonType::const_reference,
12955 typename BasicJsonType::reference>::type;
12972 switch (m_object->m_data.m_type)
12974 case value_t::object:
12976 m_it.object_iterator =
typename object_t::iterator();
12980 case value_t::array:
12982 m_it.array_iterator =
typename array_t::iterator();
12986 case value_t::null:
12987 case value_t::string:
12988 case value_t::boolean:
12989 case value_t::number_integer:
12990 case value_t::number_unsigned:
12991 case value_t::number_float:
12993 case value_t::discarded:
13019 : m_object(other.m_object), m_it(other.m_it)
13030 if (&other !=
this)
13032 m_object = other.m_object;
13044 : m_object(other.m_object), m_it(other.m_it)
13055 m_object = other.m_object;
13065 void set_begin() noexcept
13069 switch (m_object->m_data.m_type)
13071 case value_t::object:
13073 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13077 case value_t::array:
13079 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13083 case value_t::null:
13086 m_it.primitive_iterator.set_end();
13090 case value_t::string:
13091 case value_t::boolean:
13092 case value_t::number_integer:
13093 case value_t::number_unsigned:
13094 case value_t::number_float:
13096 case value_t::discarded:
13099 m_it.primitive_iterator.set_begin();
13113 switch (m_object->m_data.m_type)
13115 case value_t::object:
13117 m_it.object_iterator = m_object->m_data.m_value.object->end();
13121 case value_t::array:
13123 m_it.array_iterator = m_object->m_data.m_value.array->end();
13127 case value_t::null:
13128 case value_t::string:
13129 case value_t::boolean:
13130 case value_t::number_integer:
13131 case value_t::number_unsigned:
13132 case value_t::number_float:
13134 case value_t::discarded:
13137 m_it.primitive_iterator.set_end();
13152 switch (m_object->m_data.m_type)
13154 case value_t::object:
13156 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13157 return m_it.object_iterator->second;
13160 case value_t::array:
13162 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13163 return *m_it.array_iterator;
13166 case value_t::null:
13167 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13169 case value_t::string:
13170 case value_t::boolean:
13171 case value_t::number_integer:
13172 case value_t::number_unsigned:
13173 case value_t::number_float:
13175 case value_t::discarded:
13183 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13196 switch (m_object->m_data.m_type)
13198 case value_t::object:
13200 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13201 return &(m_it.object_iterator->second);
13204 case value_t::array:
13206 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13207 return &*m_it.array_iterator;
13210 case value_t::null:
13211 case value_t::string:
13212 case value_t::boolean:
13213 case value_t::number_integer:
13214 case value_t::number_unsigned:
13215 case value_t::number_float:
13217 case value_t::discarded:
13225 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13236 auto result = *
this;
13249 switch (m_object->m_data.m_type)
13251 case value_t::object:
13253 std::advance(m_it.object_iterator, 1);
13257 case value_t::array:
13259 std::advance(m_it.array_iterator, 1);
13263 case value_t::null:
13264 case value_t::string:
13265 case value_t::boolean:
13266 case value_t::number_integer:
13267 case value_t::number_unsigned:
13268 case value_t::number_float:
13270 case value_t::discarded:
13273 ++m_it.primitive_iterator;
13287 auto result = *
this;
13300 switch (m_object->m_data.m_type)
13302 case value_t::object:
13304 std::advance(m_it.object_iterator, -1);
13308 case value_t::array:
13310 std::advance(m_it.array_iterator, -1);
13314 case value_t::null:
13315 case value_t::string:
13316 case value_t::boolean:
13317 case value_t::number_integer:
13318 case value_t::number_unsigned:
13319 case value_t::number_float:
13321 case value_t::discarded:
13324 --m_it.primitive_iterator;
13336 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 >
13342 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13347 switch (m_object->m_data.m_type)
13349 case value_t::object:
13350 return (m_it.object_iterator == other.m_it.object_iterator);
13352 case value_t::array:
13353 return (m_it.array_iterator == other.m_it.array_iterator);
13355 case value_t::null:
13356 case value_t::string:
13357 case value_t::boolean:
13358 case value_t::number_integer:
13359 case value_t::number_unsigned:
13360 case value_t::number_float:
13362 case value_t::discarded:
13364 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
13372 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 >
13387 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13392 switch (m_object->m_data.m_type)
13394 case value_t::object:
13395 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
13397 case value_t::array:
13400 case value_t::null:
13401 case value_t::string:
13402 case value_t::boolean:
13403 case value_t::number_integer:
13404 case value_t::number_unsigned:
13405 case value_t::number_float:
13407 case value_t::discarded:
13419 return !other.operator < (*this);
13448 switch (m_object->m_data.m_type)
13450 case value_t::object:
13451 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13453 case value_t::array:
13455 std::advance(m_it.array_iterator, i);
13459 case value_t::null:
13460 case value_t::string:
13461 case value_t::boolean:
13462 case value_t::number_integer:
13463 case value_t::number_unsigned:
13464 case value_t::number_float:
13466 case value_t::discarded:
13469 m_it.primitive_iterator += i;
13483 return operator+=(-i);
13492 auto result = *
this;
13514 auto result = *
this;
13527 switch (m_object->m_data.m_type)
13529 case value_t::object:
13530 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13532 case value_t::array:
13535 case value_t::null:
13536 case value_t::string:
13537 case value_t::boolean:
13538 case value_t::number_integer:
13539 case value_t::number_unsigned:
13540 case value_t::number_float:
13542 case value_t::discarded:
13556 switch (m_object->m_data.m_type)
13558 case value_t::object:
13559 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
13561 case value_t::array:
13562 return *std::next(m_it.array_iterator,
n);
13564 case value_t::null:
13565 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13567 case value_t::string:
13568 case value_t::boolean:
13569 case value_t::number_integer:
13570 case value_t::number_unsigned:
13571 case value_t::number_float:
13573 case value_t::discarded:
13581 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13590 const typename object_t::key_type&
key()
const
13596 return m_it.object_iterator->first;
13599 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
13608 return operator*();
13635 #include <iterator>
13667 template<
typename Base>
13741 auto it = --this->base();
13748 auto it = --this->base();
13749 return it.operator * ();
13769 #include <type_traits>
13811 #include <algorithm>
13817 #endif // JSON_NO_IO
13839 template<
typename RefStringType>
13849 template<
typename T>
13868 : reference_tokens(split(s))
13875 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13879 return detail::concat(a,
'/', detail::escape(b));
13905 reference_tokens.insert(reference_tokens.end(),
13915 push_back(std::move(
token));
13971 reference_tokens.pop_back();
13983 return reference_tokens.back();
13990 reference_tokens.push_back(
token);
13997 reference_tokens.push_back(std::move(
token));
14004 return reference_tokens.empty();
14018 template<
typename BasicJsonType>
14021 using size_type =
typename BasicJsonType::size_type;
14035 const char*
p = s.c_str();
14036 char* p_end =
nullptr;
14038 const unsigned long long res = std::strtoull(
p, &p_end, 10);
14048 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14053 return static_cast<size_type
>(res);
14078 template<
typename BasicJsonType>
14085 for (
const auto& reference_token : reference_tokens)
14087 switch (result->type())
14091 if (reference_token ==
"0")
14094 result = &result->operator[](0);
14099 result = &result->operator[](reference_token);
14107 result = &result->operator[](reference_token);
14114 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14158 template<
typename BasicJsonType>
14161 for (
const auto& reference_token : reference_tokens)
14164 if (ptr->is_null())
14168 std::all_of(reference_token.begin(), reference_token.end(),
14169 [](
const unsigned char x)
14171 return std::isdigit(x);
14175 *ptr = (nums || reference_token ==
"-")
14180 switch (ptr->type())
14185 ptr = &ptr->operator[](reference_token);
14191 if (reference_token ==
"-")
14194 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14199 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14226 template<
typename BasicJsonType>
14229 for (
const auto& reference_token : reference_tokens)
14231 switch (ptr->type())
14236 ptr = &ptr->at(reference_token);
14246 "array index '-' (",
std::to_string(ptr->m_data.m_value.array->size()),
14247 ") is out of range"), ptr));
14251 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14284 template<
typename BasicJsonType>
14287 for (
const auto& reference_token : reference_tokens)
14289 switch (ptr->type())
14294 ptr = &ptr->operator[](reference_token);
14307 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14333 template<
typename BasicJsonType>
14336 for (
const auto& reference_token : reference_tokens)
14338 switch (ptr->type())
14343 ptr = &ptr->at(reference_token);
14353 "array index '-' (",
std::to_string(ptr->m_data.m_value.array->size()),
14354 ") is out of range"), ptr));
14358 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14382 template<
typename BasicJsonType>
14385 for (
const auto& reference_token : reference_tokens)
14387 switch (ptr->type())
14391 if (!ptr->contains(reference_token))
14397 ptr = &ptr->operator[](reference_token);
14408 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14420 for (std::size_t i = 1; i < reference_token.size(); i++)
14430 const auto idx = array_index<BasicJsonType>(reference_token);
14431 if (idx >= ptr->size())
14437 ptr = &ptr->operator[](idx);
14473 std::vector<string_t> result;
14476 if (reference_string.empty())
14492 std::size_t slash = reference_string.find_first_of(
'/', 1),
14499 start = (slash == string_t::npos) ? 0 : slash + 1,
14501 slash = reference_string.find_first_of(
'/', start))
14505 auto reference_token = reference_string.substr(start, slash - start);
14508 for (std::size_t pos = reference_token.find_first_of(
'~');
14509 pos != string_t::npos;
14510 pos = reference_token.find_first_of(
'~', pos + 1))
14516 (reference_token[pos + 1] !=
'0' &&
14517 reference_token[pos + 1] !=
'1')))
14525 result.push_back(reference_token);
14539 template<
typename BasicJsonType>
14541 const BasicJsonType&
value,
14542 BasicJsonType& result)
14544 switch (
value.type())
14548 if (
value.m_data.m_value.array->empty())
14551 result[reference_string] =
nullptr;
14556 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
14559 value.m_data.m_value.array->operator[](i), result);
14567 if (
value.m_data.m_value.object->empty())
14570 result[reference_string] =
nullptr;
14575 for (
const auto& element : *
value.m_data.m_value.object)
14594 result[reference_string] =
value;
14610 template<
typename BasicJsonType>
14611 static BasicJsonType
14619 BasicJsonType result;
14622 for (
const auto& element : *
value.m_data.m_value.object)
14655 #if JSON_HAS_THREE_WAY_COMPARISON
14656 template<
typename RefStringTypeRhs>
14661 return reference_tokens == rhs.reference_tokens;
14673 template<
typename RefStringTypeRhs>
14676 return reference_tokens <=> rhs.reference_tokens;
14679 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14688 template<
typename RefStringTypeLhs,
typename StringType>
14691 const StringType& rhs);
14695 template<
typename RefStringTypeRhs,
typename StringType>
14697 friend bool operator==(
const StringType& lhs,
14702 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14709 template<
typename RefStringTypeLhs,
typename StringType>
14712 const StringType& rhs);
14716 template<
typename RefStringTypeRhs,
typename StringType>
14718 friend bool operator!=(
const StringType& lhs,
14722 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14733 #if !JSON_HAS_THREE_WAY_COMPARISON
14735 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14739 return lhs.reference_tokens == rhs.reference_tokens;
14742 template<
typename RefStringTypeLhs,
14746 const StringType& rhs)
14751 template<
typename RefStringTypeRhs,
14754 inline
bool operator==(const StringType& lhs,
14760 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14764 return !(lhs == rhs);
14767 template<
typename RefStringTypeLhs,
14771 const StringType& rhs)
14773 return !(lhs == rhs);
14776 template<
typename RefStringTypeRhs,
14779 inline
bool operator!=(const StringType& lhs,
14782 return !(lhs == rhs);
14785 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14789 return lhs.reference_tokens < rhs.reference_tokens;
14806 #include <initializer_list>
14818 template<
typename BasicJsonType>
14829 : value_ref(&
value)
14833 : owned_value(init)
14852 if (value_ref ==
nullptr)
14854 return std::move(owned_value);
14861 return value_ref ? *value_ref : owned_value;
14898 #include <algorithm>
14924 #include <algorithm>
14926 #include <iterator>
14934 #endif // JSON_NO_IO
14946 virtual void write_character(CharType c) = 0;
14947 virtual void write_characters(
const CharType* s, std::size_t length) = 0;
14958 template<
typename CharType>
14962 template<
typename CharType,
typename AllocatorType = std::allocator<CharType>>
14976 void write_characters(const CharType* s,
std::
size_t length)
override
14978 v.insert(v.end(), s, s + length);
14982 std::vector<CharType, AllocatorType>&
v;
14986 template<
typename CharType>
15001 void write_characters(const CharType* s,
std::
size_t length)
override
15003 stream.write(s,
static_cast<std::streamsize
>(length));
15009 #endif // JSON_NO_IO
15012 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15026 void write_characters(const CharType* s,
std::
size_t length)
override
15028 str.append(s, length);
15035 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15039 template<
typename AllocatorType = std::allocator<CharType>>
15046 #endif // JSON_NO_IO
15077 template<
typename BasicJsonType,
typename CharType>
15103 case value_t::object:
15105 write_bson_object(*j.m_data.m_value.object);
15109 case value_t::null:
15110 case value_t::array:
15111 case value_t::string:
15112 case value_t::boolean:
15113 case value_t::number_integer:
15114 case value_t::number_unsigned:
15115 case value_t::number_float:
15117 case value_t::discarded:
15120 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15132 case value_t::null:
15134 oa->write_character(to_char_type(0xF6));
15138 case value_t::boolean:
15140 oa->write_character(j.m_data.m_value.boolean
15141 ? to_char_type(0xF5)
15142 : to_char_type(0xF4));
15146 case value_t::number_integer:
15148 if (j.m_data.m_value.number_integer >= 0)
15153 if (j.m_data.m_value.number_integer <= 0x17)
15155 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15157 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15159 oa->write_character(to_char_type(0x18));
15160 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15162 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15164 oa->write_character(to_char_type(0x19));
15165 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15167 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15169 oa->write_character(to_char_type(0x1A));
15170 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15174 oa->write_character(to_char_type(0x1B));
15175 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15182 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15183 if (j.m_data.m_value.number_integer >= -24)
15185 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15187 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15189 oa->write_character(to_char_type(0x38));
15190 write_number(
static_cast<std::uint8_t
>(positive_number));
15192 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15194 oa->write_character(to_char_type(0x39));
15195 write_number(
static_cast<std::uint16_t
>(positive_number));
15197 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15199 oa->write_character(to_char_type(0x3A));
15200 write_number(
static_cast<std::uint32_t
>(positive_number));
15204 oa->write_character(to_char_type(0x3B));
15205 write_number(
static_cast<std::uint64_t
>(positive_number));
15211 case value_t::number_unsigned:
15213 if (j.m_data.m_value.number_unsigned <= 0x17)
15215 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15217 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15219 oa->write_character(to_char_type(0x18));
15220 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15222 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15224 oa->write_character(to_char_type(0x19));
15225 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
15227 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15229 oa->write_character(to_char_type(0x1A));
15230 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
15234 oa->write_character(to_char_type(0x1B));
15235 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
15240 case value_t::number_float:
15242 if (std::isnan(j.m_data.m_value.number_float))
15245 oa->write_character(to_char_type(0xF9));
15246 oa->write_character(to_char_type(0x7E));
15247 oa->write_character(to_char_type(0x00));
15249 else if (std::isinf(j.m_data.m_value.number_float))
15252 oa->write_character(to_char_type(0xf9));
15253 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15254 oa->write_character(to_char_type(0x00));
15263 case value_t::string:
15266 const auto N = j.m_data.m_value.string->size();
15269 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15271 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15273 oa->write_character(to_char_type(0x78));
15274 write_number(
static_cast<std::uint8_t
>(N));
15276 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15278 oa->write_character(to_char_type(0x79));
15279 write_number(
static_cast<std::uint16_t
>(N));
15281 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15283 oa->write_character(to_char_type(0x7A));
15284 write_number(
static_cast<std::uint32_t
>(N));
15287 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15289 oa->write_character(to_char_type(0x7B));
15290 write_number(
static_cast<std::uint64_t
>(N));
15295 oa->write_characters(
15296 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15297 j.m_data.m_value.string->size());
15301 case value_t::array:
15304 const auto N = j.m_data.m_value.array->size();
15307 write_number(
static_cast<std::uint8_t
>(0x80 + N));
15309 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15311 oa->write_character(to_char_type(0x98));
15312 write_number(
static_cast<std::uint8_t
>(N));
15314 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15316 oa->write_character(to_char_type(0x99));
15317 write_number(
static_cast<std::uint16_t
>(N));
15319 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15321 oa->write_character(to_char_type(0x9A));
15322 write_number(
static_cast<std::uint32_t
>(N));
15325 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15327 oa->write_character(to_char_type(0x9B));
15328 write_number(
static_cast<std::uint64_t
>(N));
15333 for (
const auto& el : *j.m_data.m_value.array)
15342 if (j.m_data.m_value.binary->has_subtype())
15344 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15346 write_number(
static_cast<std::uint8_t
>(0xd8));
15347 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
15349 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15351 write_number(
static_cast<std::uint8_t
>(0xd9));
15352 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
15354 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15356 write_number(
static_cast<std::uint8_t
>(0xda));
15357 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
15359 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15361 write_number(
static_cast<std::uint8_t
>(0xdb));
15362 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
15367 const auto N = j.m_data.m_value.binary->size();
15370 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15372 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15374 oa->write_character(to_char_type(0x58));
15375 write_number(
static_cast<std::uint8_t
>(N));
15377 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15379 oa->write_character(to_char_type(0x59));
15380 write_number(
static_cast<std::uint16_t
>(N));
15382 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15384 oa->write_character(to_char_type(0x5A));
15385 write_number(
static_cast<std::uint32_t
>(N));
15388 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15390 oa->write_character(to_char_type(0x5B));
15391 write_number(
static_cast<std::uint64_t
>(N));
15396 oa->write_characters(
15397 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15403 case value_t::object:
15406 const auto N = j.m_data.m_value.object->size();
15409 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15411 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15413 oa->write_character(to_char_type(0xB8));
15414 write_number(
static_cast<std::uint8_t
>(N));
15416 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15418 oa->write_character(to_char_type(0xB9));
15419 write_number(
static_cast<std::uint16_t
>(N));
15421 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15423 oa->write_character(to_char_type(0xBA));
15424 write_number(
static_cast<std::uint32_t
>(N));
15427 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15429 oa->write_character(to_char_type(0xBB));
15430 write_number(
static_cast<std::uint64_t
>(N));
15435 for (
const auto& el : *j.m_data.m_value.object)
15437 write_cbor(el.first);
15438 write_cbor(el.second);
15443 case value_t::discarded:
15456 case value_t::null:
15458 oa->write_character(to_char_type(0xC0));
15462 case value_t::boolean:
15464 oa->write_character(j.m_data.m_value.boolean
15465 ? to_char_type(0xC3)
15466 : to_char_type(0xC2));
15470 case value_t::number_integer:
15472 if (j.m_data.m_value.number_integer >= 0)
15477 if (j.m_data.m_value.number_unsigned < 128)
15480 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15482 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15485 oa->write_character(to_char_type(0xCC));
15486 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15488 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15491 oa->write_character(to_char_type(0xCD));
15492 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15494 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15497 oa->write_character(to_char_type(0xCE));
15498 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15500 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15503 oa->write_character(to_char_type(0xCF));
15504 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15509 if (j.m_data.m_value.number_integer >= -32)
15512 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15514 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15515 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15518 oa->write_character(to_char_type(0xD0));
15519 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15521 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15522 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15525 oa->write_character(to_char_type(0xD1));
15526 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
15528 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15529 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15532 oa->write_character(to_char_type(0xD2));
15533 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
15535 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15536 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15539 oa->write_character(to_char_type(0xD3));
15540 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
15546 case value_t::number_unsigned:
15548 if (j.m_data.m_value.number_unsigned < 128)
15551 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15553 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15556 oa->write_character(to_char_type(0xCC));
15557 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15559 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15562 oa->write_character(to_char_type(0xCD));
15563 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15565 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15568 oa->write_character(to_char_type(0xCE));
15569 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15571 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15574 oa->write_character(to_char_type(0xCF));
15575 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15580 case value_t::number_float:
15586 case value_t::string:
15589 const auto N = j.m_data.m_value.string->size();
15593 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15595 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15598 oa->write_character(to_char_type(0xD9));
15599 write_number(
static_cast<std::uint8_t
>(N));
15601 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15604 oa->write_character(to_char_type(0xDA));
15605 write_number(
static_cast<std::uint16_t
>(N));
15607 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15610 oa->write_character(to_char_type(0xDB));
15611 write_number(
static_cast<std::uint32_t
>(N));
15615 oa->write_characters(
15616 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15617 j.m_data.m_value.string->size());
15621 case value_t::array:
15624 const auto N = j.m_data.m_value.array->size();
15628 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15630 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15633 oa->write_character(to_char_type(0xDC));
15634 write_number(
static_cast<std::uint16_t
>(N));
15636 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15639 oa->write_character(to_char_type(0xDD));
15640 write_number(
static_cast<std::uint32_t
>(N));
15644 for (
const auto& el : *j.m_data.m_value.array)
15655 const bool use_ext = j.m_data.m_value.binary->has_subtype();
15658 const auto N = j.m_data.m_value.binary->size();
15659 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15661 std::uint8_t output_type{};
15668 output_type = 0xD4;
15671 output_type = 0xD5;
15674 output_type = 0xD6;
15677 output_type = 0xD7;
15680 output_type = 0xD8;
15683 output_type = 0xC7;
15691 output_type = 0xC4;
15695 oa->write_character(to_char_type(output_type));
15698 write_number(
static_cast<std::uint8_t
>(N));
15701 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15703 const std::uint8_t output_type = use_ext
15707 oa->write_character(to_char_type(output_type));
15708 write_number(
static_cast<std::uint16_t
>(N));
15710 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15712 const std::uint8_t output_type = use_ext
15716 oa->write_character(to_char_type(output_type));
15717 write_number(
static_cast<std::uint32_t
>(N));
15723 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
15727 oa->write_characters(
15728 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15734 case value_t::object:
15737 const auto N = j.m_data.m_value.object->size();
15741 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15743 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15746 oa->write_character(to_char_type(0xDE));
15747 write_number(
static_cast<std::uint16_t
>(N));
15749 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15752 oa->write_character(to_char_type(0xDF));
15753 write_number(
static_cast<std::uint32_t
>(N));
15757 for (
const auto& el : *j.m_data.m_value.object)
15759 write_msgpack(el.first);
15760 write_msgpack(el.second);
15765 case value_t::discarded:
15779 const bool use_type,
const bool add_prefix =
true,
15780 const bool use_bjdata =
false)
15784 case value_t::null:
15788 oa->write_character(to_char_type(
'Z'));
15793 case value_t::boolean:
15797 oa->write_character(j.m_data.m_value.boolean
15798 ? to_char_type(
'T')
15799 : to_char_type(
'F'));
15804 case value_t::number_integer:
15806 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
15810 case value_t::number_unsigned:
15812 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
15816 case value_t::number_float:
15818 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
15822 case value_t::string:
15826 oa->write_character(to_char_type(
'S'));
15828 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
15829 oa->write_characters(
15830 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15831 j.m_data.m_value.string->size());
15835 case value_t::array:
15839 oa->write_character(to_char_type(
'['));
15842 bool prefix_required =
true;
15843 if (use_type && !j.m_data.m_value.array->empty())
15846 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15847 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15848 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15850 return ubjson_prefix(v, use_bjdata) == first_prefix;
15853 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15855 if (same_prefix && !(use_bjdata &&
std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15857 prefix_required =
false;
15858 oa->write_character(to_char_type(
'$'));
15859 oa->write_character(first_prefix);
15865 oa->write_character(to_char_type(
'#'));
15866 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
15869 for (
const auto& el : *j.m_data.m_value.array)
15871 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15876 oa->write_character(to_char_type(
']'));
15886 oa->write_character(to_char_type(
'['));
15889 if (use_type && !j.m_data.m_value.binary->empty())
15892 oa->write_character(to_char_type(
'$'));
15893 oa->write_character(
'U');
15898 oa->write_character(to_char_type(
'#'));
15899 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
15904 oa->write_characters(
15905 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15906 j.m_data.m_value.binary->size());
15910 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
15912 oa->write_character(to_char_type(
'U'));
15913 oa->write_character(j.m_data.m_value.binary->data()[i]);
15919 oa->write_character(to_char_type(
']'));
15925 case value_t::object:
15927 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
15929 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type))
15937 oa->write_character(to_char_type(
'{'));
15940 bool prefix_required =
true;
15941 if (use_type && !j.m_data.m_value.object->empty())
15944 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15945 const bool same_prefix = std::all_of(j.begin(), j.end(),
15946 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15948 return ubjson_prefix(v, use_bjdata) == first_prefix;
15951 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15953 if (same_prefix && !(use_bjdata &&
std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15955 prefix_required =
false;
15956 oa->write_character(to_char_type(
'$'));
15957 oa->write_character(first_prefix);
15963 oa->write_character(to_char_type(
'#'));
15964 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
15967 for (
const auto& el : *j.m_data.m_value.object)
15969 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15970 oa->write_characters(
15971 reinterpret_cast<const CharType*
>(el.first.c_str()),
15973 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15978 oa->write_character(to_char_type(
'}'));
15984 case value_t::discarded:
16001 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16005 static_cast<void>(j);
16008 return 1ul + name.size() + 1u;
16015 const std::uint8_t element_type)
16017 oa->write_character(to_char_type(element_type));
16018 oa->write_characters(
16019 reinterpret_cast<const CharType*
>(name.c_str()),
16029 write_bson_entry_header(name, 0x08);
16030 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
16037 const double value)
16039 write_bson_entry_header(name, 0x01);
16040 write_number<double>(
value,
true);
16048 return sizeof(std::int32_t) +
value.size() + 1ul;
16057 write_bson_entry_header(name, 0x02);
16059 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16060 oa->write_characters(
16061 reinterpret_cast<const CharType*
>(
value.c_str()),
16070 write_bson_entry_header(name, 0x0A);
16078 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
16079 ?
sizeof(std::int32_t)
16080 :
sizeof(std::int64_t);
16087 const std::int64_t
value)
16089 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
16091 write_bson_entry_header(name, 0x10);
16092 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
16096 write_bson_entry_header(name, 0x12);
16097 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
16106 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16107 ?
sizeof(std::int32_t)
16108 :
sizeof(std::int64_t);
16115 const BasicJsonType& j)
16117 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16119 write_bson_entry_header(name, 0x10 );
16120 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16122 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16124 write_bson_entry_header(name, 0x12 );
16125 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16129 JSON_THROW(out_of_range::create(407,
concat(
"integer number ",
std::to_string(j.m_data.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
16137 const typename BasicJsonType::object_t&
value)
16139 write_bson_entry_header(name, 0x03);
16140 write_bson_object(
value);
16148 std::size_t array_index = 0ul;
16150 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)
16152 return result + calc_bson_element_size(
std::to_string(array_index++), el);
16155 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16163 return sizeof(std::int32_t) +
value.size() + 1ul;
16170 const typename BasicJsonType::array_t&
value)
16172 write_bson_entry_header(name, 0x04);
16173 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
16175 std::size_t array_index = 0ul;
16177 for (
const auto& el :
value)
16182 oa->write_character(to_char_type(0x00));
16191 write_bson_entry_header(name, 0x05);
16193 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16194 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16196 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16204 const BasicJsonType& j)
16206 const auto header_size = calc_bson_entry_header_size(name, j);
16209 case value_t::object:
16210 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16212 case value_t::array:
16213 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
16216 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
16218 case value_t::boolean:
16219 return header_size + 1ul;
16221 case value_t::number_float:
16222 return header_size + 8ul;
16224 case value_t::number_integer:
16225 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
16227 case value_t::number_unsigned:
16228 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
16230 case value_t::string:
16231 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
16233 case value_t::null:
16234 return header_size + 0ul;
16237 case value_t::discarded:
16252 const BasicJsonType& j)
16256 case value_t::object:
16257 return write_bson_object_entry(name, *j.m_data.m_value.object);
16259 case value_t::array:
16260 return write_bson_array(name, *j.m_data.m_value.array);
16263 return write_bson_binary(name, *j.m_data.m_value.binary);
16265 case value_t::boolean:
16266 return write_bson_boolean(name, j.m_data.m_value.boolean);
16268 case value_t::number_float:
16269 return write_bson_double(name, j.m_data.m_value.number_float);
16271 case value_t::number_integer:
16272 return write_bson_integer(name, j.m_data.m_value.number_integer);
16274 case value_t::number_unsigned:
16275 return write_bson_unsigned(name, j);
16277 case value_t::string:
16278 return write_bson_string(name, *j.m_data.m_value.string);
16280 case value_t::null:
16281 return write_bson_null(name);
16284 case value_t::discarded:
16300 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
16301 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
16303 return result += calc_bson_element_size(el.first, el.second);
16306 return sizeof(std::int32_t) + document_size + 1ul;
16315 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
16317 for (
const auto& el :
value)
16319 write_bson_element(el.first, el.second);
16322 oa->write_character(to_char_type(0x00));
16331 return to_char_type(0xFA);
16336 return to_char_type(0xFB);
16345 return to_char_type(0xCA);
16350 return to_char_type(0xCB);
16361 const bool add_prefix,
16362 const bool use_bjdata)
16366 oa->write_character(get_ubjson_float_prefix(
n));
16368 write_number(
n, use_bjdata);
16375 const bool add_prefix,
16376 const bool use_bjdata)
16378 if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16382 oa->write_character(to_char_type(
'i'));
16384 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
16386 else if (
n <= (std::numeric_limits<std::uint8_t>::max)())
16390 oa->write_character(to_char_type(
'U'));
16392 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
16394 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16398 oa->write_character(to_char_type(
'I'));
16400 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
16402 else if (use_bjdata &&
n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
16406 oa->write_character(to_char_type(
'u'));
16408 write_number(
static_cast<std::uint16_t
>(
n), use_bjdata);
16410 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16414 oa->write_character(to_char_type(
'l'));
16416 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
16418 else if (use_bjdata &&
n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
16422 oa->write_character(to_char_type(
'm'));
16424 write_number(
static_cast<std::uint32_t
>(
n), use_bjdata);
16426 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16430 oa->write_character(to_char_type(
'L'));
16432 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
16434 else if (use_bjdata &&
n <= (std::numeric_limits<uint64_t>::max)())
16438 oa->write_character(to_char_type(
'M'));
16440 write_number(
static_cast<std::uint64_t
>(
n), use_bjdata);
16446 oa->write_character(to_char_type(
'H'));
16449 const auto number = BasicJsonType(
n).dump();
16450 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16451 for (std::size_t i = 0; i < number.size(); ++i)
16453 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16463 const bool add_prefix,
16464 const bool use_bjdata)
16466 if ((std::numeric_limits<std::int8_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int8_t>::max)())
16470 oa->write_character(to_char_type(
'i'));
16472 write_number(
static_cast<std::int8_t
>(
n), use_bjdata);
16474 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)()))
16478 oa->write_character(to_char_type(
'U'));
16480 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
16482 else if ((std::numeric_limits<std::int16_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int16_t>::max)())
16486 oa->write_character(to_char_type(
'I'));
16488 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
16490 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)())))
16494 oa->write_character(to_char_type(
'u'));
16496 write_number(
static_cast<uint16_t
>(
n), use_bjdata);
16498 else if ((std::numeric_limits<std::int32_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int32_t>::max)())
16502 oa->write_character(to_char_type(
'l'));
16504 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
16506 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)())))
16510 oa->write_character(to_char_type(
'm'));
16512 write_number(
static_cast<uint32_t
>(
n), use_bjdata);
16514 else if ((std::numeric_limits<std::int64_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int64_t>::max)())
16518 oa->write_character(to_char_type(
'L'));
16520 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
16527 oa->write_character(to_char_type(
'H'));
16530 const auto number = BasicJsonType(
n).dump();
16531 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16532 for (std::size_t i = 0; i < number.size(); ++i)
16534 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16543 CharType
ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16547 case value_t::null:
16550 case value_t::boolean:
16551 return j.m_data.m_value.boolean ?
'T' :
'F';
16553 case value_t::number_integer:
16555 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16559 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16563 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16567 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
16571 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16575 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
16579 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16587 case value_t::number_unsigned:
16589 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16593 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16597 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16601 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16605 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16609 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16613 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16617 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16625 case value_t::number_float:
16626 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
16628 case value_t::string:
16631 case value_t::array:
16635 case value_t::object:
16638 case value_t::discarded:
16659 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16660 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16665 if (it == bjdtype.end())
16669 CharType dtype = it->second;
16671 key =
"_ArraySize_";
16672 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
16673 for (
const auto& el :
value.at(
key))
16675 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
16678 key =
"_ArrayData_";
16684 oa->write_character(
'[');
16685 oa->write_character(
'$');
16686 oa->write_character(dtype);
16687 oa->write_character(
'#');
16689 key =
"_ArraySize_";
16690 write_ubjson(
value.at(
key), use_count, use_type,
true,
true);
16692 key =
"_ArrayData_";
16693 if (dtype ==
'U' || dtype ==
'C')
16695 for (
const auto& el :
value.at(
key))
16697 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
16700 else if (dtype ==
'i')
16702 for (
const auto& el :
value.at(
key))
16704 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
16707 else if (dtype ==
'u')
16709 for (
const auto& el :
value.at(
key))
16711 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
16714 else if (dtype ==
'I')
16716 for (
const auto& el :
value.at(
key))
16718 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
16721 else if (dtype ==
'm')
16723 for (
const auto& el :
value.at(
key))
16725 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
16728 else if (dtype ==
'l')
16730 for (
const auto& el :
value.at(
key))
16732 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
16735 else if (dtype ==
'M')
16737 for (
const auto& el :
value.at(
key))
16739 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
16742 else if (dtype ==
'L')
16744 for (
const auto& el :
value.at(
key))
16746 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
16749 else if (dtype ==
'd')
16751 for (
const auto& el :
value.at(
key))
16753 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
16756 else if (dtype ==
'D')
16758 for (
const auto& el :
value.at(
key))
16760 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
16783 template<
typename NumberType>
16787 std::array<CharType,
sizeof(NumberType)> vec{};
16788 std::memcpy(vec.data(), &
n,
sizeof(NumberType));
16791 if (is_little_endian != OutputIsLittleEndian)
16794 std::reverse(vec.begin(), vec.end());
16797 oa->write_characters(vec.data(),
sizeof(NumberType));
16803 #pragma GCC diagnostic push
16804 #pragma GCC diagnostic ignored "-Wfloat-equal"
16806 if (
static_cast<double>(
n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16807 static_cast<double>(
n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16808 static_cast<double>(
static_cast<float>(
n)) ==
static_cast<double>(
n))
16811 ? get_cbor_float_prefix(
static_cast<float>(
n))
16812 : get_msgpack_float_prefix(
static_cast<float>(
n)));
16813 write_number(
static_cast<float>(
n));
16818 ? get_cbor_float_prefix(
n)
16819 : get_msgpack_float_prefix(
n));
16823 #pragma GCC diagnostic pop
16832 template <
typename C = CharType,
16836 return *
reinterpret_cast<char*
>(&x);
16839 template <
typename C = CharType,
16843 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16846 std::memcpy(&result, &x,
sizeof(x));
16850 template<
typename C = CharType,
16857 template <
typename InputCharType,
typename C = CharType,
16861 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
16893 #include <algorithm>
16903 #include <type_traits>
16923 #include <type_traits>
16951 namespace dtoa_impl
16954 template<
typename Target,
typename Source>
16957 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16960 std::memcpy(&target, &source,
sizeof(Source));
16966 static constexpr
int kPrecision = 64;
16971 constexpr
diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_), e(e_) {}
16982 return {x.f - y.f, x.e};
16991 static_assert(kPrecision == 64,
"internal error");
17016 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17017 const std::uint64_t u_hi = x.f >> 32u;
17018 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17019 const std::uint64_t v_hi = y.f >> 32u;
17021 const std::uint64_t p0 = u_lo * v_lo;
17022 const std::uint64_t p1 = u_lo * v_hi;
17023 const std::uint64_t p2 = u_hi * v_lo;
17024 const std::uint64_t p3 = u_hi * v_hi;
17026 const std::uint64_t p0_hi = p0 >> 32u;
17027 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17028 const std::uint64_t p1_hi = p1 >> 32u;
17029 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17030 const std::uint64_t p2_hi = p2 >> 32u;
17032 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17043 Q += std::uint64_t{1} << (64u - 32u - 1u);
17045 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17047 return {h, x.e + y.e + 64};
17058 while ((x.f >> 63u) == 0)
17073 const int delta = x.
e - target_exponent;
17078 return {x.f << delta, target_exponent};
17095 template<
typename FloatType>
17108 static_assert(std::numeric_limits<FloatType>::is_iec559,
17109 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17112 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17113 constexpr
int kMinExp = 1 - kBias;
17114 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17116 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17118 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
17119 const std::uint64_t E =
bits >> (kPrecision - 1);
17120 const std::uint64_t F =
bits & (kHiddenBit - 1);
17122 const bool is_denormal = E == 0;
17123 const diyfp v = is_denormal
17124 ?
diyfp(F, kMinExp)
17125 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17148 const bool lower_boundary_is_closer = F == 0 && E > 1;
17150 const diyfp m_minus = lower_boundary_is_closer
17151 ?
diyfp(4 * v.
f - 1, v.
e - 2)
17152 :
diyfp(2 * v.
f - 1, v.
e - 1);
17155 const diyfp w_plus = diyfp::normalize(m_plus);
17158 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
17160 return {diyfp::normalize(v), w_minus, w_plus};
17287 constexpr
int kCachedPowersMinDecExp = -300;
17288 constexpr
int kCachedPowersDecStep = 8;
17290 static constexpr std::array<cached_power, 79> kCachedPowers =
17293 { 0xAB70FE17C79AC6CA, -1060, -300 },
17294 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17295 { 0xBE5691EF416BD60C, -1007, -284 },
17296 { 0x8DD01FAD907FFC3C, -980, -276 },
17297 { 0xD3515C2831559A83, -954, -268 },
17298 { 0x9D71AC8FADA6C9B5, -927, -260 },
17299 { 0xEA9C227723EE8BCB, -901, -252 },
17300 { 0xAECC49914078536D, -874, -244 },
17301 { 0x823C12795DB6CE57, -847, -236 },
17302 { 0xC21094364DFB5637, -821, -228 },
17303 { 0x9096EA6F3848984F, -794, -220 },
17304 { 0xD77485CB25823AC7, -768, -212 },
17305 { 0xA086CFCD97BF97F4, -741, -204 },
17306 { 0xEF340A98172AACE5, -715, -196 },
17307 { 0xB23867FB2A35B28E, -688, -188 },
17308 { 0x84C8D4DFD2C63F3B, -661, -180 },
17309 { 0xC5DD44271AD3CDBA, -635, -172 },
17310 { 0x936B9FCEBB25C996, -608, -164 },
17311 { 0xDBAC6C247D62A584, -582, -156 },
17312 { 0xA3AB66580D5FDAF6, -555, -148 },
17313 { 0xF3E2F893DEC3F126, -529, -140 },
17314 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17315 { 0x87625F056C7C4A8B, -475, -124 },
17316 { 0xC9BCFF6034C13053, -449, -116 },
17317 { 0x964E858C91BA2655, -422, -108 },
17318 { 0xDFF9772470297EBD, -396, -100 },
17319 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17320 { 0xF8A95FCF88747D94, -343, -84 },
17321 { 0xB94470938FA89BCF, -316, -76 },
17322 { 0x8A08F0F8BF0F156B, -289, -68 },
17323 { 0xCDB02555653131B6, -263, -60 },
17324 { 0x993FE2C6D07B7FAC, -236, -52 },
17325 { 0xE45C10C42A2B3B06, -210, -44 },
17326 { 0xAA242499697392D3, -183, -36 },
17327 { 0xFD87B5F28300CA0E, -157, -28 },
17328 { 0xBCE5086492111AEB, -130, -20 },
17329 { 0x8CBCCC096F5088CC, -103, -12 },
17330 { 0xD1B71758E219652C, -77, -4 },
17331 { 0x9C40000000000000, -50, 4 },
17332 { 0xE8D4A51000000000, -24, 12 },
17333 { 0xAD78EBC5AC620000, 3, 20 },
17334 { 0x813F3978F8940984, 30, 28 },
17335 { 0xC097CE7BC90715B3, 56, 36 },
17336 { 0x8F7E32CE7BEA5C70, 83, 44 },
17337 { 0xD5D238A4ABE98068, 109, 52 },
17338 { 0x9F4F2726179A2245, 136, 60 },
17339 { 0xED63A231D4C4FB27, 162, 68 },
17340 { 0xB0DE65388CC8ADA8, 189, 76 },
17341 { 0x83C7088E1AAB65DB, 216, 84 },
17342 { 0xC45D1DF942711D9A, 242, 92 },
17343 { 0x924D692CA61BE758, 269, 100 },
17344 { 0xDA01EE641A708DEA, 295, 108 },
17345 { 0xA26DA3999AEF774A, 322, 116 },
17346 { 0xF209787BB47D6B85, 348, 124 },
17347 { 0xB454E4A179DD1877, 375, 132 },
17348 { 0x865B86925B9BC5C2, 402, 140 },
17349 { 0xC83553C5C8965D3D, 428, 148 },
17350 { 0x952AB45CFA97A0B3, 455, 156 },
17351 { 0xDE469FBD99A05FE3, 481, 164 },
17352 { 0xA59BC234DB398C25, 508, 172 },
17353 { 0xF6C69A72A3989F5C, 534, 180 },
17354 { 0xB7DCBF5354E9BECE, 561, 188 },
17355 { 0x88FCF317F22241E2, 588, 196 },
17356 { 0xCC20CE9BD35C78A5, 614, 204 },
17357 { 0x98165AF37B2153DF, 641, 212 },
17358 { 0xE2A0B5DC971F303A, 667, 220 },
17359 { 0xA8D9D1535CE3B396, 694, 228 },
17360 { 0xFB9B7CD9A4A7443C, 720, 236 },
17361 { 0xBB764C4CA7A44410, 747, 244 },
17362 { 0x8BAB8EEFB6409C1A, 774, 252 },
17363 { 0xD01FEF10A657842C, 800, 260 },
17364 { 0x9B10A4E5E9913129, 827, 268 },
17365 { 0xE7109BFBA19C0C9D, 853, 276 },
17366 { 0xAC2820D9623BF429, 880, 284 },
17367 { 0x80444B5E7AA7CF85, 907, 292 },
17368 { 0xBF21E44003ACDD2D, 933, 300 },
17369 { 0x8E679C2F5E44FF8F, 960, 308 },
17370 { 0xD433179D9C8CB841, 986, 316 },
17371 { 0x9E19DB92B4E31BA9, 1013, 324 },
17381 const int f =
kAlpha - e - 1;
17382 const int k = (
f * 78913) / (1 << 18) +
static_cast<int>(
f > 0);
17384 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17386 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
17388 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
17402 if (
n >= 1000000000)
17404 pow10 = 1000000000;
17408 if (
n >= 100000000)
17453 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17454 std::uint64_t rest, std::uint64_t ten_k)
17481 && delta - rest >= ten_k
17482 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17497 static_assert(
kAlpha >= -60,
"internal error");
17498 static_assert(
kGamma <= -32,
"internal error");
17515 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
17516 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
17525 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
17527 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
17528 std::uint64_t p2 = M_plus.
f & (one.f - 1);
17536 std::uint32_t pow10{};
17564 const std::uint32_t d = p1 / pow10;
17565 const std::uint32_t r = p1 % pow10;
17571 buffer[length++] =
static_cast<char>(
'0' + d);
17590 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17595 decimal_exponent +=
n;
17606 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17668 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17670 const std::uint64_t d = p2 >> -one.e;
17671 const std::uint64_t r = p2 & (one.f - 1);
17678 buffer[length++] =
static_cast<char>(
'0' + d);
17703 decimal_exponent -= m;
17711 const std::uint64_t ten_m = one.f;
17735 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17752 const diyfp c_minus_k(cached.
f, cached.
e);
17755 const diyfp w = diyfp::mul(v, c_minus_k);
17756 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
17757 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
17780 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17781 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
17783 decimal_exponent = -cached.
k;
17793 template<
typename FloatType>
17798 "internal error: not enough precision");
17819 #if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if)
17850 auto k =
static_cast<std::uint32_t
>(e);
17856 *buf++ =
static_cast<char>(
'0' + k);
17860 *buf++ =
static_cast<char>(
'0' + k / 10);
17862 *buf++ =
static_cast<char>(
'0' + k);
17866 *buf++ =
static_cast<char>(
'0' + k / 100);
17868 *buf++ =
static_cast<char>(
'0' + k / 10);
17870 *buf++ =
static_cast<char>(
'0' + k);
17888 int min_exp,
int max_exp)
17894 const int n = len + decimal_exponent;
17900 if (k <=
n &&
n <= max_exp)
17905 std::memset(buf + k,
'0',
static_cast<size_t>(
n) -
static_cast<size_t>(k));
17909 return buf + (
static_cast<size_t>(
n) + 2);
17912 if (0 <
n &&
n <= max_exp)
17919 std::memmove(buf + (
static_cast<size_t>(
n) + 1), buf +
n,
static_cast<size_t>(k) -
static_cast<size_t>(
n));
17921 return buf + (
static_cast<size_t>(k) + 1U);
17924 if (min_exp <
n &&
n <= 0)
17929 std::memmove(buf + (2 +
static_cast<size_t>(-
n)), buf,
static_cast<size_t>(k));
17932 std::memset(buf + 2,
'0',
static_cast<size_t>(-
n));
17933 return buf + (2U +
static_cast<size_t>(-
n) +
static_cast<size_t>(k));
17948 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17950 buf += 1 +
static_cast<size_t>(k);
17969 template<
typename FloatType>
17974 static_cast<void>(last);
17978 if (std::signbit(
value))
17985 #pragma GCC diagnostic push
17986 #pragma GCC diagnostic ignored "-Wfloat-equal"
17997 #pragma GCC diagnostic pop
18000 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18007 int decimal_exponent = 0;
18010 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18013 constexpr
int kMinExp = -4;
18015 constexpr
int kMaxExp = std::numeric_limits<FloatType>::digits10;
18018 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18019 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18058 template<
typename BasicJsonType>
18066 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18067 static constexpr std::uint8_t UTF8_REJECT = 1;
18078 , loc(
std::localeconv())
18079 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->thousands_sep)))
18080 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->decimal_point)))
18081 , indent_char(ichar)
18082 , indent_string(512, indent_char)
18083 , error_handler(error_handler_)
18116 const bool pretty_print,
18117 const bool ensure_ascii,
18118 const unsigned int indent_step,
18119 const unsigned int current_indent = 0)
18121 switch (val.m_data.m_type)
18123 case value_t::object:
18125 if (val.m_data.m_value.object->empty())
18127 o->write_characters(
"{}", 2);
18133 o->write_characters(
"{\n", 2);
18136 const auto new_indent = current_indent + indent_step;
18139 indent_string.resize(indent_string.size() * 2,
' ');
18143 auto i = val.m_data.m_value.object->cbegin();
18144 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18146 o->write_characters(indent_string.c_str(), new_indent);
18147 o->write_character(
'\"');
18148 dump_escaped(i->first, ensure_ascii);
18149 o->write_characters(
"\": ", 3);
18150 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18151 o->write_characters(
",\n", 2);
18155 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18156 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18157 o->write_characters(indent_string.c_str(), new_indent);
18158 o->write_character(
'\"');
18159 dump_escaped(i->first, ensure_ascii);
18160 o->write_characters(
"\": ", 3);
18161 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18163 o->write_character(
'\n');
18164 o->write_characters(indent_string.c_str(), current_indent);
18165 o->write_character(
'}');
18169 o->write_character(
'{');
18172 auto i = val.m_data.m_value.object->cbegin();
18173 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18175 o->write_character(
'\"');
18176 dump_escaped(i->first, ensure_ascii);
18177 o->write_characters(
"\":", 2);
18178 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18179 o->write_character(
',');
18183 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18184 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18185 o->write_character(
'\"');
18186 dump_escaped(i->first, ensure_ascii);
18187 o->write_characters(
"\":", 2);
18188 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18190 o->write_character(
'}');
18196 case value_t::array:
18198 if (val.m_data.m_value.array->empty())
18200 o->write_characters(
"[]", 2);
18206 o->write_characters(
"[\n", 2);
18209 const auto new_indent = current_indent + indent_step;
18212 indent_string.resize(indent_string.size() * 2,
' ');
18216 for (
auto i = val.m_data.m_value.array->cbegin();
18217 i != val.m_data.m_value.array->cend() - 1; ++i)
18219 o->write_characters(indent_string.c_str(), new_indent);
18220 dump(*i,
true, ensure_ascii, indent_step, new_indent);
18221 o->write_characters(
",\n", 2);
18226 o->write_characters(indent_string.c_str(), new_indent);
18227 dump(val.m_data.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
18229 o->write_character(
'\n');
18230 o->write_characters(indent_string.c_str(), current_indent);
18231 o->write_character(
']');
18235 o->write_character(
'[');
18238 for (
auto i = val.m_data.m_value.array->cbegin();
18239 i != val.m_data.m_value.array->cend() - 1; ++i)
18241 dump(*i,
false, ensure_ascii, indent_step, current_indent);
18242 o->write_character(
',');
18247 dump(val.m_data.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
18249 o->write_character(
']');
18255 case value_t::string:
18257 o->write_character(
'\"');
18258 dump_escaped(*val.m_data.m_value.string, ensure_ascii);
18259 o->write_character(
'\"');
18267 o->write_characters(
"{\n", 2);
18270 const auto new_indent = current_indent + indent_step;
18273 indent_string.resize(indent_string.size() * 2,
' ');
18276 o->write_characters(indent_string.c_str(), new_indent);
18278 o->write_characters(
"\"bytes\": [", 10);
18280 if (!val.m_data.m_value.binary->empty())
18282 for (
auto i = val.m_data.m_value.binary->cbegin();
18283 i != val.m_data.m_value.binary->cend() - 1; ++i)
18286 o->write_characters(
", ", 2);
18288 dump_integer(val.m_data.m_value.binary->back());
18291 o->write_characters(
"],\n", 3);
18292 o->write_characters(indent_string.c_str(), new_indent);
18294 o->write_characters(
"\"subtype\": ", 11);
18295 if (val.m_data.m_value.binary->has_subtype())
18297 dump_integer(val.m_data.m_value.binary->subtype());
18301 o->write_characters(
"null", 4);
18303 o->write_character(
'\n');
18304 o->write_characters(indent_string.c_str(), current_indent);
18305 o->write_character(
'}');
18309 o->write_characters(
"{\"bytes\":[", 10);
18311 if (!val.m_data.m_value.binary->empty())
18313 for (
auto i = val.m_data.m_value.binary->cbegin();
18314 i != val.m_data.m_value.binary->cend() - 1; ++i)
18317 o->write_character(
',');
18319 dump_integer(val.m_data.m_value.binary->back());
18322 o->write_characters(
"],\"subtype\":", 12);
18323 if (val.m_data.m_value.binary->has_subtype())
18325 dump_integer(val.m_data.m_value.binary->subtype());
18326 o->write_character(
'}');
18330 o->write_characters(
"null}", 5);
18336 case value_t::boolean:
18338 if (val.m_data.m_value.boolean)
18340 o->write_characters(
"true", 4);
18344 o->write_characters(
"false", 5);
18349 case value_t::number_integer:
18351 dump_integer(val.m_data.m_value.number_integer);
18355 case value_t::number_unsigned:
18357 dump_integer(val.m_data.m_value.number_unsigned);
18361 case value_t::number_float:
18363 dump_float(val.m_data.m_value.number_float);
18367 case value_t::discarded:
18369 o->write_characters(
"<discarded>", 11);
18373 case value_t::null:
18375 o->write_characters(
"null", 4);
18399 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
18401 std::uint32_t codepoint{};
18402 std::uint8_t state = UTF8_ACCEPT;
18406 std::size_t bytes_after_last_accept = 0;
18407 std::size_t undumped_chars = 0;
18409 for (std::size_t i = 0; i < s.size(); ++i)
18411 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18413 switch (decode(state, codepoint,
byte))
18421 string_buffer[
bytes++] =
'\\';
18422 string_buffer[
bytes++] =
'b';
18428 string_buffer[
bytes++] =
'\\';
18429 string_buffer[
bytes++] =
't';
18435 string_buffer[
bytes++] =
'\\';
18436 string_buffer[
bytes++] =
'n';
18442 string_buffer[
bytes++] =
'\\';
18443 string_buffer[
bytes++] =
'f';
18449 string_buffer[
bytes++] =
'\\';
18450 string_buffer[
bytes++] =
'r';
18456 string_buffer[
bytes++] =
'\\';
18457 string_buffer[
bytes++] =
'\"';
18463 string_buffer[
bytes++] =
'\\';
18464 string_buffer[
bytes++] =
'\\';
18472 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
18474 if (codepoint <= 0xFFFF)
18477 static_cast<void>((std::snprintf)(string_buffer.data() +
bytes, 7,
"\\u%04x",
18478 static_cast<std::uint16_t
>(codepoint)));
18484 static_cast<void>((std::snprintf)(string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
18485 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18486 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18494 string_buffer[
bytes++] = s[i];
18503 if (string_buffer.size() -
bytes < 13)
18505 o->write_characters(string_buffer.data(),
bytes);
18510 bytes_after_last_accept =
bytes;
18511 undumped_chars = 0;
18517 switch (error_handler)
18519 case error_handler_t::strict:
18524 case error_handler_t::ignore:
18525 case error_handler_t::replace:
18531 if (undumped_chars > 0)
18538 bytes = bytes_after_last_accept;
18540 if (error_handler == error_handler_t::replace)
18545 string_buffer[
bytes++] =
'\\';
18546 string_buffer[
bytes++] =
'u';
18547 string_buffer[
bytes++] =
'f';
18548 string_buffer[
bytes++] =
'f';
18549 string_buffer[
bytes++] =
'f';
18550 string_buffer[
bytes++] =
'd';
18562 if (string_buffer.size() -
bytes < 13)
18564 o->write_characters(string_buffer.data(),
bytes);
18568 bytes_after_last_accept =
bytes;
18571 undumped_chars = 0;
18574 state = UTF8_ACCEPT;
18589 string_buffer[
bytes++] = s[i];
18603 o->write_characters(string_buffer.data(),
bytes);
18609 switch (error_handler)
18611 case error_handler_t::strict:
18613 JSON_THROW(type_error::create(316,
concat(
"incomplete UTF-8 string; last byte: 0x", hex_bytes(
static_cast<std::uint8_t
>(s.back() | 0))),
nullptr));
18616 case error_handler_t::ignore:
18619 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18623 case error_handler_t::replace:
18626 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18630 o->write_characters(
"\\ufffd", 6);
18634 o->write_characters(
"\xEF\xBF\xBD", 3);
18685 static std::string hex_bytes(std::uint8_t
byte)
18687 std::string result =
"FF";
18688 constexpr
const char* nibble_to_hex =
"0123456789ABCDEF";
18689 result[0] = nibble_to_hex[
byte / 16];
18690 result[1] = nibble_to_hex[
byte % 16];
18696 bool is_negative_number(NumberType x)
18702 bool is_negative_number(NumberType )
18722 void dump_integer(NumberType x)
18724 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18727 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18728 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18729 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18730 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18731 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18732 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18733 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18734 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18735 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18736 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18743 o->write_character(
'0');
18748 auto buffer_ptr = number_buffer.begin();
18752 unsigned int n_chars{};
18754 if (is_negative_number(x))
18760 n_chars = 1 + count_digits(abs_value);
18765 n_chars = count_digits(abs_value);
18773 buffer_ptr += n_chars;
18777 while (abs_value >= 100)
18779 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18781 *(--buffer_ptr) = digits_to_99[digits_index][1];
18782 *(--buffer_ptr) = digits_to_99[digits_index][0];
18785 if (abs_value >= 10)
18787 const auto digits_index =
static_cast<unsigned>(abs_value);
18788 *(--buffer_ptr) = digits_to_99[digits_index][1];
18789 *(--buffer_ptr) = digits_to_99[digits_index][0];
18793 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18796 o->write_characters(number_buffer.data(), n_chars);
18810 if (!std::isfinite(x))
18812 o->write_characters(
"null", 4);
18821 static constexpr
bool is_ieee_single_or_double
18825 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18830 auto*
begin = number_buffer.data();
18833 o->write_characters(
begin,
static_cast<size_t>(
end -
begin));
18839 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
18843 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
18848 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
18851 if (thousands_sep !=
'\0')
18854 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
18855 std::fill(
end, number_buffer.end(),
'\0');
18857 len = (
end - number_buffer.begin());
18861 if (decimal_point !=
'\0' && decimal_point !=
'.')
18864 const auto dec_pos =
std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
18865 if (dec_pos != number_buffer.end())
18871 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
18874 const bool value_is_int_like =
18875 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
18878 return c ==
'.' || c ==
'e';
18881 if (value_is_int_like)
18883 o->write_characters(
".0", 2);
18908 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte) noexcept
18910 static const std::array<std::uint8_t, 400> utf8d =
18913 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,
18914 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,
18915 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,
18916 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,
18917 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,
18918 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,
18919 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,
18920 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18921 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18922 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18923 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,
18924 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,
18925 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,
18926 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
18931 const std::uint8_t type = utf8d[
byte];
18933 codep = (state != UTF8_ACCEPT)
18934 ? (
byte & 0x3fu) | (codep << 6u)
18935 : (0xFFu >> type) & (
byte);
18937 const std::size_t index = 256u +
static_cast<size_t>(state) * 16u +
static_cast<size_t>(type);
18939 state = utf8d[index];
18965 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18971 output_adapter_t<char> o =
nullptr;
18974 std::array<char, 64> number_buffer{{}};
18977 const std::lconv* loc =
nullptr;
18979 const char thousands_sep =
'\0';
18981 const char decimal_point =
'\0';
18984 std::array<char, 512> string_buffer{{}};
19013 #include <functional>
19014 #include <initializer_list>
19015 #include <iterator>
19017 #include <stdexcept>
19018 #include <type_traits>
19031 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19032 class Allocator = std::allocator<std::pair<const Key, T>>>
19033 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
19037 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19042 #ifdef JSON_HAS_CPP_14
19052 template <
class It>
19055 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19060 for (
auto it = this->
begin(); it != this->
end(); ++it)
19062 if (m_compare(it->first,
key))
19064 return {it,
false};
19067 Container::emplace_back(
key, std::forward<T>(t));
19075 for (
auto it = this->
begin(); it != this->
end(); ++it)
19077 if (m_compare(it->first,
key))
19079 return {it,
false};
19082 Container::emplace_back(std::forward<KeyType>(
key), std::forward<T>(t));
19088 return emplace(
key, T{}).first->second;
19095 return emplace(std::forward<KeyType>(
key), T{}).first->second;
19107 return at(std::forward<KeyType>(
key));
19112 for (
auto it = this->
begin(); it != this->
end(); ++it)
19114 if (m_compare(it->first,
key))
19120 JSON_THROW(std::out_of_range(
"key not found"));
19127 for (
auto it = this->
begin(); it != this->
end(); ++it)
19129 if (m_compare(it->first,
key))
19135 JSON_THROW(std::out_of_range(
"key not found"));
19140 for (
auto it = this->
begin(); it != this->
end(); ++it)
19142 if (m_compare(it->first,
key))
19148 JSON_THROW(std::out_of_range(
"key not found"));
19155 for (
auto it = this->
begin(); it != this->
end(); ++it)
19157 if (m_compare(it->first,
key))
19163 JSON_THROW(std::out_of_range(
"key not found"));
19168 for (
auto it = this->
begin(); it != this->
end(); ++it)
19170 if (m_compare(it->first,
key))
19173 for (
auto next = it; ++
next != this->
end(); ++it)
19178 Container::pop_back();
19189 for (
auto it = this->
begin(); it != this->
end(); ++it)
19191 if (m_compare(it->first,
key))
19194 for (
auto next = it; ++
next != this->
end(); ++it)
19199 Container::pop_back();
19208 return erase(pos, std::next(pos));
19218 const auto elements_affected = std::distance(first, last);
19241 for (
auto it = first; std::next(it, elements_affected) !=
Container::end(); ++it)
19244 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19252 Container::resize(this->
size() -
static_cast<size_type>(elements_affected));
19266 for (
auto it = this->
begin(); it != this->
end(); ++it)
19268 if (m_compare(it->first,
key))
19280 for (
auto it = this->
begin(); it != this->
end(); ++it)
19282 if (m_compare(it->first,
key))
19292 for (
auto it = this->
begin(); it != this->
end(); ++it)
19294 if (m_compare(it->first,
key))
19306 for (
auto it = this->
begin(); it != this->
end(); ++it)
19308 if (m_compare(it->first,
key))
19318 for (
auto it = this->
begin(); it != this->
end(); ++it)
19320 if (m_compare(it->first,
key))
19330 return emplace(
value.first, std::move(
value.second));
19335 for (
auto it = this->
begin(); it != this->
end(); ++it)
19337 if (m_compare(it->first,
value.first))
19339 return {it,
false};
19342 Container::push_back(
value);
19343 return {--this->
end(),
true};
19346 template<
typename InputIt>
19347 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19350 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19353 for (
auto it = first; it != last; ++it)
19366 #if defined(JSON_HAS_CPP_17)
19367 #if JSON_HAS_STATIC_RTTI
19370 #include <string_view>
19406 friend class ::nlohmann::json_pointer;
19410 template<
typename BasicJsonType,
typename InputType>
19411 friend class ::nlohmann::detail::parser;
19412 friend ::nlohmann::detail::serializer<basic_json>;
19413 template<
typename BasicJsonType>
19414 friend class ::nlohmann::detail::iter_impl;
19415 template<
typename BasicJsonType,
typename CharType>
19416 friend class ::nlohmann::detail::binary_writer;
19417 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19418 friend class ::nlohmann::detail::binary_reader;
19419 template<
typename BasicJsonType>
19420 friend class ::nlohmann::detail::json_sax_dom_parser;
19421 template<
typename BasicJsonType>
19422 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19423 friend class ::nlohmann::detail::exception;
19431 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19433 template<
typename InputAdapterType>
19434 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19435 InputAdapterType adapter,
19437 const bool allow_exceptions =
true,
19438 const bool ignore_comments =
false
19441 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19442 std::move(cb), allow_exceptions, ignore_comments);
19447 template<
typename BasicJsonType>
19449 template<
typename BasicJsonType>
19451 template<
typename Iterator>
19455 template<
typename CharType>
19458 template<
typename InputType>
19460 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19463 using serializer = ::nlohmann::detail::serializer<basic_json>;
19469 template<
typename T,
typename SFINAE>
19525 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19527 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19554 result[
"copyright"] =
"(C) 2013-2023 Niels Lohmann";
19555 result[
"name"] =
"JSON for Modern C++";
19556 result[
"url"] =
"https://github.com/nlohmann/json";
19557 result[
"version"][
"string"] =
19566 result[
"platform"] =
"win32";
19567 #elif defined __linux__
19568 result[
"platform"] =
"linux";
19569 #elif defined __APPLE__
19570 result[
"platform"] =
"apple";
19571 #elif defined __unix__
19572 result[
"platform"] =
"unix";
19574 result[
"platform"] =
"unknown";
19577 #if defined(__ICC) || defined(__INTEL_COMPILER)
19578 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19579 #elif defined(__clang__)
19580 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19581 #elif defined(__GNUC__) || defined(__GNUG__)
19582 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19588 #elif defined(__HP_cc) || defined(__HP_aCC)
19589 result[
"compiler"] =
"hp"
19590 #elif defined(__IBMCPP__)
19591 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19592 #elif defined(_MSC_VER)
19593 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19594 #elif defined(__PGI)
19595 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19596 #elif defined(__SUNPRO_CC)
19597 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19599 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19602 #if defined(_MSVC_LANG)
19604 #elif defined(__cplusplus)
19607 result[
"compiler"][
"c++"] =
"unknown";
19625 #if defined(JSON_HAS_CPP_14)
19628 using default_object_comparator_t = std::less<>;
19635 using object_t = ObjectType<StringType,
19638 AllocatorType<std::pair<
const StringType,
19643 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19667 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19678 template<
typename T,
typename... Args>
19682 AllocatorType<T> alloc;
19683 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19685 auto deleter = [&](T * obj)
19687 AllocatorTraits::deallocate(alloc, obj, 1);
19689 std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19692 return obj.release();
19745 json_value() =
default;
19759 case value_t::object:
19761 object = create<object_t>();
19765 case value_t::array:
19767 array = create<array_t>();
19771 case value_t::string:
19773 string = create<string_t>(
"");
19779 binary = create<binary_t>();
19783 case value_t::boolean:
19785 boolean =
static_cast<boolean_t>(
false);
19789 case value_t::number_integer:
19795 case value_t::number_unsigned:
19801 case value_t::number_float:
19807 case value_t::null:
19813 case value_t::discarded:
19819 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.11.3",
nullptr));
19859 (t == value_t::object &&
object ==
nullptr) ||
19860 (t == value_t::array && array ==
nullptr) ||
19861 (t == value_t::string &&
string ==
nullptr) ||
19868 if (t == value_t::array || t == value_t::object)
19871 std::vector<basic_json> stack;
19874 if (t == value_t::array)
19876 stack.reserve(array->size());
19877 std::move(array->begin(), array->end(), std::back_inserter(stack));
19881 stack.reserve(object->size());
19882 for (
auto&& it : *
object)
19884 stack.push_back(std::move(it.second));
19888 while (!stack.empty())
19891 basic_json current_item(std::move(stack.back()));
19898 std::move(current_item.
m_data.m_value.array->begin(), current_item.
m_data.m_value.array->end(), std::back_inserter(stack));
19900 current_item.
m_data.m_value.array->clear();
19904 for (
auto&& it : *current_item.
m_data.m_value.object)
19906 stack.push_back(std::move(it.second));
19909 current_item.
m_data.m_value.object->clear();
19919 case value_t::object:
19921 AllocatorType<object_t> alloc;
19922 std::allocator_traits<decltype(alloc)>::destroy(alloc,
object);
19923 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
19927 case value_t::array:
19929 AllocatorType<array_t> alloc;
19930 std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
19931 std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
19935 case value_t::string:
19937 AllocatorType<string_t> alloc;
19938 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
19939 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
19945 AllocatorType<binary_t> alloc;
19946 std::allocator_traits<decltype(alloc)>::destroy(alloc,
binary);
19947 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
binary, 1);
19951 case value_t::null:
19952 case value_t::boolean:
19953 case value_t::number_integer:
19954 case value_t::number_unsigned:
19955 case value_t::number_float:
19956 case value_t::discarded:
19986 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
19987 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
19988 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
19991 #if JSON_DIAGNOSTICS
19997 return j.m_parent ==
this;
20002 static_cast<void>(check_parents);
20007 #if JSON_DIAGNOSTICS
20008 switch (m_data.m_type)
20010 case value_t::array:
20012 for (
auto& element : *m_data.m_value.array)
20014 element.m_parent =
this;
20019 case value_t::object:
20021 for (
auto& element : *m_data.m_value.object)
20023 element.second.m_parent =
this;
20028 case value_t::null:
20029 case value_t::string:
20030 case value_t::boolean:
20031 case value_t::number_integer:
20032 case value_t::number_unsigned:
20033 case value_t::number_float:
20035 case value_t::discarded:
20044 #if JSON_DIAGNOSTICS
20045 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20047 (it + i)->m_parent =
this;
20050 static_cast<void>(count_set_parents);
20057 #if JSON_DIAGNOSTICS
20058 if (old_capacity !=
static_cast<std::size_t
>(-1))
20072 #ifdef JSON_HEDLEY_MSVC_VERSION
20073 #pragma warning(push )
20074 #pragma warning(disable : 4127) // ignore warning to replace if with if constexpr
20081 #ifdef JSON_HEDLEY_MSVC_VERSION
20082 #pragma warning( pop )
20087 static_cast<void>(j);
20088 static_cast<void>(old_capacity);
20120 assert_invariant();
20128 assert_invariant();
20133 template <
typename CompatibleType,
20139 std::forward<CompatibleType>(val))))
20143 assert_invariant();
20148 template <
typename BasicJsonType,
20153 using other_boolean_t =
typename BasicJsonType::boolean_t;
20154 using other_number_float_t =
typename BasicJsonType::number_float_t;
20155 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20156 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20157 using other_string_t =
typename BasicJsonType::string_t;
20158 using other_object_t =
typename BasicJsonType::object_t;
20159 using other_array_t =
typename BasicJsonType::array_t;
20160 using other_binary_t =
typename BasicJsonType::binary_t;
20162 switch (val.type())
20164 case value_t::boolean:
20167 case value_t::number_float:
20170 case value_t::number_integer:
20173 case value_t::number_unsigned:
20176 case value_t::string:
20179 case value_t::object:
20182 case value_t::array:
20188 case value_t::null:
20191 case value_t::discarded:
20192 m_data.m_type = value_t::discarded;
20199 assert_invariant();
20205 bool type_deduction =
true,
20206 value_t manual_type = value_t::array)
20210 bool is_an_object = std::all_of(init.begin(), init.end(),
20216 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
20220 if (!type_deduction)
20223 if (manual_type == value_t::array)
20225 is_an_object =
false;
20231 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
20238 m_data.m_type = value_t::object;
20239 m_data.m_value = value_t::object;
20241 for (
auto& element_ref : init)
20244 m_data.
m_value.object->emplace(
20245 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
20246 std::move((*element.m_data.m_value.array)[1]));
20252 m_data.m_type = value_t::array;
20253 m_data.m_value.array = create<array_t>(init.begin(), init.end());
20257 assert_invariant();
20267 res.m_data.m_value = init;
20289 res.m_data.m_value = std::move(init);
20309 return basic_json(init,
false, value_t::array);
20317 return basic_json(init,
false, value_t::object);
20326 assert_invariant();
20342 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
20346 m_data.m_type = first.m_object->m_data.m_type;
20349 switch (m_data.m_type)
20351 case value_t::boolean:
20352 case value_t::number_float:
20353 case value_t::number_integer:
20354 case value_t::number_unsigned:
20355 case value_t::string:
20358 || !last.m_it.primitive_iterator.is_end()))
20360 JSON_THROW(invalid_iterator::create(204,
"iterators out of range", first.m_object));
20365 case value_t::null:
20366 case value_t::object:
20367 case value_t::array:
20369 case value_t::discarded:
20374 switch (m_data.m_type)
20376 case value_t::number_integer:
20378 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
20382 case value_t::number_unsigned:
20384 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
20388 case value_t::number_float:
20390 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
20394 case value_t::boolean:
20396 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
20400 case value_t::string:
20402 m_data.m_value = *first.m_object->m_data.m_value.string;
20406 case value_t::object:
20408 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
20409 last.m_it.object_iterator);
20413 case value_t::array:
20415 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
20416 last.m_it.array_iterator);
20422 m_data.m_value = *first.m_object->m_data.m_value.binary;
20426 case value_t::null:
20427 case value_t::discarded:
20429 JSON_THROW(invalid_iterator::create(206,
detail::concat(
"cannot construct with iterators from ", first.m_object->type_name()), first.m_object));
20433 assert_invariant();
20440 template<
typename JsonRef,
20442 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
20450 m_data.m_type = other.
m_data.m_type;
20454 switch (m_data.m_type)
20456 case value_t::object:
20458 m_data.m_value = *other.
m_data.m_value.object;
20462 case value_t::array:
20464 m_data.m_value = *other.
m_data.m_value.array;
20468 case value_t::string:
20470 m_data.m_value = *other.
m_data.m_value.string;
20474 case value_t::boolean:
20476 m_data.m_value = other.
m_data.m_value.boolean;
20480 case value_t::number_integer:
20482 m_data.m_value = other.
m_data.m_value.number_integer;
20486 case value_t::number_unsigned:
20488 m_data.m_value = other.
m_data.m_value.number_unsigned;
20492 case value_t::number_float:
20494 m_data.m_value = other.
m_data.m_value.number_float;
20500 m_data.m_value = *other.
m_data.m_value.binary;
20504 case value_t::null:
20505 case value_t::discarded:
20511 assert_invariant();
20518 m_data(std::move(other.m_data))
20521 other.assert_invariant(
false);
20524 other.m_data.m_type = value_t::null;
20525 other.m_data.m_value = {};
20528 assert_invariant();
20545 swap(m_data.m_type, other.m_data.m_type);
20546 swap(m_data.m_value, other.m_data.m_value);
20547 json_base_class_t::operator=(std::move(other));
20550 assert_invariant();
20558 assert_invariant(
false);
20575 const char indent_char =
' ',
20576 const bool ensure_ascii =
false,
20584 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20588 s.dump(*
this,
false, ensure_ascii, 0);
20598 return m_data.m_type;
20605 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
20612 return is_array() || is_object();
20619 return m_data.m_type == value_t::null;
20626 return m_data.m_type == value_t::boolean;
20633 return is_number_integer() || is_number_float();
20640 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
20647 return m_data.m_type == value_t::number_unsigned;
20654 return m_data.m_type == value_t::number_float;
20661 return m_data.m_type == value_t::object;
20668 return m_data.m_type == value_t::array;
20675 return m_data.m_type == value_t::string;
20689 return m_data.m_type == value_t::discarded;
20696 return m_data.m_type;
20711 return m_data.m_value.boolean;
20720 return is_object() ? m_data.m_value.object :
nullptr;
20726 return is_object() ? m_data.m_value.object :
nullptr;
20732 return is_array() ? m_data.m_value.array :
nullptr;
20738 return is_array() ? m_data.m_value.array :
nullptr;
20744 return is_string() ? m_data.m_value.string :
nullptr;
20750 return is_string() ? m_data.m_value.string :
nullptr;
20756 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
20762 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
20768 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
20774 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
20780 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
20786 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
20792 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
20798 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
20804 return is_binary() ? m_data.m_value.binary :
nullptr;
20810 return is_binary() ? m_data.m_value.binary :
nullptr;
20824 template<
typename ReferenceType,
typename ThisType>
20828 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20835 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
20850 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20857 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >::type = 0 >
20861 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20903 template <
typename ValueType,
20911 auto ret = ValueType();
20946 template <
typename ValueType,
20971 template <
typename BasicJsonType,
20994 template<
typename BasicJsonType,
21007 template<
typename PointerType,
21012 -> decltype(std::declval<const basic_json_t&>().
template get_ptr<PointerType>())
21015 return get_ptr<PointerType>();
21042 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21043 #if defined(JSON_HAS_CPP_14)
21054 "get() cannot be used with reference types, you might want to use get_ref()");
21090 return get_ptr<PointerType>();
21095 template <
typename ValueType,
21100 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
21109 template<
typename ValueType,
21120 typename T, std::size_t N,
21121 typename Array = T (&)[N],
21126 std::declval<const basic_json_t&>(), v)))
21139 return get_ref_impl<ReferenceType>(*
this);
21146 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >::type = 0 >
21150 return get_ref_impl<ReferenceType>(*
this);
21190 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21193 #if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
21201 return get<ValueType>();
21213 return *get_ptr<binary_t*>();
21225 return *get_ptr<const binary_t*>();
21247 return set_parent(m_data.m_value.array->at(idx));
21270 return m_data.m_value.array->at(idx);
21294 auto it = m_data.m_value.object->find(
key);
21295 if (it == m_data.m_value.object->end())
21299 return set_parent(it->second);
21314 auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
21315 if (it == m_data.m_value.object->end())
21319 return set_parent(it->second);
21332 auto it = m_data.m_value.object->find(
key);
21333 if (it == m_data.m_value.object->end())
21352 auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
21353 if (it == m_data.m_value.object->end())
21367 m_data.m_type = value_t::array;
21368 m_data.
m_value.array = create<array_t>();
21369 assert_invariant();
21376 if (idx >= m_data.m_value.array->size())
21378 #if JSON_DIAGNOSTICS
21380 const auto old_size = m_data.m_value.array->size();
21381 const auto old_capacity = m_data.m_value.array->capacity();
21383 m_data.m_value.array->resize(idx + 1);
21385 #if JSON_DIAGNOSTICS
21394 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21397 assert_invariant();
21400 return m_data.m_value.array->operator[](idx);
21413 return m_data.
m_value.array->operator[](idx);
21426 m_data.m_type = value_t::object;
21427 m_data.
m_value.object = create<object_t>();
21428 assert_invariant();
21434 auto result = m_data.m_value.object->emplace(std::move(
key),
nullptr);
21435 return set_parent(result.first->second);
21458 template<
typename T>
21461 return operator[](
typename object_t::key_type(
key));
21464 template<
typename T>
21467 return operator[](
typename object_t::key_type(
key));
21479 m_data.m_type = value_t::object;
21480 m_data.
m_value.object = create<object_t>();
21481 assert_invariant();
21487 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
21488 return set_parent(result.first->second);
21503 auto it = m_data.
m_value.object->find(std::forward<KeyType>(
key));
21512 template<
typename KeyType>
21516 template<
typename ValueType>
21527 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21528 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const
21537 return it->template get<ValueType>();
21540 return default_value;
21548 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21552 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21553 ReturnType
value(
const typename object_t::key_type&
key, ValueType && default_value)
const
21562 return it->template get<ReturnType>();
21565 return std::forward<ValueType>(default_value);
21578 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21579 ValueType
value(KeyType &&
key,
const ValueType& default_value)
const
21585 const auto it =
find(std::forward<KeyType>(
key));
21588 return it->template get<ValueType>();
21591 return default_value;
21599 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
21605 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21606 ReturnType
value(KeyType &&
key, ValueType && default_value)
const
21612 const auto it =
find(std::forward<KeyType>(
key));
21615 return it->template get<ReturnType>();
21618 return std::forward<ValueType>(default_value);
21628 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21637 return ptr.
get_checked(
this).template get<ValueType>();
21641 return default_value;
21650 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21653 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21662 return ptr.
get_checked(
this).template get<ReturnType>();
21666 return std::forward<ValueType>(default_value);
21676 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21678 ValueType
value(const ::nlohmann::json_pointer<BasicJsonType>& ptr,
const ValueType& default_value)
const
21680 return value(ptr.convert(), default_value);
21683 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
21687 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21689 ReturnType
value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const
21691 return value(ptr.convert(), std::forward<ValueType>(default_value));
21736 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
21739 IteratorType result =
end();
21741 switch (m_data.m_type)
21743 case value_t::boolean:
21744 case value_t::number_float:
21745 case value_t::number_integer:
21746 case value_t::number_unsigned:
21747 case value_t::string:
21752 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
21757 AllocatorType<string_t> alloc;
21758 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string);
21759 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
21760 m_data.m_value.string =
nullptr;
21762 else if (is_binary())
21764 AllocatorType<binary_t> alloc;
21765 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
21766 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
21767 m_data.m_value.binary =
nullptr;
21770 m_data.m_type = value_t::null;
21771 assert_invariant();
21775 case value_t::object:
21777 result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator);
21781 case value_t::array:
21783 result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator);
21787 case value_t::null:
21788 case value_t::discarded:
21801 IteratorType
erase(IteratorType first, IteratorType last)
21806 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
21809 IteratorType result =
end();
21811 switch (m_data.m_type)
21813 case value_t::boolean:
21814 case value_t::number_float:
21815 case value_t::number_integer:
21816 case value_t::number_unsigned:
21817 case value_t::string:
21821 || !last.m_it.primitive_iterator.is_end()))
21823 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
21828 AllocatorType<string_t> alloc;
21829 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string);
21830 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
21831 m_data.m_value.string =
nullptr;
21833 else if (is_binary())
21835 AllocatorType<binary_t> alloc;
21836 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
21837 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
21838 m_data.m_value.binary =
nullptr;
21841 m_data.m_type = value_t::null;
21842 assert_invariant();
21846 case value_t::object:
21848 result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator,
21849 last.m_it.object_iterator);
21853 case value_t::array:
21855 result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator,
21856 last.m_it.array_iterator);
21860 case value_t::null:
21861 case value_t::discarded:
21880 return m_data.m_value.object->erase(std::forward<KeyType>(
key));
21893 const auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
21894 if (it != m_data.m_value.object->end())
21896 m_data.m_value.object->erase(it);
21910 return erase_internal(
key);
21919 return erase_internal(std::forward<KeyType>(
key));
21934 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
21955 auto result =
end();
21959 result.m_it.object_iterator = m_data.m_value.object->find(
key);
21969 auto result =
cend();
21973 result.m_it.object_iterator = m_data.m_value.object->find(
key);
21985 auto result =
end();
21989 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
22001 auto result =
cend();
22005 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
22016 return is_object() ? m_data.m_value.object->count(
key) : 0;
22026 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(
key)) : 0;
22033 return is_object() && m_data.m_value.object->find(
key) != m_data.m_value.object->end();
22042 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(
key)) != m_data.m_value.object->end();
22054 bool contains(
const typename ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
22056 return ptr.contains(
this);
22070 iterator
begin() noexcept
22072 iterator result(
this);
22073 result.set_begin();
22079 const_iterator
begin() const noexcept
22086 const_iterator
cbegin() const noexcept
22088 const_iterator result(
this);
22089 result.set_begin();
22095 iterator
end() noexcept
22097 iterator result(
this);
22104 const_iterator
end() const noexcept
22111 const_iterator
cend() const noexcept
22113 const_iterator result(
this);
22120 reverse_iterator rbegin() noexcept
22122 return reverse_iterator(
end());
22127 const_reverse_iterator rbegin() const noexcept
22134 reverse_iterator rend() noexcept
22136 return reverse_iterator(
begin());
22141 const_reverse_iterator rend() const noexcept
22148 const_reverse_iterator crbegin() const noexcept
22150 return const_reverse_iterator(
cend());
22155 const_reverse_iterator crend() const noexcept
22157 return const_reverse_iterator(
cbegin());
22167 static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
22169 return ref.items();
22178 static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
22180 return ref.items();
22185 iteration_proxy<iterator> items() noexcept
22187 return iteration_proxy<iterator>(*
this);
22192 iteration_proxy<const_iterator> items() const noexcept
22194 return iteration_proxy<const_iterator>(*
this);
22208 bool empty() const noexcept
22210 switch (m_data.m_type)
22212 case value_t::null:
22218 case value_t::array:
22221 return m_data.m_value.array->empty();
22224 case value_t::object:
22227 return m_data.m_value.object->empty();
22230 case value_t::string:
22231 case value_t::boolean:
22232 case value_t::number_integer:
22233 case value_t::number_unsigned:
22234 case value_t::number_float:
22236 case value_t::discarded:
22247 size_type
size() const noexcept
22249 switch (m_data.m_type)
22251 case value_t::null:
22257 case value_t::array:
22260 return m_data.m_value.array->size();
22263 case value_t::object:
22266 return m_data.m_value.object->size();
22269 case value_t::string:
22270 case value_t::boolean:
22271 case value_t::number_integer:
22272 case value_t::number_unsigned:
22273 case value_t::number_float:
22275 case value_t::discarded:
22286 size_type max_size() const noexcept
22288 switch (m_data.m_type)
22290 case value_t::array:
22293 return m_data.m_value.array->max_size();
22296 case value_t::object:
22299 return m_data.m_value.object->max_size();
22302 case value_t::null:
22303 case value_t::string:
22304 case value_t::boolean:
22305 case value_t::number_integer:
22306 case value_t::number_unsigned:
22307 case value_t::number_float:
22309 case value_t::discarded:
22329 void clear() noexcept
22331 switch (m_data.m_type)
22333 case value_t::number_integer:
22335 m_data.m_value.number_integer = 0;
22339 case value_t::number_unsigned:
22341 m_data.m_value.number_unsigned = 0;
22345 case value_t::number_float:
22347 m_data.m_value.number_float = 0.0;
22351 case value_t::boolean:
22353 m_data.m_value.boolean =
false;
22357 case value_t::string:
22359 m_data.m_value.string->clear();
22365 m_data.m_value.binary->clear();
22369 case value_t::array:
22371 m_data.m_value.array->clear();
22375 case value_t::object:
22377 m_data.m_value.object->clear();
22381 case value_t::null:
22382 case value_t::discarded:
22401 m_data.m_type = value_t::array;
22402 m_data.m_value = value_t::array;
22403 assert_invariant();
22407 const auto old_capacity = m_data.m_value.array->capacity();
22408 m_data.m_value.array->push_back(std::move(val));
22409 set_parent(m_data.m_value.array->back(), old_capacity);
22417 push_back(std::move(val));
22434 m_data.m_type = value_t::array;
22435 m_data.m_value = value_t::array;
22436 assert_invariant();
22440 const auto old_capacity = m_data.m_value.array->capacity();
22441 m_data.m_value.array->push_back(val);
22442 set_parent(m_data.m_value.array->back(), old_capacity);
22466 m_data.m_type = value_t::object;
22467 m_data.m_value = value_t::object;
22468 assert_invariant();
22472 auto res = m_data.m_value.object->insert(val);
22473 set_parent(res.first->second);
22488 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22491 push_back(
typename object_t::value_type(
22492 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22510 template<
class... Args>
22522 m_data.m_type = value_t::array;
22523 m_data.m_value = value_t::array;
22524 assert_invariant();
22528 const auto old_capacity = m_data.m_value.array->capacity();
22529 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
22530 return set_parent(m_data.m_value.array->back(), old_capacity);
22535 template<
class... Args>
22547 m_data.m_type = value_t::object;
22548 m_data.m_value = value_t::object;
22549 assert_invariant();
22553 auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
22554 set_parent(res.first->second);
22558 it.m_it.object_iterator = res.first;
22561 return {it, res.second};
22567 template<
typename... Args>
22573 auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator);
22574 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22575 result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos;
22595 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22599 return insert_iterator(pos, val);
22609 return insert(pos, val);
22622 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22626 return insert_iterator(pos, cnt, val);
22645 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22651 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22656 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
22660 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22676 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22680 return insert_iterator(pos, ilist.begin(), ilist.end());
22696 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22702 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
22705 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22712 update(j.begin(), j.end(), merge_objects);
22722 m_data.m_type = value_t::object;
22723 m_data.m_value.object = create<object_t>();
22724 assert_invariant();
22735 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22741 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
22744 for (
auto it = first; it != last; ++it)
22746 if (merge_objects && it.value().is_object())
22748 auto it2 = m_data.m_value.object->find(it.key());
22749 if (it2 != m_data.m_value.object->end())
22751 it2->second.update(it.value(),
true);
22755 m_data.m_value.object->operator[](it.key()) = it.value();
22756 #if JSON_DIAGNOSTICS
22757 m_data.m_value.object->operator[](it.key()).m_parent =
this;
22771 std::swap(m_data.m_type, other.m_data.m_type);
22772 std::swap(m_data.m_value, other.m_data.m_value);
22775 other.set_parents();
22776 assert_invariant();
22799 swap(*(m_data.m_value.array), other);
22815 swap(*(m_data.m_value.object), other);
22831 swap(*(m_data.m_value.string), other);
22847 swap(*(m_data.m_value.binary), other);
22857 void swap(
typename binary_t::container_type& other)
22863 swap(*(m_data.m_value.binary), other);
22882 #define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22883 const auto lhs_type = lhs.type(); \
22884 const auto rhs_type = rhs.type(); \
22886 if (lhs_type == rhs_type) \
22888 switch (lhs_type) \
22890 case value_t::array: \
22891 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
22893 case value_t::object: \
22894 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
22896 case value_t::null: \
22897 return (null_result); \
22899 case value_t::string: \
22900 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
22902 case value_t::boolean: \
22903 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
22905 case value_t::number_integer: \
22906 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
22908 case value_t::number_unsigned: \
22909 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
22911 case value_t::number_float: \
22912 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
22914 case value_t::binary: \
22915 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
22917 case value_t::discarded: \
22919 return (unordered_result); \
22922 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22924 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
22926 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22928 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
22930 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22932 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
22934 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22936 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
22938 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22940 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
22942 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22944 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
22946 else if(compares_unordered(lhs, rhs))\
22948 return (unordered_result);\
22951 return (default_result);
22966 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22969 static_cast<void>(inverse);
22975 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
22977 return compares_unordered(*
this, rhs, inverse);
22981 #if JSON_HAS_THREE_WAY_COMPARISON
22982 bool operator==(const_reference rhs)
const noexcept
22987 #pragma GCC diagnostic push
22988 #pragma GCC diagnostic ignored "-Wfloat-equal"
22990 const_reference lhs = *
this;
22993 #pragma GCC diagnostic pop
22999 template<
typename ScalarType>
23000 requires std::is_scalar_v<ScalarType>
23001 bool operator==(ScalarType rhs)
const noexcept
23008 bool operator!=(const_reference rhs)
const noexcept
23010 if (compares_unordered(rhs,
true))
23019 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23021 const_reference lhs = *
this;
23025 std::partial_ordering::equivalent,
23026 std::partial_ordering::unordered,
23027 lhs_type <=> rhs_type)
23032 template<
typename ScalarType>
23033 requires std::is_scalar_v<ScalarType>
23034 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23039 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23046 bool operator<=(const_reference rhs)
const noexcept
23048 if (compares_unordered(rhs,
true))
23052 return !(rhs < *
this);
23057 template<
typename ScalarType>
23058 requires std::is_scalar_v<ScalarType>
23059 bool operator<=(ScalarType rhs)
const noexcept
23067 bool operator>=(const_reference rhs)
const noexcept
23069 if (compares_unordered(rhs,
true))
23073 return !(*
this < rhs);
23078 template<
typename ScalarType>
23079 requires std::is_scalar_v<ScalarType>
23080 bool operator>=(ScalarType rhs)
const noexcept
23086 friend bool operator==(const_reference lhs, const_reference rhs) noexcept
23091 #pragma GCC diagnostic push
23092 #pragma GCC diagnostic ignored "-Wfloat-equal"
23096 #pragma GCC diagnostic pop
23104 friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
23113 friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
23120 friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
23122 if (compares_unordered(lhs, rhs,
true))
23126 return !(lhs == rhs);
23133 friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
23142 friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
23149 friend bool operator<(const_reference lhs, const_reference rhs) noexcept
23161 friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
23170 friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
23177 friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
23179 if (compares_unordered(lhs, rhs,
true))
23183 return !(rhs < lhs);
23190 friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
23199 friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
23206 friend bool operator>(const_reference lhs, const_reference rhs) noexcept
23209 if (compares_unordered(lhs, rhs))
23213 return !(lhs <= rhs);
23220 friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
23229 friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
23236 friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
23238 if (compares_unordered(lhs, rhs,
true))
23242 return !(lhs < rhs);
23249 friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
23258 friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
23264 #undef JSON_IMPLEMENT_OPERATOR
23280 const bool pretty_print = o.width() > 0;
23281 const auto indentation = pretty_print ? o.width() : 0;
23288 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23303 #endif // JSON_NO_IO
23315 template<
typename InputType>
23319 const bool allow_exceptions =
true,
23320 const bool ignore_comments =
false)
23323 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23329 template<
typename IteratorType>
23334 const bool allow_exceptions =
true,
23335 const bool ignore_comments =
false)
23338 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23346 const bool allow_exceptions =
true,
23347 const bool ignore_comments =
false)
23350 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23356 template<
typename InputType>
23357 static bool accept(InputType&& i,
23358 const bool ignore_comments =
false)
23360 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
23365 template<
typename IteratorType>
23366 static bool accept(IteratorType first, IteratorType last,
23367 const bool ignore_comments =
false)
23369 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
23375 const bool ignore_comments =
false)
23377 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23382 template <
typename InputType,
typename SAX>
23384 static
bool sax_parse(InputType&& i, SAX* sax,
23386 const
bool strict = true,
23387 const
bool ignore_comments = false)
23391 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23397 template<
class IteratorType,
class SAX>
23399 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23401 const
bool strict = true,
23402 const
bool ignore_comments = false)
23406 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23415 template <
typename SAX>
23418 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
23420 const
bool strict = true,
23421 const
bool ignore_comments = false)
23426 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23450 #endif // JSON_NO_IO
23462 switch (m_data.m_type)
23464 case value_t::null:
23466 case value_t::object:
23468 case value_t::array:
23470 case value_t::string:
23472 case value_t::boolean:
23476 case value_t::discarded:
23477 return "discarded";
23478 case value_t::number_integer:
23479 case value_t::number_unsigned:
23480 case value_t::number_float:
23497 json_value m_value = {};
23500 : m_type(v), m_value(v)
23507 m_value.array = create<array_t>(cnt, val);
23510 data() noexcept = default;
23511 data(data&&) noexcept = default;
23512 data(const data&) noexcept = delete;
23513 data& operator=(data&&) noexcept = delete;
23514 data& operator=(const data&) noexcept = delete;
23518 m_value.destroy(m_type);
23524 #if JSON_DIAGNOSTICS
23541 std::vector<std::uint8_t> result;
23542 to_cbor(j, result);
23564 std::vector<std::uint8_t> result;
23565 to_msgpack(j, result);
23586 const bool use_size =
false,
23587 const bool use_type =
false)
23589 std::vector<std::uint8_t> result;
23590 to_ubjson(j, result, use_size, use_type);
23597 const bool use_size =
false,
const bool use_type =
false)
23605 const bool use_size =
false,
const bool use_type =
false)
23613 const bool use_size =
false,
23614 const bool use_type =
false)
23616 std::vector<std::uint8_t> result;
23617 to_bjdata(j, result, use_size, use_type);
23624 const bool use_size =
false,
const bool use_type =
false)
23632 const bool use_size =
false,
const bool use_type =
false)
23641 std::vector<std::uint8_t> result;
23642 to_bson(j, result);
23662 template<
typename InputType>
23665 const bool strict =
true,
23666 const bool allow_exceptions =
true,
23672 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23673 return res ? result :
basic_json(value_t::discarded);
23678 template<
typename IteratorType>
23681 const bool strict =
true,
23682 const bool allow_exceptions =
true,
23688 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23689 return res ? result :
basic_json(value_t::discarded);
23692 template<
typename T>
23696 const
bool strict = true,
23697 const
bool allow_exceptions = true,
23700 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23706 const
bool strict = true,
23707 const
bool allow_exceptions = true,
23714 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23715 return res ? result :
basic_json(value_t::discarded);
23720 template<
typename InputType>
23723 const bool strict =
true,
23724 const bool allow_exceptions =
true)
23729 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23730 return res ? result :
basic_json(value_t::discarded);
23735 template<
typename IteratorType>
23738 const bool strict =
true,
23739 const bool allow_exceptions =
true)
23744 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23745 return res ? result :
basic_json(value_t::discarded);
23748 template<
typename T>
23752 const
bool strict = true,
23753 const
bool allow_exceptions = true)
23755 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23761 const
bool strict = true,
23762 const
bool allow_exceptions = true)
23768 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23769 return res ? result :
basic_json(value_t::discarded);
23774 template<
typename InputType>
23777 const bool strict =
true,
23778 const bool allow_exceptions =
true)
23783 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23784 return res ? result :
basic_json(value_t::discarded);
23789 template<
typename IteratorType>
23792 const bool strict =
true,
23793 const bool allow_exceptions =
true)
23798 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23799 return res ? result :
basic_json(value_t::discarded);
23802 template<
typename T>
23806 const
bool strict = true,
23807 const
bool allow_exceptions = true)
23809 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23815 const
bool strict = true,
23816 const
bool allow_exceptions = true)
23822 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23823 return res ? result :
basic_json(value_t::discarded);
23828 template<
typename InputType>
23831 const bool strict =
true,
23832 const bool allow_exceptions =
true)
23837 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23838 return res ? result :
basic_json(value_t::discarded);
23843 template<
typename IteratorType>
23846 const bool strict =
true,
23847 const bool allow_exceptions =
true)
23852 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23853 return res ? result :
basic_json(value_t::discarded);
23858 template<
typename InputType>
23861 const bool strict =
true,
23862 const bool allow_exceptions =
true)
23868 return res ? result :
basic_json(value_t::discarded);
23873 template<
typename IteratorType>
23876 const bool strict =
true,
23877 const bool allow_exceptions =
true)
23883 return res ? result :
basic_json(value_t::discarded);
23886 template<
typename T>
23890 const
bool strict = true,
23891 const
bool allow_exceptions = true)
23893 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23899 const
bool strict = true,
23900 const
bool allow_exceptions = true)
23907 return res ? result :
basic_json(value_t::discarded);
23927 reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
23929 return ptr.get_unchecked(
this);
23941 const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
23943 return ptr.get_unchecked(
this);
23955 reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
23957 return ptr.get_checked(
this);
23969 const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
23971 return ptr.get_checked(
this);
24001 void patch_inplace(
const basic_json& json_patch)
24005 enum class patch_operations {add, remove,
replace, move, copy, test, invalid};
24007 const auto get_op = [](
const std::string &
op)
24011 return patch_operations::add;
24013 if (
op ==
"remove")
24015 return patch_operations::remove;
24017 if (
op ==
"replace")
24019 return patch_operations::replace;
24023 return patch_operations::move;
24027 return patch_operations::copy;
24031 return patch_operations::test;
24034 return patch_operations::invalid;
24049 if (top_pointer != ptr)
24051 result.
at(top_pointer);
24055 const auto last_path = ptr.
back();
24060 switch (parent.
m_data.m_type)
24062 case value_t::null:
24063 case value_t::object:
24066 parent[last_path] = val;
24070 case value_t::array:
24072 if (last_path ==
"-")
24079 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24087 parent.
insert(parent.begin() +
static_cast<difference_type
>(idx), val);
24093 case value_t::string:
24094 case value_t::boolean:
24095 case value_t::number_integer:
24096 case value_t::number_unsigned:
24097 case value_t::number_float:
24099 case value_t::discarded:
24106 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24109 const auto last_path = ptr.
back();
24117 auto it = parent.
find(last_path);
24130 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24137 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
24141 for (
const auto& val : json_patch)
24144 const auto get_value = [&val](
const std::string &
op,
24145 const std::string &
member,
24152 const auto error_msg = (
op ==
"op") ?
"operation" :
detail::concat(
"operation '",
op,
'\'');
24175 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
24179 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24180 const auto path = get_value(
op,
"path",
true).template get<std::string>();
24183 switch (get_op(
op))
24185 case patch_operations::add:
24187 operation_add(ptr, get_value(
"add",
"value",
false));
24191 case patch_operations::remove:
24193 operation_remove(ptr);
24197 case patch_operations::replace:
24200 result.
at(ptr) = get_value(
"replace",
"value",
false);
24204 case patch_operations::move:
24206 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24216 operation_remove(from_ptr);
24217 operation_add(ptr, v);
24221 case patch_operations::copy:
24223 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24232 operation_add(ptr, v);
24236 case patch_operations::test:
24243 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24259 case patch_operations::invalid:
24275 result.patch_inplace(json_patch);
24283 const std::string& path =
"")
24289 if (source == target)
24294 if (source.
type() != target.
type())
24299 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24304 switch (source.
type())
24306 case value_t::array:
24310 while (i < source.size() && i < target.size())
24314 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
24323 while (i < source.size())
24327 result.
insert(result.begin() + end_index, object(
24336 while (i < target.size())
24342 {
"value", target[i]}
24350 case value_t::object:
24353 for (
auto it = source.cbegin(); it != source.cend(); ++it)
24358 if (target.
find(it.key()) != target.end())
24361 auto temp_diff = diff(it.value(), target[it.key()], path_key);
24362 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
24369 {
"op",
"remove"}, {
"path", path_key}
24375 for (
auto it = target.cbegin(); it != target.cend(); ++it)
24377 if (source.
find(it.key()) == source.end())
24383 {
"op",
"add"}, {
"path", path_key},
24384 {
"value", it.value()}
24392 case value_t::null:
24393 case value_t::string:
24394 case value_t::boolean:
24395 case value_t::number_integer:
24396 case value_t::number_unsigned:
24397 case value_t::number_float:
24399 case value_t::discarded:
24405 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24432 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
24434 if (it.value().is_null())
24440 operator[](it.key()).merge_patch(it.value());
24446 *
this = apply_patch;
24463 inline namespace json_literals
24469 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24472 inline nlohmann::json operator "" _json(
const char* s, std::size_t
n)
24481 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24482 inline nlohmann::json::json_pointer
operator ""_json_pointer(
const char* s, std::size_t
n)
24484 inline nlohmann::json::json_pointer
operator "" _json_pointer(
const char* s, std::size_t
n)
24487 return nlohmann::json::json_pointer(std::string(s,
n));
24523 #if JSON_HAS_THREE_WAY_COMPARISON
24524 return std::is_lt(lhs <=> rhs);
24532 #ifndef JSON_HAS_CPP_20
24548 #if JSON_USE_GLOBAL_UDLS
24549 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24550 using nlohmann::literals::json_literals::operator
""_json;
24551 using nlohmann::literals::json_literals::operator
""_json_pointer;
24553 using nlohmann::literals::json_literals::operator
"" _json;
24554 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24570 #if defined(__clang__)
24571 #pragma clang diagnostic pop
24576 #undef JSON_INTERNAL_CATCH
24578 #undef JSON_PRIVATE_UNLESS_TESTED
24579 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24580 #undef NLOHMANN_BASIC_JSON_TPL
24581 #undef JSON_EXPLICIT
24582 #undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24583 #undef JSON_INLINE_VARIABLE
24584 #undef JSON_NO_UNIQUE_ADDRESS
24585 #undef JSON_DISABLE_ENUM_SERIALIZATION
24586 #undef JSON_USE_GLOBAL_UDLS
24588 #ifndef JSON_TEST_KEEP_MACROS
24591 #undef JSON_HAS_CPP_11
24592 #undef JSON_HAS_CPP_14
24593 #undef JSON_HAS_CPP_17
24594 #undef JSON_HAS_CPP_20
24595 #undef JSON_HAS_FILESYSTEM
24596 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24597 #undef JSON_HAS_THREE_WAY_COMPARISON
24598 #undef JSON_HAS_RANGES
24599 #undef JSON_HAS_STATIC_RTTI
24600 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24614 #undef JSON_HEDLEY_ALWAYS_INLINE
24615 #undef JSON_HEDLEY_ARM_VERSION
24616 #undef JSON_HEDLEY_ARM_VERSION_CHECK
24617 #undef JSON_HEDLEY_ARRAY_PARAM
24618 #undef JSON_HEDLEY_ASSUME
24619 #undef JSON_HEDLEY_BEGIN_C_DECLS
24620 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24621 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24622 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24623 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24624 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24625 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
24626 #undef JSON_HEDLEY_CLANG_HAS_WARNING
24627 #undef JSON_HEDLEY_COMPCERT_VERSION
24628 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24629 #undef JSON_HEDLEY_CONCAT
24630 #undef JSON_HEDLEY_CONCAT3
24631 #undef JSON_HEDLEY_CONCAT3_EX
24632 #undef JSON_HEDLEY_CONCAT_EX
24633 #undef JSON_HEDLEY_CONST
24634 #undef JSON_HEDLEY_CONSTEXPR
24635 #undef JSON_HEDLEY_CONST_CAST
24636 #undef JSON_HEDLEY_CPP_CAST
24637 #undef JSON_HEDLEY_CRAY_VERSION
24638 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
24639 #undef JSON_HEDLEY_C_DECL
24640 #undef JSON_HEDLEY_DEPRECATED
24641 #undef JSON_HEDLEY_DEPRECATED_FOR
24642 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24643 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24644 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24645 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24646 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24647 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24648 #undef JSON_HEDLEY_DIAGNOSTIC_POP
24649 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24650 #undef JSON_HEDLEY_DMC_VERSION
24651 #undef JSON_HEDLEY_DMC_VERSION_CHECK
24652 #undef JSON_HEDLEY_EMPTY_BASES
24653 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24654 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24655 #undef JSON_HEDLEY_END_C_DECLS
24656 #undef JSON_HEDLEY_FLAGS
24657 #undef JSON_HEDLEY_FLAGS_CAST
24658 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24659 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
24660 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24661 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24662 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
24663 #undef JSON_HEDLEY_GCC_HAS_FEATURE
24664 #undef JSON_HEDLEY_GCC_HAS_WARNING
24665 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24666 #undef JSON_HEDLEY_GCC_VERSION
24667 #undef JSON_HEDLEY_GCC_VERSION_CHECK
24668 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24669 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24670 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24671 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24672 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24673 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
24674 #undef JSON_HEDLEY_GNUC_HAS_WARNING
24675 #undef JSON_HEDLEY_GNUC_VERSION
24676 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
24677 #undef JSON_HEDLEY_HAS_ATTRIBUTE
24678 #undef JSON_HEDLEY_HAS_BUILTIN
24679 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24680 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24681 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24682 #undef JSON_HEDLEY_HAS_EXTENSION
24683 #undef JSON_HEDLEY_HAS_FEATURE
24684 #undef JSON_HEDLEY_HAS_WARNING
24685 #undef JSON_HEDLEY_IAR_VERSION
24686 #undef JSON_HEDLEY_IAR_VERSION_CHECK
24687 #undef JSON_HEDLEY_IBM_VERSION
24688 #undef JSON_HEDLEY_IBM_VERSION_CHECK
24689 #undef JSON_HEDLEY_IMPORT
24690 #undef JSON_HEDLEY_INLINE
24691 #undef JSON_HEDLEY_INTEL_CL_VERSION
24692 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24693 #undef JSON_HEDLEY_INTEL_VERSION
24694 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
24695 #undef JSON_HEDLEY_IS_CONSTANT
24696 #undef JSON_HEDLEY_IS_CONSTEXPR_
24697 #undef JSON_HEDLEY_LIKELY
24698 #undef JSON_HEDLEY_MALLOC
24699 #undef JSON_HEDLEY_MCST_LCC_VERSION
24700 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24701 #undef JSON_HEDLEY_MESSAGE
24702 #undef JSON_HEDLEY_MSVC_VERSION
24703 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
24704 #undef JSON_HEDLEY_NEVER_INLINE
24705 #undef JSON_HEDLEY_NON_NULL
24706 #undef JSON_HEDLEY_NO_ESCAPE
24707 #undef JSON_HEDLEY_NO_RETURN
24708 #undef JSON_HEDLEY_NO_THROW
24709 #undef JSON_HEDLEY_NULL
24710 #undef JSON_HEDLEY_PELLES_VERSION
24711 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
24712 #undef JSON_HEDLEY_PGI_VERSION
24713 #undef JSON_HEDLEY_PGI_VERSION_CHECK
24714 #undef JSON_HEDLEY_PREDICT
24715 #undef JSON_HEDLEY_PRINTF_FORMAT
24716 #undef JSON_HEDLEY_PRIVATE
24717 #undef JSON_HEDLEY_PUBLIC
24718 #undef JSON_HEDLEY_PURE
24719 #undef JSON_HEDLEY_REINTERPRET_CAST
24720 #undef JSON_HEDLEY_REQUIRE
24721 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24722 #undef JSON_HEDLEY_REQUIRE_MSG
24723 #undef JSON_HEDLEY_RESTRICT
24724 #undef JSON_HEDLEY_RETURNS_NON_NULL
24725 #undef JSON_HEDLEY_SENTINEL
24726 #undef JSON_HEDLEY_STATIC_ASSERT
24727 #undef JSON_HEDLEY_STATIC_CAST
24728 #undef JSON_HEDLEY_STRINGIFY
24729 #undef JSON_HEDLEY_STRINGIFY_EX
24730 #undef JSON_HEDLEY_SUNPRO_VERSION
24731 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24732 #undef JSON_HEDLEY_TINYC_VERSION
24733 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
24734 #undef JSON_HEDLEY_TI_ARMCL_VERSION
24735 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24736 #undef JSON_HEDLEY_TI_CL2000_VERSION
24737 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24738 #undef JSON_HEDLEY_TI_CL430_VERSION
24739 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24740 #undef JSON_HEDLEY_TI_CL6X_VERSION
24741 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24742 #undef JSON_HEDLEY_TI_CL7X_VERSION
24743 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24744 #undef JSON_HEDLEY_TI_CLPRU_VERSION
24745 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24746 #undef JSON_HEDLEY_TI_VERSION
24747 #undef JSON_HEDLEY_TI_VERSION_CHECK
24748 #undef JSON_HEDLEY_UNAVAILABLE
24749 #undef JSON_HEDLEY_UNLIKELY
24750 #undef JSON_HEDLEY_UNPREDICTABLE
24751 #undef JSON_HEDLEY_UNREACHABLE
24752 #undef JSON_HEDLEY_UNREACHABLE_RETURN
24753 #undef JSON_HEDLEY_VERSION
24754 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24755 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
24756 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
24757 #undef JSON_HEDLEY_VERSION_ENCODE
24758 #undef JSON_HEDLEY_WARNING
24759 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
24760 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24761 #undef JSON_HEDLEY_FALL_THROUGH
24765 #endif // INCLUDE_NLOHMANN_JSON_HPP_