18 #ifndef INCLUDE_NLOHMANN_JSON_HPP_
19 #define INCLUDE_NLOHMANN_JSON_HPP_
24 #include <initializer_list>
61 #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
62 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
63 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 1
64 #warning "Already included a different version of the library!"
69 #define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
70 #define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum)
71 #define NLOHMANN_JSON_VERSION_PATCH 1 // NOLINT(modernize-macro-to-enum)
73 #ifndef JSON_DIAGNOSTICS
74 #define JSON_DIAGNOSTICS 0
77 #ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
78 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
82 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
84 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
87 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
88 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
90 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
93 #define NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch) \
94 json_v ## major ## _ ## minor ## _ ## patch
95 #define NLOHMANN_JSON_ABI_PREFIX(major, minor, patch) \
96 NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch)
98 #define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c
99 #define NLOHMANN_JSON_ABI_CONCAT(a, b, c) \
100 NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c)
102 #define NLOHMANN_JSON_ABI_STRING \
103 NLOHMANN_JSON_ABI_CONCAT( \
104 NLOHMANN_JSON_ABI_PREFIX( \
105 NLOHMANN_JSON_VERSION_MAJOR, \
106 NLOHMANN_JSON_VERSION_MINOR, \
107 NLOHMANN_JSON_VERSION_PATCH), \
108 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
109 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
111 #ifndef NLOHMANN_JSON_NAMESPACE
112 #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING
115 #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
116 #define NLOHMANN_JSON_NAMESPACE_BEGIN \
119 inline namespace NLOHMANN_JSON_ABI_STRING \
123 #ifndef NLOHMANN_JSON_NAMESPACE_END
124 #define NLOHMANN_JSON_NAMESPACE_END \
142 #include <forward_list>
147 #include <type_traits>
148 #include <unordered_map>
208 #include <type_traits>
249 void operator=(
nonesuch const&) =
delete;
250 void operator=(
nonesuch&&) =
delete;
253 template<
class Default,
255 template<
class...>
class Op,
263 template<
class Default,
template<
class...>
class Op,
class... Args>
270 template<
template<
class...>
class Op,
class... Args>
273 template<
template<
class...>
class Op,
class... Args>
276 template<
template<
class...>
class Op,
class... Args>
279 template<
class Default,
template<
class...>
class Op,
class... Args>
282 template<
class Default,
template<
class...>
class Op,
class... Args>
285 template<
class Expected,
template<
class...>
class Op,
class... Args>
288 template<
class To,
template<
class...>
class Op,
class... Args>
311 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
312 #if defined(JSON_HEDLEY_VERSION)
313 #undef JSON_HEDLEY_VERSION
315 #define JSON_HEDLEY_VERSION 15
317 #if defined(JSON_HEDLEY_STRINGIFY_EX)
318 #undef JSON_HEDLEY_STRINGIFY_EX
320 #define JSON_HEDLEY_STRINGIFY_EX(x) #x
322 #if defined(JSON_HEDLEY_STRINGIFY)
323 #undef JSON_HEDLEY_STRINGIFY
325 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
327 #if defined(JSON_HEDLEY_CONCAT_EX)
328 #undef JSON_HEDLEY_CONCAT_EX
330 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b
332 #if defined(JSON_HEDLEY_CONCAT)
333 #undef JSON_HEDLEY_CONCAT
335 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
337 #if defined(JSON_HEDLEY_CONCAT3_EX)
338 #undef JSON_HEDLEY_CONCAT3_EX
340 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
342 #if defined(JSON_HEDLEY_CONCAT3)
343 #undef JSON_HEDLEY_CONCAT3
345 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
347 #if defined(JSON_HEDLEY_VERSION_ENCODE)
348 #undef JSON_HEDLEY_VERSION_ENCODE
350 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
352 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
353 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
355 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
357 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
358 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
360 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
362 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
363 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
365 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
367 #if defined(JSON_HEDLEY_GNUC_VERSION)
368 #undef JSON_HEDLEY_GNUC_VERSION
370 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
371 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
372 #elif defined(__GNUC__)
373 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
376 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
377 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
379 #if defined(JSON_HEDLEY_GNUC_VERSION)
380 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
382 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
385 #if defined(JSON_HEDLEY_MSVC_VERSION)
386 #undef JSON_HEDLEY_MSVC_VERSION
388 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
389 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
390 #elif defined(_MSC_FULL_VER) && !defined(__ICL)
391 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
392 #elif defined(_MSC_VER) && !defined(__ICL)
393 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
396 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
397 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
399 #if !defined(JSON_HEDLEY_MSVC_VERSION)
400 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
401 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
402 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
403 #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
404 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
406 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
409 #if defined(JSON_HEDLEY_INTEL_VERSION)
410 #undef JSON_HEDLEY_INTEL_VERSION
412 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
413 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
414 #elif defined(__INTEL_COMPILER) && !defined(__ICL)
415 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
418 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
419 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
421 #if defined(JSON_HEDLEY_INTEL_VERSION)
422 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
424 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
427 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
428 #undef JSON_HEDLEY_INTEL_CL_VERSION
430 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
431 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
434 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
435 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
437 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
438 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
440 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
443 #if defined(JSON_HEDLEY_PGI_VERSION)
444 #undef JSON_HEDLEY_PGI_VERSION
446 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
447 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
450 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
451 #undef JSON_HEDLEY_PGI_VERSION_CHECK
453 #if defined(JSON_HEDLEY_PGI_VERSION)
454 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
456 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
459 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
460 #undef JSON_HEDLEY_SUNPRO_VERSION
462 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
463 #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)
464 #elif defined(__SUNPRO_C)
465 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
466 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
467 #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)
468 #elif defined(__SUNPRO_CC)
469 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
472 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
473 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
475 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
476 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
478 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
481 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
482 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
484 #if defined(__EMSCRIPTEN__)
485 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
488 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
489 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
491 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
492 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
494 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
497 #if defined(JSON_HEDLEY_ARM_VERSION)
498 #undef JSON_HEDLEY_ARM_VERSION
500 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
501 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
502 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
503 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
506 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
507 #undef JSON_HEDLEY_ARM_VERSION_CHECK
509 #if defined(JSON_HEDLEY_ARM_VERSION)
510 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
515 #if defined(JSON_HEDLEY_IBM_VERSION)
516 #undef JSON_HEDLEY_IBM_VERSION
518 #if defined(__ibmxl__)
519 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
520 #elif defined(__xlC__) && defined(__xlC_ver__)
521 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
522 #elif defined(__xlC__)
523 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
526 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
527 #undef JSON_HEDLEY_IBM_VERSION_CHECK
529 #if defined(JSON_HEDLEY_IBM_VERSION)
530 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
532 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
535 #if defined(JSON_HEDLEY_TI_VERSION)
536 #undef JSON_HEDLEY_TI_VERSION
539 defined(__TI_COMPILER_VERSION__) && \
541 defined(__TMS470__) || defined(__TI_ARM__) || \
542 defined(__MSP430__) || \
543 defined(__TMS320C2000__) \
545 #if (__TI_COMPILER_VERSION__ >= 16000000)
546 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
550 #if defined(JSON_HEDLEY_TI_VERSION_CHECK)
551 #undef JSON_HEDLEY_TI_VERSION_CHECK
553 #if defined(JSON_HEDLEY_TI_VERSION)
554 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
556 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
559 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
560 #undef JSON_HEDLEY_TI_CL2000_VERSION
562 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
563 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
566 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
567 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
569 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
570 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
572 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
575 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
576 #undef JSON_HEDLEY_TI_CL430_VERSION
578 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
579 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
582 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
583 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
585 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
586 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
588 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
591 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
592 #undef JSON_HEDLEY_TI_ARMCL_VERSION
594 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
595 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
598 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
599 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
601 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
602 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
604 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
607 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
608 #undef JSON_HEDLEY_TI_CL6X_VERSION
610 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
611 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
614 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
615 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
617 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
618 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
620 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
623 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
624 #undef JSON_HEDLEY_TI_CL7X_VERSION
626 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
627 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
630 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
631 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
633 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
634 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
636 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
639 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
640 #undef JSON_HEDLEY_TI_CLPRU_VERSION
642 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
643 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
646 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
647 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
649 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
650 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
652 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
655 #if defined(JSON_HEDLEY_CRAY_VERSION)
656 #undef JSON_HEDLEY_CRAY_VERSION
659 #if defined(_RELEASE_PATCHLEVEL)
660 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
662 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
666 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
667 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
669 #if defined(JSON_HEDLEY_CRAY_VERSION)
670 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
672 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
675 #if defined(JSON_HEDLEY_IAR_VERSION)
676 #undef JSON_HEDLEY_IAR_VERSION
678 #if defined(__IAR_SYSTEMS_ICC__)
680 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
682 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
686 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
687 #undef JSON_HEDLEY_IAR_VERSION_CHECK
689 #if defined(JSON_HEDLEY_IAR_VERSION)
690 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
692 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
695 #if defined(JSON_HEDLEY_TINYC_VERSION)
696 #undef JSON_HEDLEY_TINYC_VERSION
698 #if defined(__TINYC__)
699 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
702 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
703 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
705 #if defined(JSON_HEDLEY_TINYC_VERSION)
706 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
708 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
711 #if defined(JSON_HEDLEY_DMC_VERSION)
712 #undef JSON_HEDLEY_DMC_VERSION
715 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
718 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
719 #undef JSON_HEDLEY_DMC_VERSION_CHECK
721 #if defined(JSON_HEDLEY_DMC_VERSION)
722 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
724 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
727 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
728 #undef JSON_HEDLEY_COMPCERT_VERSION
730 #if defined(__COMPCERT_VERSION__)
731 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
734 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
735 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
737 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
738 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
740 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
743 #if defined(JSON_HEDLEY_PELLES_VERSION)
744 #undef JSON_HEDLEY_PELLES_VERSION
746 #if defined(__POCC__)
747 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
750 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
751 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
753 #if defined(JSON_HEDLEY_PELLES_VERSION)
754 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
756 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
759 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
760 #undef JSON_HEDLEY_MCST_LCC_VERSION
762 #if defined(__LCC__) && defined(__LCC_MINOR__)
763 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
766 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
767 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
769 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
770 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
772 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
775 #if defined(JSON_HEDLEY_GCC_VERSION)
776 #undef JSON_HEDLEY_GCC_VERSION
779 defined(JSON_HEDLEY_GNUC_VERSION) && \
780 !defined(__clang__) && \
781 !defined(JSON_HEDLEY_INTEL_VERSION) && \
782 !defined(JSON_HEDLEY_PGI_VERSION) && \
783 !defined(JSON_HEDLEY_ARM_VERSION) && \
784 !defined(JSON_HEDLEY_CRAY_VERSION) && \
785 !defined(JSON_HEDLEY_TI_VERSION) && \
786 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
787 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
788 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
789 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
790 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
791 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
792 !defined(__COMPCERT__) && \
793 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
794 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
797 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
798 #undef JSON_HEDLEY_GCC_VERSION_CHECK
800 #if defined(JSON_HEDLEY_GCC_VERSION)
801 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
803 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
806 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
807 #undef JSON_HEDLEY_HAS_ATTRIBUTE
810 defined(__has_attribute) && \
812 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
814 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
816 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
819 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
820 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
822 #if defined(__has_attribute)
823 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
825 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
828 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
829 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
831 #if defined(__has_attribute)
832 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
834 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
837 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
838 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
841 defined(__has_cpp_attribute) && \
842 defined(__cplusplus) && \
843 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
844 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
846 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
849 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
850 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
852 #if !defined(__cplusplus) || !defined(__has_cpp_attribute)
853 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
855 !defined(JSON_HEDLEY_PGI_VERSION) && \
856 !defined(JSON_HEDLEY_IAR_VERSION) && \
857 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
858 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
859 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
861 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
864 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
865 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
867 #if defined(__has_cpp_attribute) && defined(__cplusplus)
868 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
870 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
873 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
874 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
876 #if defined(__has_cpp_attribute) && defined(__cplusplus)
877 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
879 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
882 #if defined(JSON_HEDLEY_HAS_BUILTIN)
883 #undef JSON_HEDLEY_HAS_BUILTIN
885 #if defined(__has_builtin)
886 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
888 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
891 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
892 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
894 #if defined(__has_builtin)
895 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
897 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
900 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
901 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
903 #if defined(__has_builtin)
904 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
906 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
909 #if defined(JSON_HEDLEY_HAS_FEATURE)
910 #undef JSON_HEDLEY_HAS_FEATURE
912 #if defined(__has_feature)
913 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
915 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
918 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
919 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
921 #if defined(__has_feature)
922 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
924 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
927 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
928 #undef JSON_HEDLEY_GCC_HAS_FEATURE
930 #if defined(__has_feature)
931 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
933 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
936 #if defined(JSON_HEDLEY_HAS_EXTENSION)
937 #undef JSON_HEDLEY_HAS_EXTENSION
939 #if defined(__has_extension)
940 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
942 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
945 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
946 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
948 #if defined(__has_extension)
949 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
951 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
954 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
955 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
957 #if defined(__has_extension)
958 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
960 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
963 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
964 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
966 #if defined(__has_declspec_attribute)
967 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
969 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
972 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
973 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
975 #if defined(__has_declspec_attribute)
976 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
978 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
981 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
982 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
984 #if defined(__has_declspec_attribute)
985 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
987 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
990 #if defined(JSON_HEDLEY_HAS_WARNING)
991 #undef JSON_HEDLEY_HAS_WARNING
993 #if defined(__has_warning)
994 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
996 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
999 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1000 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1002 #if defined(__has_warning)
1003 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1005 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1008 #if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1009 #undef JSON_HEDLEY_GCC_HAS_WARNING
1011 #if defined(__has_warning)
1012 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1014 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1018 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1019 defined(__clang__) || \
1020 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1021 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1022 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1023 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1024 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1025 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1026 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1027 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1028 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1029 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1030 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1031 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1032 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1033 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1034 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1035 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1036 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1037 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1038 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1040 #define JSON_HEDLEY_PRAGMA(value)
1043 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1044 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1046 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1047 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1049 #if defined(__clang__)
1050 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1051 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1052 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1053 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1054 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1055 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1056 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1057 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1059 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1060 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1061 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1062 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1063 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1064 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1065 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1067 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1068 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1069 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1070 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1071 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1072 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1073 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1074 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1075 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1076 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1077 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1079 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1080 #define JSON_HEDLEY_DIAGNOSTIC_POP
1085 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1086 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1088 #if defined(__cplusplus)
1089 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1090 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1091 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1092 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1093 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1094 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1095 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1096 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1098 JSON_HEDLEY_DIAGNOSTIC_POP
1100 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1101 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1102 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1103 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1105 JSON_HEDLEY_DIAGNOSTIC_POP
1108 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1109 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1110 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1112 JSON_HEDLEY_DIAGNOSTIC_POP
1116 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1117 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1120 #if defined(JSON_HEDLEY_CONST_CAST)
1121 #undef JSON_HEDLEY_CONST_CAST
1123 #if defined(__cplusplus)
1124 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1126 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1127 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1128 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1129 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1130 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1131 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1133 JSON_HEDLEY_DIAGNOSTIC_POP \
1136 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1139 #if defined(JSON_HEDLEY_REINTERPRET_CAST)
1140 #undef JSON_HEDLEY_REINTERPRET_CAST
1142 #if defined(__cplusplus)
1143 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1145 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1148 #if defined(JSON_HEDLEY_STATIC_CAST)
1149 #undef JSON_HEDLEY_STATIC_CAST
1151 #if defined(__cplusplus)
1152 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1154 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1157 #if defined(JSON_HEDLEY_CPP_CAST)
1158 #undef JSON_HEDLEY_CPP_CAST
1160 #if defined(__cplusplus)
1161 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1162 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1163 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1164 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1166 JSON_HEDLEY_DIAGNOSTIC_POP
1167 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1168 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1169 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1170 _Pragma("diag_suppress=Pe137") \
1171 JSON_HEDLEY_DIAGNOSTIC_POP
1173 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1176 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1179 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1180 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1182 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1183 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1184 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1185 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1186 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1187 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1188 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1189 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1190 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1191 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1192 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1193 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1194 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1195 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1196 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1197 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1199 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1200 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1201 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1202 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1203 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1204 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1205 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1206 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1207 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1208 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1209 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1211 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1213 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1215 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1217 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1223 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1224 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1226 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1227 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1228 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1229 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1230 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1232 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1233 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1234 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1235 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1236 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1239 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1240 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1241 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1242 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1243 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1244 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1245 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1246 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1247 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1248 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1249 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1251 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1254 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1255 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1257 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1259 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1260 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1261 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1262 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1263 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1264 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1265 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1267 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1269 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1271 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1274 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1275 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1276 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1277 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1278 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1280 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1286 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1287 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1289 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1290 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1291 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1292 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1293 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1299 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1300 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1302 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1303 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1304 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1305 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1306 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1307 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1308 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1309 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1314 #if defined(JSON_HEDLEY_DEPRECATED)
1315 #undef JSON_HEDLEY_DEPRECATED
1317 #if defined(JSON_HEDLEY_DEPRECATED_FOR)
1318 #undef JSON_HEDLEY_DEPRECATED_FOR
1321 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1322 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1323 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1324 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1326 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1327 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1328 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1329 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1330 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1331 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1332 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1333 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1334 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1335 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1336 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1337 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1338 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1339 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1340 #elif defined(__cplusplus) && (__cplusplus >= 201402L)
1341 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1342 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1344 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1345 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1346 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1347 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1348 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1349 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1350 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1351 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1352 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1353 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1354 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1355 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1356 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1357 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1358 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1359 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1360 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1361 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1363 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1364 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1365 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1366 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1367 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1368 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1369 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1370 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1372 #define JSON_HEDLEY_DEPRECATED(since)
1373 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1376 #if defined(JSON_HEDLEY_UNAVAILABLE)
1377 #undef JSON_HEDLEY_UNAVAILABLE
1380 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1381 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1382 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1383 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1384 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1386 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1389 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1390 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1392 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1393 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1396 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1397 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1398 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1399 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1400 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1401 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1402 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1403 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1404 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1405 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1406 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1407 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1408 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1409 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1410 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1411 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1412 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1413 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1414 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1415 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1416 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1417 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1418 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1419 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1420 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1421 #elif defined(_Check_return_)
1422 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1423 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1425 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1426 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1429 #if defined(JSON_HEDLEY_SENTINEL)
1430 #undef JSON_HEDLEY_SENTINEL
1433 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1434 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1435 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1436 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1437 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1438 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1440 #define JSON_HEDLEY_SENTINEL(position)
1443 #if defined(JSON_HEDLEY_NO_RETURN)
1444 #undef JSON_HEDLEY_NO_RETURN
1446 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1447 #define JSON_HEDLEY_NO_RETURN __noreturn
1449 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1450 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1451 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1452 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1453 #define JSON_HEDLEY_NO_RETURN _Noreturn
1454 #elif defined(__cplusplus) && (__cplusplus >= 201103L)
1455 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1457 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1458 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1459 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1460 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1461 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1462 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1463 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1464 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1465 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1466 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1467 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1468 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1469 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1470 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1471 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1472 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1473 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1474 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1475 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1476 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1478 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1479 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1480 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1481 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1482 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1483 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1484 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1485 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1486 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1488 #define JSON_HEDLEY_NO_RETURN
1491 #if defined(JSON_HEDLEY_NO_ESCAPE)
1492 #undef JSON_HEDLEY_NO_ESCAPE
1494 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1495 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1497 #define JSON_HEDLEY_NO_ESCAPE
1500 #if defined(JSON_HEDLEY_UNREACHABLE)
1501 #undef JSON_HEDLEY_UNREACHABLE
1503 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1504 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1506 #if defined(JSON_HEDLEY_ASSUME)
1507 #undef JSON_HEDLEY_ASSUME
1510 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1511 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1512 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1513 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1514 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1515 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1517 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1518 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1519 #if defined(__cplusplus)
1520 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1522 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1526 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1527 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1528 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1529 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1530 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1531 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1532 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1533 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1534 #elif defined(JSON_HEDLEY_ASSUME)
1535 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1537 #if !defined(JSON_HEDLEY_ASSUME)
1538 #if defined(JSON_HEDLEY_UNREACHABLE)
1539 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1541 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1544 #if defined(JSON_HEDLEY_UNREACHABLE)
1546 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1547 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1548 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1550 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1553 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1555 #if !defined(JSON_HEDLEY_UNREACHABLE)
1556 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1560 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1561 #pragma clang diagnostic ignored "-Wpedantic"
1563 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1564 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1566 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1567 #if defined(__clang__)
1568 #pragma clang diagnostic ignored "-Wvariadic-macros"
1569 #elif defined(JSON_HEDLEY_GCC_VERSION)
1570 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1573 #if defined(JSON_HEDLEY_NON_NULL)
1574 #undef JSON_HEDLEY_NON_NULL
1577 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1578 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1579 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1580 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1581 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1583 #define JSON_HEDLEY_NON_NULL(...)
1587 #if defined(JSON_HEDLEY_PRINTF_FORMAT)
1588 #undef JSON_HEDLEY_PRINTF_FORMAT
1590 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1591 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1592 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1593 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1595 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1596 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1597 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1598 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1599 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1600 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1601 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1602 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1603 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1604 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1605 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1606 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1607 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1608 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1609 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1610 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1611 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1612 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1613 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1614 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1616 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1619 #if defined(JSON_HEDLEY_CONSTEXPR)
1620 #undef JSON_HEDLEY_CONSTEXPR
1622 #if defined(__cplusplus)
1623 #if __cplusplus >= 201103L
1624 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1627 #if !defined(JSON_HEDLEY_CONSTEXPR)
1628 #define JSON_HEDLEY_CONSTEXPR
1631 #if defined(JSON_HEDLEY_PREDICT)
1632 #undef JSON_HEDLEY_PREDICT
1634 #if defined(JSON_HEDLEY_LIKELY)
1635 #undef JSON_HEDLEY_LIKELY
1637 #if defined(JSON_HEDLEY_UNLIKELY)
1638 #undef JSON_HEDLEY_UNLIKELY
1640 #if defined(JSON_HEDLEY_UNPREDICTABLE)
1641 #undef JSON_HEDLEY_UNPREDICTABLE
1643 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1644 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1647 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1648 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1649 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1650 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1651 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1652 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1653 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1654 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1656 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1657 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1658 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1659 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1660 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1661 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1662 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1663 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1664 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1665 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1666 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1667 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1668 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1669 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1670 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1671 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1672 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1673 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1674 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1676 double hedley_probability_ = (probability); \
1677 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1679 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1681 double hedley_probability_ = (probability); \
1682 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1684 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1685 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1687 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1688 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1689 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1690 # define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1691 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1693 #if !defined(JSON_HEDLEY_UNPREDICTABLE)
1694 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1697 #if defined(JSON_HEDLEY_MALLOC)
1698 #undef JSON_HEDLEY_MALLOC
1701 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1702 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1703 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1704 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1705 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1706 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1707 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1708 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1709 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1710 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1711 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1712 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1713 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1714 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1715 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1716 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1717 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1718 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1719 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1720 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1721 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1723 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1724 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1725 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1727 #define JSON_HEDLEY_MALLOC
1730 #if defined(JSON_HEDLEY_PURE)
1731 #undef JSON_HEDLEY_PURE
1734 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1735 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1736 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1737 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1738 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1739 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1740 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1741 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1742 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1743 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1744 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1745 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1746 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1747 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1748 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1749 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1750 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1751 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1752 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1753 # define JSON_HEDLEY_PURE __attribute__((__pure__))
1754 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1755 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1756 #elif defined(__cplusplus) && \
1758 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1759 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1760 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1762 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1764 # define JSON_HEDLEY_PURE
1767 #if defined(JSON_HEDLEY_CONST)
1768 #undef JSON_HEDLEY_CONST
1771 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1772 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1773 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1774 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1775 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1776 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1777 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1778 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1779 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1780 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1781 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1782 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1783 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1784 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1785 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1786 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1787 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1788 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1789 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1790 #define JSON_HEDLEY_CONST __attribute__((__const__))
1792 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1793 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1795 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1798 #if defined(JSON_HEDLEY_RESTRICT)
1799 #undef JSON_HEDLEY_RESTRICT
1801 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1802 #define JSON_HEDLEY_RESTRICT restrict
1804 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1805 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1806 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1807 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1808 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1809 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1810 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1811 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1812 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1813 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1814 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1815 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1816 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1817 defined(__clang__) || \
1818 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1819 #define JSON_HEDLEY_RESTRICT __restrict
1820 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1821 #define JSON_HEDLEY_RESTRICT _Restrict
1823 #define JSON_HEDLEY_RESTRICT
1826 #if defined(JSON_HEDLEY_INLINE)
1827 #undef JSON_HEDLEY_INLINE
1830 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1831 (defined(__cplusplus) && (__cplusplus >= 199711L))
1832 #define JSON_HEDLEY_INLINE inline
1834 defined(JSON_HEDLEY_GCC_VERSION) || \
1835 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1836 #define JSON_HEDLEY_INLINE __inline__
1838 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1839 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1840 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1841 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1842 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1843 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1844 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1845 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1846 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1847 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1848 #define JSON_HEDLEY_INLINE __inline
1850 #define JSON_HEDLEY_INLINE
1853 #if defined(JSON_HEDLEY_ALWAYS_INLINE)
1854 #undef JSON_HEDLEY_ALWAYS_INLINE
1857 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1858 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1859 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1860 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1861 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1862 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1863 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1864 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1865 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1866 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1867 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1868 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1869 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1870 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1871 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1872 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1873 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1874 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1875 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1876 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1878 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1879 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1880 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1881 #elif defined(__cplusplus) && \
1883 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1884 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1885 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1886 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1887 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1888 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1890 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1891 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1892 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1894 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1897 #if defined(JSON_HEDLEY_NEVER_INLINE)
1898 #undef JSON_HEDLEY_NEVER_INLINE
1901 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1902 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1903 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1904 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1905 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1906 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1907 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1908 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1909 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1910 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1911 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1912 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1913 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1914 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1915 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1916 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1917 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1918 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1919 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1920 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1922 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1923 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1924 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1925 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1926 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1927 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1928 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1929 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1930 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1931 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1932 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1933 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1934 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1936 #define JSON_HEDLEY_NEVER_INLINE
1939 #if defined(JSON_HEDLEY_PRIVATE)
1940 #undef JSON_HEDLEY_PRIVATE
1942 #if defined(JSON_HEDLEY_PUBLIC)
1943 #undef JSON_HEDLEY_PUBLIC
1945 #if defined(JSON_HEDLEY_IMPORT)
1946 #undef JSON_HEDLEY_IMPORT
1948 #if defined(_WIN32) || defined(__CYGWIN__)
1949 # define JSON_HEDLEY_PRIVATE
1950 # define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1951 # define JSON_HEDLEY_IMPORT __declspec(dllimport)
1954 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1955 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1956 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1957 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1958 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1959 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1961 defined(__TI_EABI__) && \
1963 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1964 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1967 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1968 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1969 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1971 # define JSON_HEDLEY_PRIVATE
1972 # define JSON_HEDLEY_PUBLIC
1974 # define JSON_HEDLEY_IMPORT extern
1977 #if defined(JSON_HEDLEY_NO_THROW)
1978 #undef JSON_HEDLEY_NO_THROW
1981 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1982 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1983 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1984 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1985 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1987 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1988 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1989 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1990 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1992 #define JSON_HEDLEY_NO_THROW
1995 #if defined(JSON_HEDLEY_FALL_THROUGH)
1996 #undef JSON_HEDLEY_FALL_THROUGH
1999 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2000 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2001 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2002 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2003 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2004 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2005 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2006 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2007 #elif defined(__fallthrough)
2008 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2010 #define JSON_HEDLEY_FALL_THROUGH
2013 #if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2014 #undef JSON_HEDLEY_RETURNS_NON_NULL
2017 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2018 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2019 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2020 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2021 #elif defined(_Ret_notnull_)
2022 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2024 #define JSON_HEDLEY_RETURNS_NON_NULL
2027 #if defined(JSON_HEDLEY_ARRAY_PARAM)
2028 #undef JSON_HEDLEY_ARRAY_PARAM
2031 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2032 !defined(__STDC_NO_VLA__) && \
2033 !defined(__cplusplus) && \
2034 !defined(JSON_HEDLEY_PGI_VERSION) && \
2035 !defined(JSON_HEDLEY_TINYC_VERSION)
2036 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2038 #define JSON_HEDLEY_ARRAY_PARAM(name)
2041 #if defined(JSON_HEDLEY_IS_CONSTANT)
2042 #undef JSON_HEDLEY_IS_CONSTANT
2044 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2045 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2049 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2050 #undef JSON_HEDLEY_IS_CONSTEXPR_
2053 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2054 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2055 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2056 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2057 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2058 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2059 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2060 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2061 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2062 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2063 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2065 #if !defined(__cplusplus)
2067 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2068 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2069 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2070 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2071 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2072 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2073 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2074 #if defined(__INTPTR_TYPE__)
2075 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2078 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2082 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2083 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2084 !defined(JSON_HEDLEY_PGI_VERSION) && \
2085 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2086 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2087 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2088 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2089 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2090 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2091 #if defined(__INTPTR_TYPE__)
2092 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2095 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2098 defined(JSON_HEDLEY_GCC_VERSION) || \
2099 defined(JSON_HEDLEY_INTEL_VERSION) || \
2100 defined(JSON_HEDLEY_TINYC_VERSION) || \
2101 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2102 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2103 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2104 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2105 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2106 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2108 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2112 ((void*) ((expr) * 0L) ) : \
2113 ((struct { char v[sizeof(void) * 2]; } *) 1) \
2119 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2120 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2121 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2123 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2125 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2126 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2128 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2131 #if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2132 #undef JSON_HEDLEY_BEGIN_C_DECLS
2134 #if defined(JSON_HEDLEY_END_C_DECLS)
2135 #undef JSON_HEDLEY_END_C_DECLS
2137 #if defined(JSON_HEDLEY_C_DECL)
2138 #undef JSON_HEDLEY_C_DECL
2140 #if defined(__cplusplus)
2141 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2142 #define JSON_HEDLEY_END_C_DECLS }
2143 #define JSON_HEDLEY_C_DECL extern "C"
2145 #define JSON_HEDLEY_BEGIN_C_DECLS
2146 #define JSON_HEDLEY_END_C_DECLS
2147 #define JSON_HEDLEY_C_DECL
2150 #if defined(JSON_HEDLEY_STATIC_ASSERT)
2151 #undef JSON_HEDLEY_STATIC_ASSERT
2154 !defined(__cplusplus) && ( \
2155 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2156 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2157 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2158 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2159 defined(_Static_assert) \
2161 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2163 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2164 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2165 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2166 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2168 # define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2171 #if defined(JSON_HEDLEY_NULL)
2172 #undef JSON_HEDLEY_NULL
2174 #if defined(__cplusplus)
2175 #if __cplusplus >= 201103L
2176 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2178 #define JSON_HEDLEY_NULL NULL
2180 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2183 #define JSON_HEDLEY_NULL NULL
2185 #define JSON_HEDLEY_NULL ((void*) 0)
2188 #if defined(JSON_HEDLEY_MESSAGE)
2189 #undef JSON_HEDLEY_MESSAGE
2191 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2192 # define JSON_HEDLEY_MESSAGE(msg) \
2193 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2194 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2195 JSON_HEDLEY_PRAGMA(message msg) \
2196 JSON_HEDLEY_DIAGNOSTIC_POP
2198 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2199 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2200 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2201 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2202 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2203 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2204 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2205 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2206 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2208 # define JSON_HEDLEY_MESSAGE(msg)
2211 #if defined(JSON_HEDLEY_WARNING)
2212 #undef JSON_HEDLEY_WARNING
2214 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2215 # define JSON_HEDLEY_WARNING(msg) \
2216 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2217 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2218 JSON_HEDLEY_PRAGMA(clang warning msg) \
2219 JSON_HEDLEY_DIAGNOSTIC_POP
2221 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2222 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2223 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2224 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2226 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2227 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2228 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2230 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2233 #if defined(JSON_HEDLEY_REQUIRE)
2234 #undef JSON_HEDLEY_REQUIRE
2236 #if defined(JSON_HEDLEY_REQUIRE_MSG)
2237 #undef JSON_HEDLEY_REQUIRE_MSG
2239 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2240 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2241 # define JSON_HEDLEY_REQUIRE(expr) \
2242 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2243 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2244 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2245 JSON_HEDLEY_DIAGNOSTIC_POP
2246 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2247 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2248 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2249 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2250 JSON_HEDLEY_DIAGNOSTIC_POP
2252 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2253 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2256 # define JSON_HEDLEY_REQUIRE(expr)
2257 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2260 #if defined(JSON_HEDLEY_FLAGS)
2261 #undef JSON_HEDLEY_FLAGS
2263 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2264 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2266 #define JSON_HEDLEY_FLAGS
2269 #if defined(JSON_HEDLEY_FLAGS_CAST)
2270 #undef JSON_HEDLEY_FLAGS_CAST
2272 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2273 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2274 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2275 _Pragma("warning(disable:188)") \
2277 JSON_HEDLEY_DIAGNOSTIC_POP \
2280 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2283 #if defined(JSON_HEDLEY_EMPTY_BASES)
2284 #undef JSON_HEDLEY_EMPTY_BASES
2287 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2288 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2289 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2291 #define JSON_HEDLEY_EMPTY_BASES
2296 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2297 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2299 #if defined(__clang__)
2300 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2302 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2305 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2306 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2308 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2310 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2311 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2313 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2315 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2316 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2318 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2320 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2321 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2323 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2325 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2326 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2328 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2330 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2331 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2333 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2335 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2336 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2338 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2350 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2351 #if defined(__clang__)
2352 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2353 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2355 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2356 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2357 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2364 #if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2365 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2366 #define JSON_HAS_CPP_20
2367 #define JSON_HAS_CPP_17
2368 #define JSON_HAS_CPP_14
2369 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
2370 #define JSON_HAS_CPP_17
2371 #define JSON_HAS_CPP_14
2372 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2373 #define JSON_HAS_CPP_14
2376 #define JSON_HAS_CPP_11
2379 #ifdef __has_include
2380 #if __has_include(<version>)
2385 #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2386 #ifdef JSON_HAS_CPP_17
2387 #if defined(__cpp_lib_filesystem)
2388 #define JSON_HAS_FILESYSTEM 1
2389 #elif defined(__cpp_lib_experimental_filesystem)
2390 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2391 #elif !defined(__has_include)
2392 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2393 #elif __has_include(<filesystem>)
2394 #define JSON_HAS_FILESYSTEM 1
2395 #elif __has_include(<experimental/filesystem>)
2396 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2400 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2401 #undef JSON_HAS_FILESYSTEM
2402 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2406 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2407 #undef JSON_HAS_FILESYSTEM
2408 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2412 #if defined(__clang_major__) && __clang_major__ < 7
2413 #undef JSON_HAS_FILESYSTEM
2414 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2418 #if defined(_MSC_VER) && _MSC_VER < 1914
2419 #undef JSON_HAS_FILESYSTEM
2420 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2424 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2425 #undef JSON_HAS_FILESYSTEM
2426 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2430 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2431 #undef JSON_HAS_FILESYSTEM
2432 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2437 #ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2438 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2441 #ifndef JSON_HAS_FILESYSTEM
2442 #define JSON_HAS_FILESYSTEM 0
2445 #ifndef JSON_HAS_THREE_WAY_COMPARISON
2446 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2447 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2448 #define JSON_HAS_THREE_WAY_COMPARISON 1
2450 #define JSON_HAS_THREE_WAY_COMPARISON 0
2454 #ifndef JSON_HAS_RANGES
2456 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2457 #define JSON_HAS_RANGES 0
2458 #elif defined(__cpp_lib_ranges)
2459 #define JSON_HAS_RANGES 1
2461 #define JSON_HAS_RANGES 0
2465 #ifdef JSON_HAS_CPP_17
2466 #define JSON_INLINE_VARIABLE inline
2468 #define JSON_INLINE_VARIABLE
2471 #if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2472 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2474 #define JSON_NO_UNIQUE_ADDRESS
2478 #if defined(__clang__)
2479 #pragma clang diagnostic push
2480 #pragma clang diagnostic ignored "-Wdocumentation"
2481 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2485 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2486 #define JSON_THROW(exception) throw exception
2487 #define JSON_TRY try
2488 #define JSON_CATCH(exception) catch(exception)
2489 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2492 #define JSON_THROW(exception) std::abort()
2493 #define JSON_TRY if(true)
2494 #define JSON_CATCH(exception) if(false)
2495 #define JSON_INTERNAL_CATCH(exception) if(false)
2499 #if defined(JSON_THROW_USER)
2501 #define JSON_THROW JSON_THROW_USER
2503 #if defined(JSON_TRY_USER)
2505 #define JSON_TRY JSON_TRY_USER
2507 #if defined(JSON_CATCH_USER)
2509 #define JSON_CATCH JSON_CATCH_USER
2510 #undef JSON_INTERNAL_CATCH
2511 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2513 #if defined(JSON_INTERNAL_CATCH_USER)
2514 #undef JSON_INTERNAL_CATCH
2515 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2519 #if !defined(JSON_ASSERT)
2521 #define JSON_ASSERT(x) assert(x)
2525 #if defined(JSON_TESTS_PRIVATE)
2526 #define JSON_PRIVATE_UNLESS_TESTED public
2528 #define JSON_PRIVATE_UNLESS_TESTED private
2536 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2537 template<typename BasicJsonType> \
2538 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2540 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2541 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2542 auto it = std::find_if(std::begin(m), std::end(m), \
2543 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2545 return ej_pair.first == e; \
2547 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2549 template<typename BasicJsonType> \
2550 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2552 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2553 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2554 auto it = std::find_if(std::begin(m), std::end(m), \
2555 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2557 return ej_pair.second == j; \
2559 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2565 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2566 template<template<typename, typename, typename...> class ObjectType, \
2567 template<typename, typename...> class ArrayType, \
2568 class StringType, class BooleanType, class NumberIntegerType, \
2569 class NumberUnsignedType, class NumberFloatType, \
2570 template<typename> class AllocatorType, \
2571 template<typename, typename = void> class JSONSerializer, \
2574 #define NLOHMANN_BASIC_JSON_TPL \
2575 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2576 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2577 AllocatorType, JSONSerializer, BinaryType>
2581 #define NLOHMANN_JSON_EXPAND( x ) x
2582 #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
2583 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2584 NLOHMANN_JSON_PASTE64, \
2585 NLOHMANN_JSON_PASTE63, \
2586 NLOHMANN_JSON_PASTE62, \
2587 NLOHMANN_JSON_PASTE61, \
2588 NLOHMANN_JSON_PASTE60, \
2589 NLOHMANN_JSON_PASTE59, \
2590 NLOHMANN_JSON_PASTE58, \
2591 NLOHMANN_JSON_PASTE57, \
2592 NLOHMANN_JSON_PASTE56, \
2593 NLOHMANN_JSON_PASTE55, \
2594 NLOHMANN_JSON_PASTE54, \
2595 NLOHMANN_JSON_PASTE53, \
2596 NLOHMANN_JSON_PASTE52, \
2597 NLOHMANN_JSON_PASTE51, \
2598 NLOHMANN_JSON_PASTE50, \
2599 NLOHMANN_JSON_PASTE49, \
2600 NLOHMANN_JSON_PASTE48, \
2601 NLOHMANN_JSON_PASTE47, \
2602 NLOHMANN_JSON_PASTE46, \
2603 NLOHMANN_JSON_PASTE45, \
2604 NLOHMANN_JSON_PASTE44, \
2605 NLOHMANN_JSON_PASTE43, \
2606 NLOHMANN_JSON_PASTE42, \
2607 NLOHMANN_JSON_PASTE41, \
2608 NLOHMANN_JSON_PASTE40, \
2609 NLOHMANN_JSON_PASTE39, \
2610 NLOHMANN_JSON_PASTE38, \
2611 NLOHMANN_JSON_PASTE37, \
2612 NLOHMANN_JSON_PASTE36, \
2613 NLOHMANN_JSON_PASTE35, \
2614 NLOHMANN_JSON_PASTE34, \
2615 NLOHMANN_JSON_PASTE33, \
2616 NLOHMANN_JSON_PASTE32, \
2617 NLOHMANN_JSON_PASTE31, \
2618 NLOHMANN_JSON_PASTE30, \
2619 NLOHMANN_JSON_PASTE29, \
2620 NLOHMANN_JSON_PASTE28, \
2621 NLOHMANN_JSON_PASTE27, \
2622 NLOHMANN_JSON_PASTE26, \
2623 NLOHMANN_JSON_PASTE25, \
2624 NLOHMANN_JSON_PASTE24, \
2625 NLOHMANN_JSON_PASTE23, \
2626 NLOHMANN_JSON_PASTE22, \
2627 NLOHMANN_JSON_PASTE21, \
2628 NLOHMANN_JSON_PASTE20, \
2629 NLOHMANN_JSON_PASTE19, \
2630 NLOHMANN_JSON_PASTE18, \
2631 NLOHMANN_JSON_PASTE17, \
2632 NLOHMANN_JSON_PASTE16, \
2633 NLOHMANN_JSON_PASTE15, \
2634 NLOHMANN_JSON_PASTE14, \
2635 NLOHMANN_JSON_PASTE13, \
2636 NLOHMANN_JSON_PASTE12, \
2637 NLOHMANN_JSON_PASTE11, \
2638 NLOHMANN_JSON_PASTE10, \
2639 NLOHMANN_JSON_PASTE9, \
2640 NLOHMANN_JSON_PASTE8, \
2641 NLOHMANN_JSON_PASTE7, \
2642 NLOHMANN_JSON_PASTE6, \
2643 NLOHMANN_JSON_PASTE5, \
2644 NLOHMANN_JSON_PASTE4, \
2645 NLOHMANN_JSON_PASTE3, \
2646 NLOHMANN_JSON_PASTE2, \
2647 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2648 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2649 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2650 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2651 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2652 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2653 #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)
2654 #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)
2655 #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)
2656 #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)
2657 #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)
2658 #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)
2659 #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)
2660 #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)
2661 #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)
2662 #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)
2663 #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)
2664 #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)
2665 #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)
2666 #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)
2667 #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)
2668 #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)
2669 #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)
2670 #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)
2671 #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)
2672 #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)
2673 #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)
2674 #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)
2675 #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)
2676 #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)
2677 #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)
2678 #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)
2679 #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)
2680 #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)
2681 #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)
2682 #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)
2683 #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)
2684 #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)
2685 #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)
2686 #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)
2687 #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)
2688 #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)
2689 #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)
2690 #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)
2691 #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)
2692 #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)
2693 #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)
2694 #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)
2695 #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)
2696 #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)
2697 #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)
2698 #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)
2699 #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)
2700 #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)
2701 #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)
2702 #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)
2703 #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)
2704 #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)
2705 #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)
2706 #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)
2707 #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)
2708 #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)
2709 #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)
2710 #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)
2712 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2713 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2714 #define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2721 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2722 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__)) } \
2723 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__)) }
2725 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2726 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__)) } \
2727 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2734 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2735 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__)) } \
2736 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__)) }
2738 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2739 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__)) } \
2740 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2749 #define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2750 namespace detail { \
2751 using std::std_name; \
2753 template<typename... T> \
2754 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2757 namespace detail2 { \
2758 struct std_name##_tag \
2762 template<typename... T> \
2763 std_name##_tag std_name(T&&...); \
2765 template<typename... T> \
2766 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2768 template<typename... T> \
2769 struct would_call_std_##std_name \
2771 static constexpr auto const value = ::nlohmann::detail:: \
2772 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2776 template<typename... T> \
2777 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2781 #ifndef JSON_USE_IMPLICIT_CONVERSIONS
2782 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2785 #if JSON_USE_IMPLICIT_CONVERSIONS
2786 #define JSON_EXPLICIT
2788 #define JSON_EXPLICIT explicit
2791 #ifndef JSON_DISABLE_ENUM_SERIALIZATION
2792 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2795 #ifndef JSON_USE_GLOBAL_UDLS
2796 #define JSON_USE_GLOBAL_UDLS 1
2799 #if JSON_HAS_THREE_WAY_COMPARISON
2862 #if JSON_HAS_THREE_WAY_COMPARISON
2863 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs) noexcept
2868 static constexpr std::array<std::uint8_t, 9> order = {{
2875 const auto l_index =
static_cast<std::size_t
>(lhs);
2876 const auto r_index =
static_cast<std::size_t
>(rhs);
2877 #if JSON_HAS_THREE_WAY_COMPARISON
2878 if (l_index < order.size() && r_index < order.size())
2880 return order[l_index] <=> order[r_index];
2882 return std::partial_ordering::unordered;
2884 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2892 #if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2895 return std::is_lt(lhs <=> rhs);
2933 template<
typename StringType>
2935 const StringType& t)
2938 for (
auto pos =
s.find(f);
2939 pos != StringType::npos;
2940 s.replace(pos, f.size(), t),
2941 pos =
s.find(f, pos + t.size()))
2952 template<
typename StringType>
2967 template<
typename StringType>
3001 std::size_t chars_read_total = 0;
3003 std::size_t chars_read_current_line = 0;
3005 std::size_t lines_read = 0;
3008 constexpr
operator size_t()
const
3010 return chars_read_total;
3032 #include <type_traits>
3042 template<
typename T>
3045 #ifdef JSON_HAS_CPP_14
3056 template<
bool B,
typename T =
void>
3083 template <
typename T,
T... Ints>
3087 static constexpr std::size_t
size() noexcept
3089 return sizeof...(Ints);
3098 template <
size_t... Ints>
3101 namespace utility_internal
3104 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3108 template <
typename T,
T... Ints,
size_t SeqSize>
3114 template <
typename T,
T... Ints,
size_t SeqSize>
3122 template <
typename T,
size_t N>
3129 template <
typename T>
3144 template <
typename T, T N>
3160 template <
typename... Ts>
3172 template<
typename T>
3175 static constexpr
T value{};
3178 #ifndef JSON_HAS_CPP_17
3180 template<
typename T>
3200 #include <type_traits>
3228 template<
typename It,
typename =
void>
3231 template<
typename It>
3235 typename It::reference, typename It::iterator_category >>
3246 template<
typename T,
typename =
void>
3251 template<
typename T>
3257 template<
typename T>
3325 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3326 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3351 template<
typename T =
void,
typename SFINAE =
void>
3356 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3358 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3359 class StringType = std::string,
class BooleanType = bool,
3360 class NumberIntegerType = std::int64_t,
3361 class NumberUnsignedType = std::uint64_t,
3362 class NumberFloatType = double,
3363 template<
typename U>
class AllocatorType = std::allocator,
3364 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3366 class BinaryType = std::vector<std::uint8_t>>
3371 template<
typename BasicJsonType>
3382 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3391 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
3427 template<
typename BasicJsonContext>
3429 std::integral_constant < bool,
3430 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3431 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3444 template<
typename T>
3451 template<
typename T>
3454 template<
typename T>
3457 template<
typename T>
3460 template<
typename T>
3463 template<
typename T>
3466 template<
typename T>
3469 template<
typename T>
3472 template<
typename T,
typename... Args>
3475 template<
typename T,
typename... Args>
3478 template<
typename T,
typename U>
3482 template<
typename BasicJsonType,
typename T,
typename =
void>
3489 template <
typename BasicJsonType,
typename T>
3495 template<
typename BasicJsonType,
typename T>
3498 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3500 static constexpr
bool value =
3502 const BasicJsonType&,
T&>::value;
3507 template<
typename BasicJsonType,
typename T,
typename =
void>
3510 template<
typename BasicJsonType,
typename T>
3513 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3515 static constexpr
bool value =
3517 const BasicJsonType&>::value;
3522 template<
typename BasicJsonType,
typename T,
typename =
void>
3525 template<
typename BasicJsonType,
typename T>
3528 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3530 static constexpr
bool value =
3535 template<
typename T>
3538 template<
typename T>
3539 struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3542 template<
typename BasicJsonType>
3551 template<
typename BasicJsonType>
3561 template<
class B,
class... Bn>
3563 : std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>
::type {};
3566 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3571 template <
typename T>
3574 template <
typename T1,
typename T2>
3576 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3578 template <
typename T1,
typename T2>
3580 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3582 template <
typename... Ts>
3584 :
conjunction<is_default_constructible<Ts>...> {};
3586 template <
typename... Ts>
3588 :
conjunction<is_default_constructible<Ts>...> {};
3591 template <
typename T,
typename... Args>
3594 template <
typename T1,
typename T2>
3597 template <
typename T1,
typename T2>
3600 template <
typename... Ts>
3603 template <
typename... Ts>
3607 template<
typename T,
typename =
void>
3610 template<
typename T>
3617 static constexpr
auto value =
3625 template<
typename T>
3637 static constexpr
auto is_iterator_begin =
3644 template<
typename R>
3647 template<
typename T>
3654 template<
typename T,
typename =
void>
3657 template<
typename T>
3660 template<
typename BasicJsonType,
typename CompatibleObjectType,
3664 template<
typename BasicJsonType,
typename CompatibleObjectType>
3666 BasicJsonType, CompatibleObjectType,
3673 static constexpr
bool value =
3675 typename CompatibleObjectType::key_type>::value &&
3677 typename CompatibleObjectType::mapped_type>::value;
3680 template<
typename BasicJsonType,
typename CompatibleObjectType>
3684 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3688 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3690 BasicJsonType, ConstructibleObjectType,
3696 static constexpr
bool value =
3701 typename object_t::key_type>::value &&
3703 typename object_t::mapped_type,
3704 typename ConstructibleObjectType::mapped_type >::value)) ||
3706 typename ConstructibleObjectType::mapped_type>::value ||
3709 typename ConstructibleObjectType::mapped_type >::value);
3712 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3715 ConstructibleObjectType> {};
3717 template<
typename BasicJsonType,
typename CompatibleStringType>
3720 static constexpr
auto value =
3724 template<
typename BasicJsonType,
typename ConstructibleStringType>
3728 #ifdef __INTEL_COMPILER
3729 using laundered_type = decltype(std::declval<ConstructibleStringType>());
3734 static constexpr
auto value =
3741 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3744 template<
typename BasicJsonType,
typename CompatibleArrayType>
3746 BasicJsonType, CompatibleArrayType,
3752 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3754 static constexpr
bool value =
3759 template<
typename BasicJsonType,
typename CompatibleArrayType>
3763 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3766 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3768 BasicJsonType, ConstructibleArrayType,
3770 typename BasicJsonType::value_type>
::value >>
3771 : std::true_type {};
3773 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3775 BasicJsonType, ConstructibleArrayType,
3777 typename BasicJsonType::value_type>
::value&&
3780 (std::is_move_assignable<ConstructibleArrayType>::value ||
3781 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3787 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3789 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3793 static constexpr
bool value =
3803 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3807 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3811 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3813 RealIntegerType, CompatibleNumberIntegerType,
3815 std::is_integral<CompatibleNumberIntegerType>
::value&&
3816 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3822 static constexpr
auto value =
3824 CompatibleNumberIntegerType>::value &&
3829 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3832 CompatibleNumberIntegerType> {};
3834 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3837 template<
typename BasicJsonType,
typename CompatibleType>
3839 BasicJsonType, CompatibleType,
3842 static constexpr
bool value =
3846 template<
typename BasicJsonType,
typename CompatibleType>
3850 template<
typename T1,
typename T2>
3853 template<
typename T1,
typename... Args>
3856 template<
typename BasicJsonType,
typename T>
3859 template<
typename BasicJsonType>
3862 template<
typename BasicJsonType>
3867 template<
template <
typename...>
class Primary,
typename T>
3870 template<
template <
typename...>
class Primary,
typename... Args>
3873 template<
typename T>
3877 template<
typename Compare,
typename A,
typename B,
typename =
void>
3880 template<
typename Compare,
typename A,
typename B>
3882 decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3883 decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3884 >> : std::true_type {};
3886 template<
typename T>
3891 template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3895 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3896 ObjectKeyType>::value)
3897 && (!RequireTransparentComparator
3909 template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3913 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3914 RequireTransparentComparator, ExcludeObjectKeyType>::value
3919 template<
typename ObjectType,
typename KeyType>
3923 template<
typename BasicJsonType,
typename KeyType>
3927 typename BasicJsonType::object_t, KeyType >::value,
3933 template <
typename T>
3943 template <
typename C>
static one test( decltype(&C::capacity) ) ;
3944 template <
typename C>
static two test(...);
3946 enum { value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3953 return static_cast<T>(value);
3962 template<
typename... Types>
3965 template<
typename... Types>
3968 template<
typename... Types>
3972 template<
typename... Types>
3973 using same_sign = std::integral_constant < bool,
3976 template<
typename OfType,
typename T>
3981 template<
typename OfType,
typename T,
3986 template<
typename OfType,
typename T>
3996 template<
typename OfType,
typename T>
4006 template<
typename OfType,
typename T>
4017 template<
typename OfType,
typename T>
4023 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4028 template<
typename OfType,
typename T,
4033 template<
typename OfType,
typename T>
4042 template<
typename OfType,
typename T>
4051 template<
typename OfType,
typename T>
4089 template<
typename... Args>
4090 inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
4092 template<
typename StringType,
typename... Args>
4093 inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
4095 template<
typename... Args>
4101 template<
typename... Args>
4105 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
4108 template<
typename StringType,
typename... Args>
4111 return str.size() +
concat_length(std::forward<Args>(rest)...);
4114 template<
typename OutStringType>
4118 template<
typename StringType,
typename Arg>
4121 template<
typename StringType,
typename Arg>
4124 template<
typename StringType,
typename Arg>
4127 template<
typename StringType,
typename Arg>
4130 template<
typename StringType,
typename Arg>
4133 template<
typename StringType,
typename Arg>
4136 template<
typename StringType,
typename Arg>
4139 template<
typename StringType,
typename Arg>
4142 template <
typename OutStringType,
typename Arg,
typename... Args,
4145 inline void concat_into(OutStringType& out, Arg &&
arg, Args && ... rest);
4147 template <
typename OutStringType,
typename Arg,
typename... Args,
4151 inline void concat_into(OutStringType& out,
const Arg&
arg, Args && ... rest);
4153 template <
typename OutStringType,
typename Arg,
typename... Args,
4158 inline void concat_into(OutStringType& out,
const Arg&
arg, Args && ... rest);
4160 template<
typename OutStringType,
typename Arg,
typename... Args,
4164 out.append(std::forward<Arg>(
arg));
4168 template <
typename OutStringType,
typename Arg,
typename... Args,
4171 inline void concat_into(OutStringType& out, Arg&&
arg, Args&& ... rest)
4173 out += std::forward<Arg>(
arg);
4177 template <
typename OutStringType,
typename Arg,
typename... Args,
4183 out.append(
arg.begin(),
arg.end());
4187 template <
typename OutStringType,
typename Arg,
typename... Args,
4192 inline void concat_into(OutStringType& out,
const Arg&
arg, Args&& ... rest)
4194 out.append(
arg.data(),
arg.size());
4198 template<
typename OutStringType = std::string,
typename... Args>
4199 inline OutStringType
concat(Args && ... args)
4226 const char*
what() const noexcept
override
4236 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
4238 static std::string
name(
const std::string& ename,
int id_)
4248 template<
typename BasicJsonType>
4251 #if JSON_DIAGNOSTICS
4252 std::vector<std::string> tokens;
4253 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4255 switch (current->m_parent->type())
4257 case value_t::array:
4259 for (std::size_t
i = 0;
i < current->m_parent->m_value.array->size(); ++
i)
4261 if (¤t->m_parent->m_value.array->operator[](
i) == current)
4270 case value_t::object:
4272 for (
const auto& element : *current->m_parent->m_value.object)
4274 if (&element.second == current)
4276 tokens.emplace_back(element.first.c_str());
4284 case value_t::string:
4285 case value_t::boolean:
4286 case value_t::number_integer:
4287 case value_t::number_unsigned:
4288 case value_t::number_float:
4289 case value_t::binary:
4290 case value_t::discarded:
4301 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4302 [](
const std::string & a,
const std::string & b)
4304 return concat(a,
'/', detail::escape(b));
4306 return concat(
'(', str,
") ");
4308 static_cast<void>(leaf_element);
4315 std::runtime_error
m;
4335 std::string
w =
concat(exception::name(
"parse_error", id_),
"parse error",
4336 position_string(pos),
": ", exception::diagnostics(context), what_arg);
4341 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4343 std::string
w =
concat(exception::name(
"parse_error", id_),
"parse error",
4345 ": ", exception::diagnostics(context), what_arg);
4346 return {id_, byte_,
w.c_str()};
4379 std::string
w =
concat(exception::name(
"invalid_iterator", id_), exception::diagnostics(context), what_arg);
4380 return {id_,
w.c_str()};
4397 std::string
w =
concat(exception::name(
"type_error", id_), exception::diagnostics(context), what_arg);
4398 return {id_,
w.c_str()};
4414 std::string
w =
concat(exception::name(
"out_of_range", id_), exception::diagnostics(context), what_arg);
4415 return {id_,
w.c_str()};
4431 std::string
w =
concat(exception::name(
"other_error", id_), exception::diagnostics(context), what_arg);
4432 return {id_,
w.c_str()};
4485 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4486 #include <experimental/filesystem>
4490 namespace std_fs = std::experimental::filesystem;
4493 #elif JSON_HAS_FILESYSTEM
4494 #include <filesystem>
4498 namespace std_fs = std::filesystem;
4514 template<
typename BasicJsonType>
4515 inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t&
n)
4525 template <
typename BasicJsonType,
typename ArithmeticType,
4531 switch (
static_cast<value_t>(j))
4533 case value_t::number_unsigned:
4535 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4538 case value_t::number_integer:
4540 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4543 case value_t::number_float:
4545 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4550 case value_t::object:
4551 case value_t::array:
4552 case value_t::string:
4553 case value_t::boolean:
4554 case value_t::binary:
4555 case value_t::discarded:
4561 template<
typename BasicJsonType>
4562 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4568 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4571 template<
typename BasicJsonType>
4572 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t&
s)
4578 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4582 typename BasicJsonType,
typename StringType,
4595 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4598 template<
typename BasicJsonType>
4599 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4604 template<
typename BasicJsonType>
4605 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4610 template<
typename BasicJsonType>
4611 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4616 #if !JSON_DISABLE_ENUM_SERIALIZATION
4617 template<
typename BasicJsonType,
typename EnumType,
4623 e =
static_cast<EnumType
>(val);
4625 #endif // JSON_DISABLE_ENUM_SERIALIZATION
4628 template<
typename BasicJsonType,
typename T,
typename Allocator,
4630 inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>&
l)
4637 std::transform(j.rbegin(), j.rend(),
4638 std::front_inserter(
l), [](
const BasicJsonType &
i)
4640 return i.template get<T>();
4645 template<
typename BasicJsonType,
typename T,
4647 inline void from_json(
const BasicJsonType& j, std::valarray<T>&
l)
4655 [](
const BasicJsonType & elem)
4657 return elem.template get<T>();
4661 template<
typename BasicJsonType,
typename T, std::
size_t N>
4663 -> decltype(j.template get<T>(),
void())
4665 for (std::size_t
i = 0;
i < N; ++
i)
4667 arr[
i] = j.at(
i).template get<T>();
4671 template<
typename BasicJsonType>
4674 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4677 template<
typename BasicJsonType,
typename T, std::
size_t N>
4680 -> decltype(j.template get<T>(),
void())
4682 for (std::size_t
i = 0;
i < N; ++
i)
4684 arr[
i] = j.at(
i).template get<T>();
4688 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4694 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4695 j.template get<typename ConstructibleArrayType::value_type>(),
4700 ConstructibleArrayType ret;
4701 ret.reserve(j.size());
4702 std::transform(j.begin(), j.end(),
4703 std::inserter(ret,
end(ret)), [](
const BasicJsonType &
i)
4707 return i.template get<typename ConstructibleArrayType::value_type>();
4709 arr = std::move(ret);
4712 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4721 ConstructibleArrayType ret;
4723 j.begin(), j.end(), std::inserter(ret,
end(ret)),
4724 [](
const BasicJsonType &
i)
4728 return i.template get<typename ConstructibleArrayType::value_type>();
4730 arr = std::move(ret);
4733 template <
typename BasicJsonType,
typename ConstructibleArrayType,
4743 j.template get<typename ConstructibleArrayType::value_type>(),
4754 template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4758 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4761 template <
typename BasicJsonType,
typename T, std::
size_t N >
4773 template<
typename BasicJsonType>
4774 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4781 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4784 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4786 inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4793 ConstructibleObjectType ret;
4794 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4797 inner_object->begin(), inner_object->end(),
4798 std::inserter(ret, ret.begin()),
4801 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4803 obj = std::move(ret);
4810 template <
typename BasicJsonType,
typename ArithmeticType,
4818 inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4820 switch (
static_cast<value_t>(j))
4822 case value_t::number_unsigned:
4824 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4827 case value_t::number_integer:
4829 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4832 case value_t::number_float:
4834 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4837 case value_t::boolean:
4839 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4844 case value_t::object:
4845 case value_t::array:
4846 case value_t::string:
4847 case value_t::binary:
4848 case value_t::discarded:
4854 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4857 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4860 template <
typename BasicJsonType,
class A1,
class A2 >
4863 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4864 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4867 template<
typename BasicJsonType,
typename A1,
typename A2>
4873 template<
typename BasicJsonType,
typename... Args>
4879 template<
typename BasicJsonType,
typename... Args>
4885 template<
typename BasicJsonType,
typename TupleRelated>
4894 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4897 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4899 typename BasicJsonType::string_t, Key >::value >>
4900 inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>&
m)
4907 for (
const auto&
p : j)
4913 m.emplace(
p.at(0).template get<Key>(),
p.at(1).template get<Value>());
4917 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4919 typename BasicJsonType::string_t, Key >::value >>
4920 inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>&
m)
4927 for (
const auto&
p : j)
4933 m.emplace(
p.at(0).template get<Key>(),
p.at(1).template get<Value>());
4937 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4938 template<
typename BasicJsonType>
4939 inline void from_json(
const BasicJsonType& j, std_fs::path&
p)
4945 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4951 template<
typename BasicJsonType,
typename T>
4953 noexcept(noexcept(
from_json(j, std::forward<T>(val))))
4954 -> decltype(
from_json(j, std::forward<T>(val)))
4956 return from_json(j, std::forward<T>(val));
4962 #ifndef JSON_HAS_CPP_17
4971 #ifndef JSON_HAS_CPP_17
4988 #include <algorithm>
4992 #include <type_traits>
5029 template<
typename string_type>
5044 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::
type >::
type;
5048 IteratorType anchor{};
5050 std::size_t array_index = 0;
5052 mutable std::size_t array_index_last = 0;
5061 noexcept(
std::is_nothrow_move_constructible<IteratorType>::value
5063 : anchor(
std::move(it))
5064 , array_index(array_index_)
5071 noexcept(
std::is_nothrow_move_constructible<IteratorType>::value
5072 &&
std::is_nothrow_move_constructible<string_type>::value) = default;
5074 noexcept(
std::is_nothrow_move_assignable<IteratorType>::value
5075 &&
std::is_nothrow_move_assignable<string_type>::value) = default;
5104 return anchor == o.
anchor;
5110 return anchor != o.
anchor;
5118 switch (anchor.m_object->type())
5121 case value_t::array:
5123 if (array_index != array_index_last)
5126 array_index_last = array_index;
5128 return array_index_str;
5132 case value_t::object:
5133 return anchor.key();
5137 case value_t::string:
5138 case value_t::boolean:
5139 case value_t::number_integer:
5140 case value_t::number_unsigned:
5141 case value_t::number_float:
5142 case value_t::binary:
5143 case value_t::discarded:
5150 typename IteratorType::reference
value()
const
5152 return anchor.value();
5161 typename IteratorType::pointer container =
nullptr;
5168 : container(&cont) {}
5192 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5193 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>&
i) -> decltype(
i.key())
5200 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5201 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>&
i) -> decltype(
i.value())
5216 #if defined(__clang__)
5218 #pragma clang diagnostic push
5219 #pragma clang diagnostic ignored "-Wmismatched-tags"
5221 template<
typename IteratorType>
5222 class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5223 :
public std::integral_constant<std::size_t, 2> {};
5225 template<std::
size_t N,
typename IteratorType>
5226 class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5229 using type = decltype(
5230 get<N>(std::declval <
5231 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5233 #if defined(__clang__)
5234 #pragma clang diagnostic pop
5240 template <
typename IteratorType>
5241 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5275 template<
typename BasicJsonType>
5276 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b) noexcept
5278 j.m_value.destroy(j.m_type);
5279 j.m_type = value_t::boolean;
5281 j.assert_invariant();
5288 template<
typename BasicJsonType>
5289 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t&
s)
5291 j.m_value.destroy(j.m_type);
5292 j.m_type = value_t::string;
5294 j.assert_invariant();
5297 template<
typename BasicJsonType>
5298 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&&
s)
5300 j.m_value.destroy(j.m_type);
5301 j.m_type = value_t::string;
5302 j.m_value = std::move(
s);
5303 j.assert_invariant();
5306 template <
typename BasicJsonType,
typename CompatibleStringType,
5309 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5311 j.m_value.destroy(j.m_type);
5312 j.m_type = value_t::string;
5313 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5314 j.assert_invariant();
5321 template<
typename BasicJsonType>
5322 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5324 j.m_value.destroy(j.m_type);
5325 j.m_type = value_t::binary;
5326 j.m_value =
typename BasicJsonType::binary_t(b);
5327 j.assert_invariant();
5330 template<
typename BasicJsonType>
5331 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5333 j.m_value.destroy(j.m_type);
5334 j.m_type = value_t::binary;
5335 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
5336 j.assert_invariant();
5343 template<
typename BasicJsonType>
5344 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val) noexcept
5346 j.m_value.destroy(j.m_type);
5347 j.m_type = value_t::number_float;
5349 j.assert_invariant();
5356 template<
typename BasicJsonType>
5357 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val) noexcept
5359 j.m_value.destroy(j.m_type);
5360 j.m_type = value_t::number_unsigned;
5362 j.assert_invariant();
5369 template<
typename BasicJsonType>
5370 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val) noexcept
5372 j.m_value.destroy(j.m_type);
5373 j.m_type = value_t::number_integer;
5375 j.assert_invariant();
5382 template<
typename BasicJsonType>
5383 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t&
arr)
5385 j.m_value.destroy(j.m_type);
5386 j.m_type = value_t::array;
5389 j.assert_invariant();
5392 template<
typename BasicJsonType>
5393 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&&
arr)
5395 j.m_value.destroy(j.m_type);
5396 j.m_type = value_t::array;
5397 j.m_value = std::move(
arr);
5399 j.assert_invariant();
5402 template <
typename BasicJsonType,
typename CompatibleArrayType,
5410 j.m_value.destroy(j.m_type);
5411 j.m_type = value_t::array;
5412 j.m_value.array = j.template create<typename BasicJsonType::array_t>(
begin(
arr),
end(
arr));
5414 j.assert_invariant();
5417 template<
typename BasicJsonType>
5420 j.m_value.destroy(j.m_type);
5421 j.m_type = value_t::array;
5422 j.m_value = value_t::array;
5423 j.m_value.array->reserve(
arr.size());
5424 for (
const bool x :
arr)
5426 j.m_value.array->push_back(
x);
5427 j.set_parent(j.m_value.array->back());
5429 j.assert_invariant();
5432 template<
typename BasicJsonType,
typename T,
5436 j.m_value.destroy(j.m_type);
5437 j.m_type = value_t::array;
5438 j.m_value = value_t::array;
5439 j.m_value.array->resize(
arr.size());
5445 j.assert_invariant();
5452 template<
typename BasicJsonType>
5453 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5455 j.m_value.destroy(j.m_type);
5456 j.m_type = value_t::object;
5459 j.assert_invariant();
5462 template<
typename BasicJsonType>
5463 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5465 j.m_value.destroy(j.m_type);
5466 j.m_type = value_t::object;
5467 j.m_value = std::move(obj);
5469 j.assert_invariant();
5472 template <
typename BasicJsonType,
typename CompatibleObjectType,
5474 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5479 j.m_value.destroy(j.m_type);
5480 j.m_type = value_t::object;
5481 j.m_value.object = j.template create<typename BasicJsonType::object_t>(
begin(obj),
end(obj));
5483 j.assert_invariant();
5491 template<
typename BasicJsonType,
typename T,
5498 template<
typename BasicJsonType,
5499 enable_if_t<std::is_convertible<const std::vector<bool>::reference&,
typename BasicJsonType::boolean_t>::value,
int> = 0>
5500 inline void to_json(BasicJsonType& j,
const std::vector<bool>::reference& b) noexcept
5505 template<
typename BasicJsonType,
typename CompatibleString,
5507 inline void to_json(BasicJsonType& j,
const CompatibleString&
s)
5512 template<
typename BasicJsonType>
5513 inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&&
s)
5518 template<
typename BasicJsonType,
typename FloatType,
5520 inline void to_json(BasicJsonType& j, FloatType val) noexcept
5525 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5527 inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
5532 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5534 inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
5539 #if !JSON_DISABLE_ENUM_SERIALIZATION
5540 template<
typename BasicJsonType,
typename EnumType,
5542 inline void to_json(BasicJsonType& j, EnumType e) noexcept
5547 #endif // JSON_DISABLE_ENUM_SERIALIZATION
5549 template<
typename BasicJsonType>
5550 inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5555 template <
typename BasicJsonType,
typename CompatibleArrayType,
5556 enable_if_t < is_compatible_array_type<BasicJsonType,
5557 CompatibleArrayType>::value&&
5563 inline void to_json(BasicJsonType& j,
const CompatibleArrayType&
arr)
5568 template<
typename BasicJsonType>
5569 inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5574 template<
typename BasicJsonType,
typename T,
5576 inline void to_json(BasicJsonType& j,
const std::valarray<T>&
arr)
5581 template<
typename BasicJsonType>
5582 inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&&
arr)
5587 template <
typename BasicJsonType,
typename CompatibleObjectType,
5589 inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5594 template<
typename BasicJsonType>
5595 inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5601 typename BasicJsonType,
typename T, std::size_t N,
5602 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5603 const T(&)[N]>::value,
5611 inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>&
p)
5613 j = {
p.first,
p.second };
5617 template<
typename BasicJsonType,
typename T,
5618 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5621 j = { {b.key(), b.value()} };
5624 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5627 j = { std::get<Idx>(t)... };
5631 inline void to_json(BasicJsonType& j,
const T& t)
5636 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5637 template<
typename BasicJsonType>
5638 inline void to_json(BasicJsonType& j,
const std_fs::path&
p)
5646 template<
typename BasicJsonType,
typename T>
5648 -> decltype(
to_json(j, std::forward<T>(val)),
void())
5650 return to_json(j, std::forward<T>(val));
5655 #ifndef JSON_HAS_CPP_17
5664 #ifndef JSON_HAS_CPP_17
5676 template<
typename ValueType,
typename>
5677 struct adl_serializer
5681 template<
typename BasicJsonType,
typename TargetType = ValueType>
5682 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
5691 template<
typename BasicJsonType,
typename TargetType = ValueType>
5701 template<
typename BasicJsonType,
typename TargetType = ValueType>
5702 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
5734 template<
typename BinaryType>
5759 , m_subtype(subtype_)
5760 , m_has_subtype(true)
5766 , m_subtype(subtype_)
5767 , m_has_subtype(true)
5772 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5778 return !(rhs == *
this);
5785 m_subtype = subtype_;
5786 m_has_subtype =
true;
5793 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5800 return m_has_subtype;
5808 m_has_subtype =
false;
5813 bool m_has_subtype =
false;
5837 #include <functional>
5849 inline std::size_t
combine(std::size_t seed, std::size_t h) noexcept
5851 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5866 template<
typename BasicJsonType>
5867 std::size_t
hash(
const BasicJsonType& j)
5869 using string_t =
typename BasicJsonType::string_t;
5870 using number_integer_t =
typename BasicJsonType::number_integer_t;
5871 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5872 using number_float_t =
typename BasicJsonType::number_float_t;
5874 const auto type =
static_cast<std::size_t
>(j.type());
5877 case BasicJsonType::value_t::null:
5878 case BasicJsonType::value_t::discarded:
5883 case BasicJsonType::value_t::object:
5886 for (
const auto& element : j.items())
5888 const auto h = std::hash<string_t> {}(element.key());
5895 case BasicJsonType::value_t::array:
5898 for (
const auto& element : j)
5905 case BasicJsonType::value_t::string:
5907 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5911 case BasicJsonType::value_t::boolean:
5913 const auto h = std::hash<bool> {}(j.template get<bool>());
5917 case BasicJsonType::value_t::number_integer:
5919 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5923 case BasicJsonType::value_t::number_unsigned:
5925 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5929 case BasicJsonType::value_t::number_float:
5931 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5935 case BasicJsonType::value_t::binary:
5938 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5940 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5941 for (
const auto byte : j.get_binary())
5943 seed =
combine(seed, std::hash<std::uint8_t> {}(
byte));
5968 #include <algorithm>
6002 #include <type_traits>
6008 #endif // JSON_NO_IO
6050 std::char_traits<
char>::int_type get_character() noexcept
6052 return std::fgetc(m_file);
6081 is->clear(is->rdstate() & std::ios::eofbit);
6086 : is(&
i), sb(
i.rdbuf())
6095 : is(rhs.is), sb(rhs.sb)
6106 auto res = sb->sbumpc();
6110 is->clear(is->rdstate() | std::ios::eofbit);
6117 std::istream* is =
nullptr;
6118 std::streambuf* sb =
nullptr;
6120 #endif // JSON_NO_IO
6124 template<
typename IteratorType>
6138 auto result = std::char_traits<char_type>::to_int_type(*current);
6139 std::advance(current, 1);
6143 return std::char_traits<char_type>::eof();
6150 template<
typename BaseInputAdapter,
size_t T>
6155 return current ==
end;
6160 template<
typename BaseInputAdapter,
size_t T>
6163 template<
typename BaseInputAdapter>
6168 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6169 size_t& utf8_bytes_index,
6170 size_t& utf8_bytes_filled)
6172 utf8_bytes_index = 0;
6176 utf8_bytes[0] = std::char_traits<char>::eof();
6177 utf8_bytes_filled = 1;
6182 const auto wc = input.get_character();
6187 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6188 utf8_bytes_filled = 1;
6190 else if (wc <= 0x7FF)
6192 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0
u | ((
static_cast<unsigned int>(wc) >> 6
u) & 0x1F
u));
6193 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6194 utf8_bytes_filled = 2;
6196 else if (wc <= 0xFFFF)
6198 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0
u | ((
static_cast<unsigned int>(wc) >> 12
u) & 0x0F
u));
6199 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | ((
static_cast<unsigned int>(wc) >> 6
u) & 0x3F
u));
6200 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6201 utf8_bytes_filled = 3;
6203 else if (wc <= 0x10FFFF)
6205 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0
u | ((
static_cast<unsigned int>(wc) >> 18
u) & 0x07
u));
6206 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | ((
static_cast<unsigned int>(wc) >> 12
u) & 0x3F
u));
6207 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | ((
static_cast<unsigned int>(wc) >> 6
u) & 0x3F
u));
6208 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6209 utf8_bytes_filled = 4;
6214 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6215 utf8_bytes_filled = 1;
6221 template<
typename BaseInputAdapter>
6226 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6227 size_t& utf8_bytes_index,
6228 size_t& utf8_bytes_filled)
6230 utf8_bytes_index = 0;
6234 utf8_bytes[0] = std::char_traits<char>::eof();
6235 utf8_bytes_filled = 1;
6240 const auto wc = input.get_character();
6245 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6246 utf8_bytes_filled = 1;
6248 else if (wc <= 0x7FF)
6250 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0
u | ((
static_cast<unsigned int>(wc) >> 6
u)));
6251 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6252 utf8_bytes_filled = 2;
6254 else if (0xD800 > wc || wc >= 0xE000)
6256 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0
u | ((
static_cast<unsigned int>(wc) >> 12
u)));
6257 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | ((
static_cast<unsigned int>(wc) >> 6
u) & 0x3F
u));
6258 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6259 utf8_bytes_filled = 3;
6265 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6266 const auto charcode = 0x10000
u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10
u) | (wc2 & 0x3FFu));
6267 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0
u | (charcode >> 18
u));
6268 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | ((charcode >> 12
u) & 0x3Fu));
6269 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | ((charcode >> 6
u) & 0x3Fu));
6270 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80
u | (charcode & 0x3F
u));
6271 utf8_bytes_filled = 4;
6275 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6276 utf8_bytes_filled = 1;
6284 template<
typename BaseInputAdapter,
typename W
ideCharType>
6291 : base_adapter(base) {}
6296 if (utf8_bytes_index == utf8_bytes_filled)
6298 fill_buffer<sizeof(WideCharType)>();
6306 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6307 return utf8_bytes[utf8_bytes_index++];
6320 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6323 std::size_t utf8_bytes_index = 0;
6325 std::size_t utf8_bytes_filled = 0;
6329 template<
typename IteratorType,
typename Enable =
void>
6342 template<
typename T>
6352 template<
typename IteratorType>
6367 template<
typename IteratorType>
6378 namespace container_input_adapter_factory_impl
6384 template<
typename ContainerType,
typename Enable =
void>
6387 template<
typename ContainerType>
6389 void_t<decltype(
begin(
std::declval<ContainerType>()),
end(std::declval<ContainerType>()))>>
6401 template<
typename ContainerType>
6423 #endif // JSON_NO_IO
6428 template <
typename CharT,
6429 typename std::enable_if <
6437 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6438 const auto*
ptr =
reinterpret_cast<const char*
>(b);
6442 template<
typename T, std::
size_t N>
6454 template <
typename CharT,
6455 typename std::enable_if <
6461 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) +
l) {}
6463 template<
class IteratorType,
6464 typename std::enable_if<
6465 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
6472 return std::move(ia);
6515 template<
typename BasicJsonType>
6528 virtual bool null() = 0;
6535 virtual bool boolean(
bool val) = 0;
6565 virtual bool string(
string_t& val) = 0;
6573 virtual bool binary(
binary_t& val) = 0;
6581 virtual bool start_object(std::size_t elements) = 0;
6589 virtual bool key(
string_t& val) = 0;
6595 virtual bool end_object() = 0;
6603 virtual bool start_array(std::size_t elements) = 0;
6609 virtual bool end_array() = 0;
6618 virtual bool parse_error(std::size_t position,
6619 const std::string& last_token,
6646 template<
typename BasicJsonType>
6662 : root(r), allow_exceptions(allow_exceptions_)
6674 handle_value(
nullptr);
6710 handle_value(std::move(val));
6716 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6732 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6741 ref_stack.back()->set_parents();
6742 ref_stack.pop_back();
6748 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6763 ref_stack.back()->set_parents();
6764 ref_stack.pop_back();
6768 template<
class Exception>
6770 const Exception& ex)
6773 static_cast<void>(ex);
6774 if (allow_exceptions)
6793 template<
typename Value>
6797 if (ref_stack.empty())
6799 root = BasicJsonType(std::forward<Value>(v));
6803 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6805 if (ref_stack.back()->is_array())
6807 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6808 return &(ref_stack.back()->m_value.array->back());
6813 *object_element = BasicJsonType(std::forward<Value>(v));
6814 return object_element;
6820 std::vector<BasicJsonType*> ref_stack {};
6822 BasicJsonType* object_element =
nullptr;
6824 bool errored =
false;
6826 const bool allow_exceptions =
true;
6829 template<
typename BasicJsonType>
6843 const bool allow_exceptions_ =
true)
6844 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6846 keep_stack.push_back(
true);
6858 handle_value(
nullptr);
6894 handle_value(std::move(val));
6901 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6902 keep_stack.push_back(keep);
6904 auto val = handle_value(BasicJsonType::value_t::object,
true);
6905 ref_stack.push_back(val.second);
6918 BasicJsonType k = BasicJsonType(val);
6921 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6922 key_keep_stack.push_back(keep);
6925 if (keep && ref_stack.back())
6927 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6935 if (ref_stack.back())
6937 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6944 ref_stack.back()->set_parents();
6950 ref_stack.pop_back();
6951 keep_stack.pop_back();
6953 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6956 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6958 if (it->is_discarded())
6960 ref_stack.back()->erase(it);
6971 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6972 keep_stack.push_back(keep);
6974 auto val = handle_value(BasicJsonType::value_t::array,
true);
6975 ref_stack.push_back(val.second);
6990 if (ref_stack.back())
6992 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6995 ref_stack.back()->set_parents();
7006 ref_stack.pop_back();
7007 keep_stack.pop_back();
7010 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7012 ref_stack.back()->m_value.array->pop_back();
7018 template<
class Exception>
7020 const Exception& ex)
7023 static_cast<void>(ex);
7024 if (allow_exceptions)
7052 template<
typename Value>
7053 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
7059 if (!keep_stack.back())
7061 return {
false,
nullptr};
7065 auto value = BasicJsonType(std::forward<Value>(v));
7073 return {
false,
nullptr};
7076 if (ref_stack.empty())
7078 root = std::move(
value);
7079 return {
true, &root};
7084 if (!ref_stack.back())
7086 return {
false,
nullptr};
7090 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7093 if (ref_stack.back()->is_array())
7095 ref_stack.back()->m_value.array->emplace_back(std::move(
value));
7096 return {
true, &(ref_stack.back()->m_value.array->back())};
7103 const bool store_element = key_keep_stack.back();
7104 key_keep_stack.pop_back();
7108 return {
false,
nullptr};
7112 *object_element = std::move(
value);
7113 return {
true, object_element};
7119 std::vector<BasicJsonType*> ref_stack {};
7121 std::vector<bool> keep_stack {};
7123 std::vector<bool> key_keep_stack {};
7125 BasicJsonType* object_element =
nullptr;
7127 bool errored =
false;
7131 const bool allow_exceptions =
true;
7133 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7136 template<
typename BasicJsonType>
7231 #include <initializer_list>
7251 template<
typename BasicJsonType>
7284 case token_type::uninitialized:
7285 return "<uninitialized>";
7286 case token_type::literal_true:
7287 return "true literal";
7288 case token_type::literal_false:
7289 return "false literal";
7290 case token_type::literal_null:
7291 return "null literal";
7292 case token_type::value_string:
7293 return "string literal";
7294 case token_type::value_unsigned:
7295 case token_type::value_integer:
7296 case token_type::value_float:
7297 return "number literal";
7298 case token_type::begin_array:
7300 case token_type::begin_object:
7302 case token_type::end_array:
7304 case token_type::end_object:
7306 case token_type::name_separator:
7308 case token_type::value_separator:
7310 case token_type::parse_error:
7311 return "<parse error>";
7312 case token_type::end_of_input:
7313 return "end of input";
7314 case token_type::literal_or_value:
7315 return "'[', '{', or a literal";
7318 return "unknown token";
7328 template<
typename BasicJsonType,
typename InputAdapterType>
7341 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7342 : ia(
std::move(adapter))
7343 , ignore_comments(ignore_comments_)
7344 , decimal_point_char(static_cast<
char_int_type>(get_decimal_point()))
7363 const auto* loc = localeconv();
7365 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7393 const auto factors = { 12
u, 8
u, 4
u, 0
u };
7394 for (
const auto factor : factors)
7398 if (current >=
'0' && current <=
'9')
7400 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7402 else if (current >=
'A' && current <=
'F')
7404 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7406 else if (current >=
'a' && current <=
'f')
7408 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7416 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7437 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7449 error_message =
"invalid string: ill-formed UTF-8 byte";
7486 case std::char_traits<char_type>::eof():
7488 error_message =
"invalid string: missing closing quote";
7489 return token_type::parse_error;
7495 return token_type::value_string;
7539 const int codepoint1 = get_codepoint();
7540 int codepoint = codepoint1;
7544 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7545 return token_type::parse_error;
7549 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7554 const int codepoint2 = get_codepoint();
7558 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7559 return token_type::parse_error;
7566 codepoint =
static_cast<int>(
7568 (
static_cast<unsigned int>(codepoint1) << 10
u)
7570 +
static_cast<unsigned int>(codepoint2)
7578 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7579 return token_type::parse_error;
7584 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7585 return token_type::parse_error;
7592 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7593 return token_type::parse_error;
7598 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7601 if (codepoint < 0x80)
7606 else if (codepoint <= 0x7FF)
7609 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6
u)));
7610 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7612 else if (codepoint <= 0xFFFF)
7615 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12
u)));
7616 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6
u) & 0x3Fu)));
7617 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7622 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18
u)));
7623 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12
u) & 0x3Fu)));
7624 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6
u) & 0x3Fu)));
7625 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7633 error_message =
"invalid string: forbidden character after backslash";
7634 return token_type::parse_error;
7643 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7644 return token_type::parse_error;
7649 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7650 return token_type::parse_error;
7655 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7656 return token_type::parse_error;
7661 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7662 return token_type::parse_error;
7667 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7668 return token_type::parse_error;
7673 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7674 return token_type::parse_error;
7679 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7680 return token_type::parse_error;
7685 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7686 return token_type::parse_error;
7691 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7692 return token_type::parse_error;
7697 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7698 return token_type::parse_error;
7703 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7704 return token_type::parse_error;
7709 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7710 return token_type::parse_error;
7715 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7716 return token_type::parse_error;
7721 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7722 return token_type::parse_error;
7727 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7728 return token_type::parse_error;
7733 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7734 return token_type::parse_error;
7739 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7740 return token_type::parse_error;
7745 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7746 return token_type::parse_error;
7751 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7752 return token_type::parse_error;
7757 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7758 return token_type::parse_error;
7763 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7764 return token_type::parse_error;
7769 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7770 return token_type::parse_error;
7775 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7776 return token_type::parse_error;
7781 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7782 return token_type::parse_error;
7787 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7788 return token_type::parse_error;
7793 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7794 return token_type::parse_error;
7799 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7800 return token_type::parse_error;
7805 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7806 return token_type::parse_error;
7811 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7812 return token_type::parse_error;
7817 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7818 return token_type::parse_error;
7823 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7824 return token_type::parse_error;
7829 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7830 return token_type::parse_error;
7967 return token_type::parse_error;
7977 return token_type::parse_error;
8001 return token_type::parse_error;
8011 return token_type::parse_error;
8021 return token_type::parse_error;
8033 return token_type::parse_error;
8043 return token_type::parse_error;
8051 error_message =
"invalid string: ill-formed UTF-8 byte";
8052 return token_type::parse_error;
8075 case std::char_traits<char_type>::eof():
8092 case std::char_traits<char_type>::eof():
8095 error_message =
"invalid comment; missing closing '*/'";
8123 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8130 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
8132 f = std::strtof(str, endptr);
8136 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
8138 f = std::strtod(str, endptr);
8142 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
8144 f = std::strtold(str, endptr);
8194 token_type number_type = token_type::value_unsigned;
8202 goto scan_number_minus;
8208 goto scan_number_zero;
8222 goto scan_number_any1;
8232 number_type = token_type::value_integer;
8238 goto scan_number_zero;
8252 goto scan_number_any1;
8257 error_message =
"invalid number; expected digit after '-'";
8258 return token_type::parse_error;
8268 add(decimal_point_char);
8269 goto scan_number_decimal1;
8276 goto scan_number_exponent;
8280 goto scan_number_done;
8299 goto scan_number_any1;
8304 add(decimal_point_char);
8305 goto scan_number_decimal1;
8312 goto scan_number_exponent;
8316 goto scan_number_done;
8319 scan_number_decimal1:
8321 number_type = token_type::value_float;
8336 goto scan_number_decimal2;
8341 error_message =
"invalid number; expected digit after '.'";
8342 return token_type::parse_error;
8346 scan_number_decimal2:
8362 goto scan_number_decimal2;
8369 goto scan_number_exponent;
8373 goto scan_number_done;
8376 scan_number_exponent:
8378 number_type = token_type::value_float;
8385 goto scan_number_sign;
8400 goto scan_number_any2;
8406 "invalid number; expected '+', '-', or digit after exponent";
8407 return token_type::parse_error;
8427 goto scan_number_any2;
8432 error_message =
"invalid number; expected digit after exponent sign";
8433 return token_type::parse_error;
8453 goto scan_number_any2;
8457 goto scan_number_done;
8465 char* endptr =
nullptr;
8469 if (number_type == token_type::value_unsigned)
8471 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8474 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8479 if (value_unsigned ==
x)
8481 return token_type::value_unsigned;
8485 else if (number_type == token_type::value_integer)
8487 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8490 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8495 if (value_integer ==
x)
8497 return token_type::value_integer;
8504 strtof(value_float, token_buffer.data(), &endptr);
8507 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8509 return token_type::value_float;
8521 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8522 for (std::size_t
i = 1;
i <
length; ++
i)
8526 error_message =
"invalid literal";
8527 return token_type::parse_error;
8540 token_buffer.clear();
8541 token_string.clear();
8542 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8557 ++position.chars_read_total;
8558 ++position.chars_read_current_line;
8567 current = ia.get_character();
8572 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8575 if (current ==
'\n')
8577 ++position.lines_read;
8578 position.chars_read_current_line = 0;
8596 --position.chars_read_total;
8599 if (position.chars_read_current_line == 0)
8601 if (position.lines_read > 0)
8603 --position.lines_read;
8608 --position.chars_read_current_line;
8614 token_string.pop_back();
8632 return value_integer;
8638 return value_unsigned;
8650 return token_buffer;
8670 for (
const auto c : token_string)
8672 if (
static_cast<unsigned char>(c) <=
'\x1F')
8675 std::array<char, 9> cs{{}};
8676 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8693 return error_message;
8709 return get() == 0xBB &&
get() == 0xBF;
8724 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8730 if (position.chars_read_total == 0 && !skip_bom())
8732 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8733 return token_type::parse_error;
8740 while (ignore_comments && current ==
'/')
8742 if (!scan_comment())
8744 return token_type::parse_error;
8755 return token_type::begin_array;
8757 return token_type::end_array;
8759 return token_type::begin_object;
8761 return token_type::end_object;
8763 return token_type::name_separator;
8765 return token_type::value_separator;
8771 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8776 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8781 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8786 return scan_string();
8800 return scan_number();
8805 case std::char_traits<char_type>::eof():
8806 return token_type::end_of_input;
8810 error_message =
"invalid literal";
8811 return token_type::parse_error;
8820 const bool ignore_comments =
false;
8826 bool next_unget =
false;
8832 std::vector<char_type> token_string {};
8838 const char* error_message =
"";
8880 template<
typename T>
8883 template<
typename T>
8885 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
8887 template<
typename T,
typename Integer>
8891 template<
typename T,
typename Un
signed>
8895 template<
typename T,
typename Float,
typename String>
8897 std::declval<Float>(), std::declval<const String&>()));
8899 template<
typename T,
typename String>
8901 decltype(std::declval<T&>().
string(std::declval<String&>()));
8903 template<
typename T,
typename Binary>
8905 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
8907 template<
typename T>
8909 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8911 template<
typename T,
typename String>
8913 decltype(std::declval<T&>().
key(std::declval<String&>()));
8915 template<
typename T>
8918 template<
typename T>
8920 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8922 template<
typename T>
8925 template<
typename T,
typename Exception>
8927 std::declval<std::size_t>(), std::declval<const std::string&>(),
8928 std::declval<const Exception&>()));
8930 template<
typename SAX,
typename BasicJsonType>
8935 "BasicJsonType must be of type basic_json<...>");
8961 template<
typename SAX,
typename BasicJsonType>
8966 "BasicJsonType must be of type basic_json<...>");
8977 "Missing/invalid function: bool null()");
8979 "Missing/invalid function: bool boolean(bool)");
8981 "Missing/invalid function: bool boolean(bool)");
8985 "Missing/invalid function: bool number_integer(number_integer_t)");
8989 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8992 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8995 "Missing/invalid function: bool string(string_t&)");
8998 "Missing/invalid function: bool binary(binary_t&)");
9000 "Missing/invalid function: bool start_object(std::size_t)");
9002 "Missing/invalid function: bool key(string_t&)");
9004 "Missing/invalid function: bool end_object()");
9006 "Missing/invalid function: bool start_array(std::size_t)");
9008 "Missing/invalid function: bool end_array()");
9011 "Missing/invalid function: bool parse_error(std::size_t, const "
9012 "std::string&, const exception&)");
9046 return *
reinterpret_cast<char*
>(&num) == 1;
9057 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9098 const
bool strict = true,
9106 case input_format_t::bson:
9107 result = parse_bson_internal();
9110 case input_format_t::cbor:
9111 result = parse_cbor_internal(
true, tag_handler);
9114 case input_format_t::msgpack:
9115 result = parse_msgpack_internal();
9118 case input_format_t::ubjson:
9119 case input_format_t::bjdata:
9120 result = parse_ubjson_internal();
9131 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9142 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9143 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9161 std::int32_t document_size{};
9162 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9174 return sax->end_object();
9186 auto out = std::back_inserter(
result);
9194 if (current == 0x00)
9213 template<
typename NumberType>
9218 auto last_token = get_token_string();
9220 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ",
std::to_string(
len)),
"string"),
nullptr));
9223 return get_string(input_format_t::bson,
len -
static_cast<NumberType
>(1),
result) &&
get() != std::char_traits<char_type>::eof();
9235 template<
typename NumberType>
9240 auto last_token = get_token_string();
9242 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ",
std::to_string(
len)),
"binary"),
nullptr));
9246 std::uint8_t subtype{};
9247 get_number<std::uint8_t>(input_format_t::bson, subtype);
9248 result.set_subtype(subtype);
9250 return get_binary(input_format_t::bson,
len,
result);
9264 const std::size_t element_type_parse_position)
9266 switch (element_type)
9271 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9278 return get_number<std::int32_t, true>(input_format_t::bson,
len) && get_bson_string(
len,
value) && sax->string(
value);
9283 return parse_bson_internal();
9288 return parse_bson_array();
9295 return get_number<std::int32_t, true>(input_format_t::bson,
len) && get_bson_binary(
len,
value) && sax->binary(
value);
9300 return sax->boolean(
get() != 0);
9310 std::int32_t
value{};
9311 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9316 std::int64_t
value{};
9317 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9322 std::array<char, 3> cr{{}};
9323 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9324 std::string cr_str{cr.data()};
9325 return sax->parse_error(element_type_parse_position, cr_str,
9347 while (
auto element_type =
get())
9354 const std::size_t element_type_parse_position = chars_read;
9360 if (!is_array && !sax->key(
key))
9365 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9383 std::int32_t document_size{};
9384 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9396 return sax->end_array();
9414 switch (get_char ?
get() : current)
9417 case std::char_traits<char_type>::eof():
9418 return unexpect_eof(input_format_t::cbor,
"value");
9449 std::uint8_t number{};
9450 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9455 std::uint16_t number{};
9456 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9461 std::uint32_t number{};
9462 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9467 std::uint64_t number{};
9468 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9496 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9500 std::uint8_t number{};
9501 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9506 std::uint16_t number{};
9507 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9512 std::uint32_t number{};
9513 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9518 std::uint64_t number{};
9519 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1)
9555 return get_cbor_binary(b) && sax->binary(b);
9590 return get_cbor_string(
s) && sax->string(
s);
9618 return get_cbor_array(
9619 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9624 return get_number(input_format_t::cbor,
len) && get_cbor_array(
static_cast<std::size_t
>(
len), tag_handler);
9629 std::uint16_t
len{};
9630 return get_number(input_format_t::cbor,
len) && get_cbor_array(
static_cast<std::size_t
>(
len), tag_handler);
9635 std::uint32_t
len{};
9636 return get_number(input_format_t::cbor,
len) && get_cbor_array(conditional_static_cast<std::size_t>(
len), tag_handler);
9641 std::uint64_t
len{};
9642 return get_number(input_format_t::cbor,
len) && get_cbor_array(conditional_static_cast<std::size_t>(
len), tag_handler);
9646 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9673 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9678 return get_number(input_format_t::cbor,
len) && get_cbor_object(
static_cast<std::size_t
>(
len), tag_handler);
9683 std::uint16_t
len{};
9684 return get_number(input_format_t::cbor,
len) && get_cbor_object(
static_cast<std::size_t
>(
len), tag_handler);
9689 std::uint32_t
len{};
9690 return get_number(input_format_t::cbor,
len) && get_cbor_object(conditional_static_cast<std::size_t>(
len), tag_handler);
9695 std::uint64_t
len{};
9696 return get_number(input_format_t::cbor,
len) && get_cbor_object(conditional_static_cast<std::size_t>(
len), tag_handler);
9700 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9722 switch (tag_handler)
9726 auto last_token = get_token_string();
9728 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9731 case cbor_tag_handler_t::ignore:
9738 std::uint8_t subtype_to_ignore{};
9739 get_number(input_format_t::cbor, subtype_to_ignore);
9744 std::uint16_t subtype_to_ignore{};
9745 get_number(input_format_t::cbor, subtype_to_ignore);
9750 std::uint32_t subtype_to_ignore{};
9751 get_number(input_format_t::cbor, subtype_to_ignore);
9756 std::uint64_t subtype_to_ignore{};
9757 get_number(input_format_t::cbor, subtype_to_ignore);
9763 return parse_cbor_internal(
true, tag_handler);
9766 case cbor_tag_handler_t::store:
9774 std::uint8_t subtype{};
9775 get_number(input_format_t::cbor, subtype);
9776 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9781 std::uint16_t subtype{};
9782 get_number(input_format_t::cbor, subtype);
9783 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9788 std::uint32_t subtype{};
9789 get_number(input_format_t::cbor, subtype);
9790 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9795 std::uint64_t subtype{};
9796 get_number(input_format_t::cbor, subtype);
9797 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9801 return parse_cbor_internal(
true, tag_handler);
9804 return get_cbor_binary(b) && sax->binary(b);
9814 return sax->boolean(
false);
9817 return sax->boolean(
true);
9824 const auto byte1_raw =
get();
9829 const auto byte2_raw =
get();
9835 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9836 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9846 const auto half =
static_cast<unsigned int>((byte1 << 8
u) + byte2);
9847 const double val = [&half]
9849 const int exp = (half >> 10
u) & 0x1Fu;
9850 const unsigned int mant = half & 0x3FF
u;
9856 return std::ldexp(mant, -24);
9859 ? std::numeric_limits<double>::infinity()
9860 : std::numeric_limits<double>::quiet_NaN();
9862 return std::ldexp(mant + 1024, exp - 25);
9865 return sax->number_float((half & 0x8000u) != 0
9873 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9879 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9884 auto last_token = get_token_string();
9886 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9937 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu,
result);
9943 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9948 std::uint16_t
len{};
9949 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9954 std::uint32_t
len{};
9955 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9960 std::uint64_t
len{};
9961 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9966 while (
get() != 0xFF)
9969 if (!get_cbor_string(
chunk))
9980 auto last_token = get_token_string();
9982 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10033 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu,
result);
10038 std::uint8_t
len{};
10039 return get_number(input_format_t::cbor,
len) &&
10040 get_binary(input_format_t::cbor,
len,
result);
10045 std::uint16_t
len{};
10046 return get_number(input_format_t::cbor,
len) &&
10047 get_binary(input_format_t::cbor,
len,
result);
10052 std::uint32_t
len{};
10053 return get_number(input_format_t::cbor,
len) &&
10054 get_binary(input_format_t::cbor,
len,
result);
10059 std::uint64_t
len{};
10060 return get_number(input_format_t::cbor,
len) &&
10061 get_binary(input_format_t::cbor,
len,
result);
10066 while (
get() != 0xFF)
10069 if (!get_cbor_binary(
chunk))
10080 auto last_token = get_token_string();
10082 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));
10101 if (
len !=
static_cast<std::size_t
>(-1))
10103 for (std::size_t
i = 0;
i <
len; ++
i)
10113 while (
get() != 0xFF)
10122 return sax->end_array();
10142 if (
len !=
static_cast<std::size_t
>(-1))
10144 for (std::size_t
i = 0;
i <
len; ++
i)
10161 while (
get() != 0xFF)
10177 return sax->end_object();
10192 case std::char_traits<char_type>::eof():
10193 return unexpect_eof(input_format_t::msgpack,
"value");
10343 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10362 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10402 return get_msgpack_string(
s) && sax->string(
s);
10406 return sax->null();
10409 return sax->boolean(
false);
10412 return sax->boolean(
true);
10427 return get_msgpack_binary(b) && sax->binary(b);
10433 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10439 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10444 std::uint8_t number{};
10445 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10450 std::uint16_t number{};
10451 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10456 std::uint32_t number{};
10457 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10462 std::uint64_t number{};
10463 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10468 std::int8_t number{};
10469 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10474 std::int16_t number{};
10475 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10480 std::int32_t number{};
10481 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10486 std::int64_t number{};
10487 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10492 std::uint16_t
len{};
10493 return get_number(input_format_t::msgpack,
len) && get_msgpack_array(
static_cast<std::size_t
>(
len));
10498 std::uint32_t
len{};
10499 return get_number(input_format_t::msgpack,
len) && get_msgpack_array(conditional_static_cast<std::size_t>(
len));
10504 std::uint16_t
len{};
10505 return get_number(input_format_t::msgpack,
len) && get_msgpack_object(
static_cast<std::size_t
>(
len));
10510 std::uint32_t
len{};
10511 return get_number(input_format_t::msgpack,
len) && get_msgpack_object(conditional_static_cast<std::size_t>(
len));
10547 return sax->number_integer(
static_cast<std::int8_t
>(current));
10551 auto last_token = get_token_string();
10553 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10611 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu,
result);
10616 std::uint8_t
len{};
10617 return get_number(input_format_t::msgpack,
len) && get_string(input_format_t::msgpack,
len,
result);
10622 std::uint16_t
len{};
10623 return get_number(input_format_t::msgpack,
len) && get_string(input_format_t::msgpack,
len,
result);
10628 std::uint32_t
len{};
10629 return get_number(input_format_t::msgpack,
len) && get_string(input_format_t::msgpack,
len,
result);
10634 auto last_token = get_token_string();
10636 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10654 auto assign_and_return_true = [&
result](std::int8_t subtype)
10656 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10664 std::uint8_t
len{};
10665 return get_number(input_format_t::msgpack,
len) &&
10666 get_binary(input_format_t::msgpack,
len,
result);
10671 std::uint16_t
len{};
10672 return get_number(input_format_t::msgpack,
len) &&
10673 get_binary(input_format_t::msgpack,
len,
result);
10678 std::uint32_t
len{};
10679 return get_number(input_format_t::msgpack,
len) &&
10680 get_binary(input_format_t::msgpack,
len,
result);
10685 std::uint8_t
len{};
10686 std::int8_t subtype{};
10687 return get_number(input_format_t::msgpack,
len) &&
10688 get_number(input_format_t::msgpack, subtype) &&
10689 get_binary(input_format_t::msgpack,
len,
result) &&
10690 assign_and_return_true(subtype);
10695 std::uint16_t
len{};
10696 std::int8_t subtype{};
10697 return get_number(input_format_t::msgpack,
len) &&
10698 get_number(input_format_t::msgpack, subtype) &&
10699 get_binary(input_format_t::msgpack,
len,
result) &&
10700 assign_and_return_true(subtype);
10705 std::uint32_t
len{};
10706 std::int8_t subtype{};
10707 return get_number(input_format_t::msgpack,
len) &&
10708 get_number(input_format_t::msgpack, subtype) &&
10709 get_binary(input_format_t::msgpack,
len,
result) &&
10710 assign_and_return_true(subtype);
10715 std::int8_t subtype{};
10716 return get_number(input_format_t::msgpack, subtype) &&
10717 get_binary(input_format_t::msgpack, 1,
result) &&
10718 assign_and_return_true(subtype);
10723 std::int8_t subtype{};
10724 return get_number(input_format_t::msgpack, subtype) &&
10725 get_binary(input_format_t::msgpack, 2,
result) &&
10726 assign_and_return_true(subtype);
10731 std::int8_t subtype{};
10732 return get_number(input_format_t::msgpack, subtype) &&
10733 get_binary(input_format_t::msgpack, 4,
result) &&
10734 assign_and_return_true(subtype);
10739 std::int8_t subtype{};
10740 return get_number(input_format_t::msgpack, subtype) &&
10741 get_binary(input_format_t::msgpack, 8,
result) &&
10742 assign_and_return_true(subtype);
10747 std::int8_t subtype{};
10748 return get_number(input_format_t::msgpack, subtype) &&
10749 get_binary(input_format_t::msgpack, 16,
result) &&
10750 assign_and_return_true(subtype);
10769 for (std::size_t
i = 0;
i <
len; ++
i)
10777 return sax->end_array();
10792 for (std::size_t
i = 0;
i <
len; ++
i)
10807 return sax->end_object();
10823 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10856 std::uint8_t
len{};
10857 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10863 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10868 std::int16_t
len{};
10869 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10874 std::int32_t
len{};
10875 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10880 std::int64_t
len{};
10881 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10886 if (input_format != input_format_t::bjdata)
10890 std::uint16_t
len{};
10891 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10896 if (input_format != input_format_t::bjdata)
10900 std::uint32_t
len{};
10901 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10906 if (input_format != input_format_t::bjdata)
10910 std::uint64_t
len{};
10911 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10917 auto last_token = get_token_string();
10918 std::string message;
10920 if (input_format != input_format_t::bjdata)
10922 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
10926 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
10928 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
10937 std::pair<std::size_t, char_int_type> size_and_type;
10939 bool no_ndarray =
true;
10946 if (size_and_type.first != string_t::npos)
10948 if (size_and_type.second != 0)
10950 if (size_and_type.second !=
'N')
10952 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
10958 dim.push_back(dimlen);
10964 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
10970 dim.push_back(dimlen);
10976 while (current !=
']')
10982 dim.push_back(dimlen);
11004 prefix = get_ignore_noop();
11011 std::uint8_t number{};
11016 result =
static_cast<std::size_t
>(number);
11022 std::int8_t number{};
11029 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11030 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11032 result =
static_cast<std::size_t
>(number);
11038 std::int16_t number{};
11045 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11046 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11048 result =
static_cast<std::size_t
>(number);
11054 std::int32_t number{};
11061 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11062 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11064 result =
static_cast<std::size_t
>(number);
11070 std::int64_t number{};
11077 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11078 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11080 if (!value_in_range_of<std::size_t>(number))
11083 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11085 result =
static_cast<std::size_t
>(number);
11091 if (input_format != input_format_t::bjdata)
11095 std::uint16_t number{};
11100 result =
static_cast<std::size_t
>(number);
11106 if (input_format != input_format_t::bjdata)
11110 std::uint32_t number{};
11115 result = conditional_static_cast<std::size_t>(number);
11121 if (input_format != input_format_t::bjdata)
11125 std::uint64_t number{};
11130 if (!value_in_range_of<std::size_t>(number))
11133 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11135 result = detail::conditional_static_cast<std::size_t>(number);
11141 if (input_format != input_format_t::bjdata)
11147 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimentional vector is not allowed",
"size"),
nullptr));
11149 std::vector<size_t> dim;
11154 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11156 result = dim.at(dim.size() - 1);
11181 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));
11189 return sax->end_array();
11198 auto last_token = get_token_string();
11199 std::string message;
11201 if (input_format != input_format_t::bjdata)
11203 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11207 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11209 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11225 result.first = string_t::npos;
11227 bool is_ndarray =
false;
11231 if (current ==
'$')
11233 std::vector<char_int_type> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
11238 auto last_token = get_token_string();
11240 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11255 auto last_token = get_token_string();
11257 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11260 bool is_error = get_ubjson_size_value(
result.first, is_ndarray);
11261 if (input_format == input_format_t::bjdata && is_ndarray)
11263 if (inside_ndarray)
11265 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11266 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11268 result.second |= (1 << 8);
11273 if (current ==
'#')
11275 bool is_error = get_ubjson_size_value(
result.first, is_ndarray);
11276 if (input_format == input_format_t::bjdata && is_ndarray)
11278 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11279 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11295 case std::char_traits<char_type>::eof():
11296 return unexpect_eof(input_format,
"value");
11299 return sax->boolean(
true);
11301 return sax->boolean(
false);
11304 return sax->null();
11308 std::uint8_t number{};
11309 return get_number(input_format, number) && sax->number_unsigned(number);
11314 std::int8_t number{};
11315 return get_number(input_format, number) && sax->number_integer(number);
11320 std::int16_t number{};
11321 return get_number(input_format, number) && sax->number_integer(number);
11326 std::int32_t number{};
11327 return get_number(input_format, number) && sax->number_integer(number);
11332 std::int64_t number{};
11333 return get_number(input_format, number) && sax->number_integer(number);
11338 if (input_format != input_format_t::bjdata)
11342 std::uint16_t number{};
11343 return get_number(input_format, number) && sax->number_unsigned(number);
11348 if (input_format != input_format_t::bjdata)
11352 std::uint32_t number{};
11353 return get_number(input_format, number) && sax->number_unsigned(number);
11358 if (input_format != input_format_t::bjdata)
11362 std::uint64_t number{};
11363 return get_number(input_format, number) && sax->number_unsigned(number);
11368 if (input_format != input_format_t::bjdata)
11372 const auto byte1_raw =
get();
11377 const auto byte2_raw =
get();
11383 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11384 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11394 const auto half =
static_cast<unsigned int>((byte2 << 8
u) + byte1);
11395 const double val = [&half]
11397 const int exp = (half >> 10
u) & 0x1Fu;
11398 const unsigned int mant = half & 0x3FF
u;
11404 return std::ldexp(mant, -24);
11407 ? std::numeric_limits<double>::infinity()
11408 : std::numeric_limits<double>::quiet_NaN();
11410 return std::ldexp(mant + 1024, exp - 25);
11413 return sax->number_float((half & 0x8000u) != 0
11421 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11427 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11432 return get_ubjson_high_precision_number();
11444 auto last_token = get_token_string();
11446 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11449 return sax->string(
s);
11455 return get_ubjson_string(
s) && sax->string(
s);
11459 return get_ubjson_array();
11462 return get_ubjson_object();
11467 auto last_token = get_token_string();
11468 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));
11476 std::pair<std::size_t, char_int_type> size_and_type;
11485 if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11487 std::map<char_int_type, string_t> bjdtype = {{
'U',
"uint8"}, {
'i',
"int8"}, {
'u',
"uint16"}, {
'I',
"int16"},
11488 {
'm',
"uint32"}, {
'l',
"int32"}, {
'M',
"uint64"}, {
'L',
"int64"}, {
'd',
"single"}, {
'D',
"double"}, {
'C',
"char"}
11491 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
11496 auto last_token = get_token_string();
11498 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11506 if (size_and_type.second ==
'C')
11508 size_and_type.second =
'U';
11511 key =
"_ArrayData_";
11517 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11525 return (sax->end_array() && sax->end_object());
11528 if (size_and_type.first != string_t::npos)
11535 if (size_and_type.second != 0)
11537 if (size_and_type.second !=
'N')
11539 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11550 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11566 while (current !=
']')
11576 return sax->end_array();
11584 std::pair<std::size_t, char_int_type> size_and_type;
11591 if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11593 auto last_token = get_token_string();
11595 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11599 if (size_and_type.first != string_t::npos)
11606 if (size_and_type.second != 0)
11608 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11623 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11644 while (current !=
'}')
11659 return sax->end_object();
11668 std::size_t
size{};
11669 bool no_ndarray =
true;
11670 auto res = get_ubjson_size_value(
size, no_ndarray);
11677 std::vector<char> number_vector;
11678 for (std::size_t
i = 0;
i <
size; ++
i)
11685 number_vector.push_back(
static_cast<char>(current));
11691 const auto result_number = number_lexer.scan();
11692 const auto number_string = number_lexer.get_token_string();
11693 const auto result_remainder = number_lexer.scan();
11700 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11703 switch (result_number)
11705 case token_type::value_integer:
11706 return sax->number_integer(number_lexer.get_number_integer());
11707 case token_type::value_unsigned:
11708 return sax->number_unsigned(number_lexer.get_number_unsigned());
11709 case token_type::value_float:
11710 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11711 case token_type::uninitialized:
11712 case token_type::literal_true:
11713 case token_type::literal_false:
11714 case token_type::literal_null:
11715 case token_type::value_string:
11716 case token_type::begin_array:
11717 case token_type::begin_object:
11718 case token_type::end_array:
11719 case token_type::end_object:
11720 case token_type::name_separator:
11721 case token_type::value_separator:
11722 case token_type::parse_error:
11723 case token_type::end_of_input:
11724 case token_type::literal_or_value:
11727 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11747 return current = ia.get_character();
11759 while (current ==
'N');
11779 template<
typename NumberType,
bool InputIsLittleEndian = false>
11783 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11784 for (std::size_t
i = 0;
i <
sizeof(NumberType); ++
i)
11793 if (is_little_endian != (InputIsLittleEndian ||
format == input_format_t::bjdata))
11795 vec[
sizeof(NumberType) -
i - 1] =
static_cast<std::uint8_t
>(current);
11799 vec[
i] =
static_cast<std::uint8_t
>(current);
11804 std::memcpy(&
result, vec.data(),
sizeof(NumberType));
11822 template<
typename NumberType>
11824 const NumberType
len,
11827 bool success =
true;
11828 for (NumberType
i = 0;
i <
len;
i++)
11855 template<
typename NumberType>
11857 const NumberType
len,
11860 bool success =
true;
11861 for (NumberType
i = 0;
i <
len;
i++)
11869 result.push_back(
static_cast<std::uint8_t
>(current));
11884 return sax->parse_error(chars_read,
"<end of file>",
11895 std::array<char, 3> cr{{}};
11896 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11897 return std::string{cr.data()};
11907 const std::string&
detail,
11908 const std::string& context)
const
11910 std::string error_msg =
"syntax error while parsing ";
11914 case input_format_t::cbor:
11915 error_msg +=
"CBOR";
11918 case input_format_t::msgpack:
11919 error_msg +=
"MessagePack";
11922 case input_format_t::ubjson:
11923 error_msg +=
"UBJSON";
11926 case input_format_t::bson:
11927 error_msg +=
"BSON";
11930 case input_format_t::bjdata:
11931 error_msg +=
"BJData";
11950 std::size_t chars_read = 0;
11982 #include <functional>
12027 template<
typename BasicJsonType>
12036 template<
typename BasicJsonType,
typename InputAdapterType>
12050 const bool allow_exceptions_ =
true,
12051 const bool skip_comments =
false)
12053 , m_lexer(
std::move(adapter), skip_comments)
12054 , allow_exceptions(allow_exceptions_)
12075 sax_parse_internal(&sdp);
12078 if (
strict && (get_token() != token_type::end_of_input))
12081 m_lexer.get_token_string(),
12083 exception_message(token_type::end_of_input,
"value"),
nullptr));
12089 result = value_t::discarded;
12095 if (
result.is_discarded())
12103 sax_parse_internal(&sdp);
12106 if (
strict && (get_token() != token_type::end_of_input))
12109 m_lexer.get_token_string(),
12110 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12116 result = value_t::discarded;
12121 result.assert_invariant();
12133 return sax_parse(&sax_acceptor,
strict);
12136 template<
typename SAX>
12138 bool sax_parse(SAX* sax, const
bool strict = true)
12141 const bool result = sax_parse_internal(sax);
12144 if (
result &&
strict && (get_token() != token_type::end_of_input))
12146 return sax->parse_error(m_lexer.get_position(),
12147 m_lexer.get_token_string(),
12148 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12155 template<
typename SAX>
12157 bool sax_parse_internal(SAX* sax)
12161 std::vector<bool> states;
12163 bool skip_to_state_evaluation =
false;
12167 if (!skip_to_state_evaluation)
12170 switch (last_token)
12172 case token_type::begin_object:
12180 if (get_token() == token_type::end_object)
12192 return sax->parse_error(m_lexer.get_position(),
12193 m_lexer.get_token_string(),
12194 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12204 return sax->parse_error(m_lexer.get_position(),
12205 m_lexer.get_token_string(),
12206 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12210 states.push_back(
false);
12217 case token_type::begin_array:
12225 if (get_token() == token_type::end_array)
12235 states.push_back(
true);
12241 case token_type::value_float:
12243 const auto res = m_lexer.get_number_float();
12247 return sax->parse_error(m_lexer.get_position(),
12248 m_lexer.get_token_string(),
12260 case token_type::literal_false:
12269 case token_type::literal_null:
12278 case token_type::literal_true:
12287 case token_type::value_integer:
12296 case token_type::value_string:
12305 case token_type::value_unsigned:
12314 case token_type::parse_error:
12317 return sax->parse_error(m_lexer.get_position(),
12318 m_lexer.get_token_string(),
12319 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12322 case token_type::uninitialized:
12323 case token_type::end_array:
12324 case token_type::end_object:
12325 case token_type::name_separator:
12326 case token_type::value_separator:
12327 case token_type::end_of_input:
12328 case token_type::literal_or_value:
12331 return sax->parse_error(m_lexer.get_position(),
12332 m_lexer.get_token_string(),
12333 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12339 skip_to_state_evaluation =
false;
12343 if (states.empty())
12352 if (get_token() == token_type::value_separator)
12373 skip_to_state_evaluation =
true;
12377 return sax->parse_error(m_lexer.get_position(),
12378 m_lexer.get_token_string(),
12379 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12385 if (get_token() == token_type::value_separator)
12390 return sax->parse_error(m_lexer.get_position(),
12391 m_lexer.get_token_string(),
12392 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12403 return sax->parse_error(m_lexer.get_position(),
12404 m_lexer.get_token_string(),
12405 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12427 skip_to_state_evaluation =
true;
12431 return sax->parse_error(m_lexer.get_position(),
12432 m_lexer.get_token_string(),
12433 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12440 return last_token = m_lexer.scan();
12445 std::string error_msg =
"syntax error ";
12447 if (!context.empty())
12449 error_msg +=
concat(
"while parsing ", context,
' ');
12454 if (last_token == token_type::parse_error)
12456 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12457 m_lexer.get_token_string(),
'\'');
12461 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
12464 if (expected != token_type::uninitialized)
12466 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
12480 const bool allow_exceptions =
true;
12549 m_it = begin_value;
12561 return m_it == begin_value;
12567 return m_it == end_value;
12572 return lhs.m_it == rhs.m_it;
12577 return lhs.m_it < rhs.m_it;
12589 return lhs.m_it - rhs.m_it;
12648 typename BasicJsonType::object_t::iterator object_iterator {};
12650 typename BasicJsonType::array_t::iterator array_iterator {};
12669 #include <iterator>
12670 #include <type_traits>
12692 template<
typename IteratorType>
class iteration_proxy;
12693 template<
typename IteratorType>
class iteration_proxy_value;
12711 template<
typename BasicJsonType>
12726 "iter_impl only accepts (const) basic_json");
12729 && std::is_base_of<std::bidirectional_iterator_tag,
typename std::iterator_traits<typename array_t::iterator>::iterator_category>::
value,
12730 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12746 typename BasicJsonType::const_pointer,
12751 typename BasicJsonType::const_reference,
12769 switch (m_object->m_type)
12771 case value_t::object:
12773 m_it.object_iterator =
typename object_t::iterator();
12777 case value_t::array:
12779 m_it.array_iterator =
typename array_t::iterator();
12783 case value_t::null:
12784 case value_t::string:
12785 case value_t::boolean:
12786 case value_t::number_integer:
12787 case value_t::number_unsigned:
12788 case value_t::number_float:
12789 case value_t::binary:
12790 case value_t::discarded:
12816 : m_object(other.m_object), m_it(other.m_it)
12827 if (&other !=
this)
12841 : m_object(other.m_object), m_it(other.m_it)
12866 switch (m_object->m_type)
12868 case value_t::object:
12870 m_it.object_iterator = m_object->m_value.object->begin();
12874 case value_t::array:
12876 m_it.array_iterator = m_object->m_value.array->begin();
12880 case value_t::null:
12883 m_it.primitive_iterator.set_end();
12887 case value_t::string:
12888 case value_t::boolean:
12889 case value_t::number_integer:
12890 case value_t::number_unsigned:
12891 case value_t::number_float:
12892 case value_t::binary:
12893 case value_t::discarded:
12896 m_it.primitive_iterator.set_begin();
12910 switch (m_object->m_type)
12912 case value_t::object:
12914 m_it.object_iterator = m_object->m_value.object->end();
12918 case value_t::array:
12920 m_it.array_iterator = m_object->m_value.array->end();
12924 case value_t::null:
12925 case value_t::string:
12926 case value_t::boolean:
12927 case value_t::number_integer:
12928 case value_t::number_unsigned:
12929 case value_t::number_float:
12930 case value_t::binary:
12931 case value_t::discarded:
12934 m_it.primitive_iterator.set_end();
12949 switch (m_object->m_type)
12951 case value_t::object:
12953 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
12954 return m_it.object_iterator->second;
12957 case value_t::array:
12959 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
12960 return *m_it.array_iterator;
12963 case value_t::null:
12966 case value_t::string:
12967 case value_t::boolean:
12968 case value_t::number_integer:
12969 case value_t::number_unsigned:
12970 case value_t::number_float:
12971 case value_t::binary:
12972 case value_t::discarded:
12993 switch (m_object->m_type)
12995 case value_t::object:
12997 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
12998 return &(m_it.object_iterator->second);
13001 case value_t::array:
13003 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
13004 return &*m_it.array_iterator;
13007 case value_t::null:
13008 case value_t::string:
13009 case value_t::boolean:
13010 case value_t::number_integer:
13011 case value_t::number_unsigned:
13012 case value_t::number_float:
13013 case value_t::binary:
13014 case value_t::discarded:
13046 switch (m_object->m_type)
13048 case value_t::object:
13050 std::advance(m_it.object_iterator, 1);
13054 case value_t::array:
13056 std::advance(m_it.array_iterator, 1);
13060 case value_t::null:
13061 case value_t::string:
13062 case value_t::boolean:
13063 case value_t::number_integer:
13064 case value_t::number_unsigned:
13065 case value_t::number_float:
13066 case value_t::binary:
13067 case value_t::discarded:
13070 ++m_it.primitive_iterator;
13097 switch (m_object->m_type)
13099 case value_t::object:
13101 std::advance(m_it.object_iterator, -1);
13105 case value_t::array:
13107 std::advance(m_it.array_iterator, -1);
13111 case value_t::null:
13112 case value_t::string:
13113 case value_t::boolean:
13114 case value_t::number_integer:
13115 case value_t::number_unsigned:
13116 case value_t::number_float:
13117 case value_t::binary:
13118 case value_t::discarded:
13121 --m_it.primitive_iterator;
13133 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 >
13144 switch (m_object->m_type)
13146 case value_t::object:
13147 return (m_it.object_iterator == other.m_it.object_iterator);
13149 case value_t::array:
13150 return (m_it.array_iterator == other.m_it.array_iterator);
13152 case value_t::null:
13153 case value_t::string:
13154 case value_t::boolean:
13155 case value_t::number_integer:
13156 case value_t::number_unsigned:
13157 case value_t::number_float:
13158 case value_t::binary:
13159 case value_t::discarded:
13161 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
13169 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 >
13189 switch (m_object->m_type)
13191 case value_t::object:
13194 case value_t::array:
13197 case value_t::null:
13198 case value_t::string:
13199 case value_t::boolean:
13200 case value_t::number_integer:
13201 case value_t::number_unsigned:
13202 case value_t::number_float:
13203 case value_t::binary:
13204 case value_t::discarded:
13216 return !other.operator < (*this);
13225 return !operator<=(other);
13245 switch (m_object->m_type)
13247 case value_t::object:
13250 case value_t::array:
13252 std::advance(m_it.array_iterator,
i);
13256 case value_t::null:
13257 case value_t::string:
13258 case value_t::boolean:
13259 case value_t::number_integer:
13260 case value_t::number_unsigned:
13261 case value_t::number_float:
13262 case value_t::binary:
13263 case value_t::discarded:
13266 m_it.primitive_iterator +=
i;
13324 switch (m_object->m_type)
13326 case value_t::object:
13329 case value_t::array:
13332 case value_t::null:
13333 case value_t::string:
13334 case value_t::boolean:
13335 case value_t::number_integer:
13336 case value_t::number_unsigned:
13337 case value_t::number_float:
13338 case value_t::binary:
13339 case value_t::discarded:
13353 switch (m_object->m_type)
13355 case value_t::object:
13358 case value_t::array:
13359 return *std::next(m_it.array_iterator,
n);
13361 case value_t::null:
13364 case value_t::string:
13365 case value_t::boolean:
13366 case value_t::number_integer:
13367 case value_t::number_unsigned:
13368 case value_t::number_float:
13369 case value_t::binary:
13370 case value_t::discarded:
13387 const typename object_t::key_type&
key()
const
13393 return m_it.object_iterator->first;
13432 #include <iterator>
13464 template<
typename Base>
13536 auto key() const -> decltype(
std::declval<Base>().key())
13538 auto it = --this->base();
13545 auto it = --this->base();
13546 return it.operator * ();
13566 #include <algorithm>
13572 #endif // JSON_NO_IO
13594 template<
typename RefStringType>
13604 template<
typename T>
13623 : reference_tokens(split(
s))
13630 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13634 return detail::concat(a,
'/', detail::escape(b));
13651 o <<
ptr.to_string();
13660 reference_tokens.insert(reference_tokens.end(),
13661 ptr.reference_tokens.begin(),
13662 ptr.reference_tokens.end());
13670 push_back(std::move(token));
13726 reference_tokens.pop_back();
13738 return reference_tokens.back();
13745 reference_tokens.push_back(token);
13752 reference_tokens.push_back(std::move(token));
13759 return reference_tokens.empty();
13773 template<
typename BasicJsonType>
13776 using size_type =
typename BasicJsonType::size_type;
13790 const char*
p =
s.c_str();
13791 char* p_end =
nullptr;
13793 unsigned long long res = std::strtoull(
p, &p_end, 10);
13808 return static_cast<size_type
>(res);
13820 result.reference_tokens = {reference_tokens[0]};
13833 template<
typename BasicJsonType>
13840 for (
const auto& reference_token : reference_tokens)
13844 case detail::value_t::null:
13846 if (reference_token ==
"0")
13859 case detail::value_t::object:
13866 case detail::value_t::array:
13869 result = &
result->operator[](array_index<BasicJsonType>(reference_token));
13879 case detail::value_t::string:
13880 case detail::value_t::boolean:
13881 case detail::value_t::number_integer:
13882 case detail::value_t::number_unsigned:
13883 case detail::value_t::number_float:
13884 case detail::value_t::binary:
13885 case detail::value_t::discarded:
13913 template<
typename BasicJsonType>
13916 for (
const auto& reference_token : reference_tokens)
13919 if (
ptr->is_null())
13923 std::all_of(reference_token.begin(), reference_token.end(),
13924 [](
const unsigned char x)
13926 return std::isdigit(x);
13930 *
ptr = (nums || reference_token ==
"-")
13931 ? detail::value_t::array
13932 : detail::value_t::object;
13935 switch (
ptr->type())
13937 case detail::value_t::object:
13940 ptr = &
ptr->operator[](reference_token);
13944 case detail::value_t::array:
13946 if (reference_token ==
"-")
13949 ptr = &
ptr->operator[](
ptr->m_value.array->size());
13954 ptr = &
ptr->operator[](array_index<BasicJsonType>(reference_token));
13959 case detail::value_t::null:
13960 case detail::value_t::string:
13961 case detail::value_t::boolean:
13962 case detail::value_t::number_integer:
13963 case detail::value_t::number_unsigned:
13964 case detail::value_t::number_float:
13965 case detail::value_t::binary:
13966 case detail::value_t::discarded:
13981 template<
typename BasicJsonType>
13984 for (
const auto& reference_token : reference_tokens)
13986 switch (
ptr->type())
13988 case detail::value_t::object:
13991 ptr = &
ptr->at(reference_token);
13995 case detail::value_t::array:
14002 ") is out of range"),
ptr));
14006 ptr = &
ptr->at(array_index<BasicJsonType>(reference_token));
14010 case detail::value_t::null:
14011 case detail::value_t::string:
14012 case detail::value_t::boolean:
14013 case detail::value_t::number_integer:
14014 case detail::value_t::number_unsigned:
14015 case detail::value_t::number_float:
14016 case detail::value_t::binary:
14017 case detail::value_t::discarded:
14039 template<
typename BasicJsonType>
14042 for (
const auto& reference_token : reference_tokens)
14044 switch (
ptr->type())
14046 case detail::value_t::object:
14049 ptr = &
ptr->operator[](reference_token);
14053 case detail::value_t::array:
14062 ptr = &
ptr->operator[](array_index<BasicJsonType>(reference_token));
14066 case detail::value_t::null:
14067 case detail::value_t::string:
14068 case detail::value_t::boolean:
14069 case detail::value_t::number_integer:
14070 case detail::value_t::number_unsigned:
14071 case detail::value_t::number_float:
14072 case detail::value_t::binary:
14073 case detail::value_t::discarded:
14088 template<
typename BasicJsonType>
14091 for (
const auto& reference_token : reference_tokens)
14093 switch (
ptr->type())
14095 case detail::value_t::object:
14098 ptr = &
ptr->at(reference_token);
14102 case detail::value_t::array:
14109 ") is out of range"),
ptr));
14113 ptr = &
ptr->at(array_index<BasicJsonType>(reference_token));
14117 case detail::value_t::null:
14118 case detail::value_t::string:
14119 case detail::value_t::boolean:
14120 case detail::value_t::number_integer:
14121 case detail::value_t::number_unsigned:
14122 case detail::value_t::number_float:
14123 case detail::value_t::binary:
14124 case detail::value_t::discarded:
14137 template<
typename BasicJsonType>
14140 for (
const auto& reference_token : reference_tokens)
14142 switch (
ptr->type())
14144 case detail::value_t::object:
14146 if (!
ptr->contains(reference_token))
14152 ptr = &
ptr->operator[](reference_token);
14156 case detail::value_t::array:
14163 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14175 for (std::size_t
i = 1;
i < reference_token.size();
i++)
14185 const auto idx = array_index<BasicJsonType>(reference_token);
14186 if (idx >=
ptr->size())
14192 ptr = &
ptr->operator[](idx);
14196 case detail::value_t::null:
14197 case detail::value_t::string:
14198 case detail::value_t::boolean:
14199 case detail::value_t::number_integer:
14200 case detail::value_t::number_unsigned:
14201 case detail::value_t::number_float:
14202 case detail::value_t::binary:
14203 case detail::value_t::discarded:
14228 std::vector<string_t>
result;
14231 if (reference_string.empty())
14247 std::size_t slash = reference_string.find_first_of(
'/', 1),
14254 start = (slash == string_t::npos) ? 0 : slash + 1,
14256 slash = reference_string.find_first_of(
'/',
start))
14260 auto reference_token = reference_string.substr(
start, slash -
start);
14263 for (std::size_t pos = reference_token.find_first_of(
'~');
14264 pos != string_t::npos;
14265 pos = reference_token.find_first_of(
'~', pos + 1))
14271 (reference_token[pos + 1] !=
'0' &&
14272 reference_token[pos + 1] !=
'1')))
14280 result.push_back(reference_token);
14294 template<
typename BasicJsonType>
14296 const BasicJsonType&
value,
14299 switch (
value.type())
14301 case detail::value_t::array:
14303 if (
value.m_value.array->empty())
14306 result[reference_string] =
nullptr;
14311 for (std::size_t
i = 0;
i <
value.m_value.array->size(); ++
i)
14320 case detail::value_t::object:
14322 if (
value.m_value.object->empty())
14325 result[reference_string] =
nullptr;
14330 for (
const auto& element : *
value.m_value.object)
14338 case detail::value_t::null:
14339 case detail::value_t::string:
14340 case detail::value_t::boolean:
14341 case detail::value_t::number_integer:
14342 case detail::value_t::number_unsigned:
14343 case detail::value_t::number_float:
14344 case detail::value_t::binary:
14345 case detail::value_t::discarded:
14365 template<
typename BasicJsonType>
14366 static BasicJsonType
14377 for (
const auto& element : *
value.m_value.object)
14398 result.reference_tokens = reference_tokens;
14405 result.reference_tokens = std::move(reference_tokens);
14420 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14436 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14446 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14450 return lhs.reference_tokens == rhs.reference_tokens;
14453 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14457 return !(lhs == rhs);
14473 #include <initializer_list>
14485 template<
typename BasicJsonType>
14496 : value_ref(&
value)
14500 : owned_value(init)
14507 : owned_value(
std::forward<Args>(args)...)
14519 if (value_ref ==
nullptr)
14521 return std::move(owned_value);
14528 return value_ref ? *value_ref : owned_value;
14565 #include <algorithm>
14591 #include <algorithm>
14593 #include <iterator>
14601 #endif // JSON_NO_IO
14613 virtual void write_character(CharType c) = 0;
14614 virtual void write_characters(
const CharType*
s, std::size_t
length) = 0;
14625 template<
typename CharType>
14629 template<
typename CharType,
typename AllocatorType = std::allocator<CharType>>
14649 std::vector<CharType, AllocatorType>&
v;
14653 template<
typename CharType>
14670 stream.write(
s,
static_cast<std::streamsize
>(
length));
14676 #endif // JSON_NO_IO
14679 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14702 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14706 template<
typename AllocatorType = std::allocator<CharType>>
14713 #endif // JSON_NO_IO
14744 template<
typename BasicJsonType,
typename CharType>
14770 case value_t::object:
14772 write_bson_object(*j.m_value.object);
14776 case value_t::null:
14777 case value_t::array:
14778 case value_t::string:
14779 case value_t::boolean:
14780 case value_t::number_integer:
14781 case value_t::number_unsigned:
14782 case value_t::number_float:
14783 case value_t::binary:
14784 case value_t::discarded:
14799 case value_t::null:
14801 oa->write_character(to_char_type(0xF6));
14805 case value_t::boolean:
14807 oa->write_character(j.m_value.boolean
14808 ? to_char_type(0xF5)
14809 : to_char_type(0xF4));
14813 case value_t::number_integer:
14815 if (j.m_value.number_integer >= 0)
14820 if (j.m_value.number_integer <= 0x17)
14822 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14826 oa->write_character(to_char_type(0x18));
14827 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14831 oa->write_character(to_char_type(0x19));
14832 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14836 oa->write_character(to_char_type(0x1A));
14837 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14841 oa->write_character(to_char_type(0x1B));
14842 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14849 const auto positive_number = -1 - j.m_value.number_integer;
14850 if (j.m_value.number_integer >= -24)
14852 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
14856 oa->write_character(to_char_type(0x38));
14857 write_number(
static_cast<std::uint8_t
>(positive_number));
14861 oa->write_character(to_char_type(0x39));
14862 write_number(
static_cast<std::uint16_t
>(positive_number));
14866 oa->write_character(to_char_type(0x3A));
14867 write_number(
static_cast<std::uint32_t
>(positive_number));
14871 oa->write_character(to_char_type(0x3B));
14872 write_number(
static_cast<std::uint64_t
>(positive_number));
14878 case value_t::number_unsigned:
14880 if (j.m_value.number_unsigned <= 0x17)
14882 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14886 oa->write_character(to_char_type(0x18));
14887 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14891 oa->write_character(to_char_type(0x19));
14892 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
14896 oa->write_character(to_char_type(0x1A));
14897 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
14901 oa->write_character(to_char_type(0x1B));
14902 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
14907 case value_t::number_float:
14912 oa->write_character(to_char_type(0xF9));
14913 oa->write_character(to_char_type(0x7E));
14914 oa->write_character(to_char_type(0x00));
14916 else if (
std::isinf(j.m_value.number_float))
14919 oa->write_character(to_char_type(0xf9));
14920 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
14921 oa->write_character(to_char_type(0x00));
14925 write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
14930 case value_t::string:
14933 const auto N = j.m_value.string->size();
14936 write_number(
static_cast<std::uint8_t
>(0x60 + N));
14940 oa->write_character(to_char_type(0x78));
14941 write_number(
static_cast<std::uint8_t
>(N));
14945 oa->write_character(to_char_type(0x79));
14946 write_number(
static_cast<std::uint16_t
>(N));
14950 oa->write_character(to_char_type(0x7A));
14951 write_number(
static_cast<std::uint32_t
>(N));
14956 oa->write_character(to_char_type(0x7B));
14957 write_number(
static_cast<std::uint64_t
>(N));
14962 oa->write_characters(
14963 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14964 j.m_value.string->size());
14968 case value_t::array:
14971 const auto N = j.m_value.array->size();
14974 write_number(
static_cast<std::uint8_t
>(0x80 + N));
14978 oa->write_character(to_char_type(0x98));
14979 write_number(
static_cast<std::uint8_t
>(N));
14983 oa->write_character(to_char_type(0x99));
14984 write_number(
static_cast<std::uint16_t
>(N));
14988 oa->write_character(to_char_type(0x9A));
14989 write_number(
static_cast<std::uint32_t
>(N));
14994 oa->write_character(to_char_type(0x9B));
14995 write_number(
static_cast<std::uint64_t
>(N));
15000 for (
const auto& el : *j.m_value.array)
15007 case value_t::binary:
15009 if (j.m_value.binary->has_subtype())
15013 write_number(
static_cast<std::uint8_t
>(0xd8));
15014 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
15018 write_number(
static_cast<std::uint8_t
>(0xd9));
15019 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
15023 write_number(
static_cast<std::uint8_t
>(0xda));
15024 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
15028 write_number(
static_cast<std::uint8_t
>(0xdb));
15029 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
15034 const auto N = j.m_value.binary->size();
15037 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15041 oa->write_character(to_char_type(0x58));
15042 write_number(
static_cast<std::uint8_t
>(N));
15046 oa->write_character(to_char_type(0x59));
15047 write_number(
static_cast<std::uint16_t
>(N));
15051 oa->write_character(to_char_type(0x5A));
15052 write_number(
static_cast<std::uint32_t
>(N));
15057 oa->write_character(to_char_type(0x5B));
15058 write_number(
static_cast<std::uint64_t
>(N));
15063 oa->write_characters(
15064 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15070 case value_t::object:
15073 const auto N = j.m_value.object->size();
15076 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15080 oa->write_character(to_char_type(0xB8));
15081 write_number(
static_cast<std::uint8_t
>(N));
15085 oa->write_character(to_char_type(0xB9));
15086 write_number(
static_cast<std::uint16_t
>(N));
15090 oa->write_character(to_char_type(0xBA));
15091 write_number(
static_cast<std::uint32_t
>(N));
15096 oa->write_character(to_char_type(0xBB));
15097 write_number(
static_cast<std::uint64_t
>(N));
15102 for (
const auto& el : *j.m_value.object)
15104 write_cbor(el.first);
15105 write_cbor(el.second);
15110 case value_t::discarded:
15123 case value_t::null:
15125 oa->write_character(to_char_type(0xC0));
15129 case value_t::boolean:
15131 oa->write_character(j.m_value.boolean
15132 ? to_char_type(0xC3)
15133 : to_char_type(0xC2));
15137 case value_t::number_integer:
15139 if (j.m_value.number_integer >= 0)
15144 if (j.m_value.number_unsigned < 128)
15147 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15152 oa->write_character(to_char_type(0xCC));
15153 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15158 oa->write_character(to_char_type(0xCD));
15159 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15164 oa->write_character(to_char_type(0xCE));
15165 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15170 oa->write_character(to_char_type(0xCF));
15171 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15176 if (j.m_value.number_integer >= -32)
15179 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15181 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15185 oa->write_character(to_char_type(0xD0));
15186 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15188 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15192 oa->write_character(to_char_type(0xD1));
15193 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
15195 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15199 oa->write_character(to_char_type(0xD2));
15200 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
15202 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15206 oa->write_character(to_char_type(0xD3));
15207 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
15213 case value_t::number_unsigned:
15215 if (j.m_value.number_unsigned < 128)
15218 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15223 oa->write_character(to_char_type(0xCC));
15224 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15229 oa->write_character(to_char_type(0xCD));
15230 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15235 oa->write_character(to_char_type(0xCE));
15236 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15241 oa->write_character(to_char_type(0xCF));
15242 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15247 case value_t::number_float:
15249 write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
15253 case value_t::string:
15256 const auto N = j.m_value.string->size();
15260 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15265 oa->write_character(to_char_type(0xD9));
15266 write_number(
static_cast<std::uint8_t
>(N));
15271 oa->write_character(to_char_type(0xDA));
15272 write_number(
static_cast<std::uint16_t
>(N));
15277 oa->write_character(to_char_type(0xDB));
15278 write_number(
static_cast<std::uint32_t
>(N));
15282 oa->write_characters(
15283 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15284 j.m_value.string->size());
15288 case value_t::array:
15291 const auto N = j.m_value.array->size();
15295 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15300 oa->write_character(to_char_type(0xDC));
15301 write_number(
static_cast<std::uint16_t
>(N));
15306 oa->write_character(to_char_type(0xDD));
15307 write_number(
static_cast<std::uint32_t
>(N));
15311 for (
const auto& el : *j.m_value.array)
15318 case value_t::binary:
15322 const bool use_ext = j.m_value.binary->has_subtype();
15325 const auto N = j.m_value.binary->size();
15328 std::uint8_t output_type{};
15335 output_type = 0xD4;
15338 output_type = 0xD5;
15341 output_type = 0xD6;
15344 output_type = 0xD7;
15347 output_type = 0xD8;
15350 output_type = 0xC7;
15358 output_type = 0xC4;
15362 oa->write_character(to_char_type(output_type));
15365 write_number(
static_cast<std::uint8_t
>(N));
15370 std::uint8_t output_type = use_ext
15374 oa->write_character(to_char_type(output_type));
15375 write_number(
static_cast<std::uint16_t
>(N));
15379 std::uint8_t output_type = use_ext
15383 oa->write_character(to_char_type(output_type));
15384 write_number(
static_cast<std::uint32_t
>(N));
15390 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
15394 oa->write_characters(
15395 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15401 case value_t::object:
15404 const auto N = j.m_value.object->size();
15408 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15413 oa->write_character(to_char_type(0xDE));
15414 write_number(
static_cast<std::uint16_t
>(N));
15419 oa->write_character(to_char_type(0xDF));
15420 write_number(
static_cast<std::uint32_t
>(N));
15424 for (
const auto& el : *j.m_value.object)
15426 write_msgpack(el.first);
15427 write_msgpack(el.second);
15432 case value_t::discarded:
15446 const bool use_type,
const bool add_prefix =
true,
15447 const bool use_bjdata =
false)
15451 case value_t::null:
15455 oa->write_character(to_char_type(
'Z'));
15460 case value_t::boolean:
15464 oa->write_character(j.m_value.boolean
15465 ? to_char_type(
'T')
15466 : to_char_type(
'F'));
15471 case value_t::number_integer:
15473 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
15477 case value_t::number_unsigned:
15479 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
15483 case value_t::number_float:
15485 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
15489 case value_t::string:
15493 oa->write_character(to_char_type(
'S'));
15495 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
15496 oa->write_characters(
15497 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15498 j.m_value.string->size());
15502 case value_t::array:
15506 oa->write_character(to_char_type(
'['));
15509 bool prefix_required =
true;
15510 if (use_type && !j.m_value.array->empty())
15513 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15514 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15515 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15517 return ubjson_prefix(v, use_bjdata) == first_prefix;
15520 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15522 if (same_prefix && !(use_bjdata &&
std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15524 prefix_required =
false;
15525 oa->write_character(to_char_type(
'$'));
15526 oa->write_character(first_prefix);
15532 oa->write_character(to_char_type(
'#'));
15533 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
15536 for (
const auto& el : *j.m_value.array)
15538 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15543 oa->write_character(to_char_type(
']'));
15549 case value_t::binary:
15553 oa->write_character(to_char_type(
'['));
15556 if (use_type && !j.m_value.binary->empty())
15559 oa->write_character(to_char_type(
'$'));
15560 oa->write_character(
'U');
15565 oa->write_character(to_char_type(
'#'));
15566 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
15571 oa->write_characters(
15572 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15573 j.m_value.binary->size());
15577 for (
size_t i = 0;
i < j.m_value.binary->size(); ++
i)
15579 oa->write_character(to_char_type(
'U'));
15580 oa->write_character(j.m_value.binary->data()[
i]);
15586 oa->write_character(to_char_type(
']'));
15592 case value_t::object:
15594 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
15596 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
15604 oa->write_character(to_char_type(
'{'));
15607 bool prefix_required =
true;
15608 if (use_type && !j.m_value.object->empty())
15611 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15612 const bool same_prefix = std::all_of(j.begin(), j.end(),
15613 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15615 return ubjson_prefix(v, use_bjdata) == first_prefix;
15618 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15620 if (same_prefix && !(use_bjdata &&
std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15622 prefix_required =
false;
15623 oa->write_character(to_char_type(
'$'));
15624 oa->write_character(first_prefix);
15630 oa->write_character(to_char_type(
'#'));
15631 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
15634 for (
const auto& el : *j.m_value.object)
15636 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15637 oa->write_characters(
15638 reinterpret_cast<const CharType*
>(el.first.c_str()),
15640 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15645 oa->write_character(to_char_type(
'}'));
15651 case value_t::discarded:
15672 static_cast<void>(j);
15675 return 1ul + name.size() + 1
u;
15682 const std::uint8_t element_type)
15684 oa->write_character(to_char_type(element_type));
15685 oa->write_characters(
15686 reinterpret_cast<const CharType*
>(name.c_str()),
15696 write_bson_entry_header(name, 0x08);
15697 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
15704 const double value)
15706 write_bson_entry_header(name, 0x01);
15707 write_number<double>(
value,
true);
15715 return sizeof(std::int32_t) +
value.size() + 1ul;
15724 write_bson_entry_header(name, 0x02);
15726 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15727 oa->write_characters(
15728 reinterpret_cast<const CharType*
>(
value.c_str()),
15737 write_bson_entry_header(name, 0x0A);
15746 ?
sizeof(std::int32_t)
15747 :
sizeof(std::int64_t);
15754 const std::int64_t
value)
15758 write_bson_entry_header(name, 0x10);
15759 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
15763 write_bson_entry_header(name, 0x12);
15764 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
15774 ?
sizeof(std::int32_t)
15775 :
sizeof(std::int64_t);
15782 const BasicJsonType& j)
15786 write_bson_entry_header(name, 0x10 );
15787 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
15791 write_bson_entry_header(name, 0x12 );
15792 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
15804 const typename BasicJsonType::object_t&
value)
15806 write_bson_entry_header(name, 0x03);
15807 write_bson_object(
value);
15815 std::size_t array_index = 0ul;
15822 return sizeof(std::int32_t) + embedded_document_size + 1ul;
15830 return sizeof(std::int32_t) +
value.size() + 1ul;
15837 const typename BasicJsonType::array_t&
value)
15839 write_bson_entry_header(name, 0x04);
15840 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
15842 std::size_t array_index = 0ul;
15844 for (
const auto& el :
value)
15849 oa->write_character(to_char_type(0x00));
15858 write_bson_entry_header(name, 0x05);
15860 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
15861 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
15863 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
15871 const BasicJsonType& j)
15873 const auto header_size = calc_bson_entry_header_size(name, j);
15876 case value_t::object:
15877 return header_size + calc_bson_object_size(*j.m_value.object);
15879 case value_t::array:
15880 return header_size + calc_bson_array_size(*j.m_value.array);
15882 case value_t::binary:
15883 return header_size + calc_bson_binary_size(*j.m_value.binary);
15885 case value_t::boolean:
15886 return header_size + 1ul;
15888 case value_t::number_float:
15889 return header_size + 8ul;
15891 case value_t::number_integer:
15892 return header_size + calc_bson_integer_size(j.m_value.number_integer);
15894 case value_t::number_unsigned:
15895 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
15897 case value_t::string:
15898 return header_size + calc_bson_string_size(*j.m_value.string);
15900 case value_t::null:
15901 return header_size + 0ul;
15904 case value_t::discarded:
15919 const BasicJsonType& j)
15923 case value_t::object:
15924 return write_bson_object_entry(name, *j.m_value.object);
15926 case value_t::array:
15927 return write_bson_array(name, *j.m_value.array);
15929 case value_t::binary:
15930 return write_bson_binary(name, *j.m_value.binary);
15932 case value_t::boolean:
15933 return write_bson_boolean(name, j.m_value.boolean);
15935 case value_t::number_float:
15936 return write_bson_double(name, j.m_value.number_float);
15938 case value_t::number_integer:
15939 return write_bson_integer(name, j.m_value.number_integer);
15941 case value_t::number_unsigned:
15942 return write_bson_unsigned(name, j);
15944 case value_t::string:
15945 return write_bson_string(name, *j.m_value.string);
15947 case value_t::null:
15948 return write_bson_null(name);
15951 case value_t::discarded:
15967 std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
15970 return result += calc_bson_element_size(el.first, el.second);
15973 return sizeof(std::int32_t) + document_size + 1ul;
15982 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
15984 for (
const auto& el :
value)
15986 write_bson_element(el.first, el.second);
15989 oa->write_character(to_char_type(0x00));
15998 return to_char_type(0xFA);
16003 return to_char_type(0xFB);
16012 return to_char_type(0xCA);
16017 return to_char_type(0xCB);
16025 template<
typename NumberType,
typename std::enable_if<
16028 const bool add_prefix,
16029 const bool use_bjdata)
16033 oa->write_character(get_ubjson_float_prefix(
n));
16035 write_number(
n, use_bjdata);
16039 template<
typename NumberType,
typename std::enable_if<
16042 const bool add_prefix,
16043 const bool use_bjdata)
16049 oa->write_character(to_char_type(
'i'));
16051 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
16057 oa->write_character(to_char_type(
'U'));
16059 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
16065 oa->write_character(to_char_type(
'I'));
16067 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
16073 oa->write_character(to_char_type(
'u'));
16075 write_number(
static_cast<std::uint16_t
>(
n), use_bjdata);
16081 oa->write_character(to_char_type(
'l'));
16083 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
16089 oa->write_character(to_char_type(
'm'));
16091 write_number(
static_cast<std::uint32_t
>(
n), use_bjdata);
16097 oa->write_character(to_char_type(
'L'));
16099 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
16105 oa->write_character(to_char_type(
'M'));
16107 write_number(
static_cast<std::uint64_t
>(
n), use_bjdata);
16113 oa->write_character(to_char_type(
'H'));
16116 const auto number = BasicJsonType(
n).dump();
16117 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16118 for (std::size_t
i = 0;
i < number.size(); ++
i)
16120 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[
i])));
16126 template <
typename NumberType,
typename std::enable_if <
16130 const bool add_prefix,
16131 const bool use_bjdata)
16137 oa->write_character(to_char_type(
'i'));
16139 write_number(
static_cast<std::int8_t
>(
n), use_bjdata);
16145 oa->write_character(to_char_type(
'U'));
16147 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
16153 oa->write_character(to_char_type(
'I'));
16155 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
16161 oa->write_character(to_char_type(
'u'));
16163 write_number(
static_cast<uint16_t
>(
n), use_bjdata);
16169 oa->write_character(to_char_type(
'l'));
16171 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
16177 oa->write_character(to_char_type(
'm'));
16179 write_number(
static_cast<uint32_t
>(
n), use_bjdata);
16185 oa->write_character(to_char_type(
'L'));
16187 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
16194 oa->write_character(to_char_type(
'H'));
16197 const auto number = BasicJsonType(
n).dump();
16198 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16199 for (std::size_t
i = 0;
i < number.size(); ++
i)
16201 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[
i])));
16210 CharType
ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16214 case value_t::null:
16217 case value_t::boolean:
16218 return j.m_value.boolean ?
'T' :
'F';
16220 case value_t::number_integer:
16254 case value_t::number_unsigned:
16292 case value_t::number_float:
16293 return get_ubjson_float_prefix(j.m_value.number_float);
16295 case value_t::string:
16298 case value_t::array:
16299 case value_t::binary:
16302 case value_t::object:
16305 case value_t::discarded:
16326 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16327 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16332 if (it == bjdtype.end())
16336 CharType dtype = it->second;
16338 key =
"_ArraySize_";
16339 std::size_t
len = (
value.at(
key).empty() ? 0 : 1);
16340 for (
const auto& el :
value.at(
key))
16342 len *=
static_cast<std::size_t
>(el.m_value.number_unsigned);
16345 key =
"_ArrayData_";
16351 oa->write_character(
'[');
16352 oa->write_character(
'$');
16353 oa->write_character(dtype);
16354 oa->write_character(
'#');
16356 key =
"_ArraySize_";
16357 write_ubjson(
value.at(
key), use_count, use_type,
true,
true);
16359 key =
"_ArrayData_";
16360 if (dtype ==
'U' || dtype ==
'C')
16362 for (
const auto& el :
value.at(
key))
16364 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
16367 else if (dtype ==
'i')
16369 for (
const auto& el :
value.at(
key))
16371 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
16374 else if (dtype ==
'u')
16376 for (
const auto& el :
value.at(
key))
16378 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
16381 else if (dtype ==
'I')
16383 for (
const auto& el :
value.at(
key))
16385 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
16388 else if (dtype ==
'm')
16390 for (
const auto& el :
value.at(
key))
16392 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
16395 else if (dtype ==
'l')
16397 for (
const auto& el :
value.at(
key))
16399 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
16402 else if (dtype ==
'M')
16404 for (
const auto& el :
value.at(
key))
16406 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
16409 else if (dtype ==
'L')
16411 for (
const auto& el :
value.at(
key))
16413 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
16416 else if (dtype ==
'd')
16418 for (
const auto& el :
value.at(
key))
16420 write_number(
static_cast<float>(el.m_value.number_float),
true);
16423 else if (dtype ==
'D')
16425 for (
const auto& el :
value.at(
key))
16427 write_number(
static_cast<double>(el.m_value.number_float),
true);
16450 template<
typename NumberType>
16454 std::array<CharType,
sizeof(NumberType)> vec{};
16455 std::memcpy(vec.data(), &
n,
sizeof(NumberType));
16458 if (is_little_endian != OutputIsLittleEndian)
16461 std::reverse(vec.begin(), vec.end());
16464 oa->write_characters(vec.data(),
sizeof(NumberType));
16470 #pragma GCC diagnostic push
16471 #pragma GCC diagnostic ignored "-Wfloat-equal"
16473 if (
static_cast<double>(
n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16475 static_cast<double>(
static_cast<float>(
n)) ==
static_cast<double>(
n))
16477 oa->write_character(
format == detail::input_format_t::cbor
16478 ? get_cbor_float_prefix(
static_cast<float>(
n))
16479 : get_msgpack_float_prefix(
static_cast<float>(
n)));
16480 write_number(
static_cast<float>(
n));
16484 oa->write_character(
format == detail::input_format_t::cbor
16485 ? get_cbor_float_prefix(
n)
16486 : get_msgpack_float_prefix(
n));
16490 #pragma GCC diagnostic pop
16499 template <
typename C = CharType,
16503 return *
reinterpret_cast<char*
>(&
x);
16506 template <
typename C = CharType,
16510 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16513 std::memcpy(&
result, &
x,
sizeof(
x));
16517 template<
typename C = CharType,
16524 template <
typename InputCharType,
typename C = CharType,
16560 #include <algorithm>
16570 #include <type_traits>
16590 #include <type_traits>
16618 namespace dtoa_impl
16621 template<
typename Target,
typename Source>
16624 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16627 std::memcpy(&
target, &source,
sizeof(Source));
16633 static constexpr
int kPrecision = 64;
16635 std::uint64_t f = 0;
16638 constexpr
diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
16649 return {
x.f -
y.f,
x.e};
16658 static_assert(kPrecision == 64,
"internal error");
16683 const std::uint64_t u_lo =
x.f & 0xFFFFFFFF
u;
16684 const std::uint64_t u_hi =
x.f >> 32
u;
16685 const std::uint64_t v_lo =
y.f & 0xFFFFFFFF
u;
16686 const std::uint64_t v_hi =
y.f >> 32
u;
16688 const std::uint64_t p0 = u_lo * v_lo;
16689 const std::uint64_t p1 = u_lo * v_hi;
16690 const std::uint64_t p2 = u_hi * v_lo;
16691 const std::uint64_t p3 = u_hi * v_hi;
16693 const std::uint64_t p0_hi = p0 >> 32
u;
16694 const std::uint64_t p1_lo = p1 & 0xFFFFFFFF
u;
16695 const std::uint64_t p1_hi = p1 >> 32
u;
16696 const std::uint64_t p2_lo = p2 & 0xFFFFFFFF
u;
16697 const std::uint64_t p2_hi = p2 >> 32
u;
16699 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16710 Q += std::uint64_t{1} << (64
u - 32
u - 1
u);
16712 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32
u);
16714 return {h,
x.e +
y.e + 64};
16725 while ((
x.f >> 63
u) == 0)
16740 const int delta =
x.e - target_exponent;
16745 return {
x.f << delta, target_exponent};
16762 template<
typename FloatType>
16775 static_assert(std::numeric_limits<FloatType>::is_iec559,
16776 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
16778 constexpr
int kPrecision = std::numeric_limits<FloatType>::digits;
16779 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
16780 constexpr
int kMinExp = 1 - kBias;
16781 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
16785 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
16786 const std::uint64_t E = bits >> (kPrecision - 1);
16787 const std::uint64_t F = bits & (kHiddenBit - 1);
16789 const bool is_denormal = E == 0;
16790 const diyfp v = is_denormal
16791 ?
diyfp(F, kMinExp)
16792 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
16815 const bool lower_boundary_is_closer = F == 0 && E > 1;
16817 const diyfp m_minus = lower_boundary_is_closer
16818 ?
diyfp(4 * v.
f - 1, v.
e - 2)
16819 :
diyfp(2 * v.
f - 1, v.
e - 1);
16825 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
16954 constexpr
int kCachedPowersMinDecExp = -300;
16955 constexpr
int kCachedPowersDecStep = 8;
16957 static constexpr std::array<cached_power, 79> kCachedPowers =
16960 { 0xAB70FE17C79AC6CA, -1060, -300 },
16961 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
16962 { 0xBE5691EF416BD60C, -1007, -284 },
16963 { 0x8DD01FAD907FFC3C, -980, -276 },
16964 { 0xD3515C2831559A83, -954, -268 },
16965 { 0x9D71AC8FADA6C9B5, -927, -260 },
16966 { 0xEA9C227723EE8BCB, -901, -252 },
16967 { 0xAECC49914078536D, -874, -244 },
16968 { 0x823C12795DB6CE57, -847, -236 },
16969 { 0xC21094364DFB5637, -821, -228 },
16970 { 0x9096EA6F3848984F, -794, -220 },
16971 { 0xD77485CB25823AC7, -768, -212 },
16972 { 0xA086CFCD97BF97F4, -741, -204 },
16973 { 0xEF340A98172AACE5, -715, -196 },
16974 { 0xB23867FB2A35B28E, -688, -188 },
16975 { 0x84C8D4DFD2C63F3B, -661, -180 },
16976 { 0xC5DD44271AD3CDBA, -635, -172 },
16977 { 0x936B9FCEBB25C996, -608, -164 },
16978 { 0xDBAC6C247D62A584, -582, -156 },
16979 { 0xA3AB66580D5FDAF6, -555, -148 },
16980 { 0xF3E2F893DEC3F126, -529, -140 },
16981 { 0xB5B5ADA8AAFF80B8, -502, -132 },
16982 { 0x87625F056C7C4A8B, -475, -124 },
16983 { 0xC9BCFF6034C13053, -449, -116 },
16984 { 0x964E858C91BA2655, -422, -108 },
16985 { 0xDFF9772470297EBD, -396, -100 },
16986 { 0xA6DFBD9FB8E5B88F, -369, -92 },
16987 { 0xF8A95FCF88747D94, -343, -84 },
16988 { 0xB94470938FA89BCF, -316, -76 },
16989 { 0x8A08F0F8BF0F156B, -289, -68 },
16990 { 0xCDB02555653131B6, -263, -60 },
16991 { 0x993FE2C6D07B7FAC, -236, -52 },
16992 { 0xE45C10C42A2B3B06, -210, -44 },
16993 { 0xAA242499697392D3, -183, -36 },
16994 { 0xFD87B5F28300CA0E, -157, -28 },
16995 { 0xBCE5086492111AEB, -130, -20 },
16996 { 0x8CBCCC096F5088CC, -103, -12 },
16997 { 0xD1B71758E219652C, -77, -4 },
16998 { 0x9C40000000000000, -50, 4 },
16999 { 0xE8D4A51000000000, -24, 12 },
17000 { 0xAD78EBC5AC620000, 3, 20 },
17001 { 0x813F3978F8940984, 30, 28 },
17002 { 0xC097CE7BC90715B3, 56, 36 },
17003 { 0x8F7E32CE7BEA5C70, 83, 44 },
17004 { 0xD5D238A4ABE98068, 109, 52 },
17005 { 0x9F4F2726179A2245, 136, 60 },
17006 { 0xED63A231D4C4FB27, 162, 68 },
17007 { 0xB0DE65388CC8ADA8, 189, 76 },
17008 { 0x83C7088E1AAB65DB, 216, 84 },
17009 { 0xC45D1DF942711D9A, 242, 92 },
17010 { 0x924D692CA61BE758, 269, 100 },
17011 { 0xDA01EE641A708DEA, 295, 108 },
17012 { 0xA26DA3999AEF774A, 322, 116 },
17013 { 0xF209787BB47D6B85, 348, 124 },
17014 { 0xB454E4A179DD1877, 375, 132 },
17015 { 0x865B86925B9BC5C2, 402, 140 },
17016 { 0xC83553C5C8965D3D, 428, 148 },
17017 { 0x952AB45CFA97A0B3, 455, 156 },
17018 { 0xDE469FBD99A05FE3, 481, 164 },
17019 { 0xA59BC234DB398C25, 508, 172 },
17020 { 0xF6C69A72A3989F5C, 534, 180 },
17021 { 0xB7DCBF5354E9BECE, 561, 188 },
17022 { 0x88FCF317F22241E2, 588, 196 },
17023 { 0xCC20CE9BD35C78A5, 614, 204 },
17024 { 0x98165AF37B2153DF, 641, 212 },
17025 { 0xE2A0B5DC971F303A, 667, 220 },
17026 { 0xA8D9D1535CE3B396, 694, 228 },
17027 { 0xFB9B7CD9A4A7443C, 720, 236 },
17028 { 0xBB764C4CA7A44410, 747, 244 },
17029 { 0x8BAB8EEFB6409C1A, 774, 252 },
17030 { 0xD01FEF10A657842C, 800, 260 },
17031 { 0x9B10A4E5E9913129, 827, 268 },
17032 { 0xE7109BFBA19C0C9D, 853, 276 },
17033 { 0xAC2820D9623BF429, 880, 284 },
17034 { 0x80444B5E7AA7CF85, 907, 292 },
17035 { 0xBF21E44003ACDD2D, 933, 300 },
17036 { 0x8E679C2F5E44FF8F, 960, 308 },
17037 { 0xD433179D9C8CB841, 986, 316 },
17038 { 0x9E19DB92B4E31BA9, 1013, 324 },
17048 const int f =
kAlpha - e - 1;
17049 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
17051 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17069 if (
n >= 1000000000)
17071 pow10 = 1000000000;
17075 if (
n >= 100000000)
17121 std::uint64_t rest, std::uint64_t ten_k)
17148 && delta - rest >= ten_k
17149 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17164 static_assert(
kAlpha >= -60,
"internal error");
17165 static_assert(
kGamma <= -32,
"internal error");
17182 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
17183 std::uint64_t dist = diyfp::sub(M_plus,
w ).f;
17192 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
17194 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
17195 std::uint64_t p2 = M_plus.
f & (one.f - 1);
17203 std::uint32_t
pow10{};
17231 const std::uint32_t
d = p1 /
pow10;
17232 const std::uint32_t r = p1 %
pow10;
17238 buffer[
length++] =
static_cast<char>(
'0' +
d);
17257 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17262 decimal_exponent +=
n;
17273 const std::uint64_t ten_n = std::uint64_t{
pow10} << -one.e;
17337 const std::uint64_t
d = p2 >> -one.e;
17338 const std::uint64_t r = p2 & (one.f - 1);
17345 buffer[
length++] =
static_cast<char>(
'0' +
d);
17370 decimal_exponent -=
m;
17378 const std::uint64_t ten_m = one.f;
17419 const diyfp c_minus_k(cached.
f, cached.
e);
17422 const diyfp w = diyfp::mul(v, c_minus_k);
17423 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
17424 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
17447 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17448 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
17450 decimal_exponent = -cached.
k;
17460 template<
typename FloatType>
17464 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
17465 "internal error: not enough precision");
17492 grisu2(buf,
len, decimal_exponent,
w.minus,
w.w,
w.plus);
17517 auto k =
static_cast<std::uint32_t
>(e);
17523 *buf++ =
static_cast<char>(
'0' + k);
17527 *buf++ =
static_cast<char>(
'0' + k / 10);
17529 *buf++ =
static_cast<char>(
'0' + k);
17533 *buf++ =
static_cast<char>(
'0' + k / 100);
17535 *buf++ =
static_cast<char>(
'0' + k / 10);
17537 *buf++ =
static_cast<char>(
'0' + k);
17555 int min_exp,
int max_exp)
17561 const int n =
len + decimal_exponent;
17567 if (k <=
n &&
n <= max_exp)
17572 std::memset(buf + k,
'0',
static_cast<size_t>(
n) -
static_cast<size_t>(k));
17576 return buf + (
static_cast<size_t>(
n) + 2);
17579 if (0 <
n &&
n <= max_exp)
17586 std::memmove(buf + (
static_cast<size_t>(
n) + 1), buf +
n,
static_cast<size_t>(k) -
static_cast<size_t>(
n));
17588 return buf + (
static_cast<size_t>(k) + 1U);
17591 if (min_exp <
n &&
n <= 0)
17596 std::memmove(buf + (2 +
static_cast<size_t>(-
n)), buf,
static_cast<size_t>(k));
17599 std::memset(buf + 2,
'0',
static_cast<size_t>(-
n));
17600 return buf + (2U +
static_cast<size_t>(-
n) +
static_cast<size_t>(k));
17615 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17617 buf += 1 +
static_cast<size_t>(k);
17636 template<
typename FloatType>
17641 static_cast<void>(last);
17652 #pragma GCC diagnostic push
17653 #pragma GCC diagnostic ignored "-Wfloat-equal"
17664 #pragma GCC diagnostic pop
17667 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10);
17674 int decimal_exponent = 0;
17677 JSON_ASSERT(
len <= std::numeric_limits<FloatType>::max_digits10);
17680 constexpr
int kMinExp = -4;
17685 JSON_ASSERT(last -
first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17686 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17725 template<
typename BasicJsonType>
17733 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17734 static constexpr std::uint8_t UTF8_REJECT = 1;
17745 , loc(
std::localeconv())
17748 , indent_char(ichar)
17749 , indent_string(512, indent_char)
17750 , error_handler(error_handler_)
17783 const bool pretty_print,
17784 const bool ensure_ascii,
17785 const unsigned int indent_step,
17786 const unsigned int current_indent = 0)
17788 switch (val.m_type)
17790 case value_t::object:
17792 if (val.m_value.object->empty())
17794 o->write_characters(
"{}", 2);
17800 o->write_characters(
"{\n", 2);
17803 const auto new_indent = current_indent + indent_step;
17806 indent_string.resize(indent_string.size() * 2,
' ');
17810 auto i = val.m_value.object->cbegin();
17811 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++
i)
17813 o->write_characters(indent_string.c_str(), new_indent);
17814 o->write_character(
'\"');
17815 dump_escaped(
i->first, ensure_ascii);
17816 o->write_characters(
"\": ", 3);
17817 dump(
i->second,
true, ensure_ascii, indent_step, new_indent);
17818 o->write_characters(
",\n", 2);
17823 JSON_ASSERT(std::next(
i) == val.m_value.object->cend());
17824 o->write_characters(indent_string.c_str(), new_indent);
17825 o->write_character(
'\"');
17826 dump_escaped(
i->first, ensure_ascii);
17827 o->write_characters(
"\": ", 3);
17828 dump(
i->second,
true, ensure_ascii, indent_step, new_indent);
17830 o->write_character(
'\n');
17831 o->write_characters(indent_string.c_str(), current_indent);
17832 o->write_character(
'}');
17836 o->write_character(
'{');
17839 auto i = val.m_value.object->cbegin();
17840 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++
i)
17842 o->write_character(
'\"');
17843 dump_escaped(
i->first, ensure_ascii);
17844 o->write_characters(
"\":", 2);
17845 dump(
i->second,
false, ensure_ascii, indent_step, current_indent);
17846 o->write_character(
',');
17851 JSON_ASSERT(std::next(
i) == val.m_value.object->cend());
17852 o->write_character(
'\"');
17853 dump_escaped(
i->first, ensure_ascii);
17854 o->write_characters(
"\":", 2);
17855 dump(
i->second,
false, ensure_ascii, indent_step, current_indent);
17857 o->write_character(
'}');
17863 case value_t::array:
17865 if (val.m_value.array->empty())
17867 o->write_characters(
"[]", 2);
17873 o->write_characters(
"[\n", 2);
17876 const auto new_indent = current_indent + indent_step;
17879 indent_string.resize(indent_string.size() * 2,
' ');
17883 for (
auto i = val.m_value.array->cbegin();
17884 i != val.m_value.array->cend() - 1; ++
i)
17886 o->write_characters(indent_string.c_str(), new_indent);
17887 dump(*
i,
true, ensure_ascii, indent_step, new_indent);
17888 o->write_characters(
",\n", 2);
17893 o->write_characters(indent_string.c_str(), new_indent);
17894 dump(val.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
17896 o->write_character(
'\n');
17897 o->write_characters(indent_string.c_str(), current_indent);
17898 o->write_character(
']');
17902 o->write_character(
'[');
17905 for (
auto i = val.m_value.array->cbegin();
17906 i != val.m_value.array->cend() - 1; ++
i)
17908 dump(*
i,
false, ensure_ascii, indent_step, current_indent);
17909 o->write_character(
',');
17914 dump(val.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
17916 o->write_character(
']');
17922 case value_t::string:
17924 o->write_character(
'\"');
17925 dump_escaped(*val.m_value.string, ensure_ascii);
17926 o->write_character(
'\"');
17930 case value_t::binary:
17934 o->write_characters(
"{\n", 2);
17937 const auto new_indent = current_indent + indent_step;
17940 indent_string.resize(indent_string.size() * 2,
' ');
17943 o->write_characters(indent_string.c_str(), new_indent);
17945 o->write_characters(
"\"bytes\": [", 10);
17947 if (!val.m_value.binary->empty())
17949 for (
auto i = val.m_value.binary->cbegin();
17950 i != val.m_value.binary->cend() - 1; ++
i)
17953 o->write_characters(
", ", 2);
17955 dump_integer(val.m_value.binary->back());
17958 o->write_characters(
"],\n", 3);
17959 o->write_characters(indent_string.c_str(), new_indent);
17961 o->write_characters(
"\"subtype\": ", 11);
17962 if (val.m_value.binary->has_subtype())
17964 dump_integer(val.m_value.binary->subtype());
17968 o->write_characters(
"null", 4);
17970 o->write_character(
'\n');
17971 o->write_characters(indent_string.c_str(), current_indent);
17972 o->write_character(
'}');
17976 o->write_characters(
"{\"bytes\":[", 10);
17978 if (!val.m_value.binary->empty())
17980 for (
auto i = val.m_value.binary->cbegin();
17981 i != val.m_value.binary->cend() - 1; ++
i)
17984 o->write_character(
',');
17986 dump_integer(val.m_value.binary->back());
17989 o->write_characters(
"],\"subtype\":", 12);
17990 if (val.m_value.binary->has_subtype())
17992 dump_integer(val.m_value.binary->subtype());
17993 o->write_character(
'}');
17997 o->write_characters(
"null}", 5);
18003 case value_t::boolean:
18005 if (val.m_value.boolean)
18007 o->write_characters(
"true", 4);
18011 o->write_characters(
"false", 5);
18016 case value_t::number_integer:
18018 dump_integer(val.m_value.number_integer);
18022 case value_t::number_unsigned:
18024 dump_integer(val.m_value.number_unsigned);
18028 case value_t::number_float:
18030 dump_float(val.m_value.number_float);
18034 case value_t::discarded:
18036 o->write_characters(
"<discarded>", 11);
18040 case value_t::null:
18042 o->write_characters(
"null", 4);
18068 std::uint32_t codepoint{};
18069 std::uint8_t state = UTF8_ACCEPT;
18070 std::size_t bytes = 0;
18073 std::size_t bytes_after_last_accept = 0;
18074 std::size_t undumped_chars = 0;
18076 for (std::size_t
i = 0;
i <
s.size(); ++
i)
18078 const auto byte =
static_cast<std::uint8_t
>(
s[
i]);
18080 switch (decode(state, codepoint,
byte))
18088 string_buffer[bytes++] =
'\\';
18089 string_buffer[bytes++] =
'b';
18095 string_buffer[bytes++] =
'\\';
18096 string_buffer[bytes++] =
't';
18102 string_buffer[bytes++] =
'\\';
18103 string_buffer[bytes++] =
'n';
18109 string_buffer[bytes++] =
'\\';
18110 string_buffer[bytes++] =
'f';
18116 string_buffer[bytes++] =
'\\';
18117 string_buffer[bytes++] =
'r';
18123 string_buffer[bytes++] =
'\\';
18124 string_buffer[bytes++] =
'\"';
18130 string_buffer[bytes++] =
'\\';
18131 string_buffer[bytes++] =
'\\';
18139 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
18141 if (codepoint <= 0xFFFF)
18144 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
18145 static_cast<std::uint16_t
>(codepoint)));
18151 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
18152 static_cast<std::uint16_t
>(0xD7C0
u + (codepoint >> 10
u)),
18153 static_cast<std::uint16_t
>(0xDC00
u + (codepoint & 0x3FF
u))));
18161 string_buffer[bytes++] =
s[
i];
18170 if (string_buffer.size() - bytes < 13)
18172 o->write_characters(string_buffer.data(), bytes);
18177 bytes_after_last_accept = bytes;
18178 undumped_chars = 0;
18184 switch (error_handler)
18186 case error_handler_t::strict:
18191 case error_handler_t::ignore:
18192 case error_handler_t::replace:
18198 if (undumped_chars > 0)
18205 bytes = bytes_after_last_accept;
18207 if (error_handler == error_handler_t::replace)
18212 string_buffer[bytes++] =
'\\';
18213 string_buffer[bytes++] =
'u';
18214 string_buffer[bytes++] =
'f';
18215 string_buffer[bytes++] =
'f';
18216 string_buffer[bytes++] =
'f';
18217 string_buffer[bytes++] =
'd';
18229 if (string_buffer.size() - bytes < 13)
18231 o->write_characters(string_buffer.data(), bytes);
18235 bytes_after_last_accept = bytes;
18238 undumped_chars = 0;
18241 state = UTF8_ACCEPT;
18256 string_buffer[bytes++] =
s[
i];
18270 o->write_characters(string_buffer.data(), bytes);
18276 switch (error_handler)
18278 case error_handler_t::strict:
18283 case error_handler_t::ignore:
18286 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18290 case error_handler_t::replace:
18293 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18297 o->write_characters(
"\\ufffd", 6);
18301 o->write_characters(
"\xEF\xBF\xBD", 3);
18323 unsigned int n_digits = 1;
18332 return n_digits + 1;
18336 return n_digits + 2;
18340 return n_digits + 3;
18354 std::string
result =
"FF";
18355 constexpr
const char* nibble_to_hex =
"0123456789ABCDEF";
18356 result[0] = nibble_to_hex[
byte / 16];
18357 result[1] = nibble_to_hex[
byte % 16];
18391 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18394 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18395 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18396 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18397 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18398 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18399 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18400 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18401 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18402 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18403 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18410 o->write_character(
'0');
18415 auto buffer_ptr = number_buffer.begin();
18419 unsigned int n_chars{};
18421 if (is_negative_number(
x))
18440 buffer_ptr += n_chars;
18444 while (abs_value >= 100)
18446 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18448 *(--buffer_ptr) = digits_to_99[digits_index][1];
18449 *(--buffer_ptr) = digits_to_99[digits_index][0];
18452 if (abs_value >= 10)
18454 const auto digits_index =
static_cast<unsigned>(abs_value);
18455 *(--buffer_ptr) = digits_to_99[digits_index][1];
18456 *(--buffer_ptr) = digits_to_99[digits_index][0];
18460 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18463 o->write_characters(number_buffer.data(), n_chars);
18479 o->write_characters(
"null", 4);
18488 static constexpr
bool is_ieee_single_or_double
18489 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
18490 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
18492 dump_float(
x, std::integral_constant<bool, is_ieee_single_or_double>());
18497 auto*
begin = number_buffer.data();
18500 o->write_characters(
begin,
static_cast<size_t>(
end -
begin));
18506 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
18510 std::ptrdiff_t
len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g",
d,
x);
18515 JSON_ASSERT(
static_cast<std::size_t
>(
len) < number_buffer.size());
18524 len = (
end - number_buffer.begin());
18532 if (dec_pos != number_buffer.end())
18538 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(
len));
18541 const bool value_is_int_like =
18542 std::none_of(number_buffer.begin(), number_buffer.begin() +
len + 1,
18545 return c ==
'.' || c ==
'e';
18548 if (value_is_int_like)
18550 o->write_characters(
".0", 2);
18575 static std::uint8_t
decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte) noexcept
18577 static const std::array<std::uint8_t, 400> utf8d =
18580 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,
18581 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,
18582 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,
18583 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,
18584 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,
18585 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,
18586 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,
18587 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18588 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18589 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18590 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,
18591 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,
18592 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,
18593 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
18598 const std::uint8_t
type = utf8d[
byte];
18600 codep = (state != UTF8_ACCEPT)
18601 ? (
byte & 0x3fu) | (codep << 6
u)
18604 std::size_t
index = 256
u +
static_cast<size_t>(state) * 16
u +
static_cast<size_t>(
type);
18606 state = utf8d[
index];
18641 std::array<char, 64> number_buffer{{}};
18644 const std::lconv* loc =
nullptr;
18651 std::array<char, 512> string_buffer{{}};
18680 #include <functional>
18681 #include <initializer_list>
18682 #include <iterator>
18684 #include <stdexcept>
18685 #include <type_traits>
18698 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18699 class Allocator = std::allocator<std::pair<const Key, T>>>
18700 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
18704 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18709 #ifdef JSON_HAS_CPP_14
18719 template <
class It>
18722 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
18727 for (
auto it = this->
begin(); it != this->
end(); ++it)
18729 if (m_compare(it->first, key))
18731 return {it,
false};
18734 Container::emplace_back(key, std::forward<T>(t));
18735 return {std::prev(this->
end()),
true};
18742 for (
auto it = this->
begin(); it != this->
end(); ++it)
18744 if (m_compare(it->first, key))
18746 return {it,
false};
18749 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
18750 return {std::prev(this->
end()),
true};
18755 return emplace(key,
T{}).
first->second;
18762 return emplace(std::forward<KeyType>(key),
T{}).
first->second;
18774 return at(std::forward<KeyType>(key));
18779 for (
auto it = this->
begin(); it != this->
end(); ++it)
18781 if (m_compare(it->first, key))
18787 JSON_THROW(std::out_of_range(
"key not found"));
18794 for (
auto it = this->
begin(); it != this->
end(); ++it)
18796 if (m_compare(it->first, key))
18802 JSON_THROW(std::out_of_range(
"key not found"));
18807 for (
auto it = this->
begin(); it != this->
end(); ++it)
18809 if (m_compare(it->first, key))
18815 JSON_THROW(std::out_of_range(
"key not found"));
18820 const T &
at(KeyType && key)
const
18822 for (
auto it = this->
begin(); it != this->
end(); ++it)
18824 if (m_compare(it->first, key))
18830 JSON_THROW(std::out_of_range(
"key not found"));
18835 for (
auto it = this->
begin(); it != this->
end(); ++it)
18837 if (m_compare(it->first, key))
18840 for (
auto next = it; ++next != this->
end(); ++it)
18845 Container::pop_back();
18856 for (
auto it = this->
begin(); it != this->
end(); ++it)
18858 if (m_compare(it->first, key))
18861 for (
auto next = it; ++next != this->
end(); ++it)
18866 Container::pop_back();
18875 return erase(pos, std::next(pos));
18885 const auto elements_affected = std::distance(
first, last);
18911 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
18919 Container::resize(this->
size() -
static_cast<size_type>(elements_affected));
18933 for (
auto it = this->
begin(); it != this->
end(); ++it)
18935 if (m_compare(it->first, key))
18947 for (
auto it = this->
begin(); it != this->
end(); ++it)
18949 if (m_compare(it->first, key))
18959 for (
auto it = this->
begin(); it != this->
end(); ++it)
18961 if (m_compare(it->first, key))
18973 for (
auto it = this->
begin(); it != this->
end(); ++it)
18975 if (m_compare(it->first, key))
18985 for (
auto it = this->
begin(); it != this->
end(); ++it)
18987 if (m_compare(it->first, key))
18997 return emplace(
value.first, std::move(
value.second));
19002 for (
auto it = this->
begin(); it != this->
end(); ++it)
19004 if (m_compare(it->first,
value.first))
19006 return {it,
false};
19009 Container::push_back(
value);
19010 return {--this->
end(),
true};
19013 template<
typename InputIt>
19014 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19017 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19020 for (
auto it =
first; it != last; ++it)
19033 #if defined(JSON_HAS_CPP_17)
19035 #include <string_view>
19070 friend class ::nlohmann::json_pointer;
19074 template<
typename BasicJsonType,
typename InputType>
19075 friend class ::nlohmann::detail::parser;
19076 friend ::nlohmann::detail::serializer<basic_json>;
19077 template<
typename BasicJsonType>
19078 friend class ::nlohmann::detail::iter_impl;
19079 template<
typename BasicJsonType,
typename CharType>
19080 friend class ::nlohmann::detail::binary_writer;
19081 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19082 friend class ::nlohmann::detail::binary_reader;
19083 template<
typename BasicJsonType>
19084 friend class ::nlohmann::detail::json_sax_dom_parser;
19085 template<
typename BasicJsonType>
19086 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19087 friend class ::nlohmann::detail::exception;
19094 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19096 template<
typename InputAdapterType>
19097 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19098 InputAdapterType adapter,
19100 const bool allow_exceptions =
true,
19101 const bool ignore_comments =
false
19104 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19105 std::move(cb), allow_exceptions, ignore_comments);
19110 template<
typename BasicJsonType>
19112 template<
typename BasicJsonType>
19114 template<
typename Iterator>
19118 template<
typename CharType>
19121 template<
typename InputType>
19123 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19132 template<
typename T,
typename SFINAE>
19189 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19191 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19219 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
19220 result[
"name"] =
"JSON for Modern C++";
19221 result[
"url"] =
"https://github.com/nlohmann/json";
19222 result[
"version"][
"string"] =
19231 result[
"platform"] =
"win32";
19232 #elif defined __linux__
19233 result[
"platform"] =
"linux";
19234 #elif defined __APPLE__
19235 result[
"platform"] =
"apple";
19236 #elif defined __unix__
19237 result[
"platform"] =
"unix";
19239 result[
"platform"] =
"unknown";
19242 #if defined(__ICC) || defined(__INTEL_COMPILER)
19243 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19244 #elif defined(__clang__)
19245 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19246 #elif defined(__GNUC__) || defined(__GNUG__)
19253 #elif defined(__HP_cc) || defined(__HP_aCC)
19254 result[
"compiler"] =
"hp"
19255 #elif defined(__IBMCPP__)
19256 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19257 #elif defined(_MSC_VER)
19258 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19259 #elif defined(__PGI)
19260 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19261 #elif defined(__SUNPRO_CC)
19262 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19264 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19268 #if defined(_MSVC_LANG)
19270 #elif defined(__cplusplus)
19273 result[
"compiler"][
"c++"] =
"unknown";
19292 #if defined(JSON_HAS_CPP_14)
19295 using default_object_comparator_t = std::less<>;
19302 using object_t = ObjectType<StringType,
19305 AllocatorType<std::pair<
const StringType,
19310 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19345 template<
typename T,
typename... Args>
19349 AllocatorType<T> alloc;
19350 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19352 auto deleter = [&](
T * obj)
19354 AllocatorTraits::deallocate(alloc, obj, 1);
19356 std::unique_ptr<
T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19357 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19359 return obj.release();
19426 case value_t::object:
19428 object = create<object_t>();
19432 case value_t::array:
19434 array = create<array_t>();
19438 case value_t::string:
19440 string = create<string_t>(
"");
19444 case value_t::binary:
19446 binary = create<binary_t>();
19450 case value_t::boolean:
19452 boolean =
static_cast<boolean_t>(
false);
19456 case value_t::number_integer:
19462 case value_t::number_unsigned:
19468 case value_t::number_float:
19474 case value_t::null:
19480 case value_t::discarded:
19525 if (t == value_t::array || t == value_t::object)
19528 std::vector<basic_json> stack;
19531 if (t == value_t::array)
19533 stack.reserve(array->size());
19534 std::move(array->begin(), array->end(), std::back_inserter(stack));
19538 stack.reserve(object->size());
19539 for (
auto&& it : *
object)
19541 stack.push_back(std::move(it.second));
19545 while (!stack.empty())
19548 basic_json current_item(std::move(stack.back()));
19563 stack.push_back(std::move(it.second));
19576 case value_t::object:
19578 AllocatorType<object_t> alloc;
19579 std::allocator_traits<decltype(alloc)>::destroy(alloc,
object);
19580 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
19584 case value_t::array:
19586 AllocatorType<array_t> alloc;
19587 std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
19588 std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
19592 case value_t::string:
19594 AllocatorType<string_t> alloc;
19595 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
19596 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
19600 case value_t::binary:
19602 AllocatorType<binary_t> alloc;
19603 std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
19604 std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
19608 case value_t::null:
19609 case value_t::boolean:
19610 case value_t::number_integer:
19611 case value_t::number_unsigned:
19612 case value_t::number_float:
19613 case value_t::discarded:
19643 JSON_ASSERT(m_type != value_t::object || m_value.object !=
nullptr);
19644 JSON_ASSERT(m_type != value_t::array || m_value.array !=
nullptr);
19645 JSON_ASSERT(m_type != value_t::string || m_value.string !=
nullptr);
19646 JSON_ASSERT(m_type != value_t::binary || m_value.binary !=
nullptr);
19648 #if JSON_DIAGNOSTICS
19654 return j.m_parent ==
this;
19659 static_cast<void>(check_parents);
19664 #if JSON_DIAGNOSTICS
19667 case value_t::array:
19669 for (
auto& element : *m_value.array)
19671 element.m_parent =
this;
19676 case value_t::object:
19678 for (
auto& element : *m_value.object)
19680 element.second.m_parent =
this;
19685 case value_t::null:
19686 case value_t::string:
19687 case value_t::boolean:
19688 case value_t::number_integer:
19689 case value_t::number_unsigned:
19690 case value_t::number_float:
19691 case value_t::binary:
19692 case value_t::discarded:
19701 #if JSON_DIAGNOSTICS
19702 for (
typename iterator::difference_type
i = 0;
i < count_set_parents; ++
i)
19704 (it +
i)->m_parent =
this;
19707 static_cast<void>(count_set_parents);
19714 #if JSON_DIAGNOSTICS
19715 if (old_capacity !=
static_cast<std::size_t
>(-1))
19729 #ifdef JSON_HEDLEY_MSVC_VERSION
19730 #pragma warning(push )
19731 #pragma warning(disable : 4127) // ignore warning to replace if with if constexpr
19738 #ifdef JSON_HEDLEY_MSVC_VERSION
19739 #pragma warning( pop )
19744 static_cast<void>(j);
19745 static_cast<void>(old_capacity);
19775 : m_type(v), m_value(v)
19777 assert_invariant();
19785 assert_invariant();
19790 template <
typename CompatibleType,
19796 std::forward<CompatibleType>(val))))
19800 assert_invariant();
19805 template <
typename BasicJsonType,
19810 using other_boolean_t =
typename BasicJsonType::boolean_t;
19811 using other_number_float_t =
typename BasicJsonType::number_float_t;
19812 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
19813 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
19814 using other_string_t =
typename BasicJsonType::string_t;
19815 using other_object_t =
typename BasicJsonType::object_t;
19816 using other_array_t =
typename BasicJsonType::array_t;
19817 using other_binary_t =
typename BasicJsonType::binary_t;
19819 switch (val.type())
19821 case value_t::boolean:
19824 case value_t::number_float:
19827 case value_t::number_integer:
19830 case value_t::number_unsigned:
19833 case value_t::string:
19836 case value_t::object:
19839 case value_t::array:
19842 case value_t::binary:
19845 case value_t::null:
19848 case value_t::discarded:
19849 m_type = value_t::discarded;
19856 assert_invariant();
19862 bool type_deduction =
true,
19863 value_t manual_type = value_t::array)
19867 bool is_an_object = std::all_of(init.begin(), init.end(),
19870 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19874 if (!type_deduction)
19877 if (manual_type == value_t::array)
19879 is_an_object =
false;
19892 m_type = value_t::object;
19893 m_value = value_t::object;
19895 for (
auto& element_ref : init)
19898 m_value.object->emplace(
19899 std::move(*((*element.m_value.array)[0].m_value.string)),
19900 std::move((*element.m_value.array)[1]));
19906 m_type = value_t::array;
19907 m_value.array = create<array_t>(init.begin(), init.end());
19911 assert_invariant();
19920 res.m_type = value_t::binary;
19921 res.m_value = init;
19928 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
19931 res.m_type = value_t::binary;
19932 res.m_value =
binary_t(init, subtype);
19942 res.m_type = value_t::binary;
19943 res.m_value = std::move(init);
19950 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
19953 res.m_type = value_t::binary;
19954 res.m_value =
binary_t(std::move(init), subtype);
19963 return basic_json(init,
false, value_t::array);
19971 return basic_json(init,
false, value_t::object);
19979 m_value.array = create<array_t>(cnt, val);
19981 assert_invariant();
19986 template <
class InputIT,
typename std::enable_if <
20001 m_type =
first.m_object->m_type;
20006 case value_t::boolean:
20007 case value_t::number_float:
20008 case value_t::number_integer:
20009 case value_t::number_unsigned:
20010 case value_t::string:
20013 || !last.m_it.primitive_iterator.is_end()))
20020 case value_t::null:
20021 case value_t::object:
20022 case value_t::array:
20023 case value_t::binary:
20024 case value_t::discarded:
20031 case value_t::number_integer:
20033 m_value.number_integer =
first.m_object->m_value.number_integer;
20037 case value_t::number_unsigned:
20039 m_value.number_unsigned =
first.m_object->m_value.number_unsigned;
20043 case value_t::number_float:
20045 m_value.number_float =
first.m_object->m_value.number_float;
20049 case value_t::boolean:
20051 m_value.boolean =
first.m_object->m_value.boolean;
20055 case value_t::string:
20057 m_value = *
first.m_object->m_value.string;
20061 case value_t::object:
20063 m_value.object = create<object_t>(
first.m_it.object_iterator,
20064 last.m_it.object_iterator);
20068 case value_t::array:
20070 m_value.array = create<array_t>(
first.m_it.array_iterator,
20071 last.m_it.array_iterator);
20075 case value_t::binary:
20077 m_value = *
first.m_object->m_value.binary;
20081 case value_t::null:
20082 case value_t::discarded:
20088 assert_invariant();
20096 template<
typename JsonRef,
20098 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
20104 : m_type(other.m_type)
20111 case value_t::object:
20117 case value_t::array:
20123 case value_t::string:
20129 case value_t::boolean:
20135 case value_t::number_integer:
20141 case value_t::number_unsigned:
20147 case value_t::number_float:
20153 case value_t::binary:
20159 case value_t::null:
20160 case value_t::discarded:
20166 assert_invariant();
20172 : m_type(std::move(other.m_type)),
20173 m_value(std::move(other.m_value))
20176 other.assert_invariant(
false);
20179 other.m_type = value_t::null;
20180 other.m_value = {};
20183 assert_invariant();
20199 swap(m_type, other.m_type);
20200 swap(m_value, other.m_value);
20203 assert_invariant();
20211 assert_invariant(
false);
20212 m_value.destroy(m_type);
20229 const char indent_char =
' ',
20230 const bool ensure_ascii =
false,
20238 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20242 s.dump(*
this,
false, ensure_ascii, 0);
20259 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
20266 return is_array() || is_object();
20273 return m_type == value_t::null;
20280 return m_type == value_t::boolean;
20287 return is_number_integer() || is_number_float();
20294 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
20301 return m_type == value_t::number_unsigned;
20308 return m_type == value_t::number_float;
20315 return m_type == value_t::object;
20322 return m_type == value_t::array;
20329 return m_type == value_t::string;
20336 return m_type == value_t::binary;
20343 return m_type == value_t::discarded;
20365 return m_value.boolean;
20374 return is_object() ? m_value.object :
nullptr;
20380 return is_object() ? m_value.object :
nullptr;
20386 return is_array() ? m_value.array :
nullptr;
20392 return is_array() ? m_value.array :
nullptr;
20398 return is_string() ? m_value.string :
nullptr;
20404 return is_string() ? m_value.string :
nullptr;
20410 return is_boolean() ? &m_value.boolean :
nullptr;
20416 return is_boolean() ? &m_value.boolean :
nullptr;
20422 return is_number_integer() ? &m_value.number_integer :
nullptr;
20428 return is_number_integer() ? &m_value.number_integer :
nullptr;
20434 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
20440 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
20446 return is_number_float() ? &m_value.number_float :
nullptr;
20452 return is_number_float() ? &m_value.number_float :
nullptr;
20458 return is_binary() ? m_value.binary :
nullptr;
20464 return is_binary() ? m_value.binary :
nullptr;
20478 template<
typename ReferenceType,
typename ThisType>
20499 template<
typename PointerType,
typename std::enable_if<
20504 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20509 template <
typename PointerType,
typename std::enable_if <
20515 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20557 template <
typename ValueType,
20565 auto ret = ValueType();
20600 template <
typename ValueType,
20625 template <
typename BasicJsonType,
20648 template<
typename BasicJsonType,
20661 template<
typename PointerType,
20666 -> decltype(std::declval<const basic_json_t&>().
template get_ptr<PointerType>())
20669 return get_ptr<PointerType>();
20696 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20697 #if defined(JSON_HAS_CPP_14)
20701 noexcept(
std::declval<const
basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
20708 "get() cannot be used with reference types, you might want to use get_ref()");
20709 return get_impl<ValueType>(detail::priority_tag<4> {});
20739 template<
typename PointerType,
typename std::enable_if<
20744 return get_ptr<PointerType>();
20749 template <
typename ValueType,
20754 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
20763 template<
typename ValueType,
20774 typename T, std::size_t N,
20775 typename Array =
T (&)[N],
20780 std::declval<const basic_json_t&>(), v)))
20788 template<
typename ReferenceType,
typename std::enable_if<
20793 return get_ref_impl<ReferenceType>(*
this);
20798 template <
typename ReferenceType,
typename std::enable_if <
20804 return get_ref_impl<ReferenceType>(*
this);
20836 template <
typename ValueType,
typename std::enable_if <
20844 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20847 #if defined(JSON_HAS_CPP_17)
20855 return get<ValueType>();
20867 return *get_ptr<binary_t*>();
20879 return *get_ptr<const binary_t*>();
20902 return set_parent(m_value.array->at(idx));
20925 return m_value.array->at(idx);
20949 auto it = m_value.object->find(key);
20950 if (it == m_value.object->end())
20954 return set_parent(it->second);
20969 auto it = m_value.object->find(std::forward<KeyType>(key));
20970 if (it == m_value.object->end())
20974 return set_parent(it->second);
20987 auto it = m_value.object->find(key);
20988 if (it == m_value.object->end())
21007 auto it = m_value.object->find(std::forward<KeyType>(key));
21008 if (it == m_value.object->end())
21022 m_type = value_t::array;
21023 m_value.
array = create<array_t>();
21024 assert_invariant();
21031 if (idx >= m_value.array->size())
21033 #if JSON_DIAGNOSTICS
21035 const auto old_size = m_value.array->size();
21036 const auto old_capacity = m_value.array->capacity();
21038 m_value.array->resize(idx + 1);
21040 #if JSON_DIAGNOSTICS
21049 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21052 assert_invariant();
21055 return m_value.array->operator[](idx);
21068 return m_value.
array->operator[](idx);
21081 m_type = value_t::object;
21082 m_value.
object = create<object_t>();
21083 assert_invariant();
21089 auto result = m_value.object->emplace(std::move(key),
nullptr);
21090 return set_parent(
result.first->second);
21113 template<
typename T>
21116 return operator[](
typename object_t::key_type(key));
21119 template<
typename T>
21122 return operator[](
typename object_t::key_type(key));
21134 m_type = value_t::object;
21135 m_value.
object = create<object_t>();
21136 assert_invariant();
21142 auto result = m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
21143 return set_parent(
result.first->second);
21158 auto it = m_value.
object->
find(std::forward<KeyType>(key));
21179 const auto it =
find(key);
21185 return std::forward<ValueType>(default_value);
21194 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
21207 return value(
typename object_t::key_type(key), std::forward<ValueType>(default_value));
21212 return value(
typename object_t::key_type(key),
string_t(default_value));
21228 const auto it =
find(std::forward<KeyType>(key));
21234 return std::forward<ValueType>(default_value);
21247 return value(std::forward<KeyType>(key),
string_t(default_value));
21262 return ptr.get_checked(
this).template get<ValueType>();
21266 return default_value;
21278 return value(
ptr.convert(), default_value);
21290 template<
typename BasicJsonType>
21295 return value(
ptr.convert(), default_value);
21347 case value_t::boolean:
21348 case value_t::number_float:
21349 case value_t::number_integer:
21350 case value_t::number_unsigned:
21351 case value_t::string:
21352 case value_t::binary:
21361 AllocatorType<string_t> alloc;
21362 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
21363 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21364 m_value.string =
nullptr;
21366 else if (is_binary())
21368 AllocatorType<binary_t> alloc;
21369 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
21370 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21371 m_value.binary =
nullptr;
21374 m_type = value_t::null;
21375 assert_invariant();
21379 case value_t::object:
21381 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
21385 case value_t::array:
21387 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
21391 case value_t::null:
21392 case value_t::discarded:
21417 case value_t::boolean:
21418 case value_t::number_float:
21419 case value_t::number_integer:
21420 case value_t::number_unsigned:
21421 case value_t::string:
21422 case value_t::binary:
21425 || !last.m_it.primitive_iterator.is_end()))
21432 AllocatorType<string_t> alloc;
21433 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
21434 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21435 m_value.string =
nullptr;
21437 else if (is_binary())
21439 AllocatorType<binary_t> alloc;
21440 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
21441 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21442 m_value.binary =
nullptr;
21445 m_type = value_t::null;
21446 assert_invariant();
21450 case value_t::object:
21452 result.m_it.object_iterator = m_value.object->erase(
first.m_it.object_iterator,
21453 last.m_it.object_iterator);
21457 case value_t::array:
21459 result.m_it.array_iterator = m_value.array->erase(
first.m_it.array_iterator,
21460 last.m_it.array_iterator);
21464 case value_t::null:
21465 case value_t::discarded:
21484 return m_value.object->erase(std::forward<KeyType>(key));
21497 const auto it = m_value.object->find(std::forward<KeyType>(key));
21498 if (it != m_value.object->end())
21500 m_value.object->erase(it);
21514 return erase_internal(key);
21523 return erase_internal(std::forward<KeyType>(key));
21538 m_value.array->erase(m_value.array->begin() +
static_cast<difference_type>(idx));
21564 result.m_it.object_iterator = m_value.object->find(key);
21578 result.m_it.object_iterator = m_value.object->find(key);
21594 result.m_it.object_iterator = m_value.object->find(std::forward<KeyType>(key));
21610 result.m_it.object_iterator = m_value.object->find(std::forward<KeyType>(key));
21621 return is_object() ? m_value.object->count(key) : 0;
21631 return is_object() ? m_value.object->count(std::forward<KeyType>(key)) : 0;
21636 bool contains(
const typename object_t::key_type& key)
const
21638 return is_object() && m_value.object->find(key) != m_value.object->end();
21647 return is_object() && m_value.object->find(std::forward<KeyType>(key)) != m_value.object->end();
21654 return ptr.contains(
this);
21657 template<
typename BasicJsonType>
21661 return ptr.contains(
this);
21775 return ref.items();
21786 return ref.items();
21819 case value_t::null:
21825 case value_t::array:
21828 return m_value.array->empty();
21831 case value_t::object:
21834 return m_value.object->empty();
21837 case value_t::string:
21838 case value_t::boolean:
21839 case value_t::number_integer:
21840 case value_t::number_unsigned:
21841 case value_t::number_float:
21842 case value_t::binary:
21843 case value_t::discarded:
21858 case value_t::null:
21864 case value_t::array:
21867 return m_value.array->size();
21870 case value_t::object:
21873 return m_value.object->size();
21876 case value_t::string:
21877 case value_t::boolean:
21878 case value_t::number_integer:
21879 case value_t::number_unsigned:
21880 case value_t::number_float:
21881 case value_t::binary:
21882 case value_t::discarded:
21897 case value_t::array:
21900 return m_value.array->max_size();
21903 case value_t::object:
21906 return m_value.object->max_size();
21909 case value_t::null:
21910 case value_t::string:
21911 case value_t::boolean:
21912 case value_t::number_integer:
21913 case value_t::number_unsigned:
21914 case value_t::number_float:
21915 case value_t::binary:
21916 case value_t::discarded:
21941 case value_t::number_integer:
21943 m_value.number_integer = 0;
21947 case value_t::number_unsigned:
21949 m_value.number_unsigned = 0;
21953 case value_t::number_float:
21955 m_value.number_float = 0.0;
21959 case value_t::boolean:
21961 m_value.boolean =
false;
21965 case value_t::string:
21967 m_value.string->clear();
21971 case value_t::binary:
21973 m_value.binary->clear();
21977 case value_t::array:
21979 m_value.array->clear();
21983 case value_t::object:
21985 m_value.object->clear();
21989 case value_t::null:
21990 case value_t::discarded:
22009 m_type = value_t::array;
22010 m_value = value_t::array;
22011 assert_invariant();
22015 const auto old_capacity = m_value.array->capacity();
22016 m_value.array->push_back(std::move(val));
22017 set_parent(m_value.array->back(), old_capacity);
22025 push_back(std::move(val));
22042 m_type = value_t::array;
22043 m_value = value_t::array;
22044 assert_invariant();
22048 const auto old_capacity = m_value.array->capacity();
22049 m_value.array->push_back(val);
22050 set_parent(m_value.array->back(), old_capacity);
22074 m_type = value_t::object;
22075 m_value = value_t::object;
22076 assert_invariant();
22080 auto res = m_value.object->insert(val);
22081 set_parent(res.first->second);
22096 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22098 basic_json&& key = init.begin()->moved_or_copied();
22100 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22118 template<
class... Args>
22130 m_type = value_t::array;
22131 m_value = value_t::array;
22132 assert_invariant();
22136 const auto old_capacity = m_value.array->capacity();
22137 m_value.array->emplace_back(std::forward<Args>(args)...);
22138 return set_parent(m_value.array->back(), old_capacity);
22143 template<
class... Args>
22155 m_type = value_t::object;
22156 m_value = value_t::object;
22157 assert_invariant();
22161 auto res = m_value.object->emplace(std::forward<Args>(args)...);
22162 set_parent(res.first->second);
22166 it.m_it.object_iterator = res.first;
22169 return {it, res.second};
22175 template<
typename... Args>
22181 auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
22182 m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22183 result.m_it.array_iterator = m_value.array->begin() + insert_pos;
22207 return insert_iterator(pos, val);
22217 return insert(pos, val);
22234 return insert_iterator(pos, cnt, val);
22268 return insert_iterator(pos,
first.m_it.array_iterator, last.m_it.array_iterator);
22288 return insert_iterator(pos, ilist.begin(), ilist.end());
22313 m_value.object->insert(
first.m_it.object_iterator, last.m_it.object_iterator);
22320 update(j.
begin(), j.
end(), merge_objects);
22330 m_type = value_t::object;
22331 m_value.object = create<object_t>();
22332 assert_invariant();
22352 for (
auto it =
first; it != last; ++it)
22354 if (merge_objects && it.value().is_object())
22356 auto it2 = m_value.object->find(it.key());
22357 if (it2 != m_value.object->end())
22359 it2->second.update(it.value(),
true);
22363 m_value.object->operator[](it.key()) = it.value();
22364 #if JSON_DIAGNOSTICS
22365 m_value.object->operator[](it.key()).m_parent =
this;
22383 other.set_parents();
22384 assert_invariant();
22407 swap(*(m_value.array), other);
22423 swap(*(m_value.object), other);
22439 swap(*(m_value.string), other);
22455 swap(*(m_value.binary), other);
22465 void swap(
typename binary_t::container_type& other)
22471 swap(*(m_value.binary), other);
22490 #define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22491 const auto lhs_type = lhs.type(); \
22492 const auto rhs_type = rhs.type(); \
22494 if (lhs_type == rhs_type) \
22496 switch (lhs_type) \
22498 case value_t::array: \
22499 return (*lhs.m_value.array) op (*rhs.m_value.array); \
22501 case value_t::object: \
22502 return (*lhs.m_value.object) op (*rhs.m_value.object); \
22504 case value_t::null: \
22505 return (null_result); \
22507 case value_t::string: \
22508 return (*lhs.m_value.string) op (*rhs.m_value.string); \
22510 case value_t::boolean: \
22511 return (lhs.m_value.boolean) op (rhs.m_value.boolean); \
22513 case value_t::number_integer: \
22514 return (lhs.m_value.number_integer) op (rhs.m_value.number_integer); \
22516 case value_t::number_unsigned: \
22517 return (lhs.m_value.number_unsigned) op (rhs.m_value.number_unsigned); \
22519 case value_t::number_float: \
22520 return (lhs.m_value.number_float) op (rhs.m_value.number_float); \
22522 case value_t::binary: \
22523 return (*lhs.m_value.binary) op (*rhs.m_value.binary); \
22525 case value_t::discarded: \
22527 return (unordered_result); \
22530 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22532 return static_cast<number_float_t>(lhs.m_value.number_integer) op rhs.m_value.number_float; \
22534 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22536 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_integer); \
22538 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22540 return static_cast<number_float_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_float; \
22542 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22544 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_unsigned); \
22546 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22548 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_integer; \
22550 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22552 return lhs.m_value.number_integer op static_cast<number_integer_t>(rhs.m_value.number_unsigned); \
22554 else if(compares_unordered(lhs, rhs))\
22556 return (unordered_result);\
22559 return (default_result);
22574 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22577 static_cast<void>(inverse);
22585 return compares_unordered(*
this, rhs, inverse);
22589 #if JSON_HAS_THREE_WAY_COMPARISON
22590 bool operator==(const_reference rhs)
const noexcept
22595 #pragma GCC diagnostic push
22596 #pragma GCC diagnostic ignored "-Wfloat-equal"
22598 const_reference lhs = *
this;
22601 #pragma GCC diagnostic pop
22607 template<
typename ScalarType>
22608 requires std::is_scalar_v<ScalarType>
22609 bool operator==(ScalarType rhs)
const noexcept
22616 bool operator!=(const_reference rhs)
const noexcept
22618 if (compares_unordered(rhs,
true))
22627 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
22629 const_reference lhs = *
this;
22633 std::partial_ordering::equivalent,
22634 std::partial_ordering::unordered,
22635 lhs_type <=> rhs_type)
22640 template<
typename ScalarType>
22641 requires std::is_scalar_v<ScalarType>
22642 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
22644 return *this <=> basic_json(rhs);
22647 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22654 bool operator<=(const_reference rhs)
const noexcept
22656 if (compares_unordered(rhs,
true))
22660 return !(rhs < *
this);
22665 template<
typename ScalarType>
22666 requires std::is_scalar_v<ScalarType>
22667 bool operator<=(ScalarType rhs)
const noexcept
22669 return *
this <= basic_json(rhs);
22675 bool operator>=(const_reference rhs)
const noexcept
22677 if (compares_unordered(rhs,
true))
22681 return !(*
this < rhs);
22686 template<
typename ScalarType>
22687 requires std::is_scalar_v<ScalarType>
22688 bool operator>=(ScalarType rhs)
const noexcept
22690 return *
this >= basic_json(rhs);
22694 friend bool operator==(const_reference lhs, const_reference rhs) noexcept
22699 #pragma GCC diagnostic push
22700 #pragma GCC diagnostic ignored "-Wfloat-equal"
22704 #pragma GCC diagnostic pop
22710 template<
typename ScalarType,
typename std::enable_if<
22719 template<
typename ScalarType,
typename std::enable_if<
22730 if (compares_unordered(lhs, rhs,
true))
22734 return !(lhs == rhs);
22739 template<
typename ScalarType,
typename std::enable_if<
22748 template<
typename ScalarType,
typename std::enable_if<
22767 template<
typename ScalarType,
typename std::enable_if<
22776 template<
typename ScalarType,
typename std::enable_if<
22787 if (compares_unordered(lhs, rhs,
true))
22791 return !(rhs < lhs);
22796 template<
typename ScalarType,
typename std::enable_if<
22805 template<
typename ScalarType,
typename std::enable_if<
22817 if (compares_unordered(lhs, rhs))
22821 return !(lhs <= rhs);
22826 template<
typename ScalarType,
typename std::enable_if<
22835 template<
typename ScalarType,
typename std::enable_if<
22846 if (compares_unordered(lhs, rhs,
true))
22850 return !(lhs < rhs);
22855 template<
typename ScalarType,
typename std::enable_if<
22864 template<
typename ScalarType,
typename std::enable_if<
22872 #undef JSON_IMPLEMENT_OPERATOR
22888 const bool pretty_print = o.width() > 0;
22889 const auto indentation = pretty_print ? o.width() : 0;
22896 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
22911 #endif // JSON_NO_IO
22924 template<
typename InputType>
22928 const bool allow_exceptions =
true,
22929 const bool ignore_comments =
false)
22938 template<
typename IteratorType>
22943 const bool allow_exceptions =
true,
22944 const bool ignore_comments =
false)
22955 const
bool allow_exceptions = true,
22956 const
bool ignore_comments = false)
22959 parser(
i.get(), cb, allow_exceptions, ignore_comments).parse(
true,
result);
22965 template<
typename InputType>
22967 const bool ignore_comments =
false)
22969 return parser(
detail::input_adapter(std::forward<InputType>(
i)),
nullptr,
false, ignore_comments).accept(
true);
22974 template<
typename IteratorType>
22976 const bool ignore_comments =
false)
22984 const
bool ignore_comments = false)
22986 return parser(
i.get(),
nullptr,
false, ignore_comments).accept(
true);
22991 template <
typename InputType,
typename SAX>
22993 static
bool sax_parse(InputType&&
i, SAX* sax,
22995 const
bool strict = true,
22996 const
bool ignore_comments = false)
23000 ? parser(std::move(ia),
nullptr,
true, ignore_comments).
sax_parse(sax, strict)
23006 template<
class IteratorType,
class SAX>
23008 static
bool sax_parse(IteratorType
first, IteratorType last, SAX* sax,
23010 const
bool strict = true,
23011 const
bool ignore_comments = false)
23015 ? parser(std::move(ia),
nullptr,
true, ignore_comments).
sax_parse(sax, strict)
23024 template <
typename SAX>
23027 static
bool sax_parse(
detail::span_input_adapter&&
i, SAX* sax,
23029 const
bool strict = true,
23030 const
bool ignore_comments = false)
23035 ? parser(std::move(ia),
nullptr,
true, ignore_comments).
sax_parse(sax, strict)
23049 return operator>>(
i, j);
23059 #endif // JSON_NO_IO
23073 case value_t::null:
23075 case value_t::object:
23077 case value_t::array:
23079 case value_t::string:
23081 case value_t::boolean:
23083 case value_t::binary:
23085 case value_t::discarded:
23086 return "discarded";
23087 case value_t::number_integer:
23088 case value_t::number_unsigned:
23089 case value_t::number_float:
23107 #if JSON_DIAGNOSTICS
23124 std::vector<std::uint8_t>
result;
23147 std::vector<std::uint8_t>
result;
23169 const bool use_size =
false,
23170 const bool use_type =
false)
23172 std::vector<std::uint8_t>
result;
23173 to_ubjson(j,
result, use_size, use_type);
23180 const bool use_size =
false,
const bool use_type =
false)
23188 const bool use_size =
false,
const bool use_type =
false)
23196 const bool use_size =
false,
23197 const bool use_type =
false)
23199 std::vector<std::uint8_t>
result;
23200 to_bjdata(j,
result, use_size, use_type);
23207 const bool use_size =
false,
const bool use_type =
false)
23215 const bool use_size =
false,
const bool use_type =
false)
23224 std::vector<std::uint8_t>
result;
23245 template<
typename InputType>
23248 const bool strict =
true,
23249 const bool allow_exceptions =
true,
23255 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23261 template<
typename IteratorType>
23264 const bool strict =
true,
23265 const bool allow_exceptions =
true,
23271 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23275 template<
typename T>
23279 const
bool strict = true,
23280 const
bool allow_exceptions = true,
23283 return from_cbor(
ptr,
ptr +
len, strict, allow_exceptions, tag_handler);
23290 const
bool strict = true,
23291 const
bool allow_exceptions = true,
23298 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23304 template<
typename InputType>
23307 const bool strict =
true,
23308 const bool allow_exceptions =
true)
23313 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23319 template<
typename IteratorType>
23322 const bool strict =
true,
23323 const bool allow_exceptions =
true)
23328 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23332 template<
typename T>
23336 const
bool strict = true,
23337 const
bool allow_exceptions = true)
23339 return from_msgpack(
ptr,
ptr +
len, strict, allow_exceptions);
23345 const
bool strict = true,
23346 const
bool allow_exceptions = true)
23352 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23358 template<
typename InputType>
23361 const bool strict =
true,
23362 const bool allow_exceptions =
true)
23367 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23373 template<
typename IteratorType>
23376 const bool strict =
true,
23377 const bool allow_exceptions =
true)
23382 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23386 template<
typename T>
23390 const
bool strict = true,
23391 const
bool allow_exceptions = true)
23393 return from_ubjson(
ptr,
ptr +
len, strict, allow_exceptions);
23399 const
bool strict = true,
23400 const
bool allow_exceptions = true)
23406 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23413 template<
typename InputType>
23416 const bool strict =
true,
23417 const bool allow_exceptions =
true)
23422 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23428 template<
typename IteratorType>
23431 const bool strict =
true,
23432 const bool allow_exceptions =
true)
23437 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23443 template<
typename InputType>
23446 const bool strict =
true,
23447 const bool allow_exceptions =
true)
23458 template<
typename IteratorType>
23461 const bool strict =
true,
23462 const bool allow_exceptions =
true)
23471 template<
typename T>
23475 const
bool strict = true,
23476 const
bool allow_exceptions = true)
23478 return from_bson(
ptr,
ptr +
len, strict, allow_exceptions);
23484 const
bool strict = true,
23485 const
bool allow_exceptions = true)
23507 return ptr.get_unchecked(
this);
23514 return ptr.get_unchecked(
this);
23521 return ptr.get_unchecked(
this);
23528 return ptr.get_unchecked(
this);
23535 return ptr.get_checked(
this);
23538 template<
typename BasicJsonType>
23542 return ptr.get_checked(
this);
23549 return ptr.get_checked(
this);
23552 template<
typename BasicJsonType>
23556 return ptr.get_checked(
this);
23564 json_pointer::flatten(
"", *
this,
result);
23572 return json_pointer::unflatten(*
this);
23590 enum class patch_operations {add,
remove, replace, move,
copy, test, invalid};
23592 const auto get_op = [](
const std::string & op)
23596 return patch_operations::add;
23598 if (op ==
"remove")
23602 if (op ==
"replace")
23604 return patch_operations::replace;
23608 return patch_operations::move;
23616 return patch_operations::test;
23619 return patch_operations::invalid;
23634 if (top_pointer !=
ptr)
23640 const auto last_path =
ptr.back();
23647 case value_t::null:
23648 case value_t::object:
23651 parent[last_path] = val;
23655 case value_t::array:
23657 if (last_path ==
"-")
23664 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
23678 case value_t::string:
23679 case value_t::boolean:
23680 case value_t::number_integer:
23681 case value_t::number_unsigned:
23682 case value_t::number_float:
23683 case value_t::binary:
23684 case value_t::discarded:
23694 const auto last_path =
ptr.back();
23702 auto it = parent.
find(last_path);
23715 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
23726 for (
const auto& val : json_patch)
23729 const auto get_value = [&val](
const std::string & op,
23730 const std::string & member,
23737 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
23764 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
23765 const auto path = get_value(op,
"path",
true).template get<std::string>();
23768 switch (get_op(op))
23770 case patch_operations::add:
23772 operation_add(
ptr, get_value(
"add",
"value",
false));
23778 operation_remove(
ptr);
23782 case patch_operations::replace:
23785 result.at(
ptr) = get_value(
"replace",
"value",
false);
23789 case patch_operations::move:
23791 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
23801 operation_remove(from_ptr);
23802 operation_add(
ptr, v);
23808 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
23817 operation_add(
ptr, v);
23821 case patch_operations::test:
23823 bool success =
false;
23828 success = (
result.at(
ptr) == get_value(
"test",
"value",
false));
23844 case patch_operations::invalid:
23860 result.patch_inplace(json_patch);
23868 const std::string& path =
"")
23884 {
"op",
"replace"}, {
"path", path}, {
"value",
target}
23889 switch (source.
type())
23891 case value_t::array:
23899 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
23908 while (
i < source.
size())
23935 case value_t::object:
23938 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
23946 auto temp_diff = diff(it.value(),
target[it.key()], path_key);
23947 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
23952 result.push_back(
object(
23954 {
"op",
"remove"}, {
"path", path_key}
23960 for (
auto it =
target.cbegin(); it !=
target.cend(); ++it)
23962 if (source.
find(it.key()) == source.
end())
23968 {
"op",
"add"}, {
"path", path_key},
23969 {
"value", it.value()}
23977 case value_t::null:
23978 case value_t::string:
23979 case value_t::boolean:
23980 case value_t::number_integer:
23981 case value_t::number_unsigned:
23982 case value_t::number_float:
23983 case value_t::binary:
23984 case value_t::discarded:
23990 {
"op",
"replace"}, {
"path", path}, {
"value",
target}
24017 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
24019 if (it.value().is_null())
24025 operator[](it.key()).merge_patch(it.value());
24031 *
this = apply_patch;
24046 inline namespace literals
24048 inline namespace json_literals
24056 return nlohmann::json::parse(
s,
s +
n);
24100 #if JSON_HAS_THREE_WAY_COMPARISON
24101 return std::is_lt(lhs <=> rhs);
24109 #ifndef JSON_HAS_CPP_20
24125 #if JSON_USE_GLOBAL_UDLS
24126 using nlohmann::literals::json_literals::operator
"" _json;
24127 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24142 #if defined(__clang__)
24143 #pragma clang diagnostic pop
24148 #undef JSON_INTERNAL_CATCH
24150 #undef JSON_PRIVATE_UNLESS_TESTED
24151 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24152 #undef NLOHMANN_BASIC_JSON_TPL
24153 #undef JSON_EXPLICIT
24154 #undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24155 #undef JSON_INLINE_VARIABLE
24156 #undef JSON_NO_UNIQUE_ADDRESS
24157 #undef JSON_DISABLE_ENUM_SERIALIZATION
24158 #undef JSON_USE_GLOBAL_UDLS
24160 #ifndef JSON_TEST_KEEP_MACROS
24163 #undef JSON_HAS_CPP_11
24164 #undef JSON_HAS_CPP_14
24165 #undef JSON_HAS_CPP_17
24166 #undef JSON_HAS_CPP_20
24167 #undef JSON_HAS_FILESYSTEM
24168 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24169 #undef JSON_HAS_THREE_WAY_COMPARISON
24170 #undef JSON_HAS_RANGES
24171 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24185 #undef JSON_HEDLEY_ALWAYS_INLINE
24186 #undef JSON_HEDLEY_ARM_VERSION
24187 #undef JSON_HEDLEY_ARM_VERSION_CHECK
24188 #undef JSON_HEDLEY_ARRAY_PARAM
24189 #undef JSON_HEDLEY_ASSUME
24190 #undef JSON_HEDLEY_BEGIN_C_DECLS
24191 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24192 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24193 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24194 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24195 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24196 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
24197 #undef JSON_HEDLEY_CLANG_HAS_WARNING
24198 #undef JSON_HEDLEY_COMPCERT_VERSION
24199 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24200 #undef JSON_HEDLEY_CONCAT
24201 #undef JSON_HEDLEY_CONCAT3
24202 #undef JSON_HEDLEY_CONCAT3_EX
24203 #undef JSON_HEDLEY_CONCAT_EX
24204 #undef JSON_HEDLEY_CONST
24205 #undef JSON_HEDLEY_CONSTEXPR
24206 #undef JSON_HEDLEY_CONST_CAST
24207 #undef JSON_HEDLEY_CPP_CAST
24208 #undef JSON_HEDLEY_CRAY_VERSION
24209 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
24210 #undef JSON_HEDLEY_C_DECL
24211 #undef JSON_HEDLEY_DEPRECATED
24212 #undef JSON_HEDLEY_DEPRECATED_FOR
24213 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24214 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24215 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24216 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24217 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24218 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24219 #undef JSON_HEDLEY_DIAGNOSTIC_POP
24220 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24221 #undef JSON_HEDLEY_DMC_VERSION
24222 #undef JSON_HEDLEY_DMC_VERSION_CHECK
24223 #undef JSON_HEDLEY_EMPTY_BASES
24224 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24225 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24226 #undef JSON_HEDLEY_END_C_DECLS
24227 #undef JSON_HEDLEY_FLAGS
24228 #undef JSON_HEDLEY_FLAGS_CAST
24229 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24230 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
24231 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24232 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24233 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
24234 #undef JSON_HEDLEY_GCC_HAS_FEATURE
24235 #undef JSON_HEDLEY_GCC_HAS_WARNING
24236 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24237 #undef JSON_HEDLEY_GCC_VERSION
24238 #undef JSON_HEDLEY_GCC_VERSION_CHECK
24239 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24240 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24241 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24242 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24243 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24244 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
24245 #undef JSON_HEDLEY_GNUC_HAS_WARNING
24246 #undef JSON_HEDLEY_GNUC_VERSION
24247 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
24248 #undef JSON_HEDLEY_HAS_ATTRIBUTE
24249 #undef JSON_HEDLEY_HAS_BUILTIN
24250 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24251 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24252 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24253 #undef JSON_HEDLEY_HAS_EXTENSION
24254 #undef JSON_HEDLEY_HAS_FEATURE
24255 #undef JSON_HEDLEY_HAS_WARNING
24256 #undef JSON_HEDLEY_IAR_VERSION
24257 #undef JSON_HEDLEY_IAR_VERSION_CHECK
24258 #undef JSON_HEDLEY_IBM_VERSION
24259 #undef JSON_HEDLEY_IBM_VERSION_CHECK
24260 #undef JSON_HEDLEY_IMPORT
24261 #undef JSON_HEDLEY_INLINE
24262 #undef JSON_HEDLEY_INTEL_CL_VERSION
24263 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24264 #undef JSON_HEDLEY_INTEL_VERSION
24265 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
24266 #undef JSON_HEDLEY_IS_CONSTANT
24267 #undef JSON_HEDLEY_IS_CONSTEXPR_
24268 #undef JSON_HEDLEY_LIKELY
24269 #undef JSON_HEDLEY_MALLOC
24270 #undef JSON_HEDLEY_MCST_LCC_VERSION
24271 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24272 #undef JSON_HEDLEY_MESSAGE
24273 #undef JSON_HEDLEY_MSVC_VERSION
24274 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
24275 #undef JSON_HEDLEY_NEVER_INLINE
24276 #undef JSON_HEDLEY_NON_NULL
24277 #undef JSON_HEDLEY_NO_ESCAPE
24278 #undef JSON_HEDLEY_NO_RETURN
24279 #undef JSON_HEDLEY_NO_THROW
24280 #undef JSON_HEDLEY_NULL
24281 #undef JSON_HEDLEY_PELLES_VERSION
24282 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
24283 #undef JSON_HEDLEY_PGI_VERSION
24284 #undef JSON_HEDLEY_PGI_VERSION_CHECK
24285 #undef JSON_HEDLEY_PREDICT
24286 #undef JSON_HEDLEY_PRINTF_FORMAT
24287 #undef JSON_HEDLEY_PRIVATE
24288 #undef JSON_HEDLEY_PUBLIC
24289 #undef JSON_HEDLEY_PURE
24290 #undef JSON_HEDLEY_REINTERPRET_CAST
24291 #undef JSON_HEDLEY_REQUIRE
24292 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24293 #undef JSON_HEDLEY_REQUIRE_MSG
24294 #undef JSON_HEDLEY_RESTRICT
24295 #undef JSON_HEDLEY_RETURNS_NON_NULL
24296 #undef JSON_HEDLEY_SENTINEL
24297 #undef JSON_HEDLEY_STATIC_ASSERT
24298 #undef JSON_HEDLEY_STATIC_CAST
24299 #undef JSON_HEDLEY_STRINGIFY
24300 #undef JSON_HEDLEY_STRINGIFY_EX
24301 #undef JSON_HEDLEY_SUNPRO_VERSION
24302 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24303 #undef JSON_HEDLEY_TINYC_VERSION
24304 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
24305 #undef JSON_HEDLEY_TI_ARMCL_VERSION
24306 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24307 #undef JSON_HEDLEY_TI_CL2000_VERSION
24308 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24309 #undef JSON_HEDLEY_TI_CL430_VERSION
24310 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24311 #undef JSON_HEDLEY_TI_CL6X_VERSION
24312 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24313 #undef JSON_HEDLEY_TI_CL7X_VERSION
24314 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24315 #undef JSON_HEDLEY_TI_CLPRU_VERSION
24316 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24317 #undef JSON_HEDLEY_TI_VERSION
24318 #undef JSON_HEDLEY_TI_VERSION_CHECK
24319 #undef JSON_HEDLEY_UNAVAILABLE
24320 #undef JSON_HEDLEY_UNLIKELY
24321 #undef JSON_HEDLEY_UNPREDICTABLE
24322 #undef JSON_HEDLEY_UNREACHABLE
24323 #undef JSON_HEDLEY_UNREACHABLE_RETURN
24324 #undef JSON_HEDLEY_VERSION
24325 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24326 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
24327 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
24328 #undef JSON_HEDLEY_VERSION_ENCODE
24329 #undef JSON_HEDLEY_WARNING
24330 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
24331 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24332 #undef JSON_HEDLEY_FALL_THROUGH
24334 #endif // INCLUDE_NLOHMANN_JSON_HPP_