18 #ifndef INCLUDE_NLOHMANN_JSON_HPP_
19 #define INCLUDE_NLOHMANN_JSON_HPP_
24 #include <initializer_list>
60 #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
63 #warning "Already included a different version of the library!"
68 #define NLOHMANN_JSON_VERSION_MAJOR 3
69 #define NLOHMANN_JSON_VERSION_MINOR 12
70 #define NLOHMANN_JSON_VERSION_PATCH 0
72 #ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76 #ifndef JSON_DIAGNOSTIC_POSITIONS
77 #define JSON_DIAGNOSTIC_POSITIONS 0
80 #ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
81 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
85 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
87 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
90 #if JSON_DIAGNOSTIC_POSITIONS
91 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
93 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
96 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
97 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
99 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
102 #ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
103 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
107 #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
108 #define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
109 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
111 #define NLOHMANN_JSON_ABI_TAGS \
112 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
113 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
114 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
115 NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
118 #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
119 _v ## major ## _ ## minor ## _ ## patch
120 #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
121 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
123 #if NLOHMANN_JSON_NAMESPACE_NO_VERSION
124 #define NLOHMANN_JSON_NAMESPACE_VERSION
126 #define NLOHMANN_JSON_NAMESPACE_VERSION \
127 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
128 NLOHMANN_JSON_VERSION_MINOR, \
129 NLOHMANN_JSON_VERSION_PATCH)
133 #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
134 #define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
135 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
137 #ifndef NLOHMANN_JSON_NAMESPACE
138 #define NLOHMANN_JSON_NAMESPACE \
139 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
140 NLOHMANN_JSON_ABI_TAGS, \
141 NLOHMANN_JSON_NAMESPACE_VERSION)
144 #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
145 #define NLOHMANN_JSON_NAMESPACE_BEGIN \
148 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
149 NLOHMANN_JSON_ABI_TAGS, \
150 NLOHMANN_JSON_NAMESPACE_VERSION) \
154 #ifndef NLOHMANN_JSON_NAMESPACE_END
155 #define NLOHMANN_JSON_NAMESPACE_END \
173 #include <forward_list>
178 #include <type_traits>
179 #include <unordered_map>
242 #include <type_traits>
287 template<
class Default,
289 template<
class...>
class Op,
297 template<
class Default,
template<
class...>
class Op,
class... Args>
304 template<
template<
class...>
class Op,
class... Args>
307 template<
template<
class...>
class Op,
class... Args>
310 template<
template<
class...>
class Op,
class... Args>
313 template<
class Default,
template<
class...>
class Op,
class... Args>
316 template<
class Default,
template<
class...>
class Op,
class... Args>
319 template<
class Expected,
template<
class...>
class Op,
class... Args>
322 template<
class To,
template<
class...>
class Op,
class... Args>
324 std::is_convertible<
detected_t<Op, Args...>, To>;
345 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
346 #if defined(JSON_HEDLEY_VERSION)
347 #undef JSON_HEDLEY_VERSION
349 #define JSON_HEDLEY_VERSION 15
351 #if defined(JSON_HEDLEY_STRINGIFY_EX)
352 #undef JSON_HEDLEY_STRINGIFY_EX
354 #define JSON_HEDLEY_STRINGIFY_EX(x) #x
356 #if defined(JSON_HEDLEY_STRINGIFY)
357 #undef JSON_HEDLEY_STRINGIFY
359 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
361 #if defined(JSON_HEDLEY_CONCAT_EX)
362 #undef JSON_HEDLEY_CONCAT_EX
364 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b
366 #if defined(JSON_HEDLEY_CONCAT)
367 #undef JSON_HEDLEY_CONCAT
369 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
371 #if defined(JSON_HEDLEY_CONCAT3_EX)
372 #undef JSON_HEDLEY_CONCAT3_EX
374 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
376 #if defined(JSON_HEDLEY_CONCAT3)
377 #undef JSON_HEDLEY_CONCAT3
379 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
381 #if defined(JSON_HEDLEY_VERSION_ENCODE)
382 #undef JSON_HEDLEY_VERSION_ENCODE
384 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
386 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
387 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
389 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
391 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
392 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
394 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
396 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
397 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
399 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
401 #if defined(JSON_HEDLEY_GNUC_VERSION)
402 #undef JSON_HEDLEY_GNUC_VERSION
404 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
405 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
406 #elif defined(__GNUC__)
407 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
410 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
411 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
413 #if defined(JSON_HEDLEY_GNUC_VERSION)
414 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
416 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
419 #if defined(JSON_HEDLEY_MSVC_VERSION)
420 #undef JSON_HEDLEY_MSVC_VERSION
422 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
423 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
424 #elif defined(_MSC_FULL_VER) && !defined(__ICL)
425 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
426 #elif defined(_MSC_VER) && !defined(__ICL)
427 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
430 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
431 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
433 #if !defined(JSON_HEDLEY_MSVC_VERSION)
434 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
435 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
436 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
437 #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
438 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
440 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
443 #if defined(JSON_HEDLEY_INTEL_VERSION)
444 #undef JSON_HEDLEY_INTEL_VERSION
446 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
447 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
448 #elif defined(__INTEL_COMPILER) && !defined(__ICL)
449 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
452 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
453 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
455 #if defined(JSON_HEDLEY_INTEL_VERSION)
456 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
458 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
461 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
462 #undef JSON_HEDLEY_INTEL_CL_VERSION
464 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
465 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
468 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
469 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
471 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
472 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
474 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
477 #if defined(JSON_HEDLEY_PGI_VERSION)
478 #undef JSON_HEDLEY_PGI_VERSION
480 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
481 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
484 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
485 #undef JSON_HEDLEY_PGI_VERSION_CHECK
487 #if defined(JSON_HEDLEY_PGI_VERSION)
488 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
490 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
493 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
494 #undef JSON_HEDLEY_SUNPRO_VERSION
496 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
497 #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)
498 #elif defined(__SUNPRO_C)
499 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
500 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
501 #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)
502 #elif defined(__SUNPRO_CC)
503 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
506 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
507 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
509 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
510 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
515 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
516 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
518 #if defined(__EMSCRIPTEN__)
519 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
522 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
523 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
525 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
526 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
528 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
531 #if defined(JSON_HEDLEY_ARM_VERSION)
532 #undef JSON_HEDLEY_ARM_VERSION
534 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
535 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
536 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
537 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
540 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
541 #undef JSON_HEDLEY_ARM_VERSION_CHECK
543 #if defined(JSON_HEDLEY_ARM_VERSION)
544 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
546 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
549 #if defined(JSON_HEDLEY_IBM_VERSION)
550 #undef JSON_HEDLEY_IBM_VERSION
552 #if defined(__ibmxl__)
553 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
554 #elif defined(__xlC__) && defined(__xlC_ver__)
555 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
556 #elif defined(__xlC__)
557 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
560 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
561 #undef JSON_HEDLEY_IBM_VERSION_CHECK
563 #if defined(JSON_HEDLEY_IBM_VERSION)
564 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
566 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
569 #if defined(JSON_HEDLEY_TI_VERSION)
570 #undef JSON_HEDLEY_TI_VERSION
573 defined(__TI_COMPILER_VERSION__) && \
575 defined(__TMS470__) || defined(__TI_ARM__) || \
576 defined(__MSP430__) || \
577 defined(__TMS320C2000__) \
579 #if (__TI_COMPILER_VERSION__ >= 16000000)
580 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
584 #if defined(JSON_HEDLEY_TI_VERSION_CHECK)
585 #undef JSON_HEDLEY_TI_VERSION_CHECK
587 #if defined(JSON_HEDLEY_TI_VERSION)
588 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
590 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
593 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
594 #undef JSON_HEDLEY_TI_CL2000_VERSION
596 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
597 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
600 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
601 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
603 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
604 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
606 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
609 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
610 #undef JSON_HEDLEY_TI_CL430_VERSION
612 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
613 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
616 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
617 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
619 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
620 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
622 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
625 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
626 #undef JSON_HEDLEY_TI_ARMCL_VERSION
628 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
629 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
632 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
633 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
635 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
636 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
638 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
641 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
642 #undef JSON_HEDLEY_TI_CL6X_VERSION
644 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
645 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
648 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
649 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
651 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
652 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
654 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
657 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
658 #undef JSON_HEDLEY_TI_CL7X_VERSION
660 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
661 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
664 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
665 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
667 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
668 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
670 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
673 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
674 #undef JSON_HEDLEY_TI_CLPRU_VERSION
676 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
677 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
680 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
681 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
683 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
684 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
686 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
689 #if defined(JSON_HEDLEY_CRAY_VERSION)
690 #undef JSON_HEDLEY_CRAY_VERSION
693 #if defined(_RELEASE_PATCHLEVEL)
694 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
696 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
700 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
701 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
703 #if defined(JSON_HEDLEY_CRAY_VERSION)
704 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
706 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
709 #if defined(JSON_HEDLEY_IAR_VERSION)
710 #undef JSON_HEDLEY_IAR_VERSION
712 #if defined(__IAR_SYSTEMS_ICC__)
714 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
716 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
720 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
721 #undef JSON_HEDLEY_IAR_VERSION_CHECK
723 #if defined(JSON_HEDLEY_IAR_VERSION)
724 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
726 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
729 #if defined(JSON_HEDLEY_TINYC_VERSION)
730 #undef JSON_HEDLEY_TINYC_VERSION
732 #if defined(__TINYC__)
733 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
736 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
737 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
739 #if defined(JSON_HEDLEY_TINYC_VERSION)
740 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
742 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
745 #if defined(JSON_HEDLEY_DMC_VERSION)
746 #undef JSON_HEDLEY_DMC_VERSION
749 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
752 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
753 #undef JSON_HEDLEY_DMC_VERSION_CHECK
755 #if defined(JSON_HEDLEY_DMC_VERSION)
756 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
758 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
761 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
762 #undef JSON_HEDLEY_COMPCERT_VERSION
764 #if defined(__COMPCERT_VERSION__)
765 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
768 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
769 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
771 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
772 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
774 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
777 #if defined(JSON_HEDLEY_PELLES_VERSION)
778 #undef JSON_HEDLEY_PELLES_VERSION
780 #if defined(__POCC__)
781 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
784 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
785 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
787 #if defined(JSON_HEDLEY_PELLES_VERSION)
788 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
790 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
793 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
794 #undef JSON_HEDLEY_MCST_LCC_VERSION
796 #if defined(__LCC__) && defined(__LCC_MINOR__)
797 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
800 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
801 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
803 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
804 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
806 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
809 #if defined(JSON_HEDLEY_GCC_VERSION)
810 #undef JSON_HEDLEY_GCC_VERSION
813 defined(JSON_HEDLEY_GNUC_VERSION) && \
814 !defined(__clang__) && \
815 !defined(JSON_HEDLEY_INTEL_VERSION) && \
816 !defined(JSON_HEDLEY_PGI_VERSION) && \
817 !defined(JSON_HEDLEY_ARM_VERSION) && \
818 !defined(JSON_HEDLEY_CRAY_VERSION) && \
819 !defined(JSON_HEDLEY_TI_VERSION) && \
820 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
821 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
822 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
823 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
824 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
825 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
826 !defined(__COMPCERT__) && \
827 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
828 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
831 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
832 #undef JSON_HEDLEY_GCC_VERSION_CHECK
834 #if defined(JSON_HEDLEY_GCC_VERSION)
835 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
837 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
840 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
841 #undef JSON_HEDLEY_HAS_ATTRIBUTE
844 defined(__has_attribute) && \
846 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
848 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
850 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
853 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
854 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
856 #if defined(__has_attribute)
857 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
859 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
862 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
863 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
865 #if defined(__has_attribute)
866 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
868 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
871 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
872 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
875 defined(__has_cpp_attribute) && \
876 defined(__cplusplus) && \
877 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
878 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
883 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
884 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
886 #if !defined(__cplusplus) || !defined(__has_cpp_attribute)
887 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
889 !defined(JSON_HEDLEY_PGI_VERSION) && \
890 !defined(JSON_HEDLEY_IAR_VERSION) && \
891 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
892 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
893 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
895 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
898 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
899 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
901 #if defined(__has_cpp_attribute) && defined(__cplusplus)
902 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
904 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
907 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
908 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
910 #if defined(__has_cpp_attribute) && defined(__cplusplus)
911 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
913 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
916 #if defined(JSON_HEDLEY_HAS_BUILTIN)
917 #undef JSON_HEDLEY_HAS_BUILTIN
919 #if defined(__has_builtin)
920 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
922 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
925 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
926 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
928 #if defined(__has_builtin)
929 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
931 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
934 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
935 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
937 #if defined(__has_builtin)
938 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
940 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
943 #if defined(JSON_HEDLEY_HAS_FEATURE)
944 #undef JSON_HEDLEY_HAS_FEATURE
946 #if defined(__has_feature)
947 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
949 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
952 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
953 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
955 #if defined(__has_feature)
956 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
958 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
961 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
962 #undef JSON_HEDLEY_GCC_HAS_FEATURE
964 #if defined(__has_feature)
965 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
967 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
970 #if defined(JSON_HEDLEY_HAS_EXTENSION)
971 #undef JSON_HEDLEY_HAS_EXTENSION
973 #if defined(__has_extension)
974 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
976 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
979 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
980 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
982 #if defined(__has_extension)
983 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
985 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
988 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
989 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
991 #if defined(__has_extension)
992 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
994 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
997 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
998 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1000 #if defined(__has_declspec_attribute)
1001 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1003 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1006 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1007 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1009 #if defined(__has_declspec_attribute)
1010 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1012 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1015 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1016 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1018 #if defined(__has_declspec_attribute)
1019 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1021 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1024 #if defined(JSON_HEDLEY_HAS_WARNING)
1025 #undef JSON_HEDLEY_HAS_WARNING
1027 #if defined(__has_warning)
1028 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1030 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1033 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1034 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1036 #if defined(__has_warning)
1037 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1039 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1042 #if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1043 #undef JSON_HEDLEY_GCC_HAS_WARNING
1045 #if defined(__has_warning)
1046 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1048 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1052 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1053 defined(__clang__) || \
1054 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1055 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1056 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1057 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1058 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1059 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1060 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1061 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1062 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1063 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1064 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1065 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1066 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1067 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1068 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1069 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1070 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1071 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1072 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1074 #define JSON_HEDLEY_PRAGMA(value)
1077 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1078 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1080 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1081 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1083 #if defined(__clang__)
1084 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1085 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1086 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1089 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1090 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1091 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1093 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1094 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1095 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1096 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1097 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1098 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1099 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1101 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1102 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1103 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1104 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1105 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1106 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1107 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1108 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1109 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1111 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1113 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1114 #define JSON_HEDLEY_DIAGNOSTIC_POP
1119 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1120 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1122 #if defined(__cplusplus)
1123 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1124 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1125 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1126 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1127 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1128 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1129 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1130 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1132 JSON_HEDLEY_DIAGNOSTIC_POP
1134 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1135 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1136 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1137 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1139 JSON_HEDLEY_DIAGNOSTIC_POP
1142 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1143 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1144 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1146 JSON_HEDLEY_DIAGNOSTIC_POP
1150 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1151 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1154 #if defined(JSON_HEDLEY_CONST_CAST)
1155 #undef JSON_HEDLEY_CONST_CAST
1157 #if defined(__cplusplus)
1158 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1160 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1161 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1162 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1163 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1164 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1165 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1167 JSON_HEDLEY_DIAGNOSTIC_POP \
1170 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1173 #if defined(JSON_HEDLEY_REINTERPRET_CAST)
1174 #undef JSON_HEDLEY_REINTERPRET_CAST
1176 #if defined(__cplusplus)
1177 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1179 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1182 #if defined(JSON_HEDLEY_STATIC_CAST)
1183 #undef JSON_HEDLEY_STATIC_CAST
1185 #if defined(__cplusplus)
1186 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1188 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1191 #if defined(JSON_HEDLEY_CPP_CAST)
1192 #undef JSON_HEDLEY_CPP_CAST
1194 #if defined(__cplusplus)
1195 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1196 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1197 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1198 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1200 JSON_HEDLEY_DIAGNOSTIC_POP
1201 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1202 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1203 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1204 _Pragma("diag_suppress=Pe137") \
1205 JSON_HEDLEY_DIAGNOSTIC_POP
1207 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1210 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1213 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1214 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1216 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1217 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1218 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1219 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1220 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1221 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1222 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1223 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1224 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1225 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1226 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1227 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1228 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1229 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1230 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1233 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1234 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1235 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1236 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1237 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1238 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1239 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1240 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1241 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1242 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1243 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1244 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1245 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1246 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1247 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1248 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1249 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1251 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1257 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1258 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1260 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1261 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1262 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1263 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1264 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1265 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1266 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1267 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1268 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1269 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1270 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1271 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1273 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1274 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1275 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1276 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1277 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1278 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1280 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1282 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1288 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1289 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1291 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1292 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1293 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1295 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1297 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1298 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1299 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1301 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1303 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1305 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1308 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1309 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1310 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1312 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1314 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1320 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1321 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1323 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1324 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1325 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1327 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1333 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1334 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1336 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1337 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1338 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1339 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1340 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1341 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1342 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1343 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1345 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1348 #if defined(JSON_HEDLEY_DEPRECATED)
1349 #undef JSON_HEDLEY_DEPRECATED
1351 #if defined(JSON_HEDLEY_DEPRECATED_FOR)
1352 #undef JSON_HEDLEY_DEPRECATED_FOR
1355 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1356 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1357 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1358 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1360 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1361 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1362 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1363 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1364 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1365 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1366 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1367 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1368 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1369 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1370 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1371 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1372 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1373 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1374 #elif defined(__cplusplus) && (__cplusplus >= 201402L)
1375 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1376 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1378 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1379 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1380 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1381 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1382 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1383 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1384 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1385 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1386 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1387 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1388 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1389 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1390 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1391 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1392 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1393 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1394 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1395 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1397 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1398 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1399 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1400 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1401 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1402 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1403 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1404 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1406 #define JSON_HEDLEY_DEPRECATED(since)
1407 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1410 #if defined(JSON_HEDLEY_UNAVAILABLE)
1411 #undef JSON_HEDLEY_UNAVAILABLE
1414 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1415 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1416 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1417 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1418 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1420 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1423 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1424 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1426 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1427 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1430 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1431 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1432 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1433 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1434 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1435 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1436 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1437 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1438 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1439 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1440 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1441 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1442 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1443 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1444 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1445 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1446 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1447 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1449 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1451 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1452 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1454 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1455 #elif defined(_Check_return_)
1456 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1457 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1459 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1460 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1463 #if defined(JSON_HEDLEY_SENTINEL)
1464 #undef JSON_HEDLEY_SENTINEL
1467 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1468 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1469 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1470 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1471 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1472 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1474 #define JSON_HEDLEY_SENTINEL(position)
1477 #if defined(JSON_HEDLEY_NO_RETURN)
1478 #undef JSON_HEDLEY_NO_RETURN
1480 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1481 #define JSON_HEDLEY_NO_RETURN __noreturn
1483 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1484 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1485 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1486 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1487 #define JSON_HEDLEY_NO_RETURN _Noreturn
1488 #elif defined(__cplusplus) && (__cplusplus >= 201103L)
1489 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1491 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1492 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1493 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1494 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1495 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1496 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1497 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1498 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1499 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1500 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1501 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1502 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1503 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1504 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1505 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1506 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1507 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1508 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1509 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1510 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1512 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1513 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1514 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1515 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1516 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1517 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1518 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1519 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1520 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1522 #define JSON_HEDLEY_NO_RETURN
1525 #if defined(JSON_HEDLEY_NO_ESCAPE)
1526 #undef JSON_HEDLEY_NO_ESCAPE
1528 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1529 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1531 #define JSON_HEDLEY_NO_ESCAPE
1534 #if defined(JSON_HEDLEY_UNREACHABLE)
1535 #undef JSON_HEDLEY_UNREACHABLE
1537 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1538 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1540 #if defined(JSON_HEDLEY_ASSUME)
1541 #undef JSON_HEDLEY_ASSUME
1544 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1545 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1546 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1547 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1548 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1549 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1551 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1552 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1553 #if defined(__cplusplus)
1554 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1556 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1560 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1561 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1562 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1563 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1564 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1565 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1566 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1567 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1568 #elif defined(JSON_HEDLEY_ASSUME)
1569 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1571 #if !defined(JSON_HEDLEY_ASSUME)
1572 #if defined(JSON_HEDLEY_UNREACHABLE)
1573 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1575 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1578 #if defined(JSON_HEDLEY_UNREACHABLE)
1580 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1581 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1582 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1584 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1587 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1589 #if !defined(JSON_HEDLEY_UNREACHABLE)
1590 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1594 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1595 #pragma clang diagnostic ignored "-Wpedantic"
1597 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1598 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1600 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1601 #if defined(__clang__)
1602 #pragma clang diagnostic ignored "-Wvariadic-macros"
1603 #elif defined(JSON_HEDLEY_GCC_VERSION)
1604 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1607 #if defined(JSON_HEDLEY_NON_NULL)
1608 #undef JSON_HEDLEY_NON_NULL
1611 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1612 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1613 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1614 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1615 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1617 #define JSON_HEDLEY_NON_NULL(...)
1621 #if defined(JSON_HEDLEY_PRINTF_FORMAT)
1622 #undef JSON_HEDLEY_PRINTF_FORMAT
1624 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1625 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1626 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1627 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1629 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1630 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1631 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1632 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1633 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1634 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1635 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1636 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1637 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1638 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1639 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1640 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1641 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1642 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1643 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1644 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1645 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1646 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1647 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1648 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1650 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1653 #if defined(JSON_HEDLEY_CONSTEXPR)
1654 #undef JSON_HEDLEY_CONSTEXPR
1656 #if defined(__cplusplus)
1657 #if __cplusplus >= 201103L
1658 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1661 #if !defined(JSON_HEDLEY_CONSTEXPR)
1662 #define JSON_HEDLEY_CONSTEXPR
1665 #if defined(JSON_HEDLEY_PREDICT)
1666 #undef JSON_HEDLEY_PREDICT
1668 #if defined(JSON_HEDLEY_LIKELY)
1669 #undef JSON_HEDLEY_LIKELY
1671 #if defined(JSON_HEDLEY_UNLIKELY)
1672 #undef JSON_HEDLEY_UNLIKELY
1674 #if defined(JSON_HEDLEY_UNPREDICTABLE)
1675 #undef JSON_HEDLEY_UNPREDICTABLE
1677 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1678 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1681 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1682 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1683 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1684 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1685 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1686 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1687 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1688 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1690 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1691 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1692 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1693 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1694 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1695 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1696 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1697 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1698 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1699 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1700 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1701 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1702 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1703 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1704 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1705 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1706 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1707 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1708 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1710 double hedley_probability_ = (probability); \
1711 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1713 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1715 double hedley_probability_ = (probability); \
1716 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1718 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1719 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1721 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1722 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1723 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1724 # define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1725 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1727 #if !defined(JSON_HEDLEY_UNPREDICTABLE)
1728 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1731 #if defined(JSON_HEDLEY_MALLOC)
1732 #undef JSON_HEDLEY_MALLOC
1735 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1736 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1737 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1738 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1739 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1740 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1741 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1742 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1743 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1744 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1745 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1746 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1747 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1748 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1749 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1750 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1751 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1752 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1753 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1754 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1755 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1757 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1758 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1759 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1761 #define JSON_HEDLEY_MALLOC
1764 #if defined(JSON_HEDLEY_PURE)
1765 #undef JSON_HEDLEY_PURE
1768 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1769 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1770 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1771 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1772 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1773 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1774 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1775 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1776 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1777 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1778 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1779 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1780 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1781 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1784 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1785 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1786 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1787 # define JSON_HEDLEY_PURE __attribute__((__pure__))
1788 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1789 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1790 #elif defined(__cplusplus) && \
1792 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1793 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1794 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1796 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1798 # define JSON_HEDLEY_PURE
1801 #if defined(JSON_HEDLEY_CONST)
1802 #undef JSON_HEDLEY_CONST
1805 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1806 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1807 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1808 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1809 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1810 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1811 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1812 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1813 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1814 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1815 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1816 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1817 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1818 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1819 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1820 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1821 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1822 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1823 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1824 #define JSON_HEDLEY_CONST __attribute__((__const__))
1826 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1827 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1829 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1832 #if defined(JSON_HEDLEY_RESTRICT)
1833 #undef JSON_HEDLEY_RESTRICT
1835 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1836 #define JSON_HEDLEY_RESTRICT restrict
1838 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1839 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1840 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1841 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1842 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1843 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1844 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1845 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1846 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1847 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1848 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1849 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1850 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1851 defined(__clang__) || \
1852 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1853 #define JSON_HEDLEY_RESTRICT __restrict
1854 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1855 #define JSON_HEDLEY_RESTRICT _Restrict
1857 #define JSON_HEDLEY_RESTRICT
1860 #if defined(JSON_HEDLEY_INLINE)
1861 #undef JSON_HEDLEY_INLINE
1864 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1865 (defined(__cplusplus) && (__cplusplus >= 199711L))
1866 #define JSON_HEDLEY_INLINE inline
1868 defined(JSON_HEDLEY_GCC_VERSION) || \
1869 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1870 #define JSON_HEDLEY_INLINE __inline__
1872 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1873 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1874 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1875 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1876 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1877 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1878 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1879 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1880 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1881 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1882 #define JSON_HEDLEY_INLINE __inline
1884 #define JSON_HEDLEY_INLINE
1887 #if defined(JSON_HEDLEY_ALWAYS_INLINE)
1888 #undef JSON_HEDLEY_ALWAYS_INLINE
1891 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1892 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1893 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1894 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1895 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1896 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1897 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1898 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1899 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1900 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1901 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1902 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1903 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1904 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1905 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1906 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1907 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1908 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1909 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1910 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1912 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1913 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1914 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1915 #elif defined(__cplusplus) && \
1917 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1918 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1919 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1920 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1921 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1922 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1924 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1925 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1926 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1928 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1931 #if defined(JSON_HEDLEY_NEVER_INLINE)
1932 #undef JSON_HEDLEY_NEVER_INLINE
1935 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1936 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1937 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1938 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1939 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1940 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1941 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1942 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1943 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1944 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1945 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1946 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1947 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1948 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1949 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1950 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1951 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1952 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1953 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1954 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1956 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1957 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1958 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1959 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1960 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1961 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1962 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1963 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1964 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1965 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1966 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1967 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1968 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1970 #define JSON_HEDLEY_NEVER_INLINE
1973 #if defined(JSON_HEDLEY_PRIVATE)
1974 #undef JSON_HEDLEY_PRIVATE
1976 #if defined(JSON_HEDLEY_PUBLIC)
1977 #undef JSON_HEDLEY_PUBLIC
1979 #if defined(JSON_HEDLEY_IMPORT)
1980 #undef JSON_HEDLEY_IMPORT
1982 #if defined(_WIN32) || defined(__CYGWIN__)
1983 # define JSON_HEDLEY_PRIVATE
1984 # define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1985 # define JSON_HEDLEY_IMPORT __declspec(dllimport)
1988 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1989 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1990 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1991 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1992 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1993 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1995 defined(__TI_EABI__) && \
1997 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1998 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2001 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2002 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2003 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2005 # define JSON_HEDLEY_PRIVATE
2006 # define JSON_HEDLEY_PUBLIC
2008 # define JSON_HEDLEY_IMPORT extern
2011 #if defined(JSON_HEDLEY_NO_THROW)
2012 #undef JSON_HEDLEY_NO_THROW
2015 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2016 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2017 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2018 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2019 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2021 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2022 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2023 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2024 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2026 #define JSON_HEDLEY_NO_THROW
2029 #if defined(JSON_HEDLEY_FALL_THROUGH)
2030 #undef JSON_HEDLEY_FALL_THROUGH
2033 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2034 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2035 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2036 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2037 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2038 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2039 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2040 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2041 #elif defined(__fallthrough)
2042 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2044 #define JSON_HEDLEY_FALL_THROUGH
2047 #if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2048 #undef JSON_HEDLEY_RETURNS_NON_NULL
2051 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2052 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2053 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2054 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2055 #elif defined(_Ret_notnull_)
2056 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2058 #define JSON_HEDLEY_RETURNS_NON_NULL
2061 #if defined(JSON_HEDLEY_ARRAY_PARAM)
2062 #undef JSON_HEDLEY_ARRAY_PARAM
2065 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2066 !defined(__STDC_NO_VLA__) && \
2067 !defined(__cplusplus) && \
2068 !defined(JSON_HEDLEY_PGI_VERSION) && \
2069 !defined(JSON_HEDLEY_TINYC_VERSION)
2070 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2072 #define JSON_HEDLEY_ARRAY_PARAM(name)
2075 #if defined(JSON_HEDLEY_IS_CONSTANT)
2076 #undef JSON_HEDLEY_IS_CONSTANT
2078 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2079 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2083 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2084 #undef JSON_HEDLEY_IS_CONSTEXPR_
2087 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2088 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2089 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2090 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2091 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2092 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2094 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2095 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2096 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2097 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2099 #if !defined(__cplusplus)
2101 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2102 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2103 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2104 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2105 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2106 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2107 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2108 #if defined(__INTPTR_TYPE__)
2109 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2112 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2116 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2117 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2118 !defined(JSON_HEDLEY_PGI_VERSION) && \
2119 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2120 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2121 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2122 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2123 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2124 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2125 #if defined(__INTPTR_TYPE__)
2126 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2129 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2132 defined(JSON_HEDLEY_GCC_VERSION) || \
2133 defined(JSON_HEDLEY_INTEL_VERSION) || \
2134 defined(JSON_HEDLEY_TINYC_VERSION) || \
2135 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2136 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2137 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2138 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2139 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2140 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2142 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2146 ((void*) ((expr) * 0L) ) : \
2147 ((struct { char v[sizeof(void) * 2]; } *) 1) \
2153 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2154 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2155 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2157 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2159 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2160 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2162 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2165 #if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2166 #undef JSON_HEDLEY_BEGIN_C_DECLS
2168 #if defined(JSON_HEDLEY_END_C_DECLS)
2169 #undef JSON_HEDLEY_END_C_DECLS
2171 #if defined(JSON_HEDLEY_C_DECL)
2172 #undef JSON_HEDLEY_C_DECL
2174 #if defined(__cplusplus)
2175 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2176 #define JSON_HEDLEY_END_C_DECLS }
2177 #define JSON_HEDLEY_C_DECL extern "C"
2179 #define JSON_HEDLEY_BEGIN_C_DECLS
2180 #define JSON_HEDLEY_END_C_DECLS
2181 #define JSON_HEDLEY_C_DECL
2184 #if defined(JSON_HEDLEY_STATIC_ASSERT)
2185 #undef JSON_HEDLEY_STATIC_ASSERT
2188 !defined(__cplusplus) && ( \
2189 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2190 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2191 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2192 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2193 defined(_Static_assert) \
2195 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2197 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2198 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2199 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2200 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2202 # define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2205 #if defined(JSON_HEDLEY_NULL)
2206 #undef JSON_HEDLEY_NULL
2208 #if defined(__cplusplus)
2209 #if __cplusplus >= 201103L
2210 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2212 #define JSON_HEDLEY_NULL NULL
2214 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2217 #define JSON_HEDLEY_NULL NULL
2219 #define JSON_HEDLEY_NULL ((void*) 0)
2222 #if defined(JSON_HEDLEY_MESSAGE)
2223 #undef JSON_HEDLEY_MESSAGE
2225 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2226 # define JSON_HEDLEY_MESSAGE(msg) \
2227 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2228 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2229 JSON_HEDLEY_PRAGMA(message msg) \
2230 JSON_HEDLEY_DIAGNOSTIC_POP
2232 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2233 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2234 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2235 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2236 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2237 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2238 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2239 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2240 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2242 # define JSON_HEDLEY_MESSAGE(msg)
2245 #if defined(JSON_HEDLEY_WARNING)
2246 #undef JSON_HEDLEY_WARNING
2248 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2249 # define JSON_HEDLEY_WARNING(msg) \
2250 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2251 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2252 JSON_HEDLEY_PRAGMA(clang warning msg) \
2253 JSON_HEDLEY_DIAGNOSTIC_POP
2255 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2256 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2257 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2258 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2260 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2261 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2262 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2264 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2267 #if defined(JSON_HEDLEY_REQUIRE)
2268 #undef JSON_HEDLEY_REQUIRE
2270 #if defined(JSON_HEDLEY_REQUIRE_MSG)
2271 #undef JSON_HEDLEY_REQUIRE_MSG
2273 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2274 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2275 # define JSON_HEDLEY_REQUIRE(expr) \
2276 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2277 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2278 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2279 JSON_HEDLEY_DIAGNOSTIC_POP
2280 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2281 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2282 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2283 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2284 JSON_HEDLEY_DIAGNOSTIC_POP
2286 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2287 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2290 # define JSON_HEDLEY_REQUIRE(expr)
2291 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2294 #if defined(JSON_HEDLEY_FLAGS)
2295 #undef JSON_HEDLEY_FLAGS
2297 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2298 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2300 #define JSON_HEDLEY_FLAGS
2303 #if defined(JSON_HEDLEY_FLAGS_CAST)
2304 #undef JSON_HEDLEY_FLAGS_CAST
2306 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2307 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2308 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2309 _Pragma("warning(disable:188)") \
2311 JSON_HEDLEY_DIAGNOSTIC_POP \
2314 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2317 #if defined(JSON_HEDLEY_EMPTY_BASES)
2318 #undef JSON_HEDLEY_EMPTY_BASES
2321 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2322 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2323 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2325 #define JSON_HEDLEY_EMPTY_BASES
2330 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2331 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2333 #if defined(__clang__)
2334 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2336 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2339 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2340 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2342 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2344 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2345 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2347 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2349 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2350 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2352 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2354 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2355 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2357 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2359 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2360 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2362 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2364 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2365 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2367 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2369 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2370 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2372 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2384 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2385 #if defined(__clang__)
2386 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2387 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2389 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2390 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2391 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2398 #if !defined(JSON_HAS_CPP_26) && !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2399 #if (defined(__cplusplus) && __cplusplus > 202302L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202302L)
2400 #define JSON_HAS_CPP_26
2401 #define JSON_HAS_CPP_23
2402 #define JSON_HAS_CPP_20
2403 #define JSON_HAS_CPP_17
2404 #define JSON_HAS_CPP_14
2405 #elif (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
2406 #define JSON_HAS_CPP_23
2407 #define JSON_HAS_CPP_20
2408 #define JSON_HAS_CPP_17
2409 #define JSON_HAS_CPP_14
2410 #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
2411 #define JSON_HAS_CPP_20
2412 #define JSON_HAS_CPP_17
2413 #define JSON_HAS_CPP_14
2414 #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2415 #define JSON_HAS_CPP_17
2416 #define JSON_HAS_CPP_14
2417 #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2418 #define JSON_HAS_CPP_14
2421 #define JSON_HAS_CPP_11
2424 #ifdef __has_include
2425 #if __has_include(<version>)
2430 #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2431 #ifdef JSON_HAS_CPP_17
2432 #if defined(__cpp_lib_filesystem)
2433 #define JSON_HAS_FILESYSTEM 1
2434 #elif defined(__cpp_lib_experimental_filesystem)
2435 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2436 #elif !defined(__has_include)
2437 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2438 #elif __has_include(<filesystem>)
2439 #define JSON_HAS_FILESYSTEM 1
2440 #elif __has_include(<experimental/filesystem>)
2441 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2445 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2446 #undef JSON_HAS_FILESYSTEM
2447 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2451 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2452 #undef JSON_HAS_FILESYSTEM
2453 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2457 #if defined(__clang_major__) && __clang_major__ < 7
2458 #undef JSON_HAS_FILESYSTEM
2459 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2463 #if defined(_MSC_VER) && _MSC_VER < 1914
2464 #undef JSON_HAS_FILESYSTEM
2465 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2469 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2470 #undef JSON_HAS_FILESYSTEM
2471 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2475 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2476 #undef JSON_HAS_FILESYSTEM
2477 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2482 #ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2483 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2486 #ifndef JSON_HAS_FILESYSTEM
2487 #define JSON_HAS_FILESYSTEM 0
2490 #ifndef JSON_HAS_THREE_WAY_COMPARISON
2491 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2492 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2493 #define JSON_HAS_THREE_WAY_COMPARISON 1
2495 #define JSON_HAS_THREE_WAY_COMPARISON 0
2499 #ifndef JSON_HAS_RANGES
2501 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2502 #define JSON_HAS_RANGES 0
2503 #elif defined(__cpp_lib_ranges)
2504 #define JSON_HAS_RANGES 1
2506 #define JSON_HAS_RANGES 0
2510 #ifndef JSON_HAS_STATIC_RTTI
2511 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2512 #define JSON_HAS_STATIC_RTTI 1
2514 #define JSON_HAS_STATIC_RTTI 0
2518 #ifdef JSON_HAS_CPP_17
2519 #define JSON_INLINE_VARIABLE inline
2521 #define JSON_INLINE_VARIABLE
2524 #if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2525 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2527 #define JSON_NO_UNIQUE_ADDRESS
2531 #if defined(__clang__)
2532 #pragma clang diagnostic push
2533 #pragma clang diagnostic ignored "-Wdocumentation"
2534 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2538 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2539 #define JSON_THROW(exception) throw exception
2540 #define JSON_TRY try
2541 #define JSON_CATCH(exception) catch(exception)
2542 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2545 #define JSON_THROW(exception) std::abort()
2546 #define JSON_TRY if(true)
2547 #define JSON_CATCH(exception) if(false)
2548 #define JSON_INTERNAL_CATCH(exception) if(false)
2552 #if defined(JSON_THROW_USER)
2554 #define JSON_THROW JSON_THROW_USER
2556 #if defined(JSON_TRY_USER)
2558 #define JSON_TRY JSON_TRY_USER
2560 #if defined(JSON_CATCH_USER)
2562 #define JSON_CATCH JSON_CATCH_USER
2563 #undef JSON_INTERNAL_CATCH
2564 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2566 #if defined(JSON_INTERNAL_CATCH_USER)
2567 #undef JSON_INTERNAL_CATCH
2568 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2572 #if !defined(JSON_ASSERT)
2574 #define JSON_ASSERT(x) assert(x)
2578 #if defined(JSON_TESTS_PRIVATE)
2579 #define JSON_PRIVATE_UNLESS_TESTED public
2581 #define JSON_PRIVATE_UNLESS_TESTED private
2589 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2590 template<typename BasicJsonType> \
2591 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2594 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2596 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2597 auto it = std::find_if(std::begin(m), std::end(m), \
2598 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2600 return ej_pair.first == e; \
2602 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2604 template<typename BasicJsonType> \
2605 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2608 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2610 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2611 auto it = std::find_if(std::begin(m), std::end(m), \
2612 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2614 return ej_pair.second == j; \
2616 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2622 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2623 template<template<typename, typename, typename...> class ObjectType, \
2624 template<typename, typename...> class ArrayType, \
2625 class StringType, class BooleanType, class NumberIntegerType, \
2626 class NumberUnsignedType, class NumberFloatType, \
2627 template<typename> class AllocatorType, \
2628 template<typename, typename = void> class JSONSerializer, \
2630 class CustomBaseClass>
2632 #define NLOHMANN_BASIC_JSON_TPL \
2633 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2634 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2635 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2639 #define NLOHMANN_JSON_EXPAND( x ) x
2640 #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
2641 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2642 NLOHMANN_JSON_PASTE64, \
2643 NLOHMANN_JSON_PASTE63, \
2644 NLOHMANN_JSON_PASTE62, \
2645 NLOHMANN_JSON_PASTE61, \
2646 NLOHMANN_JSON_PASTE60, \
2647 NLOHMANN_JSON_PASTE59, \
2648 NLOHMANN_JSON_PASTE58, \
2649 NLOHMANN_JSON_PASTE57, \
2650 NLOHMANN_JSON_PASTE56, \
2651 NLOHMANN_JSON_PASTE55, \
2652 NLOHMANN_JSON_PASTE54, \
2653 NLOHMANN_JSON_PASTE53, \
2654 NLOHMANN_JSON_PASTE52, \
2655 NLOHMANN_JSON_PASTE51, \
2656 NLOHMANN_JSON_PASTE50, \
2657 NLOHMANN_JSON_PASTE49, \
2658 NLOHMANN_JSON_PASTE48, \
2659 NLOHMANN_JSON_PASTE47, \
2660 NLOHMANN_JSON_PASTE46, \
2661 NLOHMANN_JSON_PASTE45, \
2662 NLOHMANN_JSON_PASTE44, \
2663 NLOHMANN_JSON_PASTE43, \
2664 NLOHMANN_JSON_PASTE42, \
2665 NLOHMANN_JSON_PASTE41, \
2666 NLOHMANN_JSON_PASTE40, \
2667 NLOHMANN_JSON_PASTE39, \
2668 NLOHMANN_JSON_PASTE38, \
2669 NLOHMANN_JSON_PASTE37, \
2670 NLOHMANN_JSON_PASTE36, \
2671 NLOHMANN_JSON_PASTE35, \
2672 NLOHMANN_JSON_PASTE34, \
2673 NLOHMANN_JSON_PASTE33, \
2674 NLOHMANN_JSON_PASTE32, \
2675 NLOHMANN_JSON_PASTE31, \
2676 NLOHMANN_JSON_PASTE30, \
2677 NLOHMANN_JSON_PASTE29, \
2678 NLOHMANN_JSON_PASTE28, \
2679 NLOHMANN_JSON_PASTE27, \
2680 NLOHMANN_JSON_PASTE26, \
2681 NLOHMANN_JSON_PASTE25, \
2682 NLOHMANN_JSON_PASTE24, \
2683 NLOHMANN_JSON_PASTE23, \
2684 NLOHMANN_JSON_PASTE22, \
2685 NLOHMANN_JSON_PASTE21, \
2686 NLOHMANN_JSON_PASTE20, \
2687 NLOHMANN_JSON_PASTE19, \
2688 NLOHMANN_JSON_PASTE18, \
2689 NLOHMANN_JSON_PASTE17, \
2690 NLOHMANN_JSON_PASTE16, \
2691 NLOHMANN_JSON_PASTE15, \
2692 NLOHMANN_JSON_PASTE14, \
2693 NLOHMANN_JSON_PASTE13, \
2694 NLOHMANN_JSON_PASTE12, \
2695 NLOHMANN_JSON_PASTE11, \
2696 NLOHMANN_JSON_PASTE10, \
2697 NLOHMANN_JSON_PASTE9, \
2698 NLOHMANN_JSON_PASTE8, \
2699 NLOHMANN_JSON_PASTE7, \
2700 NLOHMANN_JSON_PASTE6, \
2701 NLOHMANN_JSON_PASTE5, \
2702 NLOHMANN_JSON_PASTE4, \
2703 NLOHMANN_JSON_PASTE3, \
2704 NLOHMANN_JSON_PASTE2, \
2705 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2706 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2707 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2708 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2709 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2710 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2711 #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)
2712 #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)
2713 #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)
2714 #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)
2715 #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)
2716 #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)
2717 #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)
2718 #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)
2719 #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)
2720 #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)
2721 #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)
2722 #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)
2723 #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)
2724 #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)
2725 #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)
2726 #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)
2727 #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)
2728 #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)
2729 #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)
2730 #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)
2731 #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)
2732 #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)
2733 #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)
2734 #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)
2735 #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)
2736 #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)
2737 #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)
2738 #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)
2739 #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)
2740 #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)
2741 #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)
2742 #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)
2743 #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)
2744 #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)
2745 #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)
2746 #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)
2747 #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)
2748 #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)
2749 #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)
2750 #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)
2751 #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)
2752 #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)
2753 #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)
2754 #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)
2755 #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)
2756 #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)
2757 #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)
2758 #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)
2759 #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)
2760 #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)
2761 #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)
2762 #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)
2763 #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)
2764 #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)
2765 #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)
2766 #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)
2767 #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)
2768 #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)
2770 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2771 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2772 #define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
2780 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2781 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2782 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2783 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2784 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2792 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2793 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2794 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2795 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2796 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2804 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2805 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2806 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2814 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2815 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2816 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2817 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2818 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2826 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2827 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2828 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2829 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2830 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2838 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2839 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2840 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2848 #define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2849 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2850 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2851 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2852 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2860 #define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2861 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2862 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2863 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2864 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2872 #define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2873 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2874 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2882 #define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2883 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2884 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2885 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2886 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2894 #define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2895 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2896 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2897 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2898 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2906 #define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2907 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2908 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2916 #define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2917 namespace detail { \
2918 using std::std_name; \
2920 template<typename... T> \
2921 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2924 namespace detail2 { \
2925 struct std_name##_tag \
2929 template<typename... T> \
2930 std_name##_tag std_name(T&&...); \
2932 template<typename... T> \
2933 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2935 template<typename... T> \
2936 struct would_call_std_##std_name \
2938 static constexpr auto const value = ::nlohmann::detail:: \
2939 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2943 template<typename... T> \
2944 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2948 #ifndef JSON_USE_IMPLICIT_CONVERSIONS
2949 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2952 #if JSON_USE_IMPLICIT_CONVERSIONS
2953 #define JSON_EXPLICIT
2955 #define JSON_EXPLICIT explicit
2958 #ifndef JSON_DISABLE_ENUM_SERIALIZATION
2959 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2962 #ifndef JSON_USE_GLOBAL_UDLS
2963 #define JSON_USE_GLOBAL_UDLS 1
2966 #if JSON_HAS_THREE_WAY_COMPARISON
3029 #if JSON_HAS_THREE_WAY_COMPARISON
3030 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs) noexcept
3035 static constexpr std::array<std::uint8_t, 9> order = {{
3042 const auto l_index =
static_cast<std::size_t
>(lhs);
3043 const auto r_index =
static_cast<std::size_t
>(rhs);
3044 #if JSON_HAS_THREE_WAY_COMPARISON
3045 if (l_index < order.size() && r_index < order.size())
3047 return order[l_index] <=> order[r_index];
3049 return std::partial_ordering::unordered;
3051 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3059 #if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
3062 return std::is_lt(lhs <=> rhs);
3100 template<
typename StringType>
3102 const StringType& t)
3105 for (
auto pos = s.find(f);
3106 pos != StringType::npos;
3107 s.replace(
pos, f.size(), t),
3108 pos = s.find(f,
pos + t.size()))
3119 template<
typename StringType>
3134 template<
typename StringType>
3175 constexpr
operator size_t()
const
3200 #include <type_traits>
3210 template<
typename T>
3213 #ifdef JSON_HAS_CPP_14
3224 template<
bool B,
typename T =
void>
3251 template <
typename T, T... Ints>
3255 static constexpr std::size_t
size() noexcept
3257 return sizeof...(Ints);
3266 template <
size_t... Ints>
3269 namespace utility_internal
3272 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3276 template <
typename T, T... Ints,
size_t SeqSize>
3282 template <
typename T, T... Ints,
size_t SeqSize>
3290 template <
typename T,
size_t N>
3297 template <
typename T>
3312 template <
typename T, T N>
3328 template <
typename... Ts>
3340 template<
typename T>
3346 #ifndef JSON_HAS_CPP_17
3347 template<
typename T>
3351 template<
typename T,
typename... Args>
3352 constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3354 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3374 #include <type_traits>
3376 #if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3403 template<
typename It,
typename =
void>
3406 template<
typename It>
3410 typename It::reference, typename It::iterator_category >>
3421 template<
typename T,
typename =
void>
3426 template<
typename T>
3432 template<
typename T>
3500 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3501 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3526 template<
typename T =
void,
typename SFINAE =
void>
3531 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3533 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3534 class StringType = std::string,
class BooleanType = bool,
3537 class NumberFloatType = double,
3538 template<
typename U>
class AllocatorType = std::allocator,
3539 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3541 class BinaryType = std::vector<std::uint8_t>,
3542 class CustomBaseClass =
void>
3547 template<
typename RefStringType>
3558 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3603 template<
typename BasicJsonContext>
3605 std::integral_constant < bool,
3606 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3607 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3620 template<
typename T>
3627 template<
typename T>
3630 template<
typename T>
3633 template<
typename T>
3636 template<
typename T>
3639 template<
typename T>
3642 template<
typename T>
3645 template<
typename T>
3648 template<
typename T,
typename... Args>
3651 template<
typename T,
typename... Args>
3654 template<
typename T,
typename U>
3658 template<
typename BasicJsonType,
typename T,
typename =
void>
3665 template <
typename BasicJsonType,
typename T>
3671 template<
typename BasicJsonType,
typename T>
3674 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3678 const BasicJsonType&, T&>::value;
3683 template<
typename BasicJsonType,
typename T,
typename =
void>
3686 template<
typename BasicJsonType,
typename T>
3689 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3693 const BasicJsonType&>::value;
3698 template<
typename BasicJsonType,
typename T,
typename =
void>
3701 template<
typename BasicJsonType,
typename T>
3704 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3711 template<
typename T>
3714 template<
typename T>
3715 struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3718 template<
typename BasicJsonType>
3727 template<
typename BasicJsonType>
3735 template<
typename T>
3759 return static_cast<int_type>(std::char_traits<char>::eof());
3783 return static_cast<int_type>(std::char_traits<char>::eof());
3787 #if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3789 struct char_traits<
std::byte> : std::char_traits<char>
3791 using char_type = std::byte;
3794 static int_type to_int_type(char_type c) noexcept
3796 return static_cast<int_type
>(std::to_integer<unsigned char>(c));
3799 static char_type to_char_type(int_type i) noexcept
3801 return std::byte(
static_cast<unsigned char>(i));
3804 static constexpr int_type eof() noexcept
3806 return static_cast<int_type
>(std::char_traits<char>::eof());
3818 template<
class B,
class... Bn>
3820 : std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>
::type {};
3823 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3828 template <
typename T>
3831 template <
typename T1,
typename T2>
3833 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3835 template <
typename T1,
typename T2>
3837 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3839 template <
typename... Ts>
3841 :
conjunction<is_default_constructible<Ts>...> {};
3843 template <
typename... Ts>
3845 :
conjunction<is_default_constructible<Ts>...> {};
3847 template <
typename T,
typename... Args>
3850 template <
typename T1,
typename T2>
3853 template <
typename T1,
typename T2>
3856 template <
typename... Ts>
3859 template <
typename... Ts>
3862 template<
typename T,
typename =
void>
3865 template<
typename T>
3880 template<
typename T>
3899 template<
typename R>
3902 template<
typename T>
3909 template<
typename T,
typename =
void>
3912 template<
typename T>
3915 template<
typename BasicJsonType,
typename CompatibleObjectType,
3919 template<
typename BasicJsonType,
typename CompatibleObjectType>
3921 BasicJsonType, CompatibleObjectType,
3930 typename CompatibleObjectType::key_type>::value &&
3932 typename CompatibleObjectType::mapped_type>::value;
3935 template<
typename BasicJsonType,
typename CompatibleObjectType>
3939 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3943 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3945 BasicJsonType, ConstructibleObjectType,
3956 typename object_t::key_type>::value &&
3958 typename object_t::mapped_type,
3959 typename ConstructibleObjectType::mapped_type >::value)) ||
3961 typename ConstructibleObjectType::mapped_type>::value ||
3964 typename ConstructibleObjectType::mapped_type >::value);
3967 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3970 ConstructibleObjectType> {};
3972 template<
typename BasicJsonType,
typename CompatibleStringType>
3979 template<
typename BasicJsonType,
typename ConstructibleStringType>
3983 #ifdef __INTEL_COMPILER
3984 using laundered_type = decltype(std::declval<ConstructibleStringType>());
3996 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3999 template<
typename BasicJsonType,
typename CompatibleArrayType>
4001 BasicJsonType, CompatibleArrayType,
4007 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
4014 template<
typename BasicJsonType,
typename CompatibleArrayType>
4018 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
4021 template<
typename BasicJsonType,
typename ConstructibleArrayType>
4023 BasicJsonType, ConstructibleArrayType,
4025 typename BasicJsonType::value_type>
::value >>
4026 : std::true_type {};
4028 template<
typename BasicJsonType,
typename ConstructibleArrayType>
4030 BasicJsonType, ConstructibleArrayType,
4032 typename BasicJsonType::value_type>
::value&&
4035 (std::is_move_assignable<ConstructibleArrayType>::value ||
4036 std::is_copy_assignable<ConstructibleArrayType>::value)&&
4042 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
4044 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
4050 typename BasicJsonType::array_t::value_type>::value ||
4058 template<
typename BasicJsonType,
typename ConstructibleArrayType>
4062 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
4066 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4068 RealIntegerType, CompatibleNumberIntegerType,
4070 std::is_integral<CompatibleNumberIntegerType>
::value&&
4071 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
4079 CompatibleNumberIntegerType>::value &&
4080 CompatibleLimits::is_integer &&
4081 RealLimits::is_signed == CompatibleLimits::is_signed;
4084 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4087 CompatibleNumberIntegerType> {};
4089 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
4092 template<
typename BasicJsonType,
typename CompatibleType>
4094 BasicJsonType, CompatibleType,
4101 template<
typename BasicJsonType,
typename CompatibleType>
4105 template<
typename T1,
typename T2>
4108 template<
typename T1,
typename... Args>
4111 template<
typename BasicJsonType,
typename T>
4114 template<
typename BasicJsonType>
4117 template<
typename BasicJsonType>
4122 template<
template <
typename...>
class Primary,
typename T>
4125 template<
template <
typename...>
class Primary,
typename... Args>
4128 template<
typename T>
4132 template<
typename Compare,
typename A,
typename B,
typename =
void>
4135 template<
typename Compare,
typename A,
typename B>
4137 decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4138 decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4139 >> : std::true_type {};
4141 template<
typename T>
4146 template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4150 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4151 ObjectKeyType>::value)
4152 && (!RequireTransparentComparator
4164 template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4168 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4169 RequireTransparentComparator, ExcludeObjectKeyType>::value
4174 template<
typename ObjectType,
typename KeyType>
4178 template<
typename BasicJsonType,
typename KeyType>
4182 typename BasicJsonType::object_t, KeyType >::value,
4188 template <
typename T>
4198 template <
typename C>
static one test( decltype(&C::capacity) ) ;
4201 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
4208 return static_cast<T
>(
value);
4217 template<
typename... Types>
4220 template<
typename... Types>
4223 template<
typename... Types>
4227 template<
typename... Types>
4231 template<
typename OfType,
typename T>
4236 template<
typename OfType,
typename T,
4241 template<
typename OfType,
typename T>
4247 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4251 template<
typename OfType,
typename T>
4257 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4261 template<
typename OfType,
typename T>
4267 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4271 template<
typename OfType,
typename T>
4277 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4278 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4282 template<
typename OfType,
typename T,
4287 template<
typename OfType,
typename T>
4296 template<
typename OfType,
typename T>
4305 template<
typename OfType,
typename T>
4311 template<
bool Value>
4321 template<
typename T>
4336 template<
typename T>
4339 template<
typename T>
4349 template<
typename T>
4358 template<
typename T>
4395 template<
typename... Args>
4396 inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4398 template<
typename StringType,
typename... Args>
4399 inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4401 template<
typename... Args>
4407 template<
typename... Args>
4414 template<
typename StringType,
typename... Args>
4420 template<
typename OutStringType>
4424 template<
typename StringType,
typename Arg>
4427 template<
typename StringType,
typename Arg>
4430 template<
typename StringType,
typename Arg>
4433 template<
typename StringType,
typename Arg>
4436 template<
typename StringType,
typename Arg>
4437 using string_can_append_iter = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4439 template<
typename StringType,
typename Arg>
4442 template<
typename StringType,
typename Arg>
4443 using string_can_append_data = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4445 template<
typename StringType,
typename Arg>
4448 template <
typename OutStringType,
typename Arg,
typename... Args,
4451 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4453 template <
typename OutStringType,
typename Arg,
typename... Args,
4457 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4459 template <
typename OutStringType,
typename Arg,
typename... Args,
4464 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4466 template<
typename OutStringType,
typename Arg,
typename... Args,
4468 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4470 out.append(std::forward<Arg>(arg));
4474 template <
typename OutStringType,
typename Arg,
typename... Args,
4477 inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4479 out += std::forward<Arg>(arg);
4483 template <
typename OutStringType,
typename Arg,
typename... Args,
4487 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4489 out.append(arg.begin(), arg.end());
4493 template <
typename OutStringType,
typename Arg,
typename... Args,
4498 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4500 out.append(arg.data(), arg.size());
4504 template<
typename OutStringType = std::string,
typename... Args>
4505 inline OutStringType
concat(Args && ... args)
4524 #if defined(__clang__)
4525 #pragma clang diagnostic push
4526 #pragma clang diagnostic ignored "-Wweak-vtables"
4555 static std::string
name(
const std::string& ename,
int id_)
4565 template<
typename BasicJsonType>
4568 #if JSON_DIAGNOSTICS
4569 std::vector<std::string> tokens;
4570 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4572 switch (current->m_parent->type())
4576 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4578 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4589 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4591 if (&element.second == current)
4593 tokens.emplace_back(element.first.c_str());
4618 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4619 [](
const std::string &
a,
const std::string & b)
4621 return concat(a,
'/', detail::escape(b));
4632 std::runtime_error
m;
4633 #if JSON_DIAGNOSTIC_POSITIONS
4634 template<
typename BasicJsonType>
4637 if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
4644 template<
typename BasicJsonType>
4647 static_cast<void>(leaf_element);
4672 return {id_,
pos.chars_read_total, w.c_str()};
4676 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4681 return {id_, byte_, w.c_str()};
4715 return {id_, w.c_str()};
4733 return {id_, w.c_str()};
4750 return {id_, w.c_str()};
4767 return {id_, w.c_str()};
4778 #if defined(__clang__)
4779 #pragma clang diagnostic pop
4824 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4825 #include <experimental/filesystem>
4829 namespace std_fs = std::experimental::filesystem;
4832 #elif JSON_HAS_FILESYSTEM
4833 #include <filesystem>
4837 namespace std_fs = std::filesystem;
4850 #ifdef JSON_HAS_CPP_17
4854 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4855 #include <string_view>
4862 template<
typename BasicJsonType>
4863 inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4872 #ifdef JSON_HAS_CPP_17
4873 template<
typename BasicJsonType,
typename T>
4874 void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4882 opt.emplace(j.template get<T>());
4888 template <
typename BasicJsonType,
typename ArithmeticType,
4894 switch (
static_cast<value_t>(j))
4898 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4903 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4908 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4924 template<
typename BasicJsonType>
4925 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4931 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4934 template<
typename BasicJsonType>
4941 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4945 typename BasicJsonType,
typename StringType,
4951 inline void from_json(
const BasicJsonType& j, StringType& s)
4958 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4961 template<
typename BasicJsonType>
4962 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4967 template<
typename BasicJsonType>
4968 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4973 template<
typename BasicJsonType>
4974 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4979 #if !JSON_DISABLE_ENUM_SERIALIZATION
4980 template<
typename BasicJsonType,
typename EnumType,
4986 e =
static_cast<EnumType
>(val);
4991 template<
typename BasicJsonType,
typename T,
typename Allocator,
4993 inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
5000 std::transform(j.rbegin(), j.rend(),
5001 std::front_inserter(l), [](
const BasicJsonType & i)
5003 return i.template get<T>();
5008 template<
typename BasicJsonType,
typename T,
5010 inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
5017 std::transform(j.begin(), j.end(), std::begin(l),
5018 [](
const BasicJsonType & elem)
5020 return elem.template get<T>();
5024 template<
typename BasicJsonType,
typename T, std::
size_t N>
5026 -> decltype(j.template get<T>(),
void())
5028 for (std::size_t i = 0; i <
N; ++i)
5030 arr[i] = j.at(i).template get<T>();
5034 template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2>
5036 -> decltype(j.template get<T>(),
void())
5038 for (std::size_t i1 = 0; i1 < N1; ++i1)
5040 for (std::size_t i2 = 0; i2 < N2; ++i2)
5042 arr[i1][i2] = j.at(i1).at(i2).template get<T>();
5047 template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3>
5048 auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3])
5049 -> decltype(j.template get<T>(),
void())
5051 for (std::size_t i1 = 0; i1 < N1; ++i1)
5053 for (std::size_t i2 = 0; i2 < N2; ++i2)
5055 for (std::size_t i3 = 0; i3 < N3; ++i3)
5057 arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template get<T>();
5063 template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3, std::
size_t N4>
5064 auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3][N4])
5065 -> decltype(j.template get<T>(),
void())
5067 for (std::size_t i1 = 0; i1 < N1; ++i1)
5069 for (std::size_t i2 = 0; i2 < N2; ++i2)
5071 for (std::size_t i3 = 0; i3 < N3; ++i3)
5073 for (std::size_t i4 = 0; i4 < N4; ++i4)
5075 arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template get<T>();
5082 template<
typename BasicJsonType>
5085 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
5088 template<
typename BasicJsonType,
typename T, std::
size_t N>
5091 -> decltype(j.template get<T>(),
void())
5093 for (std::size_t i = 0; i <
N; ++i)
5095 arr[i] = j.at(i).template get<T>();
5099 template<
typename BasicJsonType,
typename ConstructibleArrayType,
5105 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
5106 j.template get<typename ConstructibleArrayType::value_type>(),
5111 ConstructibleArrayType ret;
5112 ret.reserve(j.size());
5113 std::transform(j.begin(), j.end(),
5114 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
5118 return i.template get<typename ConstructibleArrayType::value_type>();
5120 arr = std::move(ret);
5123 template<
typename BasicJsonType,
typename ConstructibleArrayType,
5132 ConstructibleArrayType ret;
5134 j.begin(), j.end(), std::inserter(ret, end(ret)),
5135 [](
const BasicJsonType & i)
5139 return i.template get<typename ConstructibleArrayType::value_type>();
5141 arr = std::move(ret);
5144 template <
typename BasicJsonType,
typename ConstructibleArrayType,
5152 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
5154 j.template get<typename ConstructibleArrayType::value_type>(),
5165 template <
typename BasicJsonType,
typename T, std::size_t... Idx >
5169 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
5172 template <
typename BasicJsonType,
typename T, std::
size_t N >
5184 template<
typename BasicJsonType>
5185 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
5192 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5195 template<
typename BasicJsonType,
typename ConstructibleObjectType,
5197 inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5204 ConstructibleObjectType ret;
5205 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5206 using value_type =
typename ConstructibleObjectType::value_type;
5208 inner_object->begin(), inner_object->end(),
5209 std::inserter(ret, ret.begin()),
5210 [](
typename BasicJsonType::object_t::value_type
const & p)
5212 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5214 obj = std::move(ret);
5221 template <
typename BasicJsonType,
typename ArithmeticType,
5229 inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5231 switch (
static_cast<value_t>(j))
5235 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5240 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5245 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5250 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5265 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5268 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5271 template<
typename BasicJsonType>
5277 template <
typename BasicJsonType,
class A1,
class A2 >
5280 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
5281 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
5284 template<
typename BasicJsonType,
typename A1,
typename A2>
5290 template<
typename BasicJsonType,
typename... Args>
5296 template<
typename BasicJsonType,
typename... Args>
5302 template<
typename BasicJsonType,
typename TupleRelated>
5311 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5314 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5317 inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5324 for (
const auto& p : j)
5330 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5334 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5337 inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5344 for (
const auto& p : j)
5350 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5354 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5355 template<
typename BasicJsonType>
5356 inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5362 const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5366 #if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
5367 p = std_fs::path(std::u8string_view(
reinterpret_cast<const char8_t*
>(s.data()), s.size()));
5369 p = std_fs::u8path(s);
5376 template<
typename BasicJsonType,
typename T>
5378 noexcept(noexcept(
from_json(j, std::forward<T>(val))))
5379 -> decltype(
from_json(j, std::forward<T>(val)))
5381 return from_json(j, std::forward<T>(val));
5387 #ifndef JSON_HAS_CPP_17
5396 #ifndef JSON_HAS_CPP_17
5415 #ifdef JSON_HAS_CPP_17
5419 #include <algorithm>
5424 #include <type_traits>
5474 template<
typename StringType>
5482 template<
typename StringType>
5508 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::
type >::
type;
5525 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5535 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5538 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5582 switch (
anchor.m_object->type())
5614 typename IteratorType::reference
value()
const
5656 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5664 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5680 #if defined(__clang__)
5682 #pragma clang diagnostic push
5683 #pragma clang diagnostic ignored "-Wmismatched-tags"
5685 template<
typename IteratorType>
5687 :
public std::integral_constant<std::size_t, 2> {};
5689 template<std::
size_t N,
typename IteratorType>
5694 get<N>(std::declval <
5697 #if defined(__clang__)
5698 #pragma clang diagnostic pop
5704 template <
typename IteratorType>
5705 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5737 template<
typename BasicJsonType>
5738 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b) noexcept
5740 j.m_data.m_value.destroy(j.m_data.m_type);
5742 j.m_data.m_value = b;
5743 j.assert_invariant();
5750 template<
typename BasicJsonType>
5753 j.m_data.m_value.destroy(j.m_data.m_type);
5755 j.m_data.m_value = s;
5756 j.assert_invariant();
5759 template<
typename BasicJsonType>
5762 j.m_data.m_value.destroy(j.m_data.m_type);
5764 j.m_data.m_value = std::move(s);
5765 j.assert_invariant();
5768 template <
typename BasicJsonType,
typename CompatibleStringType,
5771 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5773 j.m_data.m_value.destroy(j.m_data.m_type);
5775 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5776 j.assert_invariant();
5783 template<
typename BasicJsonType>
5784 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5786 j.m_data.m_value.destroy(j.m_data.m_type);
5788 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5789 j.assert_invariant();
5792 template<
typename BasicJsonType>
5793 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5795 j.m_data.m_value.destroy(j.m_data.m_type);
5797 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5798 j.assert_invariant();
5805 template<
typename BasicJsonType>
5806 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val) noexcept
5808 j.m_data.m_value.destroy(j.m_data.m_type);
5810 j.m_data.m_value = val;
5811 j.assert_invariant();
5818 template<
typename BasicJsonType>
5819 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val) noexcept
5821 j.m_data.m_value.destroy(j.m_data.m_type);
5823 j.m_data.m_value = val;
5824 j.assert_invariant();
5831 template<
typename BasicJsonType>
5832 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val) noexcept
5834 j.m_data.m_value.destroy(j.m_data.m_type);
5836 j.m_data.m_value = val;
5837 j.assert_invariant();
5844 template<
typename BasicJsonType>
5845 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5847 j.m_data.m_value.destroy(j.m_data.m_type);
5849 j.m_data.m_value = arr;
5851 j.assert_invariant();
5854 template<
typename BasicJsonType>
5855 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5857 j.m_data.m_value.destroy(j.m_data.m_type);
5859 j.m_data.m_value = std::move(arr);
5861 j.assert_invariant();
5864 template <
typename BasicJsonType,
typename CompatibleArrayType,
5867 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5872 j.m_data.m_value.destroy(j.m_data.m_type);
5874 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5876 j.assert_invariant();
5879 template<
typename BasicJsonType>
5880 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5882 j.m_data.m_value.destroy(j.m_data.m_type);
5885 j.m_data.m_value.array->reserve(arr.size());
5886 for (
const bool x : arr)
5888 j.m_data.m_value.array->push_back(x);
5889 j.set_parent(j.m_data.m_value.array->back());
5891 j.assert_invariant();
5894 template<
typename BasicJsonType,
typename T,
5896 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5898 j.m_data.m_value.destroy(j.m_data.m_type);
5901 j.m_data.m_value.array->resize(arr.size());
5904 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5907 j.assert_invariant();
5914 template<
typename BasicJsonType>
5915 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5917 j.m_data.m_value.destroy(j.m_data.m_type);
5919 j.m_data.m_value = obj;
5921 j.assert_invariant();
5924 template<
typename BasicJsonType>
5925 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5927 j.m_data.m_value.destroy(j.m_data.m_type);
5929 j.m_data.m_value = std::move(obj);
5931 j.assert_invariant();
5934 template <
typename BasicJsonType,
typename CompatibleObjectType,
5936 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5941 j.m_data.m_value.destroy(j.m_data.m_type);
5943 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5945 j.assert_invariant();
5953 #ifdef JSON_HAS_CPP_17
5954 template<
typename BasicJsonType,
typename T,
5956 void to_json(BasicJsonType& j,
const std::optional<T>& opt) noexcept
5958 if (opt.has_value())
5969 template<
typename BasicJsonType,
typename T,
5971 inline void to_json(BasicJsonType& j, T b) noexcept
5976 template <
typename BasicJsonType,
typename BoolRef,
5978 ((std::is_same<std::vector<bool>::reference, BoolRef>::value
5979 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>::value)
5980 || (std::is_same<std::vector<bool>::const_reference, BoolRef>::value
5982 typename BasicJsonType::boolean_t >::value))
5984 inline void to_json(BasicJsonType& j,
const BoolRef& b) noexcept
5989 template<
typename BasicJsonType,
typename CompatibleString,
5991 inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5996 template<
typename BasicJsonType>
6002 template<
typename BasicJsonType,
typename FloatType,
6004 inline void to_json(BasicJsonType& j, FloatType val) noexcept
6009 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
6011 inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
6016 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
6018 inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
6023 #if !JSON_DISABLE_ENUM_SERIALIZATION
6024 template<
typename BasicJsonType,
typename EnumType,
6026 inline void to_json(BasicJsonType& j, EnumType e) noexcept
6034 template<
typename BasicJsonType>
6035 inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
6040 template <
typename BasicJsonType,
typename CompatibleArrayType,
6041 enable_if_t < is_compatible_array_type<BasicJsonType,
6042 CompatibleArrayType>::value&&
6048 inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
6053 template<
typename BasicJsonType>
6054 inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
6059 template<
typename BasicJsonType,
typename T,
6061 inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
6066 template<
typename BasicJsonType>
6067 inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
6072 template <
typename BasicJsonType,
typename CompatibleObjectType,
6074 inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
6079 template<
typename BasicJsonType>
6080 inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6086 typename BasicJsonType,
typename T, std::size_t
N,
6088 const T(&)[
N]>::value,
6090 inline void to_json(BasicJsonType& j,
const T(&arr)[
N])
6096 inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
6098 j = { p.first, p.second };
6102 template<
typename BasicJsonType,
typename T,
6103 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
6106 j = { {b.key(), b.value()} };
6109 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
6112 j = { std::get<Idx>(t)... };
6115 template<
typename BasicJsonType,
typename Tuple>
6118 using array_t =
typename BasicJsonType::array_t;
6123 inline void to_json(BasicJsonType& j,
const T& t)
6128 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
6129 #if defined(__cpp_lib_char8_t)
6130 template<
typename BasicJsonType,
typename Tr,
typename Allocator>
6131 inline void to_json(BasicJsonType& j,
const std::basic_string<char8_t, Tr, Allocator>& s)
6133 using OtherAllocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<char>;
6134 j = std::basic_string<char, std::char_traits<char>, OtherAllocator>(s.begin(), s.end(), s.get_allocator());
6138 template<
typename BasicJsonType>
6139 inline void to_json(BasicJsonType& j,
const std_fs::path& p)
6149 template<
typename BasicJsonType,
typename T>
6150 auto operator()(BasicJsonType& j, T&& val)
const noexcept(noexcept(
to_json(j, std::forward<T>(val))))
6151 -> decltype(
to_json(j, std::forward<T>(val)),
void())
6153 return to_json(j, std::forward<T>(val));
6158 #ifndef JSON_HAS_CPP_17
6167 #ifndef JSON_HAS_CPP_17
6179 template<
typename ValueType,
typename>
6184 template<
typename BasicJsonType,
typename TargetType = ValueType>
6185 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
6194 template<
typename BasicJsonType,
typename TargetType = ValueType>
6204 template<
typename BasicJsonType,
typename TargetType = ValueType>
6205 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
6237 template<
typename BinaryType>
6281 return !(rhs == *
this);
6340 #include <functional>
6352 inline std::size_t
combine(std::size_t seed, std::size_t h) noexcept
6354 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6369 template<
typename BasicJsonType>
6370 std::size_t
hash(
const BasicJsonType& j)
6373 using number_integer_t =
typename BasicJsonType::number_integer_t;
6374 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6375 using number_float_t =
typename BasicJsonType::number_float_t;
6377 const auto type =
static_cast<std::size_t
>(j.type());
6380 case BasicJsonType::value_t::null:
6381 case BasicJsonType::value_t::discarded:
6386 case BasicJsonType::value_t::object:
6389 for (
const auto& element : j.items())
6391 const auto h = std::hash<string_t> {}(element.key());
6398 case BasicJsonType::value_t::array:
6401 for (
const auto& element : j)
6408 case BasicJsonType::value_t::string:
6410 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6414 case BasicJsonType::value_t::boolean:
6416 const auto h = std::hash<bool> {}(j.template get<bool>());
6420 case BasicJsonType::value_t::number_integer:
6422 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6426 case BasicJsonType::value_t::number_unsigned:
6428 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6432 case BasicJsonType::value_t::number_float:
6434 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6438 case BasicJsonType::value_t::binary:
6441 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6443 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6444 for (
const auto byte : j.get_binary())
6446 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6471 #include <algorithm>
6483 #ifdef __cpp_lib_byteswap
6506 #include <streambuf>
6508 #include <type_traits>
6562 return std::fgetc(
m_file);
6569 return fread(dest, 1,
sizeof(T) * count,
m_file);
6597 is->clear(
is->rdstate() & std::ios::eofbit);
6602 :
is(&i),
sb(i.rdbuf())
6611 :
is(rhs.is),
sb(rhs.sb)
6622 auto res =
sb->sbumpc();
6626 is->clear(
is->rdstate() | std::ios::eofbit);
6634 auto res =
static_cast<std::size_t
>(
sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(count *
sizeof(T))));
6637 is->clear(
is->rdstate() | std::ios::eofbit);
6644 std::istream*
is =
nullptr;
6645 std::streambuf*
sb =
nullptr;
6651 template<
typename IteratorType>
6655 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6677 auto* ptr =
reinterpret_cast<char*
>(dest);
6678 for (std::size_t read_index = 0; read_index < count *
sizeof(T); ++read_index)
6682 ptr[read_index] =
static_cast<char>(*current);
6690 return count *
sizeof(T);
6697 template<
typename BaseInputAdapter,
size_t T>
6706 template<
typename BaseInputAdapter,
size_t T>
6709 template<
typename BaseInputAdapter>
6714 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6715 size_t& utf8_bytes_index,
6716 size_t& utf8_bytes_filled)
6718 utf8_bytes_index = 0;
6722 utf8_bytes[0] = std::char_traits<char>::eof();
6723 utf8_bytes_filled = 1;
6728 const auto wc = input.get_character();
6733 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6734 utf8_bytes_filled = 1;
6736 else if (wc <= 0x7FF)
6738 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6739 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6740 utf8_bytes_filled = 2;
6742 else if (wc <= 0xFFFF)
6744 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6745 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6746 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6747 utf8_bytes_filled = 3;
6749 else if (wc <= 0x10FFFF)
6751 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6752 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6753 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6754 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6755 utf8_bytes_filled = 4;
6760 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6761 utf8_bytes_filled = 1;
6767 template<
typename BaseInputAdapter>
6772 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6773 size_t& utf8_bytes_index,
6774 size_t& utf8_bytes_filled)
6776 utf8_bytes_index = 0;
6780 utf8_bytes[0] = std::char_traits<char>::eof();
6781 utf8_bytes_filled = 1;
6786 const auto wc = input.get_character();
6791 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6792 utf8_bytes_filled = 1;
6794 else if (wc <= 0x7FF)
6796 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6797 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6798 utf8_bytes_filled = 2;
6800 else if (0xD800 > wc || wc >= 0xE000)
6802 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6803 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6804 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6805 utf8_bytes_filled = 3;
6811 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6812 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6813 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6814 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6815 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6816 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6817 utf8_bytes_filled = 4;
6821 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6822 utf8_bytes_filled = 1;
6830 template<
typename BaseInputAdapter,
typename W
ideCharType>
6844 fill_buffer<sizeof(WideCharType)>();
6873 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
6881 template<
typename IteratorType,
typename Enable =
void>
6885 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6890 return adapter_type(std::move(first), std::move(last));
6894 template<
typename T>
6904 template<
typename IteratorType>
6908 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6919 template<
typename IteratorType>
6923 return factory_type::create(first, last);
6930 namespace container_input_adapter_factory_impl
6936 template<
typename ContainerType,
typename Enable =
void>
6939 template<
typename ContainerType>
6941 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6953 template<
typename ContainerType>
6966 if (file ==
nullptr)
6968 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
6987 template <
typename CharT,
6988 typename std::enable_if <
6998 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
7000 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
7001 const auto* ptr =
reinterpret_cast<const char*
>(b);
7005 template<
typename T, std::
size_t N>
7017 template <
typename CharT,
7018 typename std::enable_if <
7024 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
7026 template<
class IteratorType,
7027 typename std::enable_if<
7028 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
7035 return std::move(ia);
7058 #include <type_traits>
7080 #include <initializer_list>
7102 template<
typename BasicJsonType>
7136 return "<uninitialized>";
7138 return "true literal";
7140 return "false literal";
7142 return "null literal";
7144 return "string literal";
7148 return "number literal";
7162 return "<parse error>";
7164 return "end of input";
7166 return "'[', '{', or a literal";
7169 return "unknown token";
7179 template<
typename BasicJsonType,
typename InputAdapterType>
7192 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7193 :
ia(
std::move(adapter))
7214 const auto* loc = localeconv();
7216 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7244 const auto factors = { 12u, 8u, 4u, 0u };
7245 for (
const auto factor : factors)
7251 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
7255 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
7259 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
7267 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7288 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7291 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7340 return token_type::parse_error;
7346 return token_type::value_string;
7391 int codepoint = codepoint1;
7395 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7396 return token_type::parse_error;
7400 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7409 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7410 return token_type::parse_error;
7417 codepoint =
static_cast<int>(
7419 (
static_cast<unsigned int>(codepoint1) << 10u)
7421 +
static_cast<unsigned int>(codepoint2)
7429 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7430 return token_type::parse_error;
7435 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7436 return token_type::parse_error;
7443 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7444 return token_type::parse_error;
7449 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7452 if (codepoint < 0x80)
7457 else if (codepoint <= 0x7FF)
7460 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7461 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7463 else if (codepoint <= 0xFFFF)
7466 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7467 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7468 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7473 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7474 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7475 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7476 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7484 error_message =
"invalid string: forbidden character after backslash";
7485 return token_type::parse_error;
7494 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7495 return token_type::parse_error;
7500 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7501 return token_type::parse_error;
7506 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7507 return token_type::parse_error;
7512 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7513 return token_type::parse_error;
7518 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7519 return token_type::parse_error;
7524 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7525 return token_type::parse_error;
7530 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7531 return token_type::parse_error;
7536 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7537 return token_type::parse_error;
7542 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7543 return token_type::parse_error;
7548 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7549 return token_type::parse_error;
7554 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7555 return token_type::parse_error;
7560 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7561 return token_type::parse_error;
7566 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7567 return token_type::parse_error;
7572 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7573 return token_type::parse_error;
7578 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7579 return token_type::parse_error;
7584 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7585 return token_type::parse_error;
7590 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7591 return token_type::parse_error;
7596 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7597 return token_type::parse_error;
7602 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7603 return token_type::parse_error;
7608 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7609 return token_type::parse_error;
7614 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7615 return token_type::parse_error;
7620 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7621 return token_type::parse_error;
7626 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7627 return token_type::parse_error;
7632 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7633 return token_type::parse_error;
7638 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7639 return token_type::parse_error;
7644 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7645 return token_type::parse_error;
7650 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7651 return token_type::parse_error;
7656 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7657 return token_type::parse_error;
7662 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7663 return token_type::parse_error;
7668 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7669 return token_type::parse_error;
7674 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7675 return token_type::parse_error;
7680 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7681 return token_type::parse_error;
7818 return token_type::parse_error;
7828 return token_type::parse_error;
7852 return token_type::parse_error;
7862 return token_type::parse_error;
7872 return token_type::parse_error;
7884 return token_type::parse_error;
7894 return token_type::parse_error;
7903 return token_type::parse_error;
7974 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7983 f = std::strtof(str, endptr);
7987 static
void strtof(
double& f,
const char* str,
char** endptr) noexcept
7989 f = std::strtod(str, endptr);
7993 static
void strtof(
long double& f,
const char* str,
char** endptr) noexcept
7995 f = std::strtold(str, endptr);
8045 token_type number_type = token_type::value_unsigned;
8053 goto scan_number_minus;
8059 goto scan_number_zero;
8073 goto scan_number_any1;
8083 number_type = token_type::value_integer;
8089 goto scan_number_zero;
8103 goto scan_number_any1;
8109 return token_type::parse_error;
8121 goto scan_number_decimal1;
8128 goto scan_number_exponent;
8132 goto scan_number_done;
8151 goto scan_number_any1;
8158 goto scan_number_decimal1;
8165 goto scan_number_exponent;
8169 goto scan_number_done;
8172 scan_number_decimal1:
8174 number_type = token_type::value_float;
8189 goto scan_number_decimal2;
8195 return token_type::parse_error;
8199 scan_number_decimal2:
8215 goto scan_number_decimal2;
8222 goto scan_number_exponent;
8226 goto scan_number_done;
8229 scan_number_exponent:
8231 number_type = token_type::value_float;
8238 goto scan_number_sign;
8253 goto scan_number_any2;
8259 "invalid number; expected '+', '-', or digit after exponent";
8260 return token_type::parse_error;
8280 goto scan_number_any2;
8285 error_message =
"invalid number; expected digit after exponent sign";
8286 return token_type::parse_error;
8306 goto scan_number_any2;
8310 goto scan_number_done;
8318 char* endptr =
nullptr;
8322 if (number_type == token_type::value_unsigned)
8324 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
8329 if (errno != ERANGE)
8334 return token_type::value_unsigned;
8338 else if (number_type == token_type::value_integer)
8340 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
8345 if (errno != ERANGE)
8350 return token_type::value_integer;
8362 return token_type::value_float;
8375 for (std::size_t i = 1; i < length; ++i)
8380 return token_type::parse_error;
8475 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8531 if (
static_cast<unsigned char>(c) <=
'\x1F')
8534 std::array<char, 9> cs{{}};
8535 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8536 result += cs.data();
8541 result.push_back(
static_cast<std::string::value_type
>(c));
8568 return get() == 0xBB &&
get() == 0xBF;
8591 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8592 return token_type::parse_error;
8603 return token_type::parse_error;
8614 return token_type::begin_array;
8616 return token_type::end_array;
8618 return token_type::begin_object;
8620 return token_type::end_object;
8622 return token_type::name_separator;
8624 return token_type::value_separator;
8630 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8635 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8640 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8665 return token_type::end_of_input;
8670 return token_type::parse_error;
8727 template<
typename BasicJsonType>
8740 virtual bool null() = 0;
8831 const std::string& last_token,
8846 return (std::numeric_limits<std::size_t>::max)();
8862 template<
typename BasicJsonType,
typename InputAdapterType>
8879 : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
8891 handle_value(
nullptr);
8927 handle_value(std::move(val));
8933 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
8935 #if JSON_DIAGNOSTIC_POSITIONS
8942 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8960 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
8969 #if JSON_DIAGNOSTIC_POSITIONS
8973 ref_stack.back()->end_position = m_lexer_ref->get_position();
8977 ref_stack.back()->set_parents();
8978 ref_stack.pop_back();
8984 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
8986 #if JSON_DIAGNOSTIC_POSITIONS
8991 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9008 #if JSON_DIAGNOSTIC_POSITIONS
9012 ref_stack.back()->end_position = m_lexer_ref->get_position();
9016 ref_stack.back()->set_parents();
9017 ref_stack.pop_back();
9021 template<
class Exception>
9023 const Exception& ex)
9026 static_cast<void>(ex);
9027 if (allow_exceptions)
9041 #if JSON_DIAGNOSTIC_POSITIONS
9042 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9049 v.end_position = m_lexer_ref->get_position();
9053 case value_t::boolean:
9056 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9063 v.start_position = v.end_position - 4;
9067 case value_t::string:
9070 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9079 case value_t::discarded:
9081 v.end_position = std::string::npos;
9082 v.start_position = v.end_position;
9086 case value_t::binary:
9087 case value_t::number_integer:
9088 case value_t::number_unsigned:
9089 case value_t::number_float:
9091 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9094 case value_t::object:
9095 case value_t::array:
9115 template<
typename Value>
9119 if (ref_stack.empty())
9121 root = BasicJsonType(std::forward<Value>(v));
9123 #if JSON_DIAGNOSTIC_POSITIONS
9124 handle_diagnostic_positions_for_json_value(root);
9130 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9132 if (ref_stack.back()->is_array())
9134 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
9136 #if JSON_DIAGNOSTIC_POSITIONS
9137 handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
9140 return &(ref_stack.back()->m_data.m_value.array->back());
9145 *object_element = BasicJsonType(std::forward<Value>(v));
9147 #if JSON_DIAGNOSTIC_POSITIONS
9148 handle_diagnostic_positions_for_json_value(*object_element);
9151 return object_element;
9157 std::vector<BasicJsonType*> ref_stack {};
9159 BasicJsonType* object_element =
nullptr;
9161 bool errored =
false;
9163 const bool allow_exceptions =
true;
9168 template<
typename BasicJsonType,
typename InputAdapterType>
9183 const bool allow_exceptions_ =
true,
9185 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9187 keep_stack.push_back(
true);
9199 handle_value(
nullptr);
9235 handle_value(std::move(val));
9242 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
9243 keep_stack.push_back(keep);
9245 auto val = handle_value(BasicJsonType::value_t::object,
true);
9246 ref_stack.push_back(val.second);
9248 if (ref_stack.back())
9251 #if JSON_DIAGNOSTIC_POSITIONS
9258 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9273 BasicJsonType k = BasicJsonType(val);
9276 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
9277 key_keep_stack.push_back(keep);
9280 if (keep && ref_stack.back())
9282 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
9290 if (ref_stack.back())
9292 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
9297 #if JSON_DIAGNOSTIC_POSITIONS
9299 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9305 #if JSON_DIAGNOSTIC_POSITIONS
9309 ref_stack.back()->end_position = m_lexer_ref->get_position();
9313 ref_stack.back()->set_parents();
9319 ref_stack.pop_back();
9320 keep_stack.pop_back();
9322 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
9325 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
9327 if (it->is_discarded())
9329 ref_stack.back()->erase(it);
9340 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
9341 keep_stack.push_back(keep);
9343 auto val = handle_value(BasicJsonType::value_t::array,
true);
9344 ref_stack.push_back(val.second);
9346 if (ref_stack.back())
9349 #if JSON_DIAGNOSTIC_POSITIONS
9356 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9374 if (ref_stack.back())
9376 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
9380 #if JSON_DIAGNOSTIC_POSITIONS
9384 ref_stack.back()->end_position = m_lexer_ref->get_position();
9388 ref_stack.back()->set_parents();
9395 #if JSON_DIAGNOSTIC_POSITIONS
9397 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9404 ref_stack.pop_back();
9405 keep_stack.pop_back();
9408 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
9410 ref_stack.back()->m_data.m_value.array->pop_back();
9416 template<
class Exception>
9418 const Exception& ex)
9421 static_cast<void>(ex);
9422 if (allow_exceptions)
9436 #if JSON_DIAGNOSTIC_POSITIONS
9437 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9444 v.end_position = m_lexer_ref->get_position();
9448 case value_t::boolean:
9451 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9458 v.start_position = v.end_position - 4;
9462 case value_t::string:
9465 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9469 case value_t::discarded:
9471 v.end_position = std::string::npos;
9472 v.start_position = v.end_position;
9476 case value_t::binary:
9477 case value_t::number_integer:
9478 case value_t::number_unsigned:
9479 case value_t::number_float:
9481 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9485 case value_t::object:
9486 case value_t::array:
9515 template<
typename Value>
9522 if (!keep_stack.back())
9524 return {
false,
nullptr};
9528 auto value = BasicJsonType(std::forward<Value>(v));
9530 #if JSON_DIAGNOSTIC_POSITIONS
9531 handle_diagnostic_positions_for_json_value(
value);
9540 return {
false,
nullptr};
9543 if (ref_stack.empty())
9545 root = std::move(
value);
9546 return {
true, & root};
9551 if (!ref_stack.back())
9553 return {
false,
nullptr};
9557 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9560 if (ref_stack.back()->is_array())
9562 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(
value));
9563 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
9570 const bool store_element = key_keep_stack.back();
9571 key_keep_stack.pop_back();
9575 return {
false,
nullptr};
9579 *object_element = std::move(
value);
9580 return {
true, object_element};
9586 std::vector<BasicJsonType*> ref_stack {};
9588 std::vector<bool> keep_stack {};
9590 std::vector<bool> key_keep_stack {};
9592 BasicJsonType* object_element =
nullptr;
9594 bool errored =
false;
9598 const bool allow_exceptions =
true;
9600 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
9605 template<
typename BasicJsonType>
9714 template<
typename T>
9717 template<
typename T>
9719 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
9721 template<
typename T,
typename Integer>
9723 decltype(std::declval<T&>().
number_integer(std::declval<Integer>()));
9725 template<
typename T,
typename Un
signed>
9727 decltype(std::declval<T&>().
number_unsigned(std::declval<Unsigned>()));
9729 template<
typename T,
typename Float,
typename String>
9731 std::declval<Float>(), std::declval<const String&>()));
9733 template<
typename T,
typename String>
9735 decltype(std::declval<T&>().
string(std::declval<String&>()));
9737 template<
typename T,
typename Binary>
9739 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
9741 template<
typename T>
9743 decltype(std::declval<T&>().
start_object(std::declval<std::size_t>()));
9745 template<
typename T,
typename String>
9747 decltype(std::declval<T&>().
key(std::declval<String&>()));
9749 template<
typename T>
9752 template<
typename T>
9754 decltype(std::declval<T&>().
start_array(std::declval<std::size_t>()));
9756 template<
typename T>
9759 template<
typename T,
typename Exception>
9761 std::declval<std::size_t>(), std::declval<const std::string&>(),
9762 std::declval<const Exception&>()));
9764 template<
typename SAX,
typename BasicJsonType>
9769 "BasicJsonType must be of type basic_json<...>");
9795 template<
typename SAX,
typename BasicJsonType>
9800 "BasicJsonType must be of type basic_json<...>");
9811 "Missing/invalid function: bool null()");
9813 "Missing/invalid function: bool boolean(bool)");
9815 "Missing/invalid function: bool boolean(bool)");
9819 "Missing/invalid function: bool number_integer(number_integer_t)");
9823 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9826 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9829 "Missing/invalid function: bool string(string_t&)");
9832 "Missing/invalid function: bool binary(binary_t&)");
9834 "Missing/invalid function: bool start_object(std::size_t)");
9836 "Missing/invalid function: bool key(string_t&)");
9838 "Missing/invalid function: bool end_object()");
9840 "Missing/invalid function: bool start_array(std::size_t)");
9842 "Missing/invalid function: bool end_array()");
9845 "Missing/invalid function: bool parse_error(std::size_t, const "
9846 "std::string&, const exception&)");
9880 return *
reinterpret_cast<char*
>(&num) == 1;
9890 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
9931 const bool strict = true,
9935 bool result =
false;
9939 case input_format_t::bson:
9940 result = parse_bson_internal();
9943 case input_format_t::cbor:
9944 result = parse_cbor_internal(
true, tag_handler);
9947 case input_format_t::msgpack:
9948 result = parse_msgpack_internal();
9951 case input_format_t::ubjson:
9952 case input_format_t::bjdata:
9953 result = parse_ubjson_internal();
9964 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9975 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
9976 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9995 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10007 return sax->end_object();
10019 auto out = std::back_inserter(result);
10027 if (current == 0x00)
10031 *out++ =
static_cast<typename string_t::value_type
>(current);
10046 template<
typename NumberType>
10051 auto last_token = get_token_string();
10052 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10053 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ",
std::to_string(len)),
"string"),
nullptr));
10068 template<
typename NumberType>
10073 auto last_token = get_token_string();
10074 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10075 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ",
std::to_string(len)),
"binary"),
nullptr));
10080 get_number<std::uint8_t>(input_format_t::bson, subtype);
10081 result.set_subtype(subtype);
10083 return get_binary(input_format_t::bson, len, result);
10097 const std::size_t element_type_parse_position)
10099 switch (element_type)
10104 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10111 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len,
value) && sax->string(
value);
10116 return parse_bson_internal();
10121 return parse_bson_array();
10128 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len,
value) && sax->binary(
value);
10133 return sax->boolean(
get() != 0);
10138 return sax->null();
10144 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
10150 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
10156 return get_number<std::uint64_t, true>(input_format_t::bson,
value) && sax->number_unsigned(
value);
10161 std::array<char, 3> cr{{}};
10162 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
10163 const std::string cr_str{cr.data()};
10164 return sax->parse_error(element_type_parse_position, cr_str,
10165 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
10186 while (
auto element_type =
get())
10193 const std::size_t element_type_parse_position = chars_read;
10199 if (!is_array && !sax->key(
key))
10204 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
10223 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10235 return sax->end_array();
10253 switch (get_char ?
get() : current)
10257 return unexpect_eof(input_format_t::cbor,
"value");
10289 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10295 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10301 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10307 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10335 return sax->number_integer(
static_cast<std::int8_t>(0x20 - 1 - current));
10340 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
10346 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
10352 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
10358 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1)
10394 return get_cbor_binary(b) && sax->binary(b);
10429 return get_cbor_string(s) && sax->string(s);
10457 return get_cbor_array(
10458 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10463 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10469 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10475 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10481 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10512 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10517 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10523 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10529 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10535 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10561 switch (tag_handler)
10563 case cbor_tag_handler_t::error:
10565 auto last_token = get_token_string();
10566 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10567 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10570 case cbor_tag_handler_t::ignore:
10578 get_number(input_format_t::cbor, subtype_to_ignore);
10584 get_number(input_format_t::cbor, subtype_to_ignore);
10590 get_number(input_format_t::cbor, subtype_to_ignore);
10596 get_number(input_format_t::cbor, subtype_to_ignore);
10602 return parse_cbor_internal(
true, tag_handler);
10605 case cbor_tag_handler_t::store:
10614 get_number(input_format_t::cbor, subtype);
10615 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10621 get_number(input_format_t::cbor, subtype);
10622 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10628 get_number(input_format_t::cbor, subtype);
10629 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10635 get_number(input_format_t::cbor, subtype);
10636 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10640 return parse_cbor_internal(
true, tag_handler);
10643 return get_cbor_binary(b) && sax->binary(b);
10653 return sax->boolean(
false);
10656 return sax->boolean(
true);
10659 return sax->null();
10663 const auto byte1_raw =
get();
10668 const auto byte2_raw =
get();
10674 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10675 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10685 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10686 const double val = [&half]
10688 const int exp = (half >> 10u) & 0x1Fu;
10689 const unsigned int mant = half & 0x3FFu;
10695 return std::ldexp(mant, -24);
10698 ? std::numeric_limits<double>::infinity()
10699 : std::numeric_limits<double>::quiet_NaN();
10701 return std::ldexp(mant + 1024, exp - 25);
10704 return sax->number_float((half & 0x8000u) != 0
10712 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10718 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10723 auto last_token = get_token_string();
10724 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10725 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10776 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10782 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10788 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10794 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10800 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10805 while (
get() != 0xFF)
10808 if (!get_cbor_string(chunk))
10812 result.append(chunk);
10819 auto last_token = get_token_string();
10820 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10821 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10872 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10878 return get_number(input_format_t::cbor, len) &&
10879 get_binary(input_format_t::cbor, len, result);
10885 return get_number(input_format_t::cbor, len) &&
10886 get_binary(input_format_t::cbor, len, result);
10892 return get_number(input_format_t::cbor, len) &&
10893 get_binary(input_format_t::cbor, len, result);
10899 return get_number(input_format_t::cbor, len) &&
10900 get_binary(input_format_t::cbor, len, result);
10905 while (
get() != 0xFF)
10908 if (!get_cbor_binary(chunk))
10912 result.insert(result.end(), chunk.begin(), chunk.end());
10919 auto last_token = get_token_string();
10920 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10921 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));
10942 for (std::size_t i = 0; i < len; ++i)
10952 while (
get() != 0xFF)
10961 return sax->end_array();
10983 for (std::size_t i = 0; i < len; ++i)
11000 while (
get() != 0xFF)
11016 return sax->end_object();
11032 return unexpect_eof(input_format_t::msgpack,
"value");
11182 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11201 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11241 return get_msgpack_string(s) && sax->string(s);
11245 return sax->null();
11248 return sax->boolean(
false);
11251 return sax->boolean(
true);
11266 return get_msgpack_binary(b) && sax->binary(b);
11272 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11278 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11284 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11290 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11296 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11302 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11308 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11314 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11320 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11326 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11332 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
11338 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
11344 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
11350 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
11386 return sax->number_integer(
static_cast<std::int8_t>(current));
11390 auto last_token = get_token_string();
11391 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11392 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
11450 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
11456 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11462 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11468 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11473 auto last_token = get_token_string();
11474 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11475 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
11493 auto assign_and_return_true = [&result](
std::int8_t subtype)
11495 result.set_subtype(
static_cast<std::uint8_t>(subtype));
11504 return get_number(input_format_t::msgpack, len) &&
11505 get_binary(input_format_t::msgpack, len, result);
11511 return get_number(input_format_t::msgpack, len) &&
11512 get_binary(input_format_t::msgpack, len, result);
11518 return get_number(input_format_t::msgpack, len) &&
11519 get_binary(input_format_t::msgpack, len, result);
11526 return get_number(input_format_t::msgpack, len) &&
11527 get_number(input_format_t::msgpack, subtype) &&
11528 get_binary(input_format_t::msgpack, len, result) &&
11529 assign_and_return_true(subtype);
11536 return get_number(input_format_t::msgpack, len) &&
11537 get_number(input_format_t::msgpack, subtype) &&
11538 get_binary(input_format_t::msgpack, len, result) &&
11539 assign_and_return_true(subtype);
11546 return get_number(input_format_t::msgpack, len) &&
11547 get_number(input_format_t::msgpack, subtype) &&
11548 get_binary(input_format_t::msgpack, len, result) &&
11549 assign_and_return_true(subtype);
11555 return get_number(input_format_t::msgpack, subtype) &&
11556 get_binary(input_format_t::msgpack, 1, result) &&
11557 assign_and_return_true(subtype);
11563 return get_number(input_format_t::msgpack, subtype) &&
11564 get_binary(input_format_t::msgpack, 2, result) &&
11565 assign_and_return_true(subtype);
11571 return get_number(input_format_t::msgpack, subtype) &&
11572 get_binary(input_format_t::msgpack, 4, result) &&
11573 assign_and_return_true(subtype);
11579 return get_number(input_format_t::msgpack, subtype) &&
11580 get_binary(input_format_t::msgpack, 8, result) &&
11581 assign_and_return_true(subtype);
11587 return get_number(input_format_t::msgpack, subtype) &&
11588 get_binary(input_format_t::msgpack, 16, result) &&
11589 assign_and_return_true(subtype);
11608 for (std::size_t i = 0; i < len; ++i)
11616 return sax->end_array();
11631 for (std::size_t i = 0; i < len; ++i)
11646 return sax->end_object();
11662 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11696 return get_number(input_format, len) && get_string(input_format, len, result);
11702 return get_number(input_format, len) && get_string(input_format, len, result);
11708 return get_number(input_format, len) && get_string(input_format, len, result);
11714 return get_number(input_format, len) && get_string(input_format, len, result);
11720 return get_number(input_format, len) && get_string(input_format, len, result);
11725 if (input_format != input_format_t::bjdata)
11730 return get_number(input_format, len) && get_string(input_format, len, result);
11735 if (input_format != input_format_t::bjdata)
11740 return get_number(input_format, len) && get_string(input_format, len, result);
11745 if (input_format != input_format_t::bjdata)
11750 return get_number(input_format, len) && get_string(input_format, len, result);
11756 auto last_token = get_token_string();
11757 std::string message;
11759 if (input_format != input_format_t::bjdata)
11761 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11765 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11767 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11776 std::pair<std::size_t, char_int_type> size_and_type;
11778 bool no_ndarray =
true;
11785 if (size_and_type.first != npos)
11787 if (size_and_type.second != 0)
11789 if (size_and_type.second !=
'N')
11791 for (std::size_t i = 0; i < size_and_type.first; ++i)
11797 dim.push_back(dimlen);
11803 for (std::size_t i = 0; i < size_and_type.first; ++i)
11809 dim.push_back(dimlen);
11815 while (current !=
']')
11821 dim.push_back(dimlen);
11843 prefix = get_ignore_noop();
11855 result =
static_cast<std::size_t
>(number);
11868 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11869 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11871 result =
static_cast<std::size_t
>(number);
11884 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11885 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11887 result =
static_cast<std::size_t
>(number);
11900 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11901 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11903 result =
static_cast<std::size_t
>(number);
11916 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11917 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11919 if (!value_in_range_of<std::size_t>(number))
11921 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11922 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11924 result =
static_cast<std::size_t
>(number);
11930 if (input_format != input_format_t::bjdata)
11939 result =
static_cast<std::size_t
>(number);
11945 if (input_format != input_format_t::bjdata)
11954 result = conditional_static_cast<std::size_t>(number);
11960 if (input_format != input_format_t::bjdata)
11969 if (!value_in_range_of<std::size_t>(number))
11971 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11972 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11974 result = detail::conditional_static_cast<std::size_t>(number);
11980 if (input_format != input_format_t::bjdata)
11986 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11988 std::vector<size_t> dim;
11993 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11995 result = dim.at(dim.size() - 1);
12022 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));
12026 if (result == 0 || result == npos)
12028 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));
12036 return sax->end_array();
12045 auto last_token = get_token_string();
12046 std::string message;
12048 if (input_format != input_format_t::bjdata)
12050 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
12054 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
12056 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
12072 result.first = npos;
12074 bool is_ndarray =
false;
12078 if (current ==
'$')
12080 result.second =
get();
12081 if (input_format == input_format_t::bjdata
12082 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
12084 auto last_token = get_token_string();
12085 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12086 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
12101 auto last_token = get_token_string();
12102 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12103 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
12106 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12107 if (input_format == input_format_t::bjdata && is_ndarray)
12109 if (inside_ndarray)
12111 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12112 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
12114 result.second |= (1 << 8);
12119 if (current ==
'#')
12121 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12122 if (input_format == input_format_t::bjdata && is_ndarray)
12124 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12125 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
12142 return unexpect_eof(input_format,
"value");
12145 return sax->boolean(
true);
12147 return sax->boolean(
false);
12150 return sax->null();
12154 if (input_format != input_format_t::bjdata)
12159 return get_number(input_format, number) && sax->number_unsigned(number);
12165 return get_number(input_format, number) && sax->number_unsigned(number);
12171 return get_number(input_format, number) && sax->number_integer(number);
12177 return get_number(input_format, number) && sax->number_integer(number);
12183 return get_number(input_format, number) && sax->number_integer(number);
12189 return get_number(input_format, number) && sax->number_integer(number);
12194 if (input_format != input_format_t::bjdata)
12199 return get_number(input_format, number) && sax->number_unsigned(number);
12204 if (input_format != input_format_t::bjdata)
12209 return get_number(input_format, number) && sax->number_unsigned(number);
12214 if (input_format != input_format_t::bjdata)
12219 return get_number(input_format, number) && sax->number_unsigned(number);
12224 if (input_format != input_format_t::bjdata)
12228 const auto byte1_raw =
get();
12233 const auto byte2_raw =
get();
12239 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
12240 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
12250 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
12251 const double val = [&half]
12253 const int exp = (half >> 10u) & 0x1Fu;
12254 const unsigned int mant = half & 0x3FFu;
12260 return std::ldexp(mant, -24);
12263 ? std::numeric_limits<double>::infinity()
12264 : std::numeric_limits<double>::quiet_NaN();
12266 return std::ldexp(mant + 1024, exp - 25);
12269 return sax->number_float((half & 0x8000u) != 0
12277 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
12283 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
12288 return get_ubjson_high_precision_number();
12300 auto last_token = get_token_string();
12301 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
12302 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
12304 string_t s(1,
static_cast<typename string_t::value_type
>(current));
12305 return sax->string(s);
12311 return get_ubjson_string(s) && sax->string(s);
12315 return get_ubjson_array();
12318 return get_ubjson_object();
12323 auto last_token = get_token_string();
12324 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));
12332 std::pair<std::size_t, char_int_type> size_and_type;
12341 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12343 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
12344 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type & p,
char_int_type t)
12346 return p.first < t;
12351 auto last_token = get_token_string();
12352 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12353 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
12362 if (size_and_type.second ==
'C' || size_and_type.second ==
'B')
12364 size_and_type.second =
'U';
12367 key =
"_ArrayData_";
12373 for (std::size_t i = 0; i < size_and_type.first; ++i)
12381 return (sax->end_array() && sax->end_object());
12385 if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second ==
'B')
12388 return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
12391 if (size_and_type.first != npos)
12398 if (size_and_type.second != 0)
12400 if (size_and_type.second !=
'N')
12402 for (std::size_t i = 0; i < size_and_type.first; ++i)
12413 for (std::size_t i = 0; i < size_and_type.first; ++i)
12429 while (current !=
']')
12439 return sax->end_array();
12447 std::pair<std::size_t, char_int_type> size_and_type;
12454 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12456 auto last_token = get_token_string();
12457 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12458 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
12462 if (size_and_type.first != npos)
12469 if (size_and_type.second != 0)
12471 for (std::size_t i = 0; i < size_and_type.first; ++i)
12486 for (std::size_t i = 0; i < size_and_type.first; ++i)
12507 while (current !=
'}')
12522 return sax->end_object();
12531 std::size_t size{};
12532 bool no_ndarray =
true;
12533 auto res = get_ubjson_size_value(size, no_ndarray);
12540 std::vector<char> number_vector;
12541 for (std::size_t i = 0; i < size; ++i)
12548 number_vector.push_back(
static_cast<char>(current));
12554 const auto result_number = number_lexer.scan();
12555 const auto number_string = number_lexer.get_token_string();
12556 const auto result_remainder = number_lexer.scan();
12562 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12563 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12566 switch (result_number)
12568 case token_type::value_integer:
12569 return sax->number_integer(number_lexer.get_number_integer());
12570 case token_type::value_unsigned:
12571 return sax->number_unsigned(number_lexer.get_number_unsigned());
12572 case token_type::value_float:
12573 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12574 case token_type::uninitialized:
12575 case token_type::literal_true:
12576 case token_type::literal_false:
12577 case token_type::literal_null:
12578 case token_type::value_string:
12579 case token_type::begin_array:
12580 case token_type::begin_object:
12581 case token_type::end_array:
12582 case token_type::end_object:
12583 case token_type::name_separator:
12584 case token_type::value_separator:
12585 case token_type::parse_error:
12586 case token_type::end_of_input:
12587 case token_type::literal_or_value:
12589 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12590 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12610 return current = ia.get_character();
12624 auto new_chars_read = ia.get_elements(&dest);
12625 chars_read += new_chars_read;
12630 sax->parse_error(chars_read,
"<end of file>", parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12645 while (current ==
'N');
12650 template<
class NumberType>
12653 constexpr std::size_t sz =
sizeof(number);
12654 #ifdef __cpp_lib_byteswap
12655 if constexpr (sz == 1)
12659 else if constexpr(std::is_integral_v<NumberType>)
12661 number = std::byteswap(number);
12668 for (std::size_t i = 0; i < sz / 2; ++i)
12672 #ifdef __cpp_lib_byteswap
12692 template<
typename NumberType,
bool InputIsLittleEndian = false>
12701 if (
is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
12722 template<
typename NumberType>
12724 const NumberType len,
12727 bool success =
true;
12728 for (NumberType i = 0; i < len; i++)
12736 result.push_back(
static_cast<typename string_t::value_type
>(current));
12755 template<
typename NumberType>
12757 const NumberType len,
12760 bool success =
true;
12761 for (NumberType i = 0; i < len; i++)
12769 result.push_back(
static_cast<typename binary_t::value_type
>(current));
12784 return sax->parse_error(chars_read,
"<end of file>",
12785 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12795 std::array<char, 3> cr{{}};
12796 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12797 return std::string{cr.data()};
12807 const std::string&
detail,
12808 const std::string& context)
const
12810 std::string error_msg =
"syntax error while parsing ";
12814 case input_format_t::cbor:
12815 error_msg +=
"CBOR";
12818 case input_format_t::msgpack:
12819 error_msg +=
"MessagePack";
12822 case input_format_t::ubjson:
12823 error_msg +=
"UBJSON";
12826 case input_format_t::bson:
12827 error_msg +=
"BSON";
12830 case input_format_t::bjdata:
12831 error_msg +=
"BJData";
12852 std::size_t chars_read = 0;
12864 #define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12865 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12867 #define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12868 make_array<bjd_type>( \
12869 bjd_type{'B', "byte"}, \
12870 bjd_type{'C', "char"}, \
12871 bjd_type{'D', "double"}, \
12872 bjd_type{'I', "int16"}, \
12873 bjd_type{'L', "int64"}, \
12874 bjd_type{'M', "uint64"}, \
12875 bjd_type{'U', "uint8"}, \
12876 bjd_type{'d', "single"}, \
12877 bjd_type{'i', "int8"}, \
12878 bjd_type{'l', "int32"}, \
12879 bjd_type{'m', "uint32"}, \
12880 bjd_type{'u', "uint16"})
12893 #undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12894 #undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12897 #ifndef JSON_HAS_CPP_17
12898 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12922 #include <functional>
12967 template<
typename BasicJsonType>
12969 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12976 template<
typename BasicJsonType,
typename InputAdapterType>
12990 const bool allow_exceptions_ =
true,
12991 const bool ignore_comments =
false,
12992 const bool ignore_trailing_commas_ =
false)
12993 : callback(
std::move(cb))
12994 , m_lexer(
std::move(adapter), ignore_comments)
12995 , allow_exceptions(allow_exceptions_)
12996 , ignore_trailing_commas(ignore_trailing_commas_)
13012 void parse(
const bool strict, BasicJsonType& result)
13017 sax_parse_internal(&sdp);
13020 if (
strict && (get_token() != token_type::end_of_input))
13023 m_lexer.get_token_string(),
13024 parse_error::create(101, m_lexer.get_position(),
13025 exception_message(token_type::end_of_input,
"value"),
nullptr));
13031 result = value_t::discarded;
13037 if (result.is_discarded())
13045 sax_parse_internal(&sdp);
13048 if (
strict && (get_token() != token_type::end_of_input))
13051 m_lexer.get_token_string(),
13052 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13058 result = value_t::discarded;
13063 result.assert_invariant();
13075 return sax_parse(&sax_acceptor,
strict);
13078 template<
typename SAX>
13080 bool sax_parse(SAX* sax,
const bool strict = true)
13083 const bool result = sax_parse_internal(sax);
13086 if (result &&
strict && (get_token() != token_type::end_of_input))
13088 return sax->parse_error(m_lexer.get_position(),
13089 m_lexer.get_token_string(),
13090 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13097 template<
typename SAX>
13099 bool sax_parse_internal(SAX* sax)
13103 std::vector<bool> states;
13105 bool skip_to_state_evaluation =
false;
13109 if (!skip_to_state_evaluation)
13112 switch (last_token)
13114 case token_type::begin_object:
13122 if (get_token() == token_type::end_object)
13134 return sax->parse_error(m_lexer.get_position(),
13135 m_lexer.get_token_string(),
13136 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13146 return sax->parse_error(m_lexer.get_position(),
13147 m_lexer.get_token_string(),
13148 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13152 states.push_back(
false);
13159 case token_type::begin_array:
13167 if (get_token() == token_type::end_array)
13177 states.push_back(
true);
13183 case token_type::value_float:
13185 const auto res = m_lexer.get_number_float();
13189 return sax->parse_error(m_lexer.get_position(),
13190 m_lexer.get_token_string(),
13191 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
13202 case token_type::literal_false:
13211 case token_type::literal_null:
13220 case token_type::literal_true:
13229 case token_type::value_integer:
13238 case token_type::value_string:
13247 case token_type::value_unsigned:
13256 case token_type::parse_error:
13259 return sax->parse_error(m_lexer.get_position(),
13260 m_lexer.get_token_string(),
13261 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
13263 case token_type::end_of_input:
13267 return sax->parse_error(m_lexer.get_position(),
13268 m_lexer.get_token_string(),
13269 parse_error::create(101, m_lexer.get_position(),
13270 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
13273 return sax->parse_error(m_lexer.get_position(),
13274 m_lexer.get_token_string(),
13275 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13277 case token_type::uninitialized:
13278 case token_type::end_array:
13279 case token_type::end_object:
13280 case token_type::name_separator:
13281 case token_type::value_separator:
13282 case token_type::literal_or_value:
13285 return sax->parse_error(m_lexer.get_position(),
13286 m_lexer.get_token_string(),
13287 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13293 skip_to_state_evaluation =
false;
13297 if (states.empty())
13307 if (get_token() == token_type::value_separator)
13313 if (!(ignore_trailing_commas && last_token == token_type::end_array))
13333 skip_to_state_evaluation =
true;
13337 return sax->parse_error(m_lexer.get_position(),
13338 m_lexer.get_token_string(),
13339 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
13346 if (get_token() == token_type::value_separator)
13351 if (!(ignore_trailing_commas && last_token == token_type::end_object))
13356 return sax->parse_error(m_lexer.get_position(),
13357 m_lexer.get_token_string(),
13358 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13369 return sax->parse_error(m_lexer.get_position(),
13370 m_lexer.get_token_string(),
13371 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13394 skip_to_state_evaluation =
true;
13398 return sax->parse_error(m_lexer.get_position(),
13399 m_lexer.get_token_string(),
13400 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
13407 return last_token = m_lexer.scan();
13412 std::string error_msg =
"syntax error ";
13414 if (!context.empty())
13416 error_msg +=
concat(
"while parsing ", context,
' ');
13421 if (last_token == token_type::parse_error)
13423 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
13424 m_lexer.get_token_string(),
'\'');
13428 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
13431 if (expected != token_type::uninitialized)
13433 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
13447 const bool allow_exceptions =
true;
13449 const bool ignore_trailing_commas =
false;
13518 m_it = begin_value;
13530 return m_it == begin_value;
13536 return m_it == end_value;
13541 return lhs.m_it == rhs.m_it;
13546 return lhs.m_it < rhs.m_it;
13551 auto result = *
this;
13558 return lhs.m_it - rhs.m_it;
13569 auto result = *
this;
13582 auto result = *
this;
13617 typename BasicJsonType::object_t::iterator object_iterator {};
13619 typename BasicJsonType::array_t::iterator array_iterator {};
13638 #include <iterator>
13639 #include <type_traits>
13661 template<
typename IteratorType>
class iteration_proxy;
13662 template<
typename IteratorType>
class iteration_proxy_value;
13680 template<
typename BasicJsonType>
13695 "iter_impl only accepts (const) basic_json");
13698 && std::is_base_of<std::bidirectional_iterator_tag,
typename std::iterator_traits<typename array_t::iterator>::iterator_category>::
value,
13699 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13715 typename BasicJsonType::const_pointer,
13720 typename BasicJsonType::const_reference,
13721 typename BasicJsonType::reference>
::type;
13738 switch (m_object->m_data.m_type)
13740 case value_t::object:
13742 m_it.object_iterator =
typename object_t::iterator();
13746 case value_t::array:
13748 m_it.array_iterator =
typename array_t::iterator();
13752 case value_t::null:
13753 case value_t::string:
13754 case value_t::boolean:
13755 case value_t::number_integer:
13756 case value_t::number_unsigned:
13757 case value_t::number_float:
13758 case value_t::binary:
13759 case value_t::discarded:
13785 : m_object(other.m_object), m_it(other.m_it)
13796 if (&other !=
this)
13798 m_object = other.m_object;
13810 : m_object(other.m_object), m_it(other.m_it)
13821 m_object = other.m_object;
13831 void set_begin() noexcept
13835 switch (m_object->m_data.m_type)
13837 case value_t::object:
13839 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13843 case value_t::array:
13845 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13849 case value_t::null:
13852 m_it.primitive_iterator.set_end();
13856 case value_t::string:
13857 case value_t::boolean:
13858 case value_t::number_integer:
13859 case value_t::number_unsigned:
13860 case value_t::number_float:
13861 case value_t::binary:
13862 case value_t::discarded:
13865 m_it.primitive_iterator.set_begin();
13879 switch (m_object->m_data.m_type)
13881 case value_t::object:
13883 m_it.object_iterator = m_object->m_data.m_value.object->end();
13887 case value_t::array:
13889 m_it.array_iterator = m_object->m_data.m_value.array->end();
13893 case value_t::null:
13894 case value_t::string:
13895 case value_t::boolean:
13896 case value_t::number_integer:
13897 case value_t::number_unsigned:
13898 case value_t::number_float:
13899 case value_t::binary:
13900 case value_t::discarded:
13903 m_it.primitive_iterator.set_end();
13918 switch (m_object->m_data.m_type)
13920 case value_t::object:
13922 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13923 return m_it.object_iterator->second;
13926 case value_t::array:
13928 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13929 return *m_it.array_iterator;
13932 case value_t::null:
13933 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13935 case value_t::string:
13936 case value_t::boolean:
13937 case value_t::number_integer:
13938 case value_t::number_unsigned:
13939 case value_t::number_float:
13940 case value_t::binary:
13941 case value_t::discarded:
13949 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13962 switch (m_object->m_data.m_type)
13964 case value_t::object:
13966 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13967 return &(m_it.object_iterator->second);
13970 case value_t::array:
13972 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13973 return &*m_it.array_iterator;
13976 case value_t::null:
13977 case value_t::string:
13978 case value_t::boolean:
13979 case value_t::number_integer:
13980 case value_t::number_unsigned:
13981 case value_t::number_float:
13982 case value_t::binary:
13983 case value_t::discarded:
13991 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14002 auto result = *
this;
14015 switch (m_object->m_data.m_type)
14017 case value_t::object:
14019 std::advance(m_it.object_iterator, 1);
14023 case value_t::array:
14025 std::advance(m_it.array_iterator, 1);
14029 case value_t::null:
14030 case value_t::string:
14031 case value_t::boolean:
14032 case value_t::number_integer:
14033 case value_t::number_unsigned:
14034 case value_t::number_float:
14035 case value_t::binary:
14036 case value_t::discarded:
14039 ++m_it.primitive_iterator;
14053 auto result = *
this;
14066 switch (m_object->m_data.m_type)
14068 case value_t::object:
14070 std::advance(m_it.object_iterator, -1);
14074 case value_t::array:
14076 std::advance(m_it.array_iterator, -1);
14080 case value_t::null:
14081 case value_t::string:
14082 case value_t::boolean:
14083 case value_t::number_integer:
14084 case value_t::number_unsigned:
14085 case value_t::number_float:
14086 case value_t::binary:
14087 case value_t::discarded:
14090 --m_it.primitive_iterator;
14102 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 >
14108 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14112 if (m_object ==
nullptr)
14117 switch (m_object->m_data.m_type)
14119 case value_t::object:
14120 return (m_it.object_iterator == other.m_it.object_iterator);
14122 case value_t::array:
14123 return (m_it.array_iterator == other.m_it.array_iterator);
14125 case value_t::null:
14126 case value_t::string:
14127 case value_t::boolean:
14128 case value_t::number_integer:
14129 case value_t::number_unsigned:
14130 case value_t::number_float:
14131 case value_t::binary:
14132 case value_t::discarded:
14134 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
14142 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 >
14157 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
14161 if (m_object ==
nullptr)
14167 switch (m_object->m_data.m_type)
14169 case value_t::object:
14170 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
14172 case value_t::array:
14175 case value_t::null:
14176 case value_t::string:
14177 case value_t::boolean:
14178 case value_t::number_integer:
14179 case value_t::number_unsigned:
14180 case value_t::number_float:
14181 case value_t::binary:
14182 case value_t::discarded:
14194 return !other.operator < (*this);
14203 return !operator<=(other);
14223 switch (m_object->m_data.m_type)
14225 case value_t::object:
14226 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14228 case value_t::array:
14230 std::advance(m_it.array_iterator, i);
14234 case value_t::null:
14235 case value_t::string:
14236 case value_t::boolean:
14237 case value_t::number_integer:
14238 case value_t::number_unsigned:
14239 case value_t::number_float:
14240 case value_t::binary:
14241 case value_t::discarded:
14244 m_it.primitive_iterator += i;
14267 auto result = *
this;
14289 auto result = *
this;
14302 switch (m_object->m_data.m_type)
14304 case value_t::object:
14305 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
14307 case value_t::array:
14310 case value_t::null:
14311 case value_t::string:
14312 case value_t::boolean:
14313 case value_t::number_integer:
14314 case value_t::number_unsigned:
14315 case value_t::number_float:
14316 case value_t::binary:
14317 case value_t::discarded:
14331 switch (m_object->m_data.m_type)
14333 case value_t::object:
14334 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
14336 case value_t::array:
14337 return *std::next(m_it.array_iterator, n);
14339 case value_t::null:
14340 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14342 case value_t::string:
14343 case value_t::boolean:
14344 case value_t::number_integer:
14345 case value_t::number_unsigned:
14346 case value_t::number_float:
14347 case value_t::binary:
14348 case value_t::discarded:
14356 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
14365 const typename object_t::key_type&
key()
const
14371 return m_it.object_iterator->first;
14374 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
14410 #include <iterator>
14442 template<
typename Base>
14516 auto it = --this->base();
14523 auto it = --this->base();
14524 return it.operator * ();
14544 #include <type_traits>
14586 #include <algorithm>
14614 template<
typename RefStringType>
14624 template<
typename T>
14643 : reference_tokens(split(s))
14650 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14654 return detail::concat(a,
'/', detail::escape(b));
14680 reference_tokens.insert(reference_tokens.end(),
14690 push_back(std::move(token));
14746 reference_tokens.pop_back();
14758 return reference_tokens.back();
14765 reference_tokens.push_back(token);
14772 reference_tokens.push_back(std::move(token));
14779 return reference_tokens.empty();
14793 template<
typename BasicJsonType>
14810 const char* p = s.c_str();
14811 char* p_end =
nullptr;
14813 const unsigned long long res = std::strtoull(p, &p_end, 10);
14823 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14853 template<
typename BasicJsonType>
14860 for (
const auto& reference_token : reference_tokens)
14862 switch (result->type())
14866 if (reference_token ==
"0")
14869 result = &result->operator[](0);
14874 result = &result->operator[](reference_token);
14882 result = &result->operator[](reference_token);
14889 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14933 template<
typename BasicJsonType>
14936 for (
const auto& reference_token : reference_tokens)
14939 if (ptr->is_null())
14943 std::all_of(reference_token.begin(), reference_token.end(),
14944 [](
const unsigned char x)
14946 return std::isdigit(x);
14950 *ptr = (nums || reference_token ==
"-")
14955 switch (ptr->type())
14960 ptr = &ptr->operator[](reference_token);
14966 if (reference_token ==
"-")
14969 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14974 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15001 template<
typename BasicJsonType>
15004 for (
const auto& reference_token : reference_tokens)
15006 switch (ptr->type())
15011 ptr = &ptr->at(reference_token);
15021 "array index '-' (",
std::to_string(ptr->m_data.m_value.array->size()),
15022 ") is out of range"), ptr));
15026 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15059 template<
typename BasicJsonType>
15062 for (
const auto& reference_token : reference_tokens)
15064 switch (ptr->type())
15069 ptr = &ptr->operator[](reference_token);
15082 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15108 template<
typename BasicJsonType>
15111 for (
const auto& reference_token : reference_tokens)
15113 switch (ptr->type())
15118 ptr = &ptr->at(reference_token);
15128 "array index '-' (",
std::to_string(ptr->m_data.m_value.array->size()),
15129 ") is out of range"), ptr));
15133 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15157 template<
typename BasicJsonType>
15160 for (
const auto& reference_token : reference_tokens)
15162 switch (ptr->type())
15166 if (!ptr->contains(reference_token))
15172 ptr = &ptr->operator[](reference_token);
15183 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
15195 for (std::size_t i = 1; i < reference_token.size(); i++)
15205 const auto idx = array_index<BasicJsonType>(reference_token);
15206 if (idx >= ptr->size())
15212 ptr = &ptr->operator[](idx);
15248 std::vector<string_t> result;
15251 if (reference_string.empty())
15267 std::size_t slash = reference_string.find_first_of(
'/', 1),
15274 start = (slash == string_t::npos) ? 0 : slash + 1,
15276 slash = reference_string.find_first_of(
'/', start))
15280 auto reference_token = reference_string.substr(start, slash - start);
15283 for (std::size_t
pos = reference_token.find_first_of(
'~');
15284 pos != string_t::npos;
15285 pos = reference_token.find_first_of(
'~',
pos + 1))
15291 (reference_token[
pos + 1] !=
'0' &&
15292 reference_token[
pos + 1] !=
'1')))
15300 result.push_back(reference_token);
15314 template<
typename BasicJsonType>
15316 const BasicJsonType&
value,
15317 BasicJsonType& result)
15319 switch (
value.type())
15323 if (
value.m_data.m_value.array->empty())
15326 result[reference_string] =
nullptr;
15331 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
15333 flatten(detail::concat<string_t>(reference_string,
'/',
std::to_string(i)),
15334 value.m_data.m_value.array->operator[](i), result);
15342 if (
value.m_data.m_value.object->empty())
15345 result[reference_string] =
nullptr;
15350 for (
const auto& element : *
value.m_data.m_value.object)
15352 flatten(detail::concat<string_t>(reference_string,
'/',
detail::escape(element.first)), element.second, result);
15369 result[reference_string] =
value;
15385 template<
typename BasicJsonType>
15386 static BasicJsonType
15394 BasicJsonType result;
15397 for (
const auto& element : *
value.m_data.m_value.object)
15430 #if JSON_HAS_THREE_WAY_COMPARISON
15433 template<
typename RefStringTypeRhs>
15436 return reference_tokens == rhs.reference_tokens;
15448 template<
typename RefStringTypeRhs>
15451 return reference_tokens <=> rhs.reference_tokens;
15456 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15463 template<
typename RefStringTypeLhs,
typename StringType>
15466 const StringType& rhs);
15470 template<
typename RefStringTypeRhs,
typename StringType>
15472 friend bool operator==(
const StringType& lhs,
15477 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15484 template<
typename RefStringTypeLhs,
typename StringType>
15487 const StringType& rhs);
15491 template<
typename RefStringTypeRhs,
typename StringType>
15493 friend bool operator!=(
const StringType& lhs,
15497 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15508 #if !JSON_HAS_THREE_WAY_COMPARISON
15510 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15514 return lhs.reference_tokens == rhs.reference_tokens;
15517 template<
typename RefStringTypeLhs,
15521 const StringType& rhs)
15526 template<
typename RefStringTypeRhs,
15529 inline
bool operator==(
const StringType& lhs,
15535 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15539 return !(lhs == rhs);
15542 template<
typename RefStringTypeLhs,
15546 const StringType& rhs)
15548 return !(lhs == rhs);
15551 template<
typename RefStringTypeRhs,
15554 inline
bool operator!=(
const StringType& lhs,
15557 return !(lhs == rhs);
15560 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15564 return lhs.reference_tokens < rhs.reference_tokens;
15581 #include <initializer_list>
15593 template<
typename BasicJsonType>
15604 : value_ref(&
value)
15608 : owned_value(init)
15615 : owned_value(
std::forward<Args>(args)...)
15627 if (value_ref ==
nullptr)
15629 return std::move(owned_value);
15636 return value_ref ? *value_ref : owned_value;
15675 #include <algorithm>
15701 #include <algorithm>
15703 #include <iterator>
15735 template<typename CharType>
15739 template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15753 void write_characters(
const CharType* s,
std::
size_t length)
override
15755 v.insert(v.end(), s, s + length);
15759 std::vector<CharType, AllocatorType>&
v;
15764 template<
typename CharType>
15778 void write_characters(
const CharType* s,
std::
size_t length)
override
15780 stream.write(s,
static_cast<std::streamsize
>(length));
15789 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15803 void write_characters(
const CharType* s,
std::
size_t length)
override
15805 str.append(s, length);
15812 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15816 template<
typename AllocatorType = std::allocator<CharType>>
15861 template<
typename BasicJsonType,
typename CharType>
15887 case value_t::object:
15889 write_bson_object(*j.m_data.m_value.object);
15893 case value_t::null:
15894 case value_t::array:
15895 case value_t::string:
15896 case value_t::boolean:
15897 case value_t::number_integer:
15898 case value_t::number_unsigned:
15899 case value_t::number_float:
15900 case value_t::binary:
15901 case value_t::discarded:
15904 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15916 case value_t::null:
15918 oa->write_character(to_char_type(0xF6));
15922 case value_t::boolean:
15924 oa->write_character(j.m_data.m_value.boolean
15925 ? to_char_type(0xF5)
15926 : to_char_type(0xF4));
15930 case value_t::number_integer:
15932 if (j.m_data.m_value.number_integer >= 0)
15937 if (j.m_data.m_value.number_integer <= 0x17)
15939 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
15941 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15943 oa->write_character(to_char_type(0x18));
15944 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
15946 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15948 oa->write_character(to_char_type(0x19));
15949 write_number(
static_cast<std::uint16_t>(j.m_data.m_value.number_integer));
15951 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15953 oa->write_character(to_char_type(0x1A));
15954 write_number(
static_cast<std::uint32_t>(j.m_data.m_value.number_integer));
15958 oa->write_character(to_char_type(0x1B));
15959 write_number(
static_cast<std::uint64_t>(j.m_data.m_value.number_integer));
15966 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15967 if (j.m_data.m_value.number_integer >= -24)
15969 write_number(
static_cast<std::uint8_t>(0x20 + positive_number));
15971 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15973 oa->write_character(to_char_type(0x38));
15974 write_number(
static_cast<std::uint8_t>(positive_number));
15976 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15978 oa->write_character(to_char_type(0x39));
15981 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15983 oa->write_character(to_char_type(0x3A));
15988 oa->write_character(to_char_type(0x3B));
15995 case value_t::number_unsigned:
15997 if (j.m_data.m_value.number_unsigned <= 0x17)
15999 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_unsigned));
16001 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16003 oa->write_character(to_char_type(0x18));
16004 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_unsigned));
16006 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16008 oa->write_character(to_char_type(0x19));
16009 write_number(
static_cast<std::uint16_t>(j.m_data.m_value.number_unsigned));
16011 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16013 oa->write_character(to_char_type(0x1A));
16014 write_number(
static_cast<std::uint32_t>(j.m_data.m_value.number_unsigned));
16018 oa->write_character(to_char_type(0x1B));
16019 write_number(
static_cast<std::uint64_t>(j.m_data.m_value.number_unsigned));
16024 case value_t::number_float:
16026 if (std::isnan(j.m_data.m_value.number_float))
16029 oa->write_character(to_char_type(0xF9));
16030 oa->write_character(to_char_type(0x7E));
16031 oa->write_character(to_char_type(0x00));
16033 else if (std::isinf(j.m_data.m_value.number_float))
16036 oa->write_character(to_char_type(0xf9));
16037 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
16038 oa->write_character(to_char_type(0x00));
16047 case value_t::string:
16050 const auto N = j.m_data.m_value.string->size();
16055 else if (
N <= (std::numeric_limits<std::uint8_t>::max)())
16057 oa->write_character(to_char_type(0x78));
16060 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16062 oa->write_character(to_char_type(0x79));
16065 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16067 oa->write_character(to_char_type(0x7A));
16071 else if (
N <= (std::numeric_limits<std::uint64_t>::max)())
16073 oa->write_character(to_char_type(0x7B));
16079 oa->write_characters(
16080 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16081 j.m_data.m_value.string->size());
16085 case value_t::array:
16088 const auto N = j.m_data.m_value.array->size();
16093 else if (
N <= (std::numeric_limits<std::uint8_t>::max)())
16095 oa->write_character(to_char_type(0x98));
16098 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16100 oa->write_character(to_char_type(0x99));
16103 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16105 oa->write_character(to_char_type(0x9A));
16109 else if (
N <= (std::numeric_limits<std::uint64_t>::max)())
16111 oa->write_character(to_char_type(0x9B));
16117 for (
const auto& el : *j.m_data.m_value.array)
16124 case value_t::binary:
16126 if (j.m_data.m_value.binary->has_subtype())
16128 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
16131 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.binary->subtype()));
16133 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
16136 write_number(
static_cast<std::uint16_t>(j.m_data.m_value.binary->subtype()));
16138 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
16141 write_number(
static_cast<std::uint32_t>(j.m_data.m_value.binary->subtype()));
16143 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
16146 write_number(
static_cast<std::uint64_t>(j.m_data.m_value.binary->subtype()));
16151 const auto N = j.m_data.m_value.binary->size();
16156 else if (
N <= (std::numeric_limits<std::uint8_t>::max)())
16158 oa->write_character(to_char_type(0x58));
16161 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16163 oa->write_character(to_char_type(0x59));
16166 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16168 oa->write_character(to_char_type(0x5A));
16172 else if (
N <= (std::numeric_limits<std::uint64_t>::max)())
16174 oa->write_character(to_char_type(0x5B));
16180 oa->write_characters(
16181 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16187 case value_t::object:
16190 const auto N = j.m_data.m_value.object->size();
16195 else if (
N <= (std::numeric_limits<std::uint8_t>::max)())
16197 oa->write_character(to_char_type(0xB8));
16200 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16202 oa->write_character(to_char_type(0xB9));
16205 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16207 oa->write_character(to_char_type(0xBA));
16211 else if (
N <= (std::numeric_limits<std::uint64_t>::max)())
16213 oa->write_character(to_char_type(0xBB));
16219 for (
const auto& el : *j.m_data.m_value.object)
16221 write_cbor(el.first);
16222 write_cbor(el.second);
16227 case value_t::discarded:
16240 case value_t::null:
16242 oa->write_character(to_char_type(0xC0));
16246 case value_t::boolean:
16248 oa->write_character(j.m_data.m_value.boolean
16249 ? to_char_type(0xC3)
16250 : to_char_type(0xC2));
16254 case value_t::number_integer:
16256 if (j.m_data.m_value.number_integer >= 0)
16261 if (j.m_data.m_value.number_unsigned < 128)
16264 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
16266 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16269 oa->write_character(to_char_type(0xCC));
16270 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
16272 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16275 oa->write_character(to_char_type(0xCD));
16276 write_number(
static_cast<std::uint16_t>(j.m_data.m_value.number_integer));
16278 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16281 oa->write_character(to_char_type(0xCE));
16282 write_number(
static_cast<std::uint32_t>(j.m_data.m_value.number_integer));
16284 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16287 oa->write_character(to_char_type(0xCF));
16288 write_number(
static_cast<std::uint64_t>(j.m_data.m_value.number_integer));
16293 if (j.m_data.m_value.number_integer >= -32)
16296 write_number(
static_cast<std::int8_t>(j.m_data.m_value.number_integer));
16298 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
16299 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16302 oa->write_character(to_char_type(0xD0));
16303 write_number(
static_cast<std::int8_t>(j.m_data.m_value.number_integer));
16305 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
16306 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16309 oa->write_character(to_char_type(0xD1));
16310 write_number(
static_cast<std::int16_t>(j.m_data.m_value.number_integer));
16312 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
16313 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16316 oa->write_character(to_char_type(0xD2));
16317 write_number(
static_cast<std::int32_t>(j.m_data.m_value.number_integer));
16319 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
16320 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16323 oa->write_character(to_char_type(0xD3));
16324 write_number(
static_cast<std::int64_t>(j.m_data.m_value.number_integer));
16330 case value_t::number_unsigned:
16332 if (j.m_data.m_value.number_unsigned < 128)
16335 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
16337 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16340 oa->write_character(to_char_type(0xCC));
16341 write_number(
static_cast<std::uint8_t>(j.m_data.m_value.number_integer));
16343 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16346 oa->write_character(to_char_type(0xCD));
16347 write_number(
static_cast<std::uint16_t>(j.m_data.m_value.number_integer));
16349 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16352 oa->write_character(to_char_type(0xCE));
16353 write_number(
static_cast<std::uint32_t>(j.m_data.m_value.number_integer));
16355 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16358 oa->write_character(to_char_type(0xCF));
16359 write_number(
static_cast<std::uint64_t>(j.m_data.m_value.number_integer));
16364 case value_t::number_float:
16370 case value_t::string:
16373 const auto N = j.m_data.m_value.string->size();
16379 else if (
N <= (std::numeric_limits<std::uint8_t>::max)())
16382 oa->write_character(to_char_type(0xD9));
16385 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16388 oa->write_character(to_char_type(0xDA));
16391 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16394 oa->write_character(to_char_type(0xDB));
16399 oa->write_characters(
16400 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16401 j.m_data.m_value.string->size());
16405 case value_t::array:
16408 const auto N = j.m_data.m_value.array->size();
16414 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16417 oa->write_character(to_char_type(0xDC));
16420 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16423 oa->write_character(to_char_type(0xDD));
16428 for (
const auto& el : *j.m_data.m_value.array)
16435 case value_t::binary:
16439 const bool use_ext = j.m_data.m_value.binary->has_subtype();
16442 const auto N = j.m_data.m_value.binary->size();
16443 if (
N <= (std::numeric_limits<std::uint8_t>::max)())
16452 output_type = 0xD4;
16455 output_type = 0xD5;
16458 output_type = 0xD6;
16461 output_type = 0xD7;
16464 output_type = 0xD8;
16467 output_type = 0xC7;
16475 output_type = 0xC4;
16479 oa->write_character(to_char_type(output_type));
16485 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16491 oa->write_character(to_char_type(output_type));
16494 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16500 oa->write_character(to_char_type(output_type));
16507 write_number(
static_cast<std::int8_t>(j.m_data.m_value.binary->subtype()));
16511 oa->write_characters(
16512 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16518 case value_t::object:
16521 const auto N = j.m_data.m_value.object->size();
16527 else if (
N <= (std::numeric_limits<std::uint16_t>::max)())
16530 oa->write_character(to_char_type(0xDE));
16533 else if (
N <= (std::numeric_limits<std::uint32_t>::max)())
16536 oa->write_character(to_char_type(0xDF));
16541 for (
const auto& el : *j.m_data.m_value.object)
16543 write_msgpack(el.first);
16544 write_msgpack(el.second);
16549 case value_t::discarded:
16564 const bool use_type,
const bool add_prefix =
true,
16565 const bool use_bjdata =
false,
const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
16567 const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
16571 case value_t::null:
16575 oa->write_character(to_char_type(
'Z'));
16580 case value_t::boolean:
16584 oa->write_character(j.m_data.m_value.boolean
16585 ? to_char_type(
'T')
16586 : to_char_type(
'F'));
16591 case value_t::number_integer:
16593 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16597 case value_t::number_unsigned:
16599 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16603 case value_t::number_float:
16605 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16609 case value_t::string:
16613 oa->write_character(to_char_type(
'S'));
16615 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16616 oa->write_characters(
16617 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16618 j.m_data.m_value.string->size());
16622 case value_t::array:
16626 oa->write_character(to_char_type(
'['));
16629 bool prefix_required =
true;
16630 if (use_type && !j.m_data.m_value.array->empty())
16633 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16634 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16635 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16637 return ubjson_prefix(v, use_bjdata) == first_prefix;
16640 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16642 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16644 prefix_required =
false;
16645 oa->write_character(to_char_type(
'$'));
16646 oa->write_character(first_prefix);
16652 oa->write_character(to_char_type(
'#'));
16653 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16656 for (
const auto& el : *j.m_data.m_value.array)
16658 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16663 oa->write_character(to_char_type(
']'));
16669 case value_t::binary:
16673 oa->write_character(to_char_type(
'['));
16676 if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
16679 oa->write_character(to_char_type(
'$'));
16680 oa->write_character(bjdata_draft3 ?
'B' :
'U');
16685 oa->write_character(to_char_type(
'#'));
16686 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16691 oa->write_characters(
16692 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16693 j.m_data.m_value.binary->size());
16697 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16699 oa->write_character(to_char_type(bjdata_draft3 ?
'B' :
'U'));
16700 oa->write_character(j.m_data.m_value.binary->data()[i]);
16706 oa->write_character(to_char_type(
']'));
16712 case value_t::object:
16714 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
16716 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version))
16724 oa->write_character(to_char_type(
'{'));
16727 bool prefix_required =
true;
16728 if (use_type && !j.m_data.m_value.object->empty())
16731 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16732 const bool same_prefix = std::all_of(j.begin(), j.end(),
16733 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16735 return ubjson_prefix(v, use_bjdata) == first_prefix;
16738 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16740 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16742 prefix_required =
false;
16743 oa->write_character(to_char_type(
'$'));
16744 oa->write_character(first_prefix);
16750 oa->write_character(to_char_type(
'#'));
16751 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16754 for (
const auto& el : *j.m_data.m_value.object)
16756 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16757 oa->write_characters(
16758 reinterpret_cast<const CharType*
>(el.first.c_str()),
16760 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16765 oa->write_character(to_char_type(
'}'));
16771 case value_t::discarded:
16788 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16794 static_cast<void>(j);
16795 return 1ul + name.size() + 1u;
16804 oa->write_character(to_char_type(element_type));
16805 oa->write_characters(
16806 reinterpret_cast<const CharType*
>(name.c_str()),
16816 write_bson_entry_header(name, 0x08);
16817 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
16824 const double value)
16826 write_bson_entry_header(name, 0x01);
16827 write_number<double>(
value,
true);
16844 write_bson_entry_header(name, 0x02);
16846 write_number<std::int32_t>(
static_cast<std::int32_t>(
value.size() + 1ul),
true);
16847 oa->write_characters(
16848 reinterpret_cast<const CharType*
>(
value.c_str()),
16857 write_bson_entry_header(name, 0x0A);
16865 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
16876 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
16878 write_bson_entry_header(name, 0x10);
16883 write_bson_entry_header(name, 0x12);
16893 return (
value <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
16902 const BasicJsonType& j)
16904 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
16906 write_bson_entry_header(name, 0x10 );
16907 write_number<std::int32_t>(
static_cast<std::int32_t>(j.m_data.m_value.number_unsigned),
true);
16909 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
16911 write_bson_entry_header(name, 0x12 );
16912 write_number<std::int64_t>(
static_cast<std::int64_t>(j.m_data.m_value.number_unsigned),
true);
16916 write_bson_entry_header(name, 0x11 );
16917 write_number<std::uint64_t>(
static_cast<std::uint64_t>(j.m_data.m_value.number_unsigned),
true);
16925 const typename BasicJsonType::object_t&
value)
16927 write_bson_entry_header(name, 0x03);
16928 write_bson_object(
value);
16936 std::size_t array_index = 0ul;
16938 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
16940 return result + calc_bson_element_size(
std::to_string(array_index++), el);
16943 return sizeof(
std::int32_t) + embedded_document_size + 1ul;
16958 const typename BasicJsonType::array_t&
value)
16960 write_bson_entry_header(name, 0x04);
16961 write_number<std::int32_t>(
static_cast<std::int32_t>(calc_bson_array_size(
value)),
true);
16963 std::size_t array_index = 0ul;
16965 for (
const auto& el :
value)
16970 oa->write_character(to_char_type(0x00));
16979 write_bson_entry_header(name, 0x05);
16984 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16992 const BasicJsonType& j)
16994 const auto header_size = calc_bson_entry_header_size(name, j);
16997 case value_t::object:
16998 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
17000 case value_t::array:
17001 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
17003 case value_t::binary:
17004 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
17006 case value_t::boolean:
17007 return header_size + 1ul;
17009 case value_t::number_float:
17010 return header_size + 8ul;
17012 case value_t::number_integer:
17013 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
17015 case value_t::number_unsigned:
17016 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
17018 case value_t::string:
17019 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
17021 case value_t::null:
17022 return header_size + 0ul;
17025 case value_t::discarded:
17040 const BasicJsonType& j)
17044 case value_t::object:
17045 return write_bson_object_entry(name, *j.m_data.m_value.object);
17047 case value_t::array:
17048 return write_bson_array(name, *j.m_data.m_value.array);
17050 case value_t::binary:
17051 return write_bson_binary(name, *j.m_data.m_value.binary);
17053 case value_t::boolean:
17054 return write_bson_boolean(name, j.m_data.m_value.boolean);
17056 case value_t::number_float:
17057 return write_bson_double(name, j.m_data.m_value.number_float);
17059 case value_t::number_integer:
17060 return write_bson_integer(name, j.m_data.m_value.number_integer);
17062 case value_t::number_unsigned:
17063 return write_bson_unsigned(name, j);
17065 case value_t::string:
17066 return write_bson_string(name, *j.m_data.m_value.string);
17068 case value_t::null:
17069 return write_bson_null(name);
17072 case value_t::discarded:
17088 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
17089 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
17091 return result += calc_bson_element_size(el.first, el.second);
17103 write_number<std::int32_t>(
static_cast<std::int32_t>(calc_bson_object_size(
value)),
true);
17105 for (
const auto& el :
value)
17107 write_bson_element(el.first, el.second);
17110 oa->write_character(to_char_type(0x00));
17119 return to_char_type(0xFA);
17124 return to_char_type(0xFB);
17133 return to_char_type(0xCA);
17138 return to_char_type(0xCB);
17146 template<
typename NumberType,
typename std::enable_if<
17149 const bool add_prefix,
17150 const bool use_bjdata)
17154 oa->write_character(get_ubjson_float_prefix(n));
17156 write_number(n, use_bjdata);
17160 template<
typename NumberType,
typename std::enable_if<
17163 const bool add_prefix,
17164 const bool use_bjdata)
17166 if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
17170 oa->write_character(to_char_type(
'i'));
17172 write_number(
static_cast<std::uint8_t>(n), use_bjdata);
17174 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
17178 oa->write_character(to_char_type(
'U'));
17180 write_number(
static_cast<std::uint8_t>(n), use_bjdata);
17182 else if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
17186 oa->write_character(to_char_type(
'I'));
17188 write_number(
static_cast<std::int16_t>(n), use_bjdata);
17190 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint16_t>::max)()))
17194 oa->write_character(to_char_type(
'u'));
17198 else if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
17202 oa->write_character(to_char_type(
'l'));
17204 write_number(
static_cast<std::int32_t>(n), use_bjdata);
17206 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint32_t>::max)()))
17210 oa->write_character(to_char_type(
'm'));
17214 else if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
17218 oa->write_character(to_char_type(
'L'));
17220 write_number(
static_cast<std::int64_t>(n), use_bjdata);
17222 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
17226 oa->write_character(to_char_type(
'M'));
17234 oa->write_character(to_char_type(
'H'));
17237 const auto number = BasicJsonType(n).dump();
17238 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17239 for (std::size_t i = 0; i < number.size(); ++i)
17241 oa->write_character(to_char_type(
static_cast<std::uint8_t>(number[i])));
17247 template <
typename NumberType,
typename std::enable_if <
17251 const bool add_prefix,
17252 const bool use_bjdata)
17254 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
17258 oa->write_character(to_char_type(
'i'));
17260 write_number(
static_cast<std::int8_t>(n), use_bjdata);
17262 else if (
static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
17266 oa->write_character(to_char_type(
'U'));
17268 write_number(
static_cast<std::uint8_t>(n), use_bjdata);
17270 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
17274 oa->write_character(to_char_type(
'I'));
17276 write_number(
static_cast<std::int16_t>(n), use_bjdata);
17278 else if (use_bjdata && (
static_cast<std::int64_t>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t>((std::numeric_limits<std::uint16_t>::max)())))
17282 oa->write_character(to_char_type(
'u'));
17284 write_number(
static_cast<uint16_t>(n), use_bjdata);
17286 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
17290 oa->write_character(to_char_type(
'l'));
17292 write_number(
static_cast<std::int32_t>(n), use_bjdata);
17294 else if (use_bjdata && (
static_cast<std::int64_t>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t>((std::numeric_limits<std::uint32_t>::max)())))
17298 oa->write_character(to_char_type(
'm'));
17300 write_number(
static_cast<uint32_t>(n), use_bjdata);
17302 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
17306 oa->write_character(to_char_type(
'L'));
17308 write_number(
static_cast<std::int64_t>(n), use_bjdata);
17315 oa->write_character(to_char_type(
'H'));
17318 const auto number = BasicJsonType(n).dump();
17319 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17320 for (std::size_t i = 0; i < number.size(); ++i)
17322 oa->write_character(to_char_type(
static_cast<std::uint8_t>(number[i])));
17331 CharType
ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
17335 case value_t::null:
17338 case value_t::boolean:
17339 return j.m_data.m_value.boolean ?
'T' :
'F';
17341 case value_t::number_integer:
17343 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
17347 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
17351 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
17355 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
17359 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
17363 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
17367 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
17375 case value_t::number_unsigned:
17377 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
17381 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
17385 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
17389 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::uint16_t>::max)()))
17393 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
17397 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::uint32_t>::max)()))
17401 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
17405 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
17413 case value_t::number_float:
17414 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
17416 case value_t::string:
17419 case value_t::array:
17420 case value_t::binary:
17423 case value_t::object:
17426 case value_t::discarded:
17447 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
17448 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'},
17449 {
"char",
'C'}, {
"byte",
'B'}
17454 if (it == bjdtype.end())
17458 CharType dtype = it->second;
17460 key =
"_ArraySize_";
17461 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
17462 for (
const auto& el :
value.at(
key))
17464 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
17467 key =
"_ArrayData_";
17473 oa->write_character(
'[');
17474 oa->write_character(
'$');
17475 oa->write_character(dtype);
17476 oa->write_character(
'#');
17478 key =
"_ArraySize_";
17479 write_ubjson(
value.at(
key), use_count, use_type,
true,
true, bjdata_version);
17481 key =
"_ArrayData_";
17482 if (dtype ==
'U' || dtype ==
'C' || dtype ==
'B')
17484 for (
const auto& el :
value.at(
key))
17486 write_number(
static_cast<std::uint8_t>(el.m_data.m_value.number_unsigned),
true);
17489 else if (dtype ==
'i')
17491 for (
const auto& el :
value.at(
key))
17493 write_number(
static_cast<std::int8_t>(el.m_data.m_value.number_integer),
true);
17496 else if (dtype ==
'u')
17498 for (
const auto& el :
value.at(
key))
17500 write_number(
static_cast<std::uint16_t>(el.m_data.m_value.number_unsigned),
true);
17503 else if (dtype ==
'I')
17505 for (
const auto& el :
value.at(
key))
17507 write_number(
static_cast<std::int16_t>(el.m_data.m_value.number_integer),
true);
17510 else if (dtype ==
'm')
17512 for (
const auto& el :
value.at(
key))
17514 write_number(
static_cast<std::uint32_t>(el.m_data.m_value.number_unsigned),
true);
17517 else if (dtype ==
'l')
17519 for (
const auto& el :
value.at(
key))
17521 write_number(
static_cast<std::int32_t>(el.m_data.m_value.number_integer),
true);
17524 else if (dtype ==
'M')
17526 for (
const auto& el :
value.at(
key))
17528 write_number(
static_cast<std::uint64_t>(el.m_data.m_value.number_unsigned),
true);
17531 else if (dtype ==
'L')
17533 for (
const auto& el :
value.at(
key))
17535 write_number(
static_cast<std::int64_t>(el.m_data.m_value.number_integer),
true);
17538 else if (dtype ==
'd')
17540 for (
const auto& el :
value.at(
key))
17542 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
17545 else if (dtype ==
'D')
17547 for (
const auto& el :
value.at(
key))
17549 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
17572 template<
typename NumberType>
17576 std::array<CharType,
sizeof(NumberType)> vec{};
17577 std::memcpy(vec.data(), &n,
sizeof(NumberType));
17586 oa->write_characters(vec.data(),
sizeof(NumberType));
17592 #pragma GCC diagnostic push
17593 #pragma GCC diagnostic ignored "-Wfloat-equal"
17595 if (!std::isfinite(n) || ((
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17596 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17597 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))))
17600 ? get_cbor_float_prefix(
static_cast<float>(n))
17601 : get_msgpack_float_prefix(
static_cast<float>(n)));
17602 write_number(
static_cast<float>(n));
17607 ? get_cbor_float_prefix(n)
17608 : get_msgpack_float_prefix(n));
17612 #pragma GCC diagnostic pop
17621 template <
typename C = CharType,
17625 return *
reinterpret_cast<char*
>(&x);
17628 template <
typename C = CharType,
17639 #ifdef JSON_HAS_CPP_26
17646 static_assert(
sizeof(
std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17648 std::memcpy(&result, &x,
sizeof(x));
17652 template<
typename C = CharType,
17659 template <
typename InputCharType,
typename C = CharType,
17695 #include <algorithm>
17705 #include <type_traits>
17725 #include <type_traits>
17753 namespace dtoa_impl
17756 template<
typename Target,
typename Source>
17759 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17762 std::memcpy(&target, &
source,
sizeof(Source));
17768 static constexpr
int kPrecision = 64;
17784 return {x.f - y.f, x.e};
17793 static_assert(kPrecision == 64,
"internal error");
17849 return {h, x.e + y.e + 64};
17860 while ((x.f >> 63u) == 0)
17875 const int delta = x.
e - target_exponent;
17880 return {x.f << delta, target_exponent};
17897 template<
typename FloatType>
17910 static_assert(std::numeric_limits<FloatType>::is_iec559,
17911 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17913 constexpr
int kPrecision = std::numeric_limits<FloatType>::digits;
17914 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17915 constexpr
int kMinExp = 1 - kBias;
17924 const bool is_denormal = E == 0;
17925 const diyfp v = is_denormal
17926 ?
diyfp(F, kMinExp)
17927 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17950 const bool lower_boundary_is_closer = F == 0 && E > 1;
17952 const diyfp m_minus = lower_boundary_is_closer
17953 ?
diyfp((4 * v.
f) - 1, v.
e - 2)
17954 :
diyfp((2 * v.
f) - 1, v.
e - 1);
17957 const diyfp w_plus = diyfp::normalize(m_plus);
17960 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
17962 return {diyfp::normalize(v), w_minus, w_plus};
18089 constexpr
int kCachedPowersMinDecExp = -300;
18090 constexpr
int kCachedPowersDecStep = 8;
18092 static constexpr std::array<cached_power, 79> kCachedPowers =
18095 { 0xAB70FE17C79AC6CA, -1060, -300 },
18096 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
18097 { 0xBE5691EF416BD60C, -1007, -284 },
18098 { 0x8DD01FAD907FFC3C, -980, -276 },
18099 { 0xD3515C2831559A83, -954, -268 },
18100 { 0x9D71AC8FADA6C9B5, -927, -260 },
18101 { 0xEA9C227723EE8BCB, -901, -252 },
18102 { 0xAECC49914078536D, -874, -244 },
18103 { 0x823C12795DB6CE57, -847, -236 },
18104 { 0xC21094364DFB5637, -821, -228 },
18105 { 0x9096EA6F3848984F, -794, -220 },
18106 { 0xD77485CB25823AC7, -768, -212 },
18107 { 0xA086CFCD97BF97F4, -741, -204 },
18108 { 0xEF340A98172AACE5, -715, -196 },
18109 { 0xB23867FB2A35B28E, -688, -188 },
18110 { 0x84C8D4DFD2C63F3B, -661, -180 },
18111 { 0xC5DD44271AD3CDBA, -635, -172 },
18112 { 0x936B9FCEBB25C996, -608, -164 },
18113 { 0xDBAC6C247D62A584, -582, -156 },
18114 { 0xA3AB66580D5FDAF6, -555, -148 },
18115 { 0xF3E2F893DEC3F126, -529, -140 },
18116 { 0xB5B5ADA8AAFF80B8, -502, -132 },
18117 { 0x87625F056C7C4A8B, -475, -124 },
18118 { 0xC9BCFF6034C13053, -449, -116 },
18119 { 0x964E858C91BA2655, -422, -108 },
18120 { 0xDFF9772470297EBD, -396, -100 },
18121 { 0xA6DFBD9FB8E5B88F, -369, -92 },
18122 { 0xF8A95FCF88747D94, -343, -84 },
18123 { 0xB94470938FA89BCF, -316, -76 },
18124 { 0x8A08F0F8BF0F156B, -289, -68 },
18125 { 0xCDB02555653131B6, -263, -60 },
18126 { 0x993FE2C6D07B7FAC, -236, -52 },
18127 { 0xE45C10C42A2B3B06, -210, -44 },
18128 { 0xAA242499697392D3, -183, -36 },
18129 { 0xFD87B5F28300CA0E, -157, -28 },
18130 { 0xBCE5086492111AEB, -130, -20 },
18131 { 0x8CBCCC096F5088CC, -103, -12 },
18132 { 0xD1B71758E219652C, -77, -4 },
18133 { 0x9C40000000000000, -50, 4 },
18134 { 0xE8D4A51000000000, -24, 12 },
18135 { 0xAD78EBC5AC620000, 3, 20 },
18136 { 0x813F3978F8940984, 30, 28 },
18137 { 0xC097CE7BC90715B3, 56, 36 },
18138 { 0x8F7E32CE7BEA5C70, 83, 44 },
18139 { 0xD5D238A4ABE98068, 109, 52 },
18140 { 0x9F4F2726179A2245, 136, 60 },
18141 { 0xED63A231D4C4FB27, 162, 68 },
18142 { 0xB0DE65388CC8ADA8, 189, 76 },
18143 { 0x83C7088E1AAB65DB, 216, 84 },
18144 { 0xC45D1DF942711D9A, 242, 92 },
18145 { 0x924D692CA61BE758, 269, 100 },
18146 { 0xDA01EE641A708DEA, 295, 108 },
18147 { 0xA26DA3999AEF774A, 322, 116 },
18148 { 0xF209787BB47D6B85, 348, 124 },
18149 { 0xB454E4A179DD1877, 375, 132 },
18150 { 0x865B86925B9BC5C2, 402, 140 },
18151 { 0xC83553C5C8965D3D, 428, 148 },
18152 { 0x952AB45CFA97A0B3, 455, 156 },
18153 { 0xDE469FBD99A05FE3, 481, 164 },
18154 { 0xA59BC234DB398C25, 508, 172 },
18155 { 0xF6C69A72A3989F5C, 534, 180 },
18156 { 0xB7DCBF5354E9BECE, 561, 188 },
18157 { 0x88FCF317F22241E2, 588, 196 },
18158 { 0xCC20CE9BD35C78A5, 614, 204 },
18159 { 0x98165AF37B2153DF, 641, 212 },
18160 { 0xE2A0B5DC971F303A, 667, 220 },
18161 { 0xA8D9D1535CE3B396, 694, 228 },
18162 { 0xFB9B7CD9A4A7443C, 720, 236 },
18163 { 0xBB764C4CA7A44410, 747, 244 },
18164 { 0x8BAB8EEFB6409C1A, 774, 252 },
18165 { 0xD01FEF10A657842C, 800, 260 },
18166 { 0x9B10A4E5E9913129, 827, 268 },
18167 { 0xE7109BFBA19C0C9D, 853, 276 },
18168 { 0xAC2820D9623BF429, 880, 284 },
18169 { 0x80444B5E7AA7CF85, 907, 292 },
18170 { 0xBF21E44003ACDD2D, 933, 300 },
18171 { 0x8E679C2F5E44FF8F, 960, 308 },
18172 { 0xD433179D9C8CB841, 986, 316 },
18173 { 0x9E19DB92B4E31BA9, 1013, 324 },
18183 const int f =
kAlpha - e - 1;
18184 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
18186 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
18188 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
18190 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
18204 if (n >= 1000000000)
18206 pow10 = 1000000000;
18210 if (n >= 100000000)
18283 && delta - rest >= ten_k
18284 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
18299 static_assert(
kAlpha >= -60,
"internal error");
18300 static_assert(
kGamma <= -32,
"internal error");
18373 buffer[length++] =
static_cast<char>(
'0' +
d);
18397 decimal_exponent += n;
18409 grisu2_round(buffer, length, dist, delta, rest, ten_n);
18470 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
18480 buffer[length++] =
static_cast<char>(
'0' +
d);
18505 decimal_exponent -= m;
18537 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
18554 const diyfp c_minus_k(cached.
f, cached.
e);
18557 const diyfp w = diyfp::mul(v, c_minus_k);
18558 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
18559 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
18582 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
18583 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
18585 decimal_exponent = -cached.
k;
18595 template<
typename FloatType>
18599 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
18600 "internal error: not enough precision");
18658 *buf++ =
static_cast<char>(
'0' + k);
18662 *buf++ =
static_cast<char>(
'0' + (k / 10));
18664 *buf++ =
static_cast<char>(
'0' + k);
18668 *buf++ =
static_cast<char>(
'0' + (k / 100));
18670 *buf++ =
static_cast<char>(
'0' + (k / 10));
18672 *buf++ =
static_cast<char>(
'0' + k);
18690 int min_exp,
int max_exp)
18696 const int n = len + decimal_exponent;
18702 if (k <= n && n <= max_exp)
18707 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18711 return buf + (
static_cast<size_t>(n) + 2);
18714 if (0 < n && n <= max_exp)
18721 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18723 return buf + (
static_cast<size_t>(k) + 1U);
18726 if (min_exp < n && n <= 0)
18731 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18734 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18735 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18750 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18752 buf += 1 +
static_cast<size_t>(k);
18771 template<
typename FloatType>
18776 static_cast<void>(last);
18780 if (std::signbit(
value))
18787 #pragma GCC diagnostic push
18788 #pragma GCC diagnostic ignored "-Wfloat-equal"
18799 #pragma GCC diagnostic pop
18802 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18809 int decimal_exponent = 0;
18812 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18815 constexpr
int kMinExp = -4;
18817 constexpr
int kMaxExp = std::numeric_limits<FloatType>::digits10;
18820 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18821 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18860 template<
typename BasicJsonType>
18880 , loc(
std::localeconv())
18881 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->thousands_sep)))
18882 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::
char_traits<char>::to_char_type(* (loc->decimal_point)))
18883 , indent_char(ichar)
18884 , indent_string(512, indent_char)
18885 , error_handler(error_handler_)
18918 const bool pretty_print,
18919 const bool ensure_ascii,
18920 const unsigned int indent_step,
18921 const unsigned int current_indent = 0)
18923 switch (val.m_data.m_type)
18925 case value_t::object:
18927 if (val.m_data.m_value.object->empty())
18929 o->write_characters(
"{}", 2);
18935 o->write_characters(
"{\n", 2);
18938 const auto new_indent = current_indent + indent_step;
18941 indent_string.resize(indent_string.size() * 2,
' ');
18945 auto i = val.m_data.m_value.object->cbegin();
18946 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18948 o->write_characters(indent_string.c_str(), new_indent);
18949 o->write_character(
'\"');
18950 dump_escaped(i->first, ensure_ascii);
18951 o->write_characters(
"\": ", 3);
18952 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18953 o->write_characters(
",\n", 2);
18957 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18958 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18959 o->write_characters(indent_string.c_str(), new_indent);
18960 o->write_character(
'\"');
18961 dump_escaped(i->first, ensure_ascii);
18962 o->write_characters(
"\": ", 3);
18963 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18965 o->write_character(
'\n');
18966 o->write_characters(indent_string.c_str(), current_indent);
18967 o->write_character(
'}');
18971 o->write_character(
'{');
18974 auto i = val.m_data.m_value.object->cbegin();
18975 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18977 o->write_character(
'\"');
18978 dump_escaped(i->first, ensure_ascii);
18979 o->write_characters(
"\":", 2);
18980 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18981 o->write_character(
',');
18985 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18986 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18987 o->write_character(
'\"');
18988 dump_escaped(i->first, ensure_ascii);
18989 o->write_characters(
"\":", 2);
18990 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18992 o->write_character(
'}');
18998 case value_t::array:
19000 if (val.m_data.m_value.array->empty())
19002 o->write_characters(
"[]", 2);
19008 o->write_characters(
"[\n", 2);
19011 const auto new_indent = current_indent + indent_step;
19014 indent_string.resize(indent_string.size() * 2,
' ');
19018 for (
auto i = val.m_data.m_value.array->cbegin();
19019 i != val.m_data.m_value.array->cend() - 1; ++i)
19021 o->write_characters(indent_string.c_str(), new_indent);
19022 dump(*i,
true, ensure_ascii, indent_step, new_indent);
19023 o->write_characters(
",\n", 2);
19028 o->write_characters(indent_string.c_str(), new_indent);
19029 dump(val.m_data.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
19031 o->write_character(
'\n');
19032 o->write_characters(indent_string.c_str(), current_indent);
19033 o->write_character(
']');
19037 o->write_character(
'[');
19040 for (
auto i = val.m_data.m_value.array->cbegin();
19041 i != val.m_data.m_value.array->cend() - 1; ++i)
19043 dump(*i,
false, ensure_ascii, indent_step, current_indent);
19044 o->write_character(
',');
19049 dump(val.m_data.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
19051 o->write_character(
']');
19057 case value_t::string:
19059 o->write_character(
'\"');
19060 dump_escaped(*val.m_data.m_value.string, ensure_ascii);
19061 o->write_character(
'\"');
19065 case value_t::binary:
19069 o->write_characters(
"{\n", 2);
19072 const auto new_indent = current_indent + indent_step;
19075 indent_string.resize(indent_string.size() * 2,
' ');
19078 o->write_characters(indent_string.c_str(), new_indent);
19080 o->write_characters(
"\"bytes\": [", 10);
19082 if (!val.m_data.m_value.binary->empty())
19084 for (
auto i = val.m_data.m_value.binary->cbegin();
19085 i != val.m_data.m_value.binary->cend() - 1; ++i)
19088 o->write_characters(
", ", 2);
19090 dump_integer(val.m_data.m_value.binary->back());
19093 o->write_characters(
"],\n", 3);
19094 o->write_characters(indent_string.c_str(), new_indent);
19096 o->write_characters(
"\"subtype\": ", 11);
19097 if (val.m_data.m_value.binary->has_subtype())
19099 dump_integer(val.m_data.m_value.binary->subtype());
19103 o->write_characters(
"null", 4);
19105 o->write_character(
'\n');
19106 o->write_characters(indent_string.c_str(), current_indent);
19107 o->write_character(
'}');
19111 o->write_characters(
"{\"bytes\":[", 10);
19113 if (!val.m_data.m_value.binary->empty())
19115 for (
auto i = val.m_data.m_value.binary->cbegin();
19116 i != val.m_data.m_value.binary->cend() - 1; ++i)
19119 o->write_character(
',');
19121 dump_integer(val.m_data.m_value.binary->back());
19124 o->write_characters(
"],\"subtype\":", 12);
19125 if (val.m_data.m_value.binary->has_subtype())
19127 dump_integer(val.m_data.m_value.binary->subtype());
19128 o->write_character(
'}');
19132 o->write_characters(
"null}", 5);
19138 case value_t::boolean:
19140 if (val.m_data.m_value.boolean)
19142 o->write_characters(
"true", 4);
19146 o->write_characters(
"false", 5);
19151 case value_t::number_integer:
19153 dump_integer(val.m_data.m_value.number_integer);
19157 case value_t::number_unsigned:
19159 dump_integer(val.m_data.m_value.number_unsigned);
19163 case value_t::number_float:
19165 dump_float(val.m_data.m_value.number_float);
19169 case value_t::discarded:
19171 o->write_characters(
"<discarded>", 11);
19175 case value_t::null:
19177 o->write_characters(
"null", 4);
19201 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
19205 std::size_t bytes = 0;
19208 std::size_t bytes_after_last_accept = 0;
19209 std::size_t undumped_chars = 0;
19211 for (std::size_t i = 0; i < s.size(); ++i)
19215 switch (
decode(state, codepoint,
byte))
19223 string_buffer[bytes++] =
'\\';
19224 string_buffer[bytes++] =
'b';
19230 string_buffer[bytes++] =
'\\';
19231 string_buffer[bytes++] =
't';
19237 string_buffer[bytes++] =
'\\';
19238 string_buffer[bytes++] =
'n';
19244 string_buffer[bytes++] =
'\\';
19245 string_buffer[bytes++] =
'f';
19251 string_buffer[bytes++] =
'\\';
19252 string_buffer[bytes++] =
'r';
19258 string_buffer[bytes++] =
'\\';
19259 string_buffer[bytes++] =
'\"';
19265 string_buffer[bytes++] =
'\\';
19266 string_buffer[bytes++] =
'\\';
19274 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
19276 if (codepoint <= 0xFFFF)
19279 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
19286 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
19288 static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu))));
19296 string_buffer[bytes++] = s[i];
19305 if (string_buffer.size() - bytes < 13)
19307 o->write_characters(string_buffer.data(), bytes);
19312 bytes_after_last_accept = bytes;
19313 undumped_chars = 0;
19319 switch (error_handler)
19321 case error_handler_t::strict:
19326 case error_handler_t::ignore:
19327 case error_handler_t::replace:
19333 if (undumped_chars > 0)
19340 bytes = bytes_after_last_accept;
19342 if (error_handler == error_handler_t::replace)
19347 string_buffer[bytes++] =
'\\';
19348 string_buffer[bytes++] =
'u';
19349 string_buffer[bytes++] =
'f';
19350 string_buffer[bytes++] =
'f';
19351 string_buffer[bytes++] =
'f';
19352 string_buffer[bytes++] =
'd';
19364 if (string_buffer.size() - bytes < 13)
19366 o->write_characters(string_buffer.data(), bytes);
19370 bytes_after_last_accept = bytes;
19373 undumped_chars = 0;
19376 state = UTF8_ACCEPT;
19391 string_buffer[bytes++] = s[i];
19405 o->write_characters(string_buffer.data(), bytes);
19411 switch (error_handler)
19413 case error_handler_t::strict:
19415 JSON_THROW(type_error::create(316,
concat(
"incomplete UTF-8 string; last byte: 0x", hex_bytes(
static_cast<std::uint8_t>(s.back() | 0))),
nullptr));
19418 case error_handler_t::ignore:
19421 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19425 case error_handler_t::replace:
19428 o->write_characters(string_buffer.data(), bytes_after_last_accept);
19432 o->write_characters(
"\\ufffd", 6);
19436 o->write_characters(
"\xEF\xBF\xBD", 3);
19458 unsigned int n_digits = 1;
19467 return n_digits + 1;
19471 return n_digits + 2;
19475 return n_digits + 3;
19489 std::string result =
"FF";
19490 constexpr
const char* nibble_to_hex =
"0123456789ABCDEF";
19491 result[0] = nibble_to_hex[
byte / 16];
19492 result[1] = nibble_to_hex[
byte % 16];
19498 bool is_negative_number(NumberType x)
19504 bool is_negative_number(NumberType )
19524 void dump_integer(NumberType x)
19526 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
19529 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
19530 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
19531 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
19532 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
19533 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
19534 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
19535 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
19536 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
19537 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
19538 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
19545 o->write_character(
'0');
19550 auto buffer_ptr = number_buffer.begin();
19554 unsigned int n_chars{};
19556 if (is_negative_number(x))
19562 n_chars = 1 + count_digits(abs_value);
19567 n_chars = count_digits(abs_value);
19575 buffer_ptr +=
static_cast<typename decltype(number_buffer)::difference_type
>(n_chars);
19579 while (abs_value >= 100)
19581 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
19583 *(--buffer_ptr) = digits_to_99[digits_index][1];
19584 *(--buffer_ptr) = digits_to_99[digits_index][0];
19587 if (abs_value >= 10)
19589 const auto digits_index =
static_cast<unsigned>(abs_value);
19590 *(--buffer_ptr) = digits_to_99[digits_index][1];
19591 *(--buffer_ptr) = digits_to_99[digits_index][0];
19595 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19598 o->write_characters(number_buffer.data(), n_chars);
19612 if (!std::isfinite(x))
19614 o->write_characters(
"null", 4);
19623 static constexpr
bool is_ieee_single_or_double
19624 = (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) ||
19625 (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);
19627 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
19632 auto* begin = number_buffer.data();
19635 o->write_characters(begin,
static_cast<size_t>(end - begin));
19641 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
19645 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g",
d, x);
19650 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
19653 if (thousands_sep !=
'\0')
19656 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
19657 std::fill(end, number_buffer.end(),
'\0');
19658 JSON_ASSERT((end - number_buffer.begin()) <= len);
19659 len = (end - number_buffer.begin());
19663 if (decimal_point !=
'\0' && decimal_point !=
'.')
19666 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
19667 if (dec_pos != number_buffer.end())
19673 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
19676 const bool value_is_int_like =
19677 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
19680 return c ==
'.' || c ==
'e';
19683 if (value_is_int_like)
19685 o->write_characters(
".0", 2);
19712 static const std::array<std::uint8_t, 400> utf8d =
19715 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,
19716 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,
19717 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,
19718 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,
19719 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,
19720 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,
19721 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,
19722 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19723 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19724 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19725 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,
19726 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,
19727 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,
19728 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
19735 codep = (state != UTF8_ACCEPT)
19736 ? (
byte & 0x3fu) | (codep << 6u)
19737 : (0xFFu >>
type) & (byte);
19739 const std::size_t index = 256u + (
static_cast<size_t>(state) * 16u) +
static_cast<size_t>(
type);
19741 state = utf8d[index];
19767 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19773 output_adapter_t<char> o =
nullptr;
19776 std::array<char, 64> number_buffer{{}};
19779 const std::lconv* loc =
nullptr;
19781 const char thousands_sep =
'\0';
19783 const char decimal_point =
'\0';
19786 std::array<char, 512> string_buffer{{}};
19815 #include <functional>
19816 #include <initializer_list>
19817 #include <iterator>
19819 #include <stdexcept>
19820 #include <type_traits>
19833 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19834 class Allocator = std::allocator<std::pair<const Key, T>>>
19844 #ifdef JSON_HAS_CPP_14
19854 template <
class It>
19862 for (
auto it = this->begin(); it != this->end(); ++it)
19864 if (m_compare(it->first,
key))
19866 return {it,
false};
19869 Container::emplace_back(
key, std::forward<T>(t));
19870 return {std::prev(this->end()),
true};
19877 for (
auto it = this->begin(); it != this->end(); ++it)
19879 if (m_compare(it->first,
key))
19881 return {it,
false};
19884 Container::emplace_back(std::forward<KeyType>(
key), std::forward<T>(t));
19885 return {std::prev(this->end()),
true};
19890 return emplace(
key, T{}).first->second;
19897 return emplace(std::forward<KeyType>(
key), T{}).first->second;
19909 return at(std::forward<KeyType>(
key));
19914 for (
auto it = this->begin(); it != this->end(); ++it)
19916 if (m_compare(it->first,
key))
19922 JSON_THROW(std::out_of_range(
"key not found"));
19929 for (
auto it = this->begin(); it != this->end(); ++it)
19931 if (m_compare(it->first,
key))
19937 JSON_THROW(std::out_of_range(
"key not found"));
19942 for (
auto it = this->begin(); it != this->end(); ++it)
19944 if (m_compare(it->first,
key))
19950 JSON_THROW(std::out_of_range(
"key not found"));
19957 for (
auto it = this->begin(); it != this->end(); ++it)
19959 if (m_compare(it->first,
key))
19965 JSON_THROW(std::out_of_range(
"key not found"));
19970 for (
auto it = this->begin(); it != this->end(); ++it)
19972 if (m_compare(it->first,
key))
19975 for (
auto next = it; ++next != this->end(); ++it)
19980 Container::pop_back();
19991 for (
auto it = this->begin(); it != this->end(); ++it)
19993 if (m_compare(it->first,
key))
19996 for (
auto next = it; ++next != this->end(); ++it)
20001 Container::pop_back();
20010 return erase(
pos, std::next(
pos));
20020 const auto elements_affected = std::distance(first, last);
20021 const auto offset = std::distance(Container::begin(), first);
20043 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
20046 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
20054 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
20063 return Container::begin() + offset;
20068 for (
auto it = this->begin(); it != this->end(); ++it)
20070 if (m_compare(it->first,
key))
20082 for (
auto it = this->begin(); it != this->end(); ++it)
20084 if (m_compare(it->first,
key))
20094 for (
auto it = this->begin(); it != this->end(); ++it)
20096 if (m_compare(it->first,
key))
20101 return Container::end();
20108 for (
auto it = this->begin(); it != this->end(); ++it)
20110 if (m_compare(it->first,
key))
20115 return Container::end();
20120 for (
auto it = this->begin(); it != this->end(); ++it)
20122 if (m_compare(it->first,
key))
20127 return Container::end();
20132 return emplace(
value.first, std::move(
value.second));
20137 for (
auto it = this->begin(); it != this->end(); ++it)
20139 if (m_compare(it->first,
value.first))
20141 return {it,
false};
20144 Container::push_back(
value);
20145 return {--this->end(),
true};
20148 template<
typename InputIt>
20149 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20152 template<
typename InputIt,
typename = require_input_iter<InputIt>>
20155 for (
auto it = first; it != last; ++it)
20168 #if defined(JSON_HAS_CPP_17)
20169 #if JSON_HAS_STATIC_RTTI
20172 #include <string_view>
20208 friend class ::nlohmann::json_pointer;
20212 template<
typename BasicJsonType,
typename InputType>
20213 friend class ::nlohmann::detail::parser;
20214 friend ::nlohmann::detail::serializer<basic_json>;
20215 template<
typename BasicJsonType>
20216 friend class ::nlohmann::detail::iter_impl;
20217 template<
typename BasicJsonType,
typename CharType>
20218 friend class ::nlohmann::detail::binary_writer;
20219 template<
typename BasicJsonType,
typename InputType,
typename SAX>
20220 friend class ::nlohmann::detail::binary_reader;
20221 template<
typename BasicJsonType,
typename InputAdapterType>
20222 friend class ::nlohmann::detail::json_sax_dom_parser;
20223 template<
typename BasicJsonType,
typename InputAdapterType>
20224 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
20225 friend class ::nlohmann::detail::exception;
20235 template<
typename InputAdapterType>
20236 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
20237 InputAdapterType adapter,
20239 const bool allow_exceptions =
true,
20240 const bool ignore_comments =
false,
20241 const bool ignore_trailing_commas =
false
20244 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20245 std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
20250 template<
typename BasicJsonType>
20252 template<
typename BasicJsonType>
20254 template<
typename Iterator>
20258 template<
typename CharType>
20261 template<
typename InputType>
20272 template<
typename T,
typename SFINAE>
20332 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
20359 result[
"copyright"] =
"(C) 2013-2025 Niels Lohmann";
20360 result[
"name"] =
"JSON for Modern C++";
20361 result[
"url"] =
"https://github.com/nlohmann/json";
20362 result[
"version"][
"string"] =
20371 result[
"platform"] =
"win32";
20372 #elif defined __linux__
20373 result[
"platform"] =
"linux";
20374 #elif defined __APPLE__
20375 result[
"platform"] =
"apple";
20376 #elif defined __unix__
20377 result[
"platform"] =
"unix";
20379 result[
"platform"] =
"unknown";
20382 #if defined(__ICC) || defined(__INTEL_COMPILER)
20383 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
20384 #elif defined(__clang__)
20385 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
20386 #elif defined(__GNUC__) || defined(__GNUG__)
20387 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
20393 #elif defined(__HP_cc) || defined(__HP_aCC)
20394 result[
"compiler"] =
"hp"
20395 #elif defined(__IBMCPP__)
20396 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
20397 #elif defined(_MSC_VER)
20398 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
20399 #elif defined(__PGI)
20400 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
20401 #elif defined(__SUNPRO_CC)
20402 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
20404 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
20407 #if defined(_MSVC_LANG)
20409 #elif defined(__cplusplus)
20412 result[
"compiler"][
"c++"] =
"unknown";
20430 #if defined(JSON_HAS_CPP_14)
20433 using default_object_comparator_t = std::less<>;
20443 AllocatorType<std::pair<
const StringType,
20483 template<
typename T,
typename... Args>
20487 AllocatorType<T> alloc;
20488 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
20490 auto deleter = [&](T * obj)
20492 AllocatorTraits::deallocate(alloc, obj, 1);
20494 std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
20495 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
20497 return obj.release();
20564 case value_t::object:
20566 object = create<object_t>();
20570 case value_t::array:
20572 array = create<array_t>();
20576 case value_t::string:
20578 string = create<string_t>(
"");
20582 case value_t::binary:
20584 binary = create<binary_t>();
20588 case value_t::boolean:
20590 boolean =
static_cast<boolean_t>(
false);
20594 case value_t::number_integer:
20600 case value_t::number_unsigned:
20606 case value_t::number_float:
20612 case value_t::null:
20618 case value_t::discarded:
20624 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0",
nullptr));
20664 (t == value_t::object &&
object ==
nullptr) ||
20665 (t == value_t::array && array ==
nullptr) ||
20666 (t == value_t::string &&
string ==
nullptr) ||
20667 (t == value_t::binary &&
binary ==
nullptr)
20673 if (t == value_t::array || t == value_t::object)
20676 std::vector<basic_json> stack;
20679 if (t == value_t::array)
20681 stack.reserve(array->size());
20682 std::move(array->begin(), array->end(), std::back_inserter(stack));
20686 stack.reserve(object->size());
20687 for (
auto&& it : *
object)
20689 stack.push_back(std::move(it.second));
20693 while (!stack.empty())
20696 basic_json current_item(std::move(stack.back()));
20703 std::move(current_item.
m_data.m_value.array->begin(), current_item.
m_data.m_value.array->end(), std::back_inserter(stack));
20705 current_item.
m_data.m_value.array->clear();
20709 for (
auto&& it : *current_item.
m_data.m_value.object)
20711 stack.push_back(std::move(it.second));
20714 current_item.
m_data.m_value.object->clear();
20724 case value_t::object:
20726 AllocatorType<object_t> alloc;
20727 std::allocator_traits<decltype(alloc)>::destroy(alloc,
object);
20728 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
20732 case value_t::array:
20734 AllocatorType<array_t> alloc;
20735 std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
20736 std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
20740 case value_t::string:
20742 AllocatorType<string_t> alloc;
20743 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
20744 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
20748 case value_t::binary:
20750 AllocatorType<binary_t> alloc;
20751 std::allocator_traits<decltype(alloc)>::destroy(alloc,
binary);
20752 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
binary, 1);
20756 case value_t::null:
20757 case value_t::boolean:
20758 case value_t::number_integer:
20759 case value_t::number_unsigned:
20760 case value_t::number_float:
20761 case value_t::discarded:
20791 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
20792 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
20793 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
20794 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
20796 #if JSON_DIAGNOSTICS
20800 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
20802 return j.m_parent ==
this;
20807 static_cast<void>(check_parents);
20812 #if JSON_DIAGNOSTICS
20813 switch (m_data.m_type)
20815 case value_t::array:
20817 for (
auto& element : *m_data.m_value.array)
20819 element.m_parent =
this;
20824 case value_t::object:
20826 for (
auto& element : *m_data.m_value.object)
20828 element.second.m_parent =
this;
20833 case value_t::null:
20834 case value_t::string:
20835 case value_t::boolean:
20836 case value_t::number_integer:
20837 case value_t::number_unsigned:
20838 case value_t::number_float:
20839 case value_t::binary:
20840 case value_t::discarded:
20849 #if JSON_DIAGNOSTICS
20852 (it + i)->m_parent =
this;
20855 static_cast<void>(count_set_parents);
20862 #if JSON_DIAGNOSTICS
20877 #ifdef JSON_HEDLEY_MSVC_VERSION
20878 #pragma warning(push )
20879 #pragma warning(disable : 4127)
20886 #ifdef JSON_HEDLEY_MSVC_VERSION
20887 #pragma warning( pop )
20892 static_cast<void>(j);
20893 static_cast<void>(old_capacity);
20925 assert_invariant();
20933 assert_invariant();
20938 template <
typename CompatibleType,
20944 std::forward<CompatibleType>(val))))
20948 assert_invariant();
20953 template <
typename BasicJsonType,
20957 #if JSON_DIAGNOSTIC_POSITIONS
20958 : start_position(val.start_pos()),
20959 end_position(val.end_pos())
20962 using other_boolean_t =
typename BasicJsonType::boolean_t;
20963 using other_number_float_t =
typename BasicJsonType::number_float_t;
20964 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20965 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20967 using other_object_t =
typename BasicJsonType::object_t;
20968 using other_array_t =
typename BasicJsonType::array_t;
20969 using other_binary_t =
typename BasicJsonType::binary_t;
20971 switch (val.type())
20973 case value_t::boolean:
20976 case value_t::number_float:
20979 case value_t::number_integer:
20982 case value_t::number_unsigned:
20985 case value_t::string:
20988 case value_t::object:
20991 case value_t::array:
20994 case value_t::binary:
20997 case value_t::null:
21000 case value_t::discarded:
21001 m_data.m_type = value_t::discarded;
21009 assert_invariant();
21015 bool type_deduction =
true,
21016 value_t manual_type = value_t::array)
21020 bool is_an_object = std::all_of(init.begin(), init.end(),
21026 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
21030 if (!type_deduction)
21033 if (manual_type == value_t::array)
21035 is_an_object =
false;
21041 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
21048 m_data.m_type = value_t::object;
21049 m_data.m_value = value_t::object;
21051 for (
auto& element_ref : init)
21054 m_data.m_value.object->emplace(
21055 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
21056 std::move((*element.m_data.m_value.array)[1]));
21062 m_data.m_type = value_t::array;
21063 m_data.m_value.array = create<array_t>(init.begin(), init.end());
21067 assert_invariant();
21076 res.m_data.m_type = value_t::binary;
21077 res.m_data.m_value = init;
21087 res.m_data.m_type = value_t::binary;
21088 res.m_data.m_value =
binary_t(init, subtype);
21098 res.m_data.m_type = value_t::binary;
21099 res.m_data.m_value = std::move(init);
21109 res.m_data.m_type = value_t::binary;
21110 res.m_data.m_value =
binary_t(std::move(init), subtype);
21119 return basic_json(init,
false, value_t::array);
21127 return basic_json(init,
false, value_t::object);
21136 assert_invariant();
21141 template <
class InputIT,
typename std::enable_if <
21152 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
21156 m_data.m_type = first.m_object->m_data.m_type;
21159 switch (m_data.m_type)
21161 case value_t::boolean:
21162 case value_t::number_float:
21163 case value_t::number_integer:
21164 case value_t::number_unsigned:
21165 case value_t::string:
21168 || !last.m_it.primitive_iterator.is_end()))
21170 JSON_THROW(invalid_iterator::create(204,
"iterators out of range", first.m_object));
21175 case value_t::null:
21176 case value_t::object:
21177 case value_t::array:
21178 case value_t::binary:
21179 case value_t::discarded:
21184 switch (m_data.m_type)
21186 case value_t::number_integer:
21188 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
21192 case value_t::number_unsigned:
21194 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
21198 case value_t::number_float:
21200 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
21204 case value_t::boolean:
21206 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
21210 case value_t::string:
21212 m_data.m_value = *first.m_object->m_data.m_value.string;
21216 case value_t::object:
21218 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
21219 last.m_it.object_iterator);
21223 case value_t::array:
21225 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
21226 last.m_it.array_iterator);
21230 case value_t::binary:
21232 m_data.m_value = *first.m_object->m_data.m_value.binary;
21236 case value_t::null:
21237 case value_t::discarded:
21239 JSON_THROW(invalid_iterator::create(206,
detail::concat(
"cannot construct with iterators from ", first.m_object->type_name()), first.m_object));
21243 assert_invariant();
21250 template<
typename JsonRef,
21252 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
21260 , start_position(other.start_position)
21261 , end_position(other.end_position)
21264 m_data.m_type = other.
m_data.m_type;
21268 switch (m_data.m_type)
21270 case value_t::object:
21272 m_data.m_value = *other.
m_data.m_value.object;
21276 case value_t::array:
21278 m_data.m_value = *other.
m_data.m_value.array;
21282 case value_t::string:
21284 m_data.m_value = *other.
m_data.m_value.string;
21288 case value_t::boolean:
21290 m_data.m_value = other.
m_data.m_value.boolean;
21294 case value_t::number_integer:
21296 m_data.m_value = other.
m_data.m_value.number_integer;
21300 case value_t::number_unsigned:
21302 m_data.m_value = other.
m_data.m_value.number_unsigned;
21306 case value_t::number_float:
21308 m_data.m_value = other.
m_data.m_value.number_float;
21312 case value_t::binary:
21314 m_data.m_value = *other.
m_data.m_value.binary;
21318 case value_t::null:
21319 case value_t::discarded:
21325 assert_invariant();
21332 m_data(std::move(other.m_data))
21333 #if JSON_DIAGNOSTIC_POSITIONS
21334 , start_position(other.start_position)
21335 , end_position(other.end_position)
21339 other.assert_invariant(
false);
21342 other.m_data.m_type = value_t::null;
21343 other.m_data.m_value = {};
21345 #if JSON_DIAGNOSTIC_POSITIONS
21346 other.start_position = std::string::npos;
21347 other.end_position = std::string::npos;
21351 assert_invariant();
21368 swap(m_data.m_type, other.m_data.m_type);
21369 swap(m_data.m_value, other.m_data.m_value);
21371 #if JSON_DIAGNOSTIC_POSITIONS
21372 swap(start_position, other.start_position);
21373 swap(end_position, other.end_position);
21376 json_base_class_t::operator=(std::move(other));
21379 assert_invariant();
21387 assert_invariant(
false);
21404 const char indent_char =
' ',
21405 const bool ensure_ascii =
false,
21413 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
21417 s.dump(*
this,
false, ensure_ascii, 0);
21427 return m_data.m_type;
21434 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
21441 return is_array() || is_object();
21448 return m_data.m_type == value_t::null;
21455 return m_data.m_type == value_t::boolean;
21462 return is_number_integer() || is_number_float();
21469 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
21476 return m_data.m_type == value_t::number_unsigned;
21483 return m_data.m_type == value_t::number_float;
21490 return m_data.m_type == value_t::object;
21497 return m_data.m_type == value_t::array;
21504 return m_data.m_type == value_t::string;
21511 return m_data.m_type == value_t::binary;
21518 return m_data.m_type == value_t::discarded;
21525 return m_data.m_type;
21540 return m_data.m_value.boolean;
21549 return is_object() ? m_data.m_value.object :
nullptr;
21555 return is_object() ? m_data.m_value.object :
nullptr;
21561 return is_array() ? m_data.m_value.array :
nullptr;
21567 return is_array() ? m_data.m_value.array :
nullptr;
21573 return is_string() ? m_data.m_value.string :
nullptr;
21579 return is_string() ? m_data.m_value.string :
nullptr;
21585 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21591 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21597 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21603 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21609 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21615 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21621 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21627 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21633 return is_binary() ? m_data.m_value.binary :
nullptr;
21639 return is_binary() ? m_data.m_value.binary :
nullptr;
21653 template<
typename ReferenceType,
typename ThisType>
21664 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
21674 template<
typename PointerType,
typename std::enable_if<
21679 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21684 template <
typename PointerType,
typename std::enable_if <
21690 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21732 template <
typename ValueType,
21740 auto ret = ValueType();
21775 template <
typename ValueType,
21800 template <
typename BasicJsonType,
21823 template<
typename BasicJsonType,
21836 template<
typename PointerType,
21841 -> decltype(std::declval<const basic_json_t&>().
template get_ptr<PointerType>())
21844 return get_ptr<PointerType>();
21871 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21872 #if defined(JSON_HAS_CPP_14)
21883 "get() cannot be used with reference types, you might want to use get_ref()");
21914 template<
typename PointerType,
typename std::enable_if<
21919 return get_ptr<PointerType>();
21924 template <
typename ValueType,
21929 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
21938 template<
typename ValueType,
21949 typename T, std::size_t
N,
21950 typename Array = T (&)[
N],
21955 std::declval<const basic_json_t&>(), v)))
21963 template<
typename ReferenceType,
typename std::enable_if<
21968 return get_ref_impl<ReferenceType>(*
this);
21973 template <
typename ReferenceType,
typename std::enable_if <
21979 return get_ref_impl<ReferenceType>(*
this);
22011 template <
typename ValueType,
typename std::enable_if <
22019 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
22022 #if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
22030 return get<ValueType>();
22042 return *get_ptr<binary_t*>();
22054 return *get_ptr<const binary_t*>();
22076 return set_parent(m_data.m_value.array->at(idx));
22099 return m_data.m_value.array->at(idx);
22123 auto it = m_data.m_value.object->find(
key);
22124 if (it == m_data.m_value.object->end())
22128 return set_parent(it->second);
22143 auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22144 if (it == m_data.m_value.object->end())
22148 return set_parent(it->second);
22161 auto it = m_data.m_value.object->find(
key);
22162 if (it == m_data.m_value.object->end())
22181 auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22182 if (it == m_data.m_value.object->end())
22196 m_data.m_type = value_t::array;
22197 m_data.
m_value.array = create<array_t>();
22198 assert_invariant();
22205 if (idx >= m_data.m_value.array->size())
22207 #if JSON_DIAGNOSTICS
22209 const auto old_size = m_data.m_value.array->size();
22210 const auto old_capacity = m_data.m_value.array->capacity();
22212 m_data.m_value.array->resize(idx + 1);
22214 #if JSON_DIAGNOSTICS
22226 assert_invariant();
22229 return m_data.m_value.array->operator[](idx);
22232 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22242 return m_data.
m_value.array->operator[](idx);
22245 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
22255 m_data.m_type = value_t::object;
22256 m_data.
m_value.object = create<object_t>();
22257 assert_invariant();
22263 auto result = m_data.m_value.object->emplace(std::move(
key),
nullptr);
22264 return set_parent(result.first->second);
22267 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22282 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22287 template<
typename T>
22290 return operator[](
typename object_t::key_type(
key));
22293 template<
typename T>
22296 return operator[](
typename object_t::key_type(
key));
22308 m_data.m_type = value_t::object;
22309 m_data.
m_value.object = create<object_t>();
22310 assert_invariant();
22316 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
22317 return set_parent(result.first->second);
22320 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22332 auto it = m_data.
m_value.object->find(std::forward<KeyType>(
key));
22337 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
22341 template<
typename KeyType>
22345 template<
typename ValueType>
22356 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22357 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const
22363 const auto it = find(
key);
22366 return it->template get<ValueType>();
22369 return default_value;
22381 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22382 ReturnType
value(
const typename object_t::key_type&
key, ValueType && default_value)
const
22388 const auto it = find(
key);
22391 return it->template get<ReturnType>();
22394 return std::forward<ValueType>(default_value);
22407 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22408 ValueType
value(KeyType &&
key,
const ValueType& default_value)
const
22414 const auto it = find(std::forward<KeyType>(
key));
22417 return it->template get<ValueType>();
22420 return default_value;
22434 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22435 ReturnType
value(KeyType &&
key, ValueType && default_value)
const
22441 const auto it = find(std::forward<KeyType>(
key));
22444 return it->template get<ReturnType>();
22447 return std::forward<ValueType>(default_value);
22457 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22467 return ptr.
get_checked(
this).template get<ValueType>();
22471 return default_value;
22483 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22493 return ptr.
get_checked(
this).template get<ReturnType>();
22497 return std::forward<ValueType>(default_value);
22507 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22509 ValueType
value(const ::nlohmann::json_pointer<BasicJsonType>& ptr,
const ValueType& default_value)
const
22511 return value(ptr.convert(), default_value);
22518 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
22520 ReturnType
value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const
22522 return value(ptr.convert(), std::forward<ValueType>(default_value));
22567 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22570 IteratorType result = end();
22572 switch (m_data.m_type)
22574 case value_t::boolean:
22575 case value_t::number_float:
22576 case value_t::number_integer:
22577 case value_t::number_unsigned:
22578 case value_t::string:
22579 case value_t::binary:
22583 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
22588 AllocatorType<string_t> alloc;
22589 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22590 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22591 m_data.m_value.string =
nullptr;
22593 else if (is_binary())
22595 AllocatorType<binary_t> alloc;
22596 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22597 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22598 m_data.m_value.binary =
nullptr;
22601 m_data.m_type = value_t::null;
22602 assert_invariant();
22606 case value_t::object:
22608 result.m_it.object_iterator = m_data.m_value.object->erase(
pos.m_it.object_iterator);
22612 case value_t::array:
22614 result.m_it.array_iterator = m_data.m_value.array->erase(
pos.m_it.array_iterator);
22618 case value_t::null:
22619 case value_t::discarded:
22632 IteratorType
erase(IteratorType first, IteratorType last)
22637 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
22640 IteratorType result = end();
22642 switch (m_data.m_type)
22644 case value_t::boolean:
22645 case value_t::number_float:
22646 case value_t::number_integer:
22647 case value_t::number_unsigned:
22648 case value_t::string:
22649 case value_t::binary:
22652 || !last.m_it.primitive_iterator.is_end()))
22654 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
22659 AllocatorType<string_t> alloc;
22660 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string);
22661 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
22662 m_data.m_value.string =
nullptr;
22664 else if (is_binary())
22666 AllocatorType<binary_t> alloc;
22667 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
22668 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
22669 m_data.m_value.binary =
nullptr;
22672 m_data.m_type = value_t::null;
22673 assert_invariant();
22677 case value_t::object:
22679 result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator,
22680 last.m_it.object_iterator);
22684 case value_t::array:
22686 result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator,
22687 last.m_it.array_iterator);
22691 case value_t::null:
22692 case value_t::discarded:
22711 return m_data.m_value.object->erase(std::forward<KeyType>(
key));
22724 const auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22725 if (it != m_data.m_value.object->end())
22727 m_data.m_value.object->erase(it);
22741 return erase_internal(
key);
22750 return erase_internal(std::forward<KeyType>(
key));
22765 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
22786 auto result = end();
22790 result.m_it.object_iterator = m_data.m_value.object->find(
key);
22800 auto result = cend();
22804 result.m_it.object_iterator = m_data.m_value.object->find(
key);
22816 auto result = end();
22820 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
22832 auto result = cend();
22836 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
22847 return is_object() ? m_data.m_value.object->count(
key) : 0;
22857 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(
key)) : 0;
22864 return is_object() && m_data.m_value.object->find(
key) != m_data.m_value.object->end();
22873 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(
key)) != m_data.m_value.object->end();
22885 bool contains(
const typename ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
22887 return ptr.contains(
this);
22901 iterator begin() noexcept
22903 iterator result(
this);
22904 result.set_begin();
22910 const_iterator begin()
const noexcept
22917 const_iterator cbegin()
const noexcept
22919 const_iterator result(
this);
22920 result.set_begin();
22926 iterator end() noexcept
22928 iterator result(
this);
22935 const_iterator end()
const noexcept
22942 const_iterator cend()
const noexcept
22944 const_iterator result(
this);
22951 reverse_iterator rbegin() noexcept
22953 return reverse_iterator(end());
22958 const_reverse_iterator rbegin()
const noexcept
22965 reverse_iterator rend() noexcept
22967 return reverse_iterator(begin());
22972 const_reverse_iterator rend()
const noexcept
22979 const_reverse_iterator crbegin()
const noexcept
22981 return const_reverse_iterator(cend());
22986 const_reverse_iterator crend()
const noexcept
22988 return const_reverse_iterator(cbegin());
22998 static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
23000 return ref.items();
23009 static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
23011 return ref.items();
23016 iteration_proxy<iterator> items() noexcept
23018 return iteration_proxy<iterator>(*
this);
23023 iteration_proxy<const_iterator> items()
const noexcept
23025 return iteration_proxy<const_iterator>(*
this);
23039 bool empty()
const noexcept
23041 switch (m_data.m_type)
23043 case value_t::null:
23049 case value_t::array:
23052 return m_data.m_value.array->empty();
23055 case value_t::object:
23058 return m_data.m_value.object->empty();
23061 case value_t::string:
23062 case value_t::boolean:
23063 case value_t::number_integer:
23064 case value_t::number_unsigned:
23065 case value_t::number_float:
23066 case value_t::binary:
23067 case value_t::discarded:
23080 switch (m_data.m_type)
23082 case value_t::null:
23088 case value_t::array:
23091 return m_data.m_value.array->size();
23094 case value_t::object:
23097 return m_data.m_value.object->size();
23100 case value_t::string:
23101 case value_t::boolean:
23102 case value_t::number_integer:
23103 case value_t::number_unsigned:
23104 case value_t::number_float:
23105 case value_t::binary:
23106 case value_t::discarded:
23119 switch (m_data.m_type)
23121 case value_t::array:
23124 return m_data.m_value.array->max_size();
23127 case value_t::object:
23130 return m_data.m_value.object->max_size();
23133 case value_t::null:
23134 case value_t::string:
23135 case value_t::boolean:
23136 case value_t::number_integer:
23137 case value_t::number_unsigned:
23138 case value_t::number_float:
23139 case value_t::binary:
23140 case value_t::discarded:
23160 void clear() noexcept
23162 switch (m_data.m_type)
23164 case value_t::number_integer:
23166 m_data.m_value.number_integer = 0;
23170 case value_t::number_unsigned:
23172 m_data.m_value.number_unsigned = 0;
23176 case value_t::number_float:
23178 m_data.m_value.number_float = 0.0;
23182 case value_t::boolean:
23184 m_data.m_value.boolean =
false;
23188 case value_t::string:
23190 m_data.m_value.string->clear();
23194 case value_t::binary:
23196 m_data.m_value.binary->clear();
23200 case value_t::array:
23202 m_data.m_value.array->clear();
23206 case value_t::object:
23208 m_data.m_value.object->clear();
23212 case value_t::null:
23213 case value_t::discarded:
23232 m_data.m_type = value_t::array;
23233 m_data.m_value = value_t::array;
23234 assert_invariant();
23238 const auto old_capacity = m_data.m_value.array->capacity();
23239 m_data.m_value.array->push_back(std::move(val));
23240 set_parent(m_data.m_value.array->back(), old_capacity);
23248 push_back(std::move(val));
23265 m_data.m_type = value_t::array;
23266 m_data.m_value = value_t::array;
23267 assert_invariant();
23271 const auto old_capacity = m_data.m_value.array->capacity();
23272 m_data.m_value.array->push_back(val);
23273 set_parent(m_data.m_value.array->back(), old_capacity);
23297 m_data.m_type = value_t::object;
23298 m_data.m_value = value_t::object;
23299 assert_invariant();
23303 auto res = m_data.m_value.object->insert(val);
23304 set_parent(res.first->second);
23319 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
23322 push_back(
typename object_t::value_type(
23323 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23341 template<
class... Args>
23353 m_data.m_type = value_t::array;
23354 m_data.m_value = value_t::array;
23355 assert_invariant();
23359 const auto old_capacity = m_data.m_value.array->capacity();
23360 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
23361 return set_parent(m_data.m_value.array->back(), old_capacity);
23366 template<
class... Args>
23378 m_data.m_type = value_t::object;
23379 m_data.m_value = value_t::object;
23380 assert_invariant();
23384 auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
23385 set_parent(res.first->second);
23389 it.m_it.object_iterator = res.first;
23392 return {it, res.second};
23398 template<
typename... Args>
23404 auto insert_pos = std::distance(m_data.m_value.array->begin(),
pos.m_it.array_iterator);
23405 m_data.m_value.array->insert(
pos.m_it.array_iterator, std::forward<Args>(args)...);
23426 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23430 return insert_iterator(
pos, val);
23440 return insert(
pos, val);
23453 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23457 return insert_iterator(
pos, cnt, val);
23476 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23482 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23487 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
23507 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
23511 return insert_iterator(
pos, ilist.begin(), ilist.end());
23527 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23533 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
23544 update(j.begin(), j.end(), merge_objects);
23554 m_data.m_type = value_t::object;
23555 m_data.m_value.object = create<object_t>();
23556 assert_invariant();
23567 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
23573 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
23576 for (
auto it = first; it != last; ++it)
23578 if (merge_objects && it.value().is_object())
23580 auto it2 = m_data.m_value.object->find(it.key());
23581 if (it2 != m_data.m_value.object->end())
23583 it2->second.update(it.value(),
true);
23587 m_data.m_value.object->operator[](it.key()) = it.value();
23588 #if JSON_DIAGNOSTICS
23589 m_data.m_value.object->operator[](it.key()).m_parent =
this;
23603 std::swap(m_data.m_type, other.m_data.m_type);
23604 std::swap(m_data.m_value, other.m_data.m_value);
23607 other.set_parents();
23608 assert_invariant();
23631 swap(*(m_data.m_value.array), other);
23647 swap(*(m_data.m_value.object), other);
23663 swap(*(m_data.m_value.string), other);
23679 swap(*(m_data.m_value.binary), other);
23695 swap(*(m_data.m_value.binary), other);
23699 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
23714 #define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23715 const auto lhs_type = lhs.type(); \
23716 const auto rhs_type = rhs.type(); \
23718 if (lhs_type == rhs_type) \
23720 switch (lhs_type) \
23722 case value_t::array: \
23723 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23725 case value_t::object: \
23726 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23728 case value_t::null: \
23729 return (null_result); \
23731 case value_t::string: \
23732 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23734 case value_t::boolean: \
23735 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23737 case value_t::number_integer: \
23738 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23740 case value_t::number_unsigned: \
23741 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23743 case value_t::number_float: \
23744 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23746 case value_t::binary: \
23747 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23749 case value_t::discarded: \
23751 return (unordered_result); \
23754 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23756 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23758 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23760 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23762 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23764 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23766 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23768 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23770 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23772 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23774 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23776 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23778 else if(compares_unordered(lhs, rhs))\
23780 return (unordered_result);\
23783 return (default_result);
23798 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23801 static_cast<void>(inverse);
23807 bool compares_unordered(const_reference rhs,
bool inverse =
false)
const noexcept
23809 return compares_unordered(*
this, rhs, inverse);
23813 #if JSON_HAS_THREE_WAY_COMPARISON
23816 bool operator==(const_reference rhs)
const noexcept
23819 #pragma GCC diagnostic push
23820 #pragma GCC diagnostic ignored "-Wfloat-equal"
23822 const_reference lhs = *
this;
23825 #pragma GCC diagnostic pop
23831 template<
typename ScalarType>
23832 requires std::is_scalar_v<ScalarType>
23833 bool operator==(ScalarType rhs)
const noexcept
23840 bool operator!=(const_reference rhs)
const noexcept
23842 if (compares_unordered(rhs,
true))
23851 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23853 const_reference lhs = *
this;
23857 std::partial_ordering::equivalent,
23858 std::partial_ordering::unordered,
23859 lhs_type <=> rhs_type)
23864 template<
typename ScalarType>
23865 requires std::is_scalar_v<ScalarType>
23866 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23871 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23878 bool operator<=(const_reference rhs)
const noexcept
23880 if (compares_unordered(rhs,
true))
23884 return !(rhs < *
this);
23889 template<
typename ScalarType>
23890 requires std::is_scalar_v<ScalarType>
23891 bool operator<=(ScalarType rhs)
const noexcept
23899 bool operator>=(const_reference rhs)
const noexcept
23901 if (compares_unordered(rhs,
true))
23905 return !(*
this < rhs);
23910 template<
typename ScalarType>
23911 requires std::is_scalar_v<ScalarType>
23912 bool operator>=(ScalarType rhs)
const noexcept
23920 friend bool operator==(const_reference lhs, const_reference rhs) noexcept
23923 #pragma GCC diagnostic push
23924 #pragma GCC diagnostic ignored "-Wfloat-equal"
23928 #pragma GCC diagnostic pop
23934 template<
typename ScalarType,
typename std::enable_if<
23936 friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
23943 template<
typename ScalarType,
typename std::enable_if<
23945 friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
23952 friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
23954 if (compares_unordered(lhs, rhs,
true))
23958 return !(lhs == rhs);
23963 template<
typename ScalarType,
typename std::enable_if<
23965 friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
23972 template<
typename ScalarType,
typename std::enable_if<
23974 friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
23981 friend bool operator<(const_reference lhs, const_reference rhs) noexcept
23991 template<
typename ScalarType,
typename std::enable_if<
23993 friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
24000 template<
typename ScalarType,
typename std::enable_if<
24002 friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
24009 friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
24011 if (compares_unordered(lhs, rhs,
true))
24015 return !(rhs < lhs);
24020 template<
typename ScalarType,
typename std::enable_if<
24022 friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
24029 template<
typename ScalarType,
typename std::enable_if<
24031 friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
24038 friend bool operator>(const_reference lhs, const_reference rhs) noexcept
24041 if (compares_unordered(lhs, rhs))
24045 return !(lhs <= rhs);
24050 template<
typename ScalarType,
typename std::enable_if<
24052 friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
24059 template<
typename ScalarType,
typename std::enable_if<
24061 friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
24068 friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
24070 if (compares_unordered(lhs, rhs,
true))
24074 return !(lhs < rhs);
24079 template<
typename ScalarType,
typename std::enable_if<
24081 friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
24088 template<
typename ScalarType,
typename std::enable_if<
24090 friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
24096 #undef JSON_IMPLEMENT_OPERATOR
24112 const bool pretty_print = o.width() > 0;
24113 const auto indentation = pretty_print ? o.width() : 0;
24120 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24147 template<
typename InputType>
24151 const bool allow_exceptions =
true,
24152 const bool ignore_comments =
false,
24153 const bool ignore_trailing_commas =
false)
24156 parser(
detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24162 template<
typename IteratorType>
24167 const bool allow_exceptions =
true,
24168 const bool ignore_comments =
false,
24169 const bool ignore_trailing_commas =
false)
24172 parser(
detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24180 const bool allow_exceptions =
true,
24181 const bool ignore_comments =
false,
24182 const bool ignore_trailing_commas =
false)
24185 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(
true, result);
24191 template<
typename InputType>
24192 static bool accept(InputType&& i,
24193 const bool ignore_comments =
false,
24194 const bool ignore_trailing_commas =
false)
24196 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24201 template<
typename IteratorType>
24202 static bool accept(IteratorType first, IteratorType last,
24203 const bool ignore_comments =
false,
24204 const bool ignore_trailing_commas =
false)
24206 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24212 const bool ignore_comments =
false,
24213 const bool ignore_trailing_commas =
false)
24215 return parser(i.get(),
nullptr,
false, ignore_comments, ignore_trailing_commas).accept(
true);
24220 template <
typename InputType,
typename SAX>
24222 static
bool sax_parse(InputType&& i, SAX* sax,
24224 const bool strict = true,
24225 const bool ignore_comments = false,
24226 const bool ignore_trailing_commas = false)
24230 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24236 template<
class IteratorType,
class SAX>
24238 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24240 const bool strict = true,
24241 const bool ignore_comments = false,
24242 const bool ignore_trailing_commas = false)
24246 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24255 template <
typename SAX>
24258 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
24260 const bool strict = true,
24261 const bool ignore_comments = false,
24262 const bool ignore_trailing_commas = false)
24267 ? parser(std::move(ia),
nullptr,
true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict)
24303 switch (m_data.m_type)
24305 case value_t::null:
24307 case value_t::object:
24309 case value_t::array:
24311 case value_t::string:
24313 case value_t::boolean:
24315 case value_t::binary:
24317 case value_t::discarded:
24318 return "discarded";
24319 case value_t::number_integer:
24320 case value_t::number_unsigned:
24321 case value_t::number_float:
24336 value_t m_type = value_t::null;
24339 json_value m_value = {};
24342 : m_type(v), m_value(v)
24349 m_value.array = create<array_t>(cnt, val);
24353 data(data&&) noexcept = default;
24355 data& operator=(data&&) noexcept = delete;
24356 data& operator=(
const data&) noexcept = delete;
24360 m_value.destroy(m_type);
24366 #if JSON_DIAGNOSTICS
24371 #if JSON_DIAGNOSTIC_POSITIONS
24373 std::size_t start_position = std::string::npos;
24375 std::size_t end_position = std::string::npos;
24377 constexpr std::size_t start_pos()
const noexcept
24379 return start_position;
24382 constexpr std::size_t end_pos()
const noexcept
24384 return end_position;
24400 std::vector<std::uint8_t> result;
24401 to_cbor(j, result);
24423 std::vector<std::uint8_t> result;
24424 to_msgpack(j, result);
24445 const bool use_size =
false,
24446 const bool use_type =
false)
24448 std::vector<std::uint8_t> result;
24449 to_ubjson(j, result, use_size, use_type);
24456 const bool use_size =
false,
const bool use_type =
false)
24464 const bool use_size =
false,
const bool use_type =
false)
24472 const bool use_size =
false,
24473 const bool use_type =
false,
24476 std::vector<std::uint8_t> result;
24477 to_bjdata(j, result, use_size, use_type, version);
24484 const bool use_size =
false,
const bool use_type =
false,
24493 const bool use_size =
false,
const bool use_type =
false,
24503 std::vector<std::uint8_t> result;
24504 to_bson(j, result);
24524 template<
typename InputType>
24527 const bool strict =
true,
24528 const bool allow_exceptions =
true,
24535 return res ? result :
basic_json(value_t::discarded);
24540 template<
typename IteratorType>
24543 const bool strict =
true,
24544 const bool allow_exceptions =
true,
24551 return res ? result :
basic_json(value_t::discarded);
24554 template<
typename T>
24558 const bool strict = true,
24559 const bool allow_exceptions = true,
24562 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24568 const bool strict = true,
24569 const bool allow_exceptions = true,
24577 return res ? result :
basic_json(value_t::discarded);
24582 template<
typename InputType>
24585 const bool strict =
true,
24586 const bool allow_exceptions =
true)
24592 return res ? result :
basic_json(value_t::discarded);
24597 template<
typename IteratorType>
24600 const bool strict =
true,
24601 const bool allow_exceptions =
true)
24607 return res ? result :
basic_json(value_t::discarded);
24610 template<
typename T>
24614 const bool strict = true,
24615 const bool allow_exceptions = true)
24617 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24623 const bool strict = true,
24624 const bool allow_exceptions = true)
24631 return res ? result :
basic_json(value_t::discarded);
24636 template<
typename InputType>
24639 const bool strict =
true,
24640 const bool allow_exceptions =
true)
24646 return res ? result :
basic_json(value_t::discarded);
24651 template<
typename IteratorType>
24654 const bool strict =
true,
24655 const bool allow_exceptions =
true)
24661 return res ? result :
basic_json(value_t::discarded);
24664 template<
typename T>
24668 const bool strict = true,
24669 const bool allow_exceptions = true)
24671 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24677 const bool strict = true,
24678 const bool allow_exceptions = true)
24685 return res ? result :
basic_json(value_t::discarded);
24690 template<
typename InputType>
24693 const bool strict =
true,
24694 const bool allow_exceptions =
true)
24700 return res ? result :
basic_json(value_t::discarded);
24705 template<
typename IteratorType>
24708 const bool strict =
true,
24709 const bool allow_exceptions =
true)
24715 return res ? result :
basic_json(value_t::discarded);
24720 template<
typename InputType>
24723 const bool strict =
true,
24724 const bool allow_exceptions =
true)
24730 return res ? result :
basic_json(value_t::discarded);
24735 template<
typename IteratorType>
24738 const bool strict =
true,
24739 const bool allow_exceptions =
true)
24745 return res ? result :
basic_json(value_t::discarded);
24748 template<
typename T>
24752 const bool strict = true,
24753 const bool allow_exceptions = true)
24755 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24761 const bool strict = true,
24762 const bool allow_exceptions = true)
24769 return res ? result :
basic_json(value_t::discarded);
24789 reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
24791 return ptr.get_unchecked(
this);
24803 const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
24805 return ptr.get_unchecked(
this);
24817 reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
24819 return ptr.get_checked(
this);
24831 const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
24833 return ptr.get_checked(
this);
24863 void patch_inplace(
const basic_json& json_patch)
24867 enum class patch_operations {add, remove,
replace, move, copy, test, invalid};
24869 const auto get_op = [](
const string_t& op)
24873 return patch_operations::add;
24875 if (op ==
"remove")
24877 return patch_operations::remove;
24879 if (op ==
"replace")
24881 return patch_operations::replace;
24885 return patch_operations::move;
24889 return patch_operations::copy;
24893 return patch_operations::test;
24896 return patch_operations::invalid;
24911 if (top_pointer != ptr)
24913 result.
at(top_pointer);
24917 const auto last_path = ptr.
back();
24922 switch (parent.
m_data.m_type)
24924 case value_t::null:
24925 case value_t::object:
24928 parent[last_path] = val;
24932 case value_t::array:
24934 if (last_path ==
"-")
24941 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24949 parent.
insert(parent.begin() +
static_cast<difference_type
>(idx), val);
24955 case value_t::string:
24956 case value_t::boolean:
24957 case value_t::number_integer:
24958 case value_t::number_unsigned:
24959 case value_t::number_float:
24960 case value_t::binary:
24961 case value_t::discarded:
24968 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24971 const auto last_path = ptr.
back();
24979 auto it = parent.
find(last_path);
24992 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24999 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
25003 for (
const auto& val : json_patch)
25006 const auto get_value = [&val](
const string_t& op,
25011 auto it = val.
m_data.m_value.object->find(member);
25014 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
25027 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
25037 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
25041 const auto op = get_value(
"op",
"op",
true).template get<string_t>();
25042 const auto path = get_value(op,
"path",
true).template get<string_t>();
25045 switch (get_op(op))
25047 case patch_operations::add:
25049 operation_add(ptr, get_value(
"add",
"value",
false));
25053 case patch_operations::remove:
25055 operation_remove(ptr);
25059 case patch_operations::replace:
25062 result.
at(ptr) = get_value(
"replace",
"value",
false);
25066 case patch_operations::move:
25068 const auto from_path = get_value(
"move",
"from",
true).template get<string_t>();
25078 operation_remove(from_ptr);
25079 operation_add(ptr, v);
25083 case patch_operations::copy:
25085 const auto from_path = get_value(
"copy",
"from",
true).template get<string_t>();
25094 operation_add(ptr, v);
25098 case patch_operations::test:
25100 bool success =
false;
25105 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25121 case patch_operations::invalid:
25137 result.patch_inplace(json_patch);
25161 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25168 case value_t::array:
25172 while (i <
source.size() && i < target.size())
25175 auto temp_diff = diff(
source[i], target[i], detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i)));
25176 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
25185 while (i <
source.size())
25189 result.
insert(result.begin() + end_index, object(
25192 {
"path", detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i))}
25198 while (i < target.size())
25203 {
"path", detail::concat<string_t>(path,
"/-")},
25204 {
"value", target[i]}
25212 case value_t::object:
25215 for (
auto it =
source.cbegin(); it !=
source.cend(); ++it)
25218 const auto path_key = detail::concat<string_t>(path,
'/',
detail::escape(it.key()));
25220 if (target.
find(it.key()) != target.end())
25223 auto temp_diff = diff(it.value(), target[it.key()], path_key);
25224 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
25231 {
"op",
"remove"}, {
"path", path_key}
25237 for (
auto it = target.cbegin(); it != target.cend(); ++it)
25242 const auto path_key = detail::concat<string_t>(path,
'/',
detail::escape(it.key()));
25245 {
"op",
"add"}, {
"path", path_key},
25246 {
"value", it.value()}
25254 case value_t::null:
25255 case value_t::string:
25256 case value_t::boolean:
25257 case value_t::number_integer:
25258 case value_t::number_unsigned:
25259 case value_t::number_float:
25260 case value_t::binary:
25261 case value_t::discarded:
25267 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25294 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
25296 if (it.value().is_null())
25302 operator[](it.key()).merge_patch(it.value());
25308 *
this = apply_patch;
25325 inline namespace json_literals
25331 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25334 inline nlohmann::json operator "" _json(
const char* s, std::size_t n)
25343 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25385 #if JSON_HAS_THREE_WAY_COMPARISON
25386 return std::is_lt(lhs <=> rhs);
25394 #ifndef JSON_HAS_CPP_20
25410 #if JSON_USE_GLOBAL_UDLS
25411 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25412 using nlohmann::literals::json_literals::operator
""_json;
25413 using nlohmann::literals::json_literals::operator
""_json_pointer;
25415 using nlohmann::literals::json_literals::operator
"" _json;
25416 using nlohmann::literals::json_literals::operator
"" _json_pointer;
25432 #if defined(__clang__)
25433 #pragma clang diagnostic pop
25438 #undef JSON_INTERNAL_CATCH
25440 #undef JSON_PRIVATE_UNLESS_TESTED
25441 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25442 #undef NLOHMANN_BASIC_JSON_TPL
25443 #undef JSON_EXPLICIT
25444 #undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
25445 #undef JSON_INLINE_VARIABLE
25446 #undef JSON_NO_UNIQUE_ADDRESS
25447 #undef JSON_DISABLE_ENUM_SERIALIZATION
25448 #undef JSON_USE_GLOBAL_UDLS
25450 #ifndef JSON_TEST_KEEP_MACROS
25453 #undef JSON_HAS_CPP_11
25454 #undef JSON_HAS_CPP_14
25455 #undef JSON_HAS_CPP_17
25456 #undef JSON_HAS_CPP_20
25457 #undef JSON_HAS_CPP_23
25458 #undef JSON_HAS_CPP_26
25459 #undef JSON_HAS_FILESYSTEM
25460 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
25461 #undef JSON_HAS_THREE_WAY_COMPARISON
25462 #undef JSON_HAS_RANGES
25463 #undef JSON_HAS_STATIC_RTTI
25464 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
25478 #undef JSON_HEDLEY_ALWAYS_INLINE
25479 #undef JSON_HEDLEY_ARM_VERSION
25480 #undef JSON_HEDLEY_ARM_VERSION_CHECK
25481 #undef JSON_HEDLEY_ARRAY_PARAM
25482 #undef JSON_HEDLEY_ASSUME
25483 #undef JSON_HEDLEY_BEGIN_C_DECLS
25484 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25485 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25486 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25487 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25488 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25489 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
25490 #undef JSON_HEDLEY_CLANG_HAS_WARNING
25491 #undef JSON_HEDLEY_COMPCERT_VERSION
25492 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25493 #undef JSON_HEDLEY_CONCAT
25494 #undef JSON_HEDLEY_CONCAT3
25495 #undef JSON_HEDLEY_CONCAT3_EX
25496 #undef JSON_HEDLEY_CONCAT_EX
25497 #undef JSON_HEDLEY_CONST
25498 #undef JSON_HEDLEY_CONSTEXPR
25499 #undef JSON_HEDLEY_CONST_CAST
25500 #undef JSON_HEDLEY_CPP_CAST
25501 #undef JSON_HEDLEY_CRAY_VERSION
25502 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
25503 #undef JSON_HEDLEY_C_DECL
25504 #undef JSON_HEDLEY_DEPRECATED
25505 #undef JSON_HEDLEY_DEPRECATED_FOR
25506 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25507 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25508 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25509 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25510 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25511 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
25512 #undef JSON_HEDLEY_DIAGNOSTIC_POP
25513 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25514 #undef JSON_HEDLEY_DMC_VERSION
25515 #undef JSON_HEDLEY_DMC_VERSION_CHECK
25516 #undef JSON_HEDLEY_EMPTY_BASES
25517 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25518 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25519 #undef JSON_HEDLEY_END_C_DECLS
25520 #undef JSON_HEDLEY_FLAGS
25521 #undef JSON_HEDLEY_FLAGS_CAST
25522 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25523 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
25524 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25525 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25526 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
25527 #undef JSON_HEDLEY_GCC_HAS_FEATURE
25528 #undef JSON_HEDLEY_GCC_HAS_WARNING
25529 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25530 #undef JSON_HEDLEY_GCC_VERSION
25531 #undef JSON_HEDLEY_GCC_VERSION_CHECK
25532 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25533 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25534 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25535 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25536 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25537 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
25538 #undef JSON_HEDLEY_GNUC_HAS_WARNING
25539 #undef JSON_HEDLEY_GNUC_VERSION
25540 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
25541 #undef JSON_HEDLEY_HAS_ATTRIBUTE
25542 #undef JSON_HEDLEY_HAS_BUILTIN
25543 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25544 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25545 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25546 #undef JSON_HEDLEY_HAS_EXTENSION
25547 #undef JSON_HEDLEY_HAS_FEATURE
25548 #undef JSON_HEDLEY_HAS_WARNING
25549 #undef JSON_HEDLEY_IAR_VERSION
25550 #undef JSON_HEDLEY_IAR_VERSION_CHECK
25551 #undef JSON_HEDLEY_IBM_VERSION
25552 #undef JSON_HEDLEY_IBM_VERSION_CHECK
25553 #undef JSON_HEDLEY_IMPORT
25554 #undef JSON_HEDLEY_INLINE
25555 #undef JSON_HEDLEY_INTEL_CL_VERSION
25556 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25557 #undef JSON_HEDLEY_INTEL_VERSION
25558 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
25559 #undef JSON_HEDLEY_IS_CONSTANT
25560 #undef JSON_HEDLEY_IS_CONSTEXPR_
25561 #undef JSON_HEDLEY_LIKELY
25562 #undef JSON_HEDLEY_MALLOC
25563 #undef JSON_HEDLEY_MCST_LCC_VERSION
25564 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
25565 #undef JSON_HEDLEY_MESSAGE
25566 #undef JSON_HEDLEY_MSVC_VERSION
25567 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
25568 #undef JSON_HEDLEY_NEVER_INLINE
25569 #undef JSON_HEDLEY_NON_NULL
25570 #undef JSON_HEDLEY_NO_ESCAPE
25571 #undef JSON_HEDLEY_NO_RETURN
25572 #undef JSON_HEDLEY_NO_THROW
25573 #undef JSON_HEDLEY_NULL
25574 #undef JSON_HEDLEY_PELLES_VERSION
25575 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
25576 #undef JSON_HEDLEY_PGI_VERSION
25577 #undef JSON_HEDLEY_PGI_VERSION_CHECK
25578 #undef JSON_HEDLEY_PREDICT
25579 #undef JSON_HEDLEY_PRINTF_FORMAT
25580 #undef JSON_HEDLEY_PRIVATE
25581 #undef JSON_HEDLEY_PUBLIC
25582 #undef JSON_HEDLEY_PURE
25583 #undef JSON_HEDLEY_REINTERPRET_CAST
25584 #undef JSON_HEDLEY_REQUIRE
25585 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25586 #undef JSON_HEDLEY_REQUIRE_MSG
25587 #undef JSON_HEDLEY_RESTRICT
25588 #undef JSON_HEDLEY_RETURNS_NON_NULL
25589 #undef JSON_HEDLEY_SENTINEL
25590 #undef JSON_HEDLEY_STATIC_ASSERT
25591 #undef JSON_HEDLEY_STATIC_CAST
25592 #undef JSON_HEDLEY_STRINGIFY
25593 #undef JSON_HEDLEY_STRINGIFY_EX
25594 #undef JSON_HEDLEY_SUNPRO_VERSION
25595 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25596 #undef JSON_HEDLEY_TINYC_VERSION
25597 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
25598 #undef JSON_HEDLEY_TI_ARMCL_VERSION
25599 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25600 #undef JSON_HEDLEY_TI_CL2000_VERSION
25601 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25602 #undef JSON_HEDLEY_TI_CL430_VERSION
25603 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25604 #undef JSON_HEDLEY_TI_CL6X_VERSION
25605 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25606 #undef JSON_HEDLEY_TI_CL7X_VERSION
25607 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25608 #undef JSON_HEDLEY_TI_CLPRU_VERSION
25609 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25610 #undef JSON_HEDLEY_TI_VERSION
25611 #undef JSON_HEDLEY_TI_VERSION_CHECK
25612 #undef JSON_HEDLEY_UNAVAILABLE
25613 #undef JSON_HEDLEY_UNLIKELY
25614 #undef JSON_HEDLEY_UNPREDICTABLE
25615 #undef JSON_HEDLEY_UNREACHABLE
25616 #undef JSON_HEDLEY_UNREACHABLE_RETURN
25617 #undef JSON_HEDLEY_VERSION
25618 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25619 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
25620 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
25621 #undef JSON_HEDLEY_VERSION_ENCODE
25622 #undef JSON_HEDLEY_WARNING
25623 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
25624 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25625 #undef JSON_HEDLEY_FALL_THROUGH
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition: json.hpp:2622
#define JSON_HEDLEY_CONST
Definition: json.hpp:1829
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition: json.hpp:1113
#define JSON_INLINE_VARIABLE
Definition: json.hpp:2521
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition: json.hpp:1459
#define JSON_PRIVATE_UNLESS_TESTED
Definition: json.hpp:2581
#define NLOHMANN_JSON_VERSION_PATCH
Definition: json.hpp:70
#define JSON_HEDLEY_LIKELY(expr)
Definition: json.hpp:1724
#define JSON_HEDLEY_NON_NULL(...)
Definition: json.hpp:1617
#define JSON_INTERNAL_CATCH(exception)
Definition: json.hpp:2548
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:25318
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition: json.hpp:2058
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:15511
#define JSON_CATCH(exception)
Definition: json.hpp:2547
#define JSON_ASSERT(x)
Definition: json.hpp:2574
#define JSON_THROW(exception)
Definition: json.hpp:2545
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition: json.hpp:81
#define NLOHMANN_JSON_VERSION_MAJOR
Definition: json.hpp:68
#define NLOHMANN_BASIC_JSON_TPL
Definition: json.hpp:2632
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1725
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
Definition: json.hpp:12867
#define JSON_TRY
Definition: json.hpp:2546
#define NLOHMANN_JSON_NAMESPACE_END
Definition: json.hpp:155
#define JSON_NO_UNIQUE_ADDRESS
Definition: json.hpp:2527
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:15536
#define NLOHMANN_JSON_VERSION_MINOR
Definition: json.hpp:69
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition: json.hpp:2916
#define NLOHMANN_JSON_NAMESPACE_BEGIN
Definition: json.hpp:145
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
Definition: json.hpp:12864
basic_json<> json
default specialization
Definition: json.hpp:3554
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition: json.hpp:1114
#define JSON_EXPLICIT
Definition: json.hpp:2953
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition: json.hpp:1407
#define JSON_HEDLEY_PURE
Definition: json.hpp:1798
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:15561
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition: json.hpp:23714
#define JSON_DIAGNOSTIC_POSITIONS
Definition: json.hpp:77
ArrayType
Definition: Xml.h:25
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:585
namespace for Niels Lohmann
Definition: json.hpp:20203
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
Definition: json.hpp:21637
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:21502
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition: json.hpp:21929
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:22737
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
Definition: json.hpp:20485
reference operator[](KeyType &&key)
access specified object element
Definition: json.hpp:22303
json_value(object_t &&value)
constructor for rvalue objects
Definition: json.hpp:20641
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:24542
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
Definition: json.hpp:20653
number_unsigned_t number_unsigned
number (unsigned integer)
Definition: json.hpp:20545
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition: json.hpp:21875
reference back()
access the last element
Definition: json.hpp:22541
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition: json.hpp:20942
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
Definition: json.hpp:21547
number_float_t number_float
number (floating-point)
Definition: json.hpp:20547
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition: json.hpp:25134
json_value(const array_t &value)
constructor for arrays
Definition: json.hpp:20644
const_reference front() const
access the first element
Definition: json.hpp:22534
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) const _reference operator[](const
access specified element via JSON Pointer
Definition: json.hpp:24802
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:21495
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:23596
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:22484
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:22854
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:21613
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.hpp:20281
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:21467
data(size_type cnt, const basic_json &val)
Definition: json.hpp:24346
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:24737
::nlohmann::detail::json_base_class< CustomBaseClass > json_base_class_t
Definition: json.hpp:20229
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
Definition: json.hpp:21827
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:24782
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:20332
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference at(const
Definition: json.hpp:24816
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:20324
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:21439
json_value(boolean_t v) noexcept
constructor for booleans
Definition: json.hpp:20552
const_reference operator[](KeyType &&key) const
access specified object element
Definition: json.hpp:22327
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
Definition: json.hpp:21536
void swap(binary_t &other)
exchanges the values
Definition: json.hpp:23673
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:21965
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:23542
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:21976
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:21516
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.hpp:23333
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) ValueType value(const
access the first element
Definition: json.hpp:22508
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
Definition: json.hpp:20259
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition: json.hpp:22272
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
Definition: json.hpp:20554
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
Definition: json.hpp:21654
const_reference back() const
access the last element
Definition: json.hpp:22550
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:22632
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:23278
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:23613
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:24638
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:21084
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition: json.hpp:23445
const binary_t & get_binary() const
get a binary value
Definition: json.hpp:22047
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:24722
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:20347
reference at(KeyType &&key)
access specified object element with bounds checking
Definition: json.hpp:22135
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:21474
json_value(array_t &&value)
constructor for rvalue arrays
Definition: json.hpp:20647
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:23549
data m_data
Definition: json.hpp:24364
void push_back(initializer_list_t init)
add an object to an object
Definition: json.hpp:23317
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition: json.hpp:20909
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.hpp:21125
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:24437
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:20535
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition: json.hpp:20789
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:22382
void destroy(value_t t)
Definition: json.hpp:20661
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
Definition: json.hpp:21737
json_value(string_t &&value)
constructor for rvalue strings
Definition: json.hpp:20635
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:24692
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
Definition: json.hpp:21595
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:24824
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition: json.hpp:21095
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:20930
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:24526
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:24653
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
Definition: json.hpp:20556
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition: json.hpp:22748
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
Definition: json.hpp:21553
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
Definition: json.hpp:21577
json_value(const string_t &value)
constructor for strings
Definition: json.hpp:20632
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition: json.hpp:23465
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:22435
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:24796
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
Definition: json.hpp:20558
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:20448
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition: json.hpp:22871
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:24407
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition: json.hpp:24471
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:24517
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition: json.hpp:22784
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition: json.hpp:21073
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
Definition: json.hpp:21804
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
Definition: json.hpp:21601
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition: json.hpp:22173
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition: json.hpp:20355
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:21132
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition: json.hpp:22798
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:22562
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition: json.hpp:23418
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:20468
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition: json.hpp:22357
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:21625
string_t * string
string (stored with pointer to save storage)
Definition: json.hpp:20537
ValueType & get_to(ValueType &v) const
Definition: json.hpp:21942
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:20327
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:20330
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:21619
reference set_parent(reference j, std::size_t old_capacity=detail::unknown_size())
Definition: json.hpp:20860
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:21403
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition: json.hpp:25286
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition: json.hpp:24483
reference operator[](T *key)
Definition: json.hpp:22288
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:22069
iterator find(KeyType &&key)
find an element in a JSON object
Definition: json.hpp:22814
binary_t * binary
binary (stored with pointer to save storage)
Definition: json.hpp:20539
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:21481
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
Definition: json.hpp:21559
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:20456
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const string_t &path="")
creates a diff as a JSON patch
Definition: json.hpp:25144
void set_parents()
Definition: json.hpp:20810
std::conditional< detail::is_c_string_uncvref< ValueType >::value, string_t, typename std::decay< ValueType >::type > value_return_type
Definition: json.hpp:22348
size_type erase_internal(KeyType &&key)
Definition: json.hpp:22703
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition: json.hpp:20435
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:23309
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:21607
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition: json.hpp:24398
reference operator[](typename object_t::key_type key)
access specified object element
Definition: json.hpp:22250
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:21687
~basic_json() noexcept
destructor
Definition: json.hpp:21385
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
Definition: json.hpp:20659
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition: json.hpp:21014
json_value(const object_t &value)
constructor for objects
Definition: json.hpp:20638
void swap(typename binary_t::container_type &other)
exchanges the values
Definition: json.hpp:23689
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:21460
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:24286
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition: json.hpp:23516
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
Definition: json.hpp:21356
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:24584
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:21916
const_reference operator[](T *key) const
Definition: json.hpp:22294
data(const value_t v)
Definition: json.hpp:24341
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:22191
basic_json(const JsonRef &ref)
Definition: json.hpp:21253
JSONSerializer< T, SFINAE > json_serializer
Definition: json.hpp:20273
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:24463
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition: json.hpp:21953
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:20460
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:21676
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:22153
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:21509
void swap(object_t &other)
exchanges the values
Definition: json.hpp:23641
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
Definition: json.hpp:20847
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:21840
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition: json.hpp:23496
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition: json.hpp:24492
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:21106
void swap(array_t &other)
exchanges the values
Definition: json.hpp:23625
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:22755
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition: json.hpp:23367
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:23246
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition: json.hpp:22878
binary_t & get_binary()
get a binary value
Definition: json.hpp:22035
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
Definition: json.hpp:21779
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:21425
reference emplace_back(Args &&... args)
add an object to an array
Definition: json.hpp:23342
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:22458
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.hpp:21117
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
Definition: json.hpp:21589
StringType string_t
a type for a string
Definition: json.hpp:20452
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
Definition: json.hpp:20444
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:23254
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
Definition: json.hpp:22408
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:22115
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:24707
json_value m_value
the value of the current element
Definition: json.hpp:24339
number_integer_t number_integer
number (integer)
Definition: json.hpp:20543
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:21453
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:22844
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:24421
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:21432
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:21446
json_value(value_t t)
constructor for empty values of a given type
Definition: json.hpp:20560
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:24455
json_value()=default
default constructor (for null values)
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition: json.hpp:24501
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
Definition: json.hpp:21571
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:21330
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:20922
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:22237
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:20322
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition: json.hpp:23438
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:20464
void swap(string_t &other)
exchanges the values
Definition: json.hpp:23657
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition: json.hpp:20956
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
Definition: json.hpp:20228
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
Definition: json.hpp:21583
json_value(const binary_t &value)
constructor for binary arrays (internal type)
Definition: json.hpp:20656
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
Definition: json.hpp:21565
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:22092
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition: json.hpp:20476
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:21257
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:23286
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:24414
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:21488
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
Definition: json.hpp:21631
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:24430
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false, const bool ignore_trailing_commas=false)
Definition: json.hpp:20236
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:24599
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition: json.hpp:23399
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:21144
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference operator[](const
Definition: json.hpp:24788
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:24444
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:24301
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition: json.hpp:22862
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:24510
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition: json.hpp:22830
boolean_t boolean
boolean
Definition: json.hpp:20541
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
Definition: json.hpp:20650
an internal type for a backed binary type
Definition: json.hpp:6239
bool operator!=(const byte_container_with_subtype &rhs) const
Definition: json.hpp:6279
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition: json.hpp:6245
std::uint64_t subtype_type
Definition: json.hpp:6242
bool operator==(const byte_container_with_subtype &rhs) const
Definition: json.hpp:6273
BinaryType container_type
Definition: json.hpp:6241
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:6267
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:6255
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition: json.hpp:6294
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition: json.hpp:6260
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition: json.hpp:6301
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition: json.hpp:6250
subtype_type m_subtype
Definition: json.hpp:6315
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition: json.hpp:6286
bool m_has_subtype
Definition: json.hpp:6316
void clear_subtype() noexcept
clears the binary subtype
Definition: json.hpp:6308
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:9892
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:12723
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result, bool inside_ndarray=false)
determine the type and size for a container
Definition: json.hpp:12070
binary_reader(const binary_reader &)=delete
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
Definition: json.hpp:10220
typename BasicJsonType::string_t string_t
Definition: json.hpp:9896
std::pair< char_int_type, string_t > bjd_type
Definition: json.hpp:12888
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
Definition: json.hpp:10182
typename InputAdapterType::char_type char_type
Definition: json.hpp:9899
bool parse_msgpack_internal()
Definition: json.hpp:11026
std::string get_token_string() const
Definition: json.hpp:12793
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:9894
bool get_msgpack_string(string_t &result)
reads a MessagePack string
Definition: json.hpp:11407
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:12806
InputAdapterType ia
input adapter
Definition: json.hpp:12846
bool get_ubjson_high_precision_number()
Definition: json.hpp:12528
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
Definition: json.hpp:12756
binary_reader(binary_reader &&)=default
static void byte_swap(NumberType &number)
Definition: json.hpp:12651
char_int_type get_ignore_noop()
Definition: json.hpp:12639
bool get_ubjson_value(const char_int_type prefix)
Definition: json.hpp:12137
bool get_ubjson_ndarray_size(std::vector< size_t > &dim)
Definition: json.hpp:11774
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
Definition: json.hpp:10096
bool get_msgpack_object(const std::size_t len)
Definition: json.hpp:11623
typename char_traits< char_type >::int_type char_int_type
Definition: json.hpp:9900
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition: json.hpp:9908
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:9897
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
Definition: json.hpp:9992
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:10970
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
Definition: json.hpp:10837
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:12693
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:9893
bool get_ubjson_array()
Definition: json.hpp:12330
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
Definition: json.hpp:10017
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition: json.hpp:9929
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:10932
bool get_msgpack_array(const std::size_t len)
Definition: json.hpp:11601
char_int_type get()
get next character from the input
Definition: json.hpp:12607
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:9895
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
Definition: json.hpp:11490
bool parse_ubjson_internal(const bool get_char=true)
Definition: json.hpp:11660
SAX json_sax_t
Definition: json.hpp:9898
bool get_ubjson_size_value(std::size_t &result, bool &is_ndarray, char_int_type prefix=0)
Definition: json.hpp:11839
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:10250
binary_reader & operator=(binary_reader &&)=default
binary_reader & operator=(const binary_reader &)=delete
bool get_ubjson_object()
Definition: json.hpp:12445
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
Definition: json.hpp:10047
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
Definition: json.hpp:11679
bool get_to(T &dest, const input_format_t format, const char *context)
get_to read into a primitive type
Definition: json.hpp:12622
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition: json.hpp:10741
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
Definition: json.hpp:10069
serialization to CBOR and MessagePack values
Definition: json.hpp:15863
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
Definition: json.hpp:16976
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
Definition: json.hpp:16813
void write_bson(const BasicJsonType &j)
Definition: json.hpp:15883
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:15865
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
Definition: json.hpp:16873
typename BasicJsonType::string_t string_t
Definition: json.hpp:15864
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:17623
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
Definition: json.hpp:16891
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false, const bjdata_version_t bjdata_version=bjdata_version_t::draft2)
Definition: json.hpp:16563
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
Definition: json.hpp:16957
static CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:17630
static constexpr CharType get_cbor_float_prefix(double)
Definition: json.hpp:17122
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
Definition: json.hpp:16841
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition: json.hpp:15874
static constexpr CharType get_ubjson_float_prefix(double)
Definition: json.hpp:17437
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
Definition: json.hpp:17148
static constexpr CharType get_msgpack_float_prefix(double)
Definition: json.hpp:17136
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
Definition: json.hpp:17039
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition: json.hpp:17665
void write_bson_object(const typename BasicJsonType::object_t &value)
Definition: json.hpp:17101
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
Definition: json.hpp:16823
static std::size_t calc_bson_string_size(const string_t &value)
Definition: json.hpp:16833
void write_number(const NumberType n, const bool OutputIsLittleEndian=false)
Definition: json.hpp:17573
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
Definition: json.hpp:16786
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
Definition: json.hpp:16855
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:15866
CharType ubjson_prefix(const BasicJsonType &j, const bool use_bjdata) const noexcept
determine the type prefix of container values
Definition: json.hpp:17331
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
Definition: json.hpp:16901
static constexpr CharType get_ubjson_float_prefix(float)
Definition: json.hpp:17432
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
Definition: json.hpp:16949
bool write_bjdata_ndarray(const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type, const bjdata_version_t bjdata_version)
Definition: json.hpp:17445
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
Definition: json.hpp:16991
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:16236
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
Definition: json.hpp:17086
void write_compact_float(const number_float_t n, detail::input_format_t format)
Definition: json.hpp:17589
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:15912
static constexpr CharType get_cbor_float_prefix(float)
Definition: json.hpp:17117
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
Definition: json.hpp:16801
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
Definition: json.hpp:16924
static constexpr CharType get_msgpack_float_prefix(float)
Definition: json.hpp:17131
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
Definition: json.hpp:16934
static std::size_t calc_bson_integer_size(const std::int64_t value)
Definition: json.hpp:16863
general exception of the basic_json class
Definition: json.hpp:4540
static std::string get_byte_positions(const BasicJsonType *leaf_element)
Definition: json.hpp:4645
const int id
the id of the exception
Definition: json.hpp:4549
static std::string diagnostics(std::nullptr_t)
Definition: json.hpp:4560
std::runtime_error m
an exception object as storage for error messages
Definition: json.hpp:4632
const char * what() const noexcept override
returns the explanatory string
Definition: json.hpp:4543
static std::string name(const std::string &ename, int id_)
Definition: json.hpp:4555
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition: json.hpp:4566
exception indicating errors with iterators
Definition: json.hpp:4709
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4712
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:13682
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition: json.hpp:13794
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.hpp:14265
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:14256
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:14219
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.hpp:14210
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.hpp:13809
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:14152
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:14192
iter_impl & operator++()
pre-increment (++it)
Definition: json.hpp:14011
bool operator==(const IterImpl &other) const
comparison: equal
Definition: json.hpp:14103
iter_impl operator++(int) &
post-increment (it++)
Definition: json.hpp:14000
iter_impl & operator--()
pre-decrement (–it)
Definition: json.hpp:14062
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:14327
const object_t::key_type & key() const
return the key of an object iterator
Definition: json.hpp:14365
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:13712
pointer operator->() const
dereference the iterator
Definition: json.hpp:13958
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.hpp:13819
friend other_iter_impl
allow basic_json to access private members
Definition: json.hpp:13686
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:14390
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.hpp:14298
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
Definition: json.hpp:13707
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.hpp:14276
reference value() const
return the value of an iterator
Definition: json.hpp:14381
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.hpp:14201
typename BasicJsonType::array_t array_t
Definition: json.hpp:13692
typename BasicJsonType::object_t object_t
Definition: json.hpp:13691
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition: json.hpp:13716
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:13710
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:13914
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:14287
friend BasicJsonType
Definition: json.hpp:13687
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition: json.hpp:14143
iter_impl operator--(int) &
post-decrement (it–)
Definition: json.hpp:14051
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition: json.hpp:13721
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition: json.hpp:13784
void set_end() noexcept
set the iterator past the last value
Definition: json.hpp:13875
Definition: json.hpp:5501
iteration_proxy_value operator++(int) &
Definition: json.hpp:5557
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: json.hpp:5566
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: json.hpp:5572
std::ptrdiff_t difference_type
Definition: json.hpp:5503
string_type empty_str
an empty string (to return a reference for primitive values)
Definition: json.hpp:5520
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
Definition: json.hpp:5524
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
Definition: json.hpp:5507
std::size_t array_index_last
last stringified array index
Definition: json.hpp:5516
std::size_t array_index
an index for arrays (used to create key names)
Definition: json.hpp:5514
const string_type & key() const
return key of the iterator
Definition: json.hpp:5578
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
Definition: json.hpp:5614
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: json.hpp:5549
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
string_type array_index_str
a string representation of the array index
Definition: json.hpp:5518
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition: json.hpp:5508
IteratorType anchor
the iterator
Definition: json.hpp:5512
proxy class for the items() function
Definition: json.hpp:5622
IteratorType::pointer container
the container to iterate
Definition: json.hpp:5625
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition: json.hpp:5647
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition: json.hpp:5641
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.hpp:5631
iteration_proxy & operator=(iteration_proxy const &)=default
Definition: json.hpp:15595
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
Definition: json.hpp:15603
json_ref(value_type &&value)
Definition: json.hpp:15599
value_type const & operator*() const
Definition: json.hpp:15634
json_ref(std::initializer_list< json_ref > init)
Definition: json.hpp:15607
json_ref(Args &&... args)
Definition: json.hpp:15614
value_type moved_or_copied() const
Definition: json.hpp:15625
BasicJsonType value_type
Definition: json.hpp:15597
value_type const * operator->() const
Definition: json.hpp:15639
a template for a reverse iterator class
Definition: json.hpp:14444
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition: json.hpp:14460
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:14466
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition: json.hpp:14472
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:14478
std::ptrdiff_t difference_type
Definition: json.hpp:14446
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:14508
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.hpp:14514
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:14502
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:14484
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:14450
reference value() const
return the value of an iterator
Definition: json.hpp:14521
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:14457
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.hpp:14448
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:14496
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:14453
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:14490
Definition: json.hpp:9607
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:9610
bool end_object()
Definition: json.hpp:9660
bool binary(binary_t &)
Definition: json.hpp:9645
bool number_integer(number_integer_t)
Definition: json.hpp:9625
bool start_array(std::size_t=detail::unknown_size())
Definition: json.hpp:9665
bool boolean(bool)
Definition: json.hpp:9620
bool end_array()
Definition: json.hpp:9670
bool number_unsigned(number_unsigned_t)
Definition: json.hpp:9630
bool start_object(std::size_t=detail::unknown_size())
Definition: json.hpp:9650
bool string(string_t &)
Definition: json.hpp:9640
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:9613
bool number_float(number_float_t, const string_t &)
Definition: json.hpp:9635
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition: json.hpp:9675
bool key(string_t &)
Definition: json.hpp:9655
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:9609
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:9611
typename BasicJsonType::string_t string_t
Definition: json.hpp:9612
Definition: json.hpp:9170
bool start_array(std::size_t len)
Definition: json.hpp:9338
typename BasicJsonType::parser_callback_t parser_callback_t
Definition: json.hpp:9177
typename BasicJsonType::parse_event_t parse_event_t
Definition: json.hpp:9178
bool number_integer(number_integer_t val)
Definition: json.hpp:9209
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:9417
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:9174
bool end_object()
Definition: json.hpp:9288
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:9215
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:9221
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
constexpr bool is_errored() const
Definition: json.hpp:9429
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition: json.hpp:9181
bool binary(binary_t &val)
Definition: json.hpp:9233
typename BasicJsonType::string_t string_t
Definition: json.hpp:9175
bool boolean(bool val)
Definition: json.hpp:9203
bool key(string_t &val)
Definition: json.hpp:9271
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
Definition: json.hpp:9516
bool string(string_t &val)
Definition: json.hpp:9227
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:9584
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:9173
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:9172
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:9176
~json_sax_dom_callback_parser()=default
bool end_array()
Definition: json.hpp:9370
bool start_object(std::size_t len)
Definition: json.hpp:9239
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
SAX implementation to create a JSON value from SAX events.
Definition: json.hpp:8864
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
Definition: json.hpp:9117
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:8913
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:8907
json_sax_dom_parser(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
Definition: json.hpp:8925
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8870
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition: json.hpp:8878
bool start_object(std::size_t len)
Definition: json.hpp:8931
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8866
bool key(string_t &val)
Definition: json.hpp:8954
bool end_object()
Definition: json.hpp:8964
typename BasicJsonType::string_t string_t
Definition: json.hpp:8869
~json_sax_dom_parser()=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8867
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:9022
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool boolean(bool val)
Definition: json.hpp:8895
bool start_array(std::size_t len)
Definition: json.hpp:8982
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8868
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:9155
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool end_array()
Definition: json.hpp:9003
json_sax_dom_parser(json_sax_dom_parser &&)=default
constexpr bool is_errored() const
Definition: json.hpp:9034
bool string(string_t &val)
Definition: json.hpp:8919
bool number_integer(number_integer_t val)
Definition: json.hpp:8901
Definition: json.hpp:7104
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition: json.hpp:7131
token_type
token types for the parser
Definition: json.hpp:7108
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
lexical analysis
Definition: json.hpp:7181
void reset() noexcept
reset token_buffer; current character is beginning of token
Definition: json.hpp:8391
bool skip_bom()
skip the UTF-8 byte order mark
Definition: json.hpp:8563
string_t token_buffer
buffer for variable-length tokens (numbers, strings)
Definition: json.hpp:8694
int get_codepoint()
get codepoint from 4 hex characters following \u
Definition: json.hpp:7238
token_type scan_string()
scan a string literal
Definition: json.hpp:7323
number_integer_t value_integer
Definition: json.hpp:8700
void skip_whitespace()
Definition: json.hpp:8577
lexer & operator=(lexer &&)=default
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
Definition: json.hpp:8679
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition: json.hpp:7192
char_int_type current
the current character
Definition: json.hpp:8682
std::string get_token_string() const
Definition: json.hpp:8525
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:7184
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition: json.hpp:8484
typename BasicJsonType::string_t string_t
Definition: json.hpp:7185
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:7183
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
Definition: json.hpp:7286
char_int_type get()
Definition: json.hpp:8409
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:8517
static void strtof(float &f, const char *str, char **endptr) noexcept
Definition: json.hpp:7981
const char_int_type decimal_point_char
the decimal point
Definition: json.hpp:8705
number_unsigned_t value_unsigned
Definition: json.hpp:8701
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:7182
token_type scan()
Definition: json.hpp:8586
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition: json.hpp:8490
typename char_traits< char_type >::int_type char_int_type
Definition: json.hpp:7187
bool scan_comment()
scan a comment
Definition: json.hpp:7913
typename lexer_base< BasicJsonType >::token_type token_type
Definition: json.hpp:7190
const char * error_message
a description of occurred lexer errors
Definition: json.hpp:8697
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition: json.hpp:8502
lexer & operator=(lexer &)=delete
bool next_unget
whether the next get() call should just return current
Definition: json.hpp:8685
lexer(const lexer &)=delete
constexpr JSON_HEDLEY_RETURNS_NON_NULL const char * get_error_message() const noexcept
return syntax error message
Definition: json.hpp:8550
std::size_t decimal_point_position
the position of the decimal point in the input
Definition: json.hpp:8707
typename InputAdapterType::char_type char_type
Definition: json.hpp:7186
InputAdapterType ia
input adapter
Definition: json.hpp:8676
token_type scan_number()
scan a number literal
Definition: json.hpp:8038
number_float_t value_float
Definition: json.hpp:8702
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
Definition: json.hpp:8371
std::vector< char_type > token_string
raw input token string (for error messages)
Definition: json.hpp:8691
void add(char_int_type c)
add a character to token_buffer
Definition: json.hpp:8473
position_t position
the start position of the current token
Definition: json.hpp:8688
void unget()
unget current character (read it again on next get)
Definition: json.hpp:8446
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition: json.hpp:8496
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
Definition: json.hpp:7212
exception indicating other library errors
Definition: json.hpp:4761
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4764
exception indicating access out of the defined range
Definition: json.hpp:4744
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4747
Definition: json.hpp:15814
output_adapter(StringType &s)
Definition: json.hpp:15825
output_adapter(std::basic_ostream< CharType > &s)
Definition: json.hpp:15821
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition: json.hpp:15817
output adapter for output streams
Definition: json.hpp:15766
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition: json.hpp:15768
void write_character(CharType c) override
Definition: json.hpp:15772
std::basic_ostream< CharType > & stream
Definition: json.hpp:15784
output adapter for basic_string
Definition: json.hpp:15791
void write_character(CharType c) override
Definition: json.hpp:15797
output_string_adapter(StringType &s) noexcept
Definition: json.hpp:15793
StringType & str
Definition: json.hpp:15809
output adapter for byte vectors
Definition: json.hpp:15741
std::vector< CharType, AllocatorType > & v
Definition: json.hpp:15759
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition: json.hpp:15743
void write_character(CharType c) override
Definition: json.hpp:15747
exception indicating a parse error
Definition: json.hpp:4656
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition: json.hpp:4668
static std::string position_string(const position_t &pos)
Definition: json.hpp:4699
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4676
const std::size_t byte
byte index of the parse error
Definition: json.hpp:4693
parse_error(int id_, std::size_t byte_, const char *what_arg)
Definition: json.hpp:4696
syntax analysis
Definition: json.hpp:12978
std::string exception_message(const token_type expected, const std::string &context)
Definition: json.hpp:13410
typename lexer_t::token_type token_type
Definition: json.hpp:12984
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition: json.hpp:13012
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:12980
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:12979
typename BasicJsonType::string_t string_t
Definition: json.hpp:12982
lexer_t m_lexer
the lexer
Definition: json.hpp:13445
bool accept(const bool strict=true)
public accept interface
Definition: json.hpp:13072
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:12981
token_type get_token()
get next token from lexer
Definition: json.hpp:13405
parser(InputAdapterType &&adapter, parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool ignore_comments=false, const bool ignore_trailing_commas_=false)
a parser reading from an input adapter
Definition: json.hpp:12988
Definition: json.hpp:13499
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.hpp:13587
primitive_iterator_t & operator--() noexcept
Definition: json.hpp:13574
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:13528
constexpr friend bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:13544
primitive_iterator_t & operator++() noexcept
Definition: json.hpp:13561
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:13522
constexpr friend difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:13556
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.hpp:13534
primitive_iterator_t operator++(int) &noexcept
Definition: json.hpp:13567
constexpr difference_type get_value() const noexcept
Definition: json.hpp:13510
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.hpp:13549
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.hpp:13593
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:13516
primitive_iterator_t operator--(int) &noexcept
Definition: json.hpp:13580
std::ptrdiff_t difference_type
Definition: json.hpp:13501
constexpr friend bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:13539
Definition: json.hpp:18862
serializer & operator=(serializer &&)=delete
typename BasicJsonType::binary_t::value_type binary_char_t
Definition: json.hpp:18867
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:18866
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition: json.hpp:18877
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition: json.hpp:19794
string_t indent_string
the indentation string
Definition: json.hpp:19791
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:18865
serializer & operator=(const serializer &)=delete
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:18864
typename BasicJsonType::string_t string_t
Definition: json.hpp:18863
const char indent_char
the indentation character
Definition: json.hpp:19789
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition: json.hpp:18917
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
Definition: json.hpp:4727
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4730
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition: json.hpp:14616
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
Definition: json.hpp:15060
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition: json.hpp:14711
BasicJsonType & get_checked(BasicJsonType *ptr) const
Definition: json.hpp:15002
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition: json.hpp:14688
static BasicJsonType::size_type array_index(const string_t &s)
Definition: json.hpp:14794
typename string_t_helper< RefStringType >::type string_t
Definition: json.hpp:14638
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition: json.hpp:14718
result reference_tokens
Definition: json.hpp:14840
static std::vector< string_t > split(const string_t &reference_string)
split the string input to reference tokens
Definition: json.hpp:15246
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition: json.hpp:14678
json_pointer(const string_t &s="")
create JSON pointer
Definition: json.hpp:14642
bool empty() const noexcept
return whether pointer points to the root document
Definition: json.hpp:14777
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
Definition: json.hpp:14669
void pop_back()
remove last reference token
Definition: json.hpp:14739
string_t to_string() const
return a string representation of the JSON pointer
Definition: json.hpp:14648
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:14770
std::vector< string_t > reference_tokens
the reference tokens
Definition: json.hpp:15505
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
Definition: json.hpp:14934
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
Definition: json.hpp:15109
return result
Definition: json.hpp:14841
static void flatten(const string_t &reference_string, const BasicJsonType &value, BasicJsonType &result)
Definition: json.hpp:15315
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
Definition: json.hpp:14854
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition: json.hpp:14703
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition: json.hpp:14725
static BasicJsonType unflatten(const BasicJsonType &value)
Definition: json.hpp:15387
const string_t & back() const
return last reference token
Definition: json.hpp:14751
json_pointer< string_t > convert() &&
Definition: json.hpp:15422
json_pointer< string_t > convert() const &
Definition: json.hpp:15415
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:14763
bool contains(const BasicJsonType *ptr) const
Definition: json.hpp:15158
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition: json.hpp:14696
a class to store JSON values
Definition: json.hpp:17064
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
Definition: json.hpp:23644
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:17126
an internal type for a backed binary type
Definition: json.hpp:4803
BinaryType container_type
the type of the underlying container
Definition: json.hpp:4806
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:8109
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition: json.hpp:8146
serialization to CBOR and MessagePack values
Definition: json.hpp:13132
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true)
Definition: json.hpp:13801
void write_bson(const BasicJsonType &j)
Definition: json.hpp:13152
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:13172
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:13477
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:11218
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:11245
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:11821
Definition: json.hpp:4201
proxy class for the items() function
Definition: json.hpp:4291
a template for a reverse iterator class
Definition: json.hpp:11863
Definition: json.hpp:6319
Definition: json.hpp:11045
Definition: json.hpp:15853
JSON Pointer.
Definition: json.hpp:11975
BasicJsonType & get_checked(BasicJsonType *ptr) const
Definition: json.hpp:12485
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
Definition: json.hpp:12426
bool contains(const BasicJsonType *ptr) const
Definition: json.hpp:12614
Concept for allocating, resizing and freeing memory block.
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition: json.hpp:5695
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2117
v1d & operator+=(v1d &a, cv1d &b)
Definition: Tools.cpp:29
v1d operator-(v1d a, double &b)
Definition: Tools.cpp:17
@ pos
Definition: Typedefs.h:19
v1d operator*(v1d a, double b)
Definition: Tools.cpp:9
v1d operator+(v1d a, double b)
Definition: Tools.cpp:13
std::string decode(std::string const &encoded_string)
Definition: base64.hpp:89
type
The type the bitset is encoded with.
Definition: bitset.hpp:44
C const & container(std::queue< T, C > const &queue)
Allows access to the protected container in queue.
Definition: queue.hpp:48
std::basic_ostream< Ch > & operator<<(std::basic_ostream< Ch > &out, const xml_node< Ch > &node)
Definition: rapidxml_print.hpp:418
CEREAL_SIZE_TYPE size_type
The size type used by cereal.
Definition: helpers.hpp:61
constexpr bool is_transparent()
Definition: json.hpp:4350
constexpr bool is_c_string()
Definition: json.hpp:4322
detail namespace with internal helper functions
Definition: json.hpp:260
input_format_t
the supported input formats
Definition: json.hpp:6530
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:6110
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: json.hpp:320
typename make_void< Ts... >::type void_t
Definition: json.hpp:266
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: json.hpp:9754
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:15736
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition: json.hpp:4431
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: json.hpp:9762
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
Definition: json.hpp:3352
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:12969
OutStringType concat(Args &&... args)
Definition: json.hpp:4505
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition: json.hpp:4440
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 >>, priority_tag< 0 >)
Definition: json.hpp:5278
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: json.hpp:3649
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: json.hpp:3655
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition: json.hpp:4172
typename T::pointer pointer_t
Definition: json.hpp:3640
parse_event_t
Definition: json.hpp:12952
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition: json.hpp:4434
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition: json.hpp:5083
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition: json.hpp:3313
typename T::value_type value_type_t
Definition: json.hpp:3634
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: json.hpp:324
void int_to_string(StringType &target, std::size_t value)
Definition: json.hpp:5475
T conditional_static_cast(U value)
Definition: json.hpp:4206
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition: json.hpp:4446
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:3225
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: json.hpp:9723
typename T::mapped_type mapped_type_t
Definition: json.hpp:3628
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition: json.hpp:3101
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: json.hpp:9731
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition: json.hpp:3900
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:5657
bool little_endianness(int num=1) noexcept
determine system byte order
Definition: json.hpp:9878
cbor_tag_handler_t
how to treat CBOR tags
Definition: json.hpp:9865
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: json.hpp:317
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: json.hpp:3652
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: json.hpp:6984
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3321
std::integral_constant< bool, Value > bool_constant
Definition: json.hpp:4312
void concat_into(OutStringType &)
Definition: json.hpp:4421
typename T::key_type key_type_t
Definition: json.hpp:3631
constexpr bool value_in_range_of(T val)
Definition: json.hpp:4306
value_t
the JSON type enumeration
Definition: json.hpp:3003
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition: json.hpp:4229
constexpr std::size_t unknown_size()
Definition: json.hpp:8844
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:6920
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition: json.hpp:5266
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: json.hpp:9739
StringType to_string(std::size_t value)
Definition: json.hpp:5483
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: json.hpp:311
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition: json.hpp:4156
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:6370
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition: json.hpp:4437
typename T::iterator_category iterator_category_t
Definition: json.hpp:3646
void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:3135
decltype(input_adapter(std::declval< std::string >())) string_input_adapter_type
Definition: json.hpp:6960
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: json.hpp:6352
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:3032
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: json.hpp:9757
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition: json.hpp:4184
error_handler_t
how to treat decoding errors
Definition: json.hpp:18854
@ strict
throw a type_error exception in case of invalid UTF-8
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
Definition: json.hpp:4390
value_type_t< iterator_traits< iterator_t< T > >> range_value_t
Definition: json.hpp:3903
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:4863
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition: json.hpp:3728
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition: json.hpp:4425
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.hpp:5971
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:4892
decltype(std::declval< T & >().null()) null_function_t
Definition: json.hpp:9715
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3329
typename T::difference_type difference_type_t
Definition: json.hpp:3637
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.hpp:3211
typename T::is_transparent detect_is_transparent
Definition: json.hpp:4142
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: json.hpp:9735
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
Definition: json.hpp:14570
typename T::reference reference_t
Definition: json.hpp:3643
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: json.hpp:9719
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: json.hpp:9750
bjdata_version_t
how to encode BJData
Definition: json.hpp:15849
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition: json.hpp:4175
typename T::key_compare detect_key_compare
Definition: json.hpp:3712
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: json.hpp:9743
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition: json.hpp:4443
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: json.hpp:9727
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: json.hpp:305
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:3120
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
Definition: json.hpp:4234
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition: json.hpp:4428
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)>>, index_sequence< Idx... >)
Definition: json.hpp:5166
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: json.hpp:9747
Definition: json.hpp:25324
std::istream & operator>>(std::istream &in, JsonValue &value)
Definition: json_parser.h:246
Target reinterpret_bits(const Source source)
Definition: json.hpp:14757
boundaries compute_boundaries(FloatType value)
Definition: json.hpp:14898
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition: json.hpp:15201
constexpr int kGamma
Definition: json.hpp:15021
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition: json.hpp:15255
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition: json.hpp:15296
void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value)
Definition: json.hpp:15597
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition: json.hpp:15689
constexpr int kAlpha
Definition: json.hpp:15020
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition: json.hpp:15637
cached_power get_cached_power_for_binary_exponent(int e)
Definition: json.hpp:15037
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:3042
value_t
the JSON type enumeration
Definition: json.hpp:118
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3146
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:10569
parse_event_t
Definition: json.hpp:10552
integer_sequence< size_t, Ints... > index_sequence
Definition: json.hpp:3084
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:4986
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
Definition: json.hpp:15774
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3138
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:13020
void to_json(BasicJsonType &j, const T &b)
Definition: json.hpp:4697
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4317
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
Definition: json.hpp:4125
namespace for Niels Lohmann
Definition: json.hpp:86
std::basic_string< PUGIXML_CHAR, std::char_traits< PUGIXML_CHAR >, std::allocator< PUGIXML_CHAR > > string_t
Definition: pugixml.hpp:141
Definition: json.hpp:5678
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:25399
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1282
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1181
const CharType(& source)[N]
Definition: pointer.h:1204
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1181
PUGI_IMPL_FN void reverse(I begin, I end)
Definition: pugixml.cpp:7615
void swap(T &lhs, T &rhs)
Definition: pugixml.cpp:7597
PUGI_IMPL_FN bool is_little_endian()
Definition: pugixml.cpp:1931
signed short int16_t
Definition: stdint.h:122
unsigned short uint16_t
Definition: stdint.h:125
signed __int64 int64_t
Definition: stdint.h:135
unsigned int uint32_t
Definition: stdint.h:126
signed int int32_t
Definition: stdint.h:123
unsigned char uint8_t
Definition: stdint.h:124
unsigned __int64 uint64_t
Definition: stdint.h:136
signed char int8_t
Definition: stdint.h:121
namespace for Niels Lohmann
Definition: json.hpp:6181
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition: json.hpp:6205
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition: json.hpp:6195
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition: json.hpp:6185
Definition: json.hpp:3720
typename BasicJsonType::object_t object_t
Definition: json.hpp:3721
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition: json.hpp:3722
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition: json.hpp:3724
signed char char_type
Definition: json.hpp:3767
static constexpr int_type eof() noexcept
Definition: json.hpp:3781
uint64_t int_type
Definition: json.hpp:3768
static char_type to_char_type(int_type i) noexcept
Definition: json.hpp:3776
static int_type to_int_type(char_type c) noexcept
Definition: json.hpp:3771
static char_type to_char_type(int_type i) noexcept
Definition: json.hpp:3752
static constexpr int_type eof() noexcept
Definition: json.hpp:3757
unsigned char char_type
Definition: json.hpp:3743
uint64_t int_type
Definition: json.hpp:3744
static int_type to_int_type(char_type c) noexcept
Definition: json.hpp:3747
Definition: json.hpp:3737
Definition: json.hpp:3817
Definition: json.hpp:3816
std::true_type value_t
Definition: json.hpp:300
Op< Args... > type
Definition: json.hpp:301
std::false_type value_t
Definition: json.hpp:293
Default type
Definition: json.hpp:294
Definition: json.hpp:17885
diyfp w
Definition: json.hpp:17886
diyfp minus
Definition: json.hpp:17887
diyfp plus
Definition: json.hpp:17888
Definition: json.hpp:18024
std::uint64_t f
Definition: json.hpp:18025
int e
Definition: json.hpp:18026
int k
Definition: json.hpp:18027
Definition: json.hpp:17767
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition: json.hpp:17791
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition: json.hpp:17873
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition: json.hpp:17856
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition: json.hpp:17779
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition: json.hpp:17773
std::uint64_t f
Definition: json.hpp:17770
int e
Definition: json.hpp:17771
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.hpp:5880
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.hpp:5855
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.hpp:5845
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.hpp:5867
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition: json.hpp:5896
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition: json.hpp:5784
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition: json.hpp:5793
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition: json.hpp:5738
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition: json.hpp:5806
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition: json.hpp:5832
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition: json.hpp:5819
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.hpp:5915
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.hpp:5936
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.hpp:5925
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition: json.hpp:5760
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition: json.hpp:5771
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition: json.hpp:5751
Definition: json.hpp:5732
Definition: json.hpp:5375
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition: json.hpp:5377
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3674
Definition: json.hpp:3659
Definition: json.hpp:3715
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3689
Definition: json.hpp:3684
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3704
Definition: json.hpp:3699
Definition: json.hpp:4805
Definition: json.hpp:3253
T value_type
Definition: json.hpp:3254
static constexpr std::size_t size() noexcept
Definition: json.hpp:3255
an iterator value
Definition: json.hpp:13615
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:13619
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:13621
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:13617
Definition: json.hpp:3608
Definition: json.hpp:3595
Definition: json.hpp:4337
Definition: json.hpp:4133
Definition: json.hpp:3997
Definition: json.hpp:4016
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.hpp:4074
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.hpp:4075
Definition: json.hpp:4064
Definition: json.hpp:4087
typename BasicJsonType::object_t object_t
Definition: json.hpp:3925
Definition: json.hpp:3917
Definition: json.hpp:3937
Definition: json.hpp:3974
static constexpr auto value
Definition: json.hpp:3975
Definition: json.hpp:4090
Definition: json.hpp:4103
Definition: json.hpp:3910
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition: json.hpp:4046
Definition: json.hpp:4019
Definition: json.hpp:4060
typename BasicJsonType::object_t object_t
Definition: json.hpp:3949
Definition: json.hpp:3941
Definition: json.hpp:3970
Definition: json.hpp:3981
ConstructibleStringType laundered_type
Definition: json.hpp:3986
static constexpr auto value
Definition: json.hpp:3989
Definition: json.hpp:4106
Definition: json.hpp:3848
Definition: json.hpp:3829
Definition: json.hpp:3667
static constexpr bool value
Definition: json.hpp:3668
Definition: json.hpp:6896
typename std::iterator_traits< T >::value_type value_type
Definition: json.hpp:6897
Definition: json.hpp:3863
Definition: json.hpp:4112
Definition: json.hpp:3618
Definition: json.hpp:4194
char x[2]
Definition: json.hpp:4195
Definition: json.hpp:4190
static one test(decltype(&C::capacity))
char one
Definition: json.hpp:4191
@ value
Definition: json.hpp:4201
Definition: json.hpp:3882
detected_t< result_of_end, t_ref > sentinel
Definition: json.hpp:3887
detected_t< result_of_begin, t_ref > iterator
Definition: json.hpp:3886
typename std::add_lvalue_reference< T >::type t_ref
Definition: json.hpp:3884
static constexpr bool value
Definition: json.hpp:3896
static constexpr auto is_iterator_begin
Definition: json.hpp:3892
Definition: json.hpp:9797
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:9802
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:9803
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:9806
typename BasicJsonType::exception exception_t
Definition: json.hpp:9807
typename BasicJsonType::string_t string_t
Definition: json.hpp:9805
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:9804
Definition: json.hpp:9766
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:9775
typename BasicJsonType::exception exception_t
Definition: json.hpp:9776
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:9773
typename BasicJsonType::string_t string_t
Definition: json.hpp:9774
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:9772
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:9771
Definition: json.hpp:4123
Definition: json.hpp:4359
T value_type
Definition: json.hpp:3436
T * pointer
Definition: json.hpp:3438
ptrdiff_t difference_type
Definition: json.hpp:3437
T & reference
Definition: json.hpp:3439
std::random_access_iterator_tag iterator_category
Definition: json.hpp:3435
Definition: json.hpp:3423
typename It::iterator_category iterator_category
Definition: json.hpp:3416
typename It::difference_type difference_type
Definition: json.hpp:3412
typename It::value_type value_type
Definition: json.hpp:3413
typename It::reference reference
Definition: json.hpp:3415
typename It::pointer pointer
Definition: json.hpp:3414
Definition: json.hpp:3404
Default base class of the basic_json class.
Definition: json.hpp:14563
void type
Definition: json.hpp:264
Definition: json.hpp:3823
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
Definition: json.hpp:15722
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
Definition: json.hpp:3166
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: json.hpp:3170
std::size_t lines_read
the number of lines read
Definition: json.hpp:3172
std::size_t chars_read_total
the total number of characters read
Definition: json.hpp:3168
Definition: json.hpp:3337
Definition: json.hpp:3336
Definition: json.hpp:3342
static constexpr JSON_INLINE_VARIABLE T value
Definition: json.hpp:3343
Definition: json.hpp:6148
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition: json.hpp:6150
Definition: json.hpp:3273
Definition: json.hpp:3292
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition: json.hpp:3294
static constexpr bool test(T val)
Definition: json.hpp:4290
static constexpr bool test(T)
Definition: json.hpp:4299
Definition: json.hpp:4285
static constexpr bool test(T val)
Definition: json.hpp:4244
static constexpr bool test(T val)
Definition: json.hpp:4264
static constexpr bool test(T val)
Definition: json.hpp:4254
static constexpr bool test(T val)
Definition: json.hpp:4274
Definition: json.hpp:4239
StringType type
Definition: json.hpp:14633
Definition: json.hpp:14626
T type
Definition: json.hpp:14627
SAX interface.
Definition: json.hpp:8729
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8730
typename BasicJsonType::string_t string_t
Definition: json.hpp:8733
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8732
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8731
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8734
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
Definition: pugixml.cpp:7582
an iterator value
Definition: json.hpp:11160
a minimal map-like container that preserves insertion order
Definition: json.hpp:19836
const T & at(const key_type &key) const
Definition: json.hpp:19940
std::vector< std::pair< const Key, T >, Allocator > Container
Definition: json.hpp:19839
const T & operator[](const key_type &key) const
Definition: json.hpp:19900
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
Definition: json.hpp:19875
typename Container::value_type value_type
Definition: json.hpp:19843
std::equal_to< Key > key_compare
Definition: json.hpp:19847
iterator erase(iterator pos)
Definition: json.hpp:20008
T mapped_type
Definition: json.hpp:19838
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition: json.hpp:19853
typename Container::iterator iterator
Definition: json.hpp:19840
T & operator[](KeyType &&key)
Definition: json.hpp:19895
iterator find(const key_type &key)
Definition: json.hpp:20092
T & at(const key_type &key)
Definition: json.hpp:19912
iterator erase(iterator first, iterator last)
Definition: json.hpp:20013
const_iterator find(const key_type &key) const
Definition: json.hpp:20118
std::pair< iterator, bool > insert(const value_type &value)
Definition: json.hpp:20135
size_type erase(KeyType &&key)
Definition: json.hpp:19989
typename Container::size_type size_type
Definition: json.hpp:19842
const T & at(KeyType &&key) const
Definition: json.hpp:19955
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition: json.hpp:19860
ordered_map() noexcept(noexcept(Container()))
Definition: json.hpp:19852
void insert(InputIt first, InputIt last)
Definition: json.hpp:20153
T & operator[](const key_type &key)
Definition: json.hpp:19888
size_type count(const key_type &key) const
Definition: json.hpp:20066
size_type erase(const key_type &key)
Definition: json.hpp:19968
std::pair< iterator, bool > insert(value_type &&value)
Definition: json.hpp:20130
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition: json.hpp:19857
size_type count(KeyType &&key) const
Definition: json.hpp:20080
Key key_type
Definition: json.hpp:19837
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition: json.hpp:19855
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition: json.hpp:20150
iterator find(KeyType &&key)
Definition: json.hpp:20106
T & at(KeyType &&key)
Definition: json.hpp:19927
typename Container::const_iterator const_iterator
Definition: json.hpp:19841
const T & operator[](KeyType &&key) const
Definition: json.hpp:19907
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition: json.hpp:25368
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.hpp:25382
#define const
Definition: zconf.h:233