18 #ifndef INCLUDE_NLOHMANN_JSON_HPP_ 19 #define INCLUDE_NLOHMANN_JSON_HPP_ 24 #include <initializer_list> 60 #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK 61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) 62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2 63 #warning "Already included a different version of the library!" 68 #define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) 69 #define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) 70 #define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum) 72 #ifndef JSON_DIAGNOSTICS 73 #define JSON_DIAGNOSTICS 0 76 #ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 77 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 81 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag 83 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS 86 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 87 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp 89 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON 92 #ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION 93 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 97 #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b 98 #define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ 99 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) 101 #define NLOHMANN_JSON_ABI_TAGS \ 102 NLOHMANN_JSON_ABI_TAGS_CONCAT( \ 103 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ 104 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) 107 #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ 108 _v ## major ## _ ## minor ## _ ## patch 109 #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ 110 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) 112 #if NLOHMANN_JSON_NAMESPACE_NO_VERSION 113 #define NLOHMANN_JSON_NAMESPACE_VERSION 115 #define NLOHMANN_JSON_NAMESPACE_VERSION \ 116 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ 117 NLOHMANN_JSON_VERSION_MINOR, \ 118 NLOHMANN_JSON_VERSION_PATCH) 122 #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b 123 #define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ 124 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) 126 #ifndef NLOHMANN_JSON_NAMESPACE 127 #define NLOHMANN_JSON_NAMESPACE \ 128 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ 129 NLOHMANN_JSON_ABI_TAGS, \ 130 NLOHMANN_JSON_NAMESPACE_VERSION) 133 #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN 134 #define NLOHMANN_JSON_NAMESPACE_BEGIN \ 137 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ 138 NLOHMANN_JSON_ABI_TAGS, \ 139 NLOHMANN_JSON_NAMESPACE_VERSION) \ 143 #ifndef NLOHMANN_JSON_NAMESPACE_END 144 #define NLOHMANN_JSON_NAMESPACE_END \ 146 } // namespace nlohmann 162 #include <forward_list> 167 #include <type_traits> 168 #include <unordered_map> 231 #include <type_traits> 276 template<
class Default,
278 template<
class...>
class Op,
286 template<
class Default,
template<
class...>
class Op,
class... Args>
293 template<
template<
class...>
class Op,
class... Args>
296 template<
template<
class...>
class Op,
class... Args>
299 template<
template<
class...>
class Op,
class... Args>
302 template<
class Default,
template<
class...>
class Op,
class... Args>
305 template<
class Default,
template<
class...>
class Op,
class... Args>
308 template<
class Expected,
template<
class...>
class Op,
class... Args>
311 template<
class To,
template<
class...>
class Op,
class... Args>
334 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) 335 #if defined(JSON_HEDLEY_VERSION) 336 #undef JSON_HEDLEY_VERSION 338 #define JSON_HEDLEY_VERSION 15 340 #if defined(JSON_HEDLEY_STRINGIFY_EX) 341 #undef JSON_HEDLEY_STRINGIFY_EX 343 #define JSON_HEDLEY_STRINGIFY_EX(x) #x 345 #if defined(JSON_HEDLEY_STRINGIFY) 346 #undef JSON_HEDLEY_STRINGIFY 348 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) 350 #if defined(JSON_HEDLEY_CONCAT_EX) 351 #undef JSON_HEDLEY_CONCAT_EX 353 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b 355 #if defined(JSON_HEDLEY_CONCAT) 356 #undef JSON_HEDLEY_CONCAT 358 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) 360 #if defined(JSON_HEDLEY_CONCAT3_EX) 361 #undef JSON_HEDLEY_CONCAT3_EX 363 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c 365 #if defined(JSON_HEDLEY_CONCAT3) 366 #undef JSON_HEDLEY_CONCAT3 368 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) 370 #if defined(JSON_HEDLEY_VERSION_ENCODE) 371 #undef JSON_HEDLEY_VERSION_ENCODE 373 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) 375 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) 376 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR 378 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) 380 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) 381 #undef JSON_HEDLEY_VERSION_DECODE_MINOR 383 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) 385 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) 386 #undef JSON_HEDLEY_VERSION_DECODE_REVISION 388 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) 390 #if defined(JSON_HEDLEY_GNUC_VERSION) 391 #undef JSON_HEDLEY_GNUC_VERSION 393 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) 394 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) 395 #elif defined(__GNUC__) 396 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) 399 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) 400 #undef JSON_HEDLEY_GNUC_VERSION_CHECK 402 #if defined(JSON_HEDLEY_GNUC_VERSION) 403 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 405 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) 408 #if defined(JSON_HEDLEY_MSVC_VERSION) 409 #undef JSON_HEDLEY_MSVC_VERSION 411 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) 412 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) 413 #elif defined(_MSC_FULL_VER) && !defined(__ICL) 414 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) 415 #elif defined(_MSC_VER) && !defined(__ICL) 416 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) 419 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) 420 #undef JSON_HEDLEY_MSVC_VERSION_CHECK 422 #if !defined(JSON_HEDLEY_MSVC_VERSION) 423 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) 424 #elif defined(_MSC_VER) && (_MSC_VER >= 1400) 425 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) 426 #elif defined(_MSC_VER) && (_MSC_VER >= 1200) 427 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) 429 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) 432 #if defined(JSON_HEDLEY_INTEL_VERSION) 433 #undef JSON_HEDLEY_INTEL_VERSION 435 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) 436 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) 437 #elif defined(__INTEL_COMPILER) && !defined(__ICL) 438 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) 441 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) 442 #undef JSON_HEDLEY_INTEL_VERSION_CHECK 444 #if defined(JSON_HEDLEY_INTEL_VERSION) 445 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 447 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) 450 #if defined(JSON_HEDLEY_INTEL_CL_VERSION) 451 #undef JSON_HEDLEY_INTEL_CL_VERSION 453 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) 454 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) 457 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) 458 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK 460 #if defined(JSON_HEDLEY_INTEL_CL_VERSION) 461 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 463 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) 466 #if defined(JSON_HEDLEY_PGI_VERSION) 467 #undef JSON_HEDLEY_PGI_VERSION 469 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) 470 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) 473 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK) 474 #undef JSON_HEDLEY_PGI_VERSION_CHECK 476 #if defined(JSON_HEDLEY_PGI_VERSION) 477 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 479 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) 482 #if defined(JSON_HEDLEY_SUNPRO_VERSION) 483 #undef JSON_HEDLEY_SUNPRO_VERSION 485 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) 486 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) 487 #elif defined(__SUNPRO_C) 488 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) 489 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) 490 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) 491 #elif defined(__SUNPRO_CC) 492 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) 495 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) 496 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK 498 #if defined(JSON_HEDLEY_SUNPRO_VERSION) 499 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 501 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) 504 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) 505 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION 507 #if defined(__EMSCRIPTEN__) 508 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) 511 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) 512 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK 514 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) 515 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 517 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) 520 #if defined(JSON_HEDLEY_ARM_VERSION) 521 #undef JSON_HEDLEY_ARM_VERSION 523 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) 524 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) 525 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) 526 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) 529 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK) 530 #undef JSON_HEDLEY_ARM_VERSION_CHECK 532 #if defined(JSON_HEDLEY_ARM_VERSION) 533 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 535 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) 538 #if defined(JSON_HEDLEY_IBM_VERSION) 539 #undef JSON_HEDLEY_IBM_VERSION 541 #if defined(__ibmxl__) 542 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) 543 #elif defined(__xlC__) && defined(__xlC_ver__) 544 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) 545 #elif defined(__xlC__) 546 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) 549 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK) 550 #undef JSON_HEDLEY_IBM_VERSION_CHECK 552 #if defined(JSON_HEDLEY_IBM_VERSION) 553 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 555 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) 558 #if defined(JSON_HEDLEY_TI_VERSION) 559 #undef JSON_HEDLEY_TI_VERSION 562 defined(__TI_COMPILER_VERSION__) && \ 564 defined(__TMS470__) || defined(__TI_ARM__) || \ 565 defined(__MSP430__) || \ 566 defined(__TMS320C2000__) \ 568 #if (__TI_COMPILER_VERSION__ >= 16000000) 569 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 573 #if defined(JSON_HEDLEY_TI_VERSION_CHECK) 574 #undef JSON_HEDLEY_TI_VERSION_CHECK 576 #if defined(JSON_HEDLEY_TI_VERSION) 577 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 579 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) 582 #if defined(JSON_HEDLEY_TI_CL2000_VERSION) 583 #undef JSON_HEDLEY_TI_CL2000_VERSION 585 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) 586 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 589 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) 590 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK 592 #if defined(JSON_HEDLEY_TI_CL2000_VERSION) 593 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 595 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) 598 #if defined(JSON_HEDLEY_TI_CL430_VERSION) 599 #undef JSON_HEDLEY_TI_CL430_VERSION 601 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) 602 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 605 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) 606 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK 608 #if defined(JSON_HEDLEY_TI_CL430_VERSION) 609 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 611 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) 614 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) 615 #undef JSON_HEDLEY_TI_ARMCL_VERSION 617 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) 618 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 621 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) 622 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK 624 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) 625 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 627 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) 630 #if defined(JSON_HEDLEY_TI_CL6X_VERSION) 631 #undef JSON_HEDLEY_TI_CL6X_VERSION 633 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) 634 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 637 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) 638 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK 640 #if defined(JSON_HEDLEY_TI_CL6X_VERSION) 641 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 643 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) 646 #if defined(JSON_HEDLEY_TI_CL7X_VERSION) 647 #undef JSON_HEDLEY_TI_CL7X_VERSION 649 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) 650 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 653 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) 654 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK 656 #if defined(JSON_HEDLEY_TI_CL7X_VERSION) 657 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 659 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) 662 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) 663 #undef JSON_HEDLEY_TI_CLPRU_VERSION 665 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) 666 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 669 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) 670 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK 672 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) 673 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 675 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) 678 #if defined(JSON_HEDLEY_CRAY_VERSION) 679 #undef JSON_HEDLEY_CRAY_VERSION 682 #if defined(_RELEASE_PATCHLEVEL) 683 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) 685 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) 689 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) 690 #undef JSON_HEDLEY_CRAY_VERSION_CHECK 692 #if defined(JSON_HEDLEY_CRAY_VERSION) 693 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 695 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) 698 #if defined(JSON_HEDLEY_IAR_VERSION) 699 #undef JSON_HEDLEY_IAR_VERSION 701 #if defined(__IAR_SYSTEMS_ICC__) 703 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) 705 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) 709 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK) 710 #undef JSON_HEDLEY_IAR_VERSION_CHECK 712 #if defined(JSON_HEDLEY_IAR_VERSION) 713 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 715 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) 718 #if defined(JSON_HEDLEY_TINYC_VERSION) 719 #undef JSON_HEDLEY_TINYC_VERSION 721 #if defined(__TINYC__) 722 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) 725 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) 726 #undef JSON_HEDLEY_TINYC_VERSION_CHECK 728 #if defined(JSON_HEDLEY_TINYC_VERSION) 729 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 731 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) 734 #if defined(JSON_HEDLEY_DMC_VERSION) 735 #undef JSON_HEDLEY_DMC_VERSION 738 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) 741 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK) 742 #undef JSON_HEDLEY_DMC_VERSION_CHECK 744 #if defined(JSON_HEDLEY_DMC_VERSION) 745 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 747 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) 750 #if defined(JSON_HEDLEY_COMPCERT_VERSION) 751 #undef JSON_HEDLEY_COMPCERT_VERSION 753 #if defined(__COMPCERT_VERSION__) 754 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) 757 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) 758 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK 760 #if defined(JSON_HEDLEY_COMPCERT_VERSION) 761 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 763 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) 766 #if defined(JSON_HEDLEY_PELLES_VERSION) 767 #undef JSON_HEDLEY_PELLES_VERSION 769 #if defined(__POCC__) 770 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) 773 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) 774 #undef JSON_HEDLEY_PELLES_VERSION_CHECK 776 #if defined(JSON_HEDLEY_PELLES_VERSION) 777 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 779 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) 782 #if defined(JSON_HEDLEY_MCST_LCC_VERSION) 783 #undef JSON_HEDLEY_MCST_LCC_VERSION 785 #if defined(__LCC__) && defined(__LCC_MINOR__) 786 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) 789 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) 790 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK 792 #if defined(JSON_HEDLEY_MCST_LCC_VERSION) 793 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 795 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) 798 #if defined(JSON_HEDLEY_GCC_VERSION) 799 #undef JSON_HEDLEY_GCC_VERSION 802 defined(JSON_HEDLEY_GNUC_VERSION) && \ 803 !defined(__clang__) && \ 804 !defined(JSON_HEDLEY_INTEL_VERSION) && \ 805 !defined(JSON_HEDLEY_PGI_VERSION) && \ 806 !defined(JSON_HEDLEY_ARM_VERSION) && \ 807 !defined(JSON_HEDLEY_CRAY_VERSION) && \ 808 !defined(JSON_HEDLEY_TI_VERSION) && \ 809 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ 810 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ 811 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ 812 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ 813 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ 814 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ 815 !defined(__COMPCERT__) && \ 816 !defined(JSON_HEDLEY_MCST_LCC_VERSION) 817 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION 820 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK) 821 #undef JSON_HEDLEY_GCC_VERSION_CHECK 823 #if defined(JSON_HEDLEY_GCC_VERSION) 824 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 826 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) 829 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) 830 #undef JSON_HEDLEY_HAS_ATTRIBUTE 833 defined(__has_attribute) && \ 835 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ 837 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) 839 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) 842 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) 843 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE 845 #if defined(__has_attribute) 846 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 848 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 851 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) 852 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE 854 #if defined(__has_attribute) 855 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 857 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 860 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) 861 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE 864 defined(__has_cpp_attribute) && \ 865 defined(__cplusplus) && \ 866 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) 867 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) 869 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) 872 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) 873 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS 875 #if !defined(__cplusplus) || !defined(__has_cpp_attribute) 876 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) 878 !defined(JSON_HEDLEY_PGI_VERSION) && \ 879 !defined(JSON_HEDLEY_IAR_VERSION) && \ 880 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ 881 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) 882 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) 884 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) 887 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) 888 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE 890 #if defined(__has_cpp_attribute) && defined(__cplusplus) 891 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) 893 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 896 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) 897 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE 899 #if defined(__has_cpp_attribute) && defined(__cplusplus) 900 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) 902 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 905 #if defined(JSON_HEDLEY_HAS_BUILTIN) 906 #undef JSON_HEDLEY_HAS_BUILTIN 908 #if defined(__has_builtin) 909 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) 911 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) 914 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) 915 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN 917 #if defined(__has_builtin) 918 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) 920 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 923 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) 924 #undef JSON_HEDLEY_GCC_HAS_BUILTIN 926 #if defined(__has_builtin) 927 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) 929 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 932 #if defined(JSON_HEDLEY_HAS_FEATURE) 933 #undef JSON_HEDLEY_HAS_FEATURE 935 #if defined(__has_feature) 936 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) 938 #define JSON_HEDLEY_HAS_FEATURE(feature) (0) 941 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) 942 #undef JSON_HEDLEY_GNUC_HAS_FEATURE 944 #if defined(__has_feature) 945 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) 947 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 950 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE) 951 #undef JSON_HEDLEY_GCC_HAS_FEATURE 953 #if defined(__has_feature) 954 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) 956 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 959 #if defined(JSON_HEDLEY_HAS_EXTENSION) 960 #undef JSON_HEDLEY_HAS_EXTENSION 962 #if defined(__has_extension) 963 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) 965 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) 968 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) 969 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION 971 #if defined(__has_extension) 972 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) 974 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 977 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) 978 #undef JSON_HEDLEY_GCC_HAS_EXTENSION 980 #if defined(__has_extension) 981 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) 983 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 986 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) 987 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE 989 #if defined(__has_declspec_attribute) 990 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) 992 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) 995 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) 996 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE 998 #if defined(__has_declspec_attribute) 999 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) 1001 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 1004 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) 1005 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE 1007 #if defined(__has_declspec_attribute) 1008 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) 1010 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 1013 #if defined(JSON_HEDLEY_HAS_WARNING) 1014 #undef JSON_HEDLEY_HAS_WARNING 1016 #if defined(__has_warning) 1017 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) 1019 #define JSON_HEDLEY_HAS_WARNING(warning) (0) 1022 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING) 1023 #undef JSON_HEDLEY_GNUC_HAS_WARNING 1025 #if defined(__has_warning) 1026 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) 1028 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 1031 #if defined(JSON_HEDLEY_GCC_HAS_WARNING) 1032 #undef JSON_HEDLEY_GCC_HAS_WARNING 1034 #if defined(__has_warning) 1035 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) 1037 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 1041 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ 1042 defined(__clang__) || \ 1043 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ 1044 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1045 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ 1046 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ 1047 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1048 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1049 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ 1050 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ 1051 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ 1052 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ 1053 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1054 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1055 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ 1056 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ 1057 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ 1058 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) 1059 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) 1060 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 1061 #define JSON_HEDLEY_PRAGMA(value) __pragma(value) 1063 #define JSON_HEDLEY_PRAGMA(value) 1066 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) 1067 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH 1069 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP) 1070 #undef JSON_HEDLEY_DIAGNOSTIC_POP 1072 #if defined(__clang__) 1073 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 1074 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 1075 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1076 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") 1077 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") 1078 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) 1079 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 1080 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 1082 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ 1083 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1084 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) 1085 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) 1086 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) 1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") 1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") 1090 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1091 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1092 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ 1093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ 1094 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1095 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) 1096 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") 1097 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") 1098 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) 1099 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") 1100 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") 1102 #define JSON_HEDLEY_DIAGNOSTIC_PUSH 1103 #define JSON_HEDLEY_DIAGNOSTIC_POP 1108 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) 1109 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ 1111 #if defined(__cplusplus) 1112 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") 1113 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") 1114 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") 1115 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 1116 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1117 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 1118 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ 1119 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ 1121 JSON_HEDLEY_DIAGNOSTIC_POP 1123 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 1124 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1125 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 1126 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ 1128 JSON_HEDLEY_DIAGNOSTIC_POP 1131 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 1132 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1133 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 1135 JSON_HEDLEY_DIAGNOSTIC_POP 1139 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) 1140 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x 1143 #if defined(JSON_HEDLEY_CONST_CAST) 1144 #undef JSON_HEDLEY_CONST_CAST 1146 #if defined(__cplusplus) 1147 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr)) 1149 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ 1150 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ 1151 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1152 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ 1153 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1154 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ 1156 JSON_HEDLEY_DIAGNOSTIC_POP \ 1159 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) 1162 #if defined(JSON_HEDLEY_REINTERPRET_CAST) 1163 #undef JSON_HEDLEY_REINTERPRET_CAST 1165 #if defined(__cplusplus) 1166 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr)) 1168 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) 1171 #if defined(JSON_HEDLEY_STATIC_CAST) 1172 #undef JSON_HEDLEY_STATIC_CAST 1174 #if defined(__cplusplus) 1175 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr)) 1177 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) 1180 #if defined(JSON_HEDLEY_CPP_CAST) 1181 #undef JSON_HEDLEY_CPP_CAST 1183 #if defined(__cplusplus) 1184 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") 1185 # define JSON_HEDLEY_CPP_CAST(T, expr) \ 1186 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1187 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ 1189 JSON_HEDLEY_DIAGNOSTIC_POP 1190 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) 1191 # define JSON_HEDLEY_CPP_CAST(T, expr) \ 1192 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1193 _Pragma("diag_suppress=Pe137") \ 1194 JSON_HEDLEY_DIAGNOSTIC_POP 1196 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) 1199 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr) 1202 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) 1203 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 1205 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") 1206 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") 1207 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1208 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") 1209 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) 1211 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) 1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") 1213 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") 1215 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) 1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 1217 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) 1219 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") 1222 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1223 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1224 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1225 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1226 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1227 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1228 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1229 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1230 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1231 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1232 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) 1233 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") 1234 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) 1235 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") 1236 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) 1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") 1238 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1239 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") 1240 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) 1241 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") 1243 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 1246 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) 1247 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 1249 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") 1251 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") 1253 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) 1255 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1256 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") 1257 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) 1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") 1259 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 1260 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) 1262 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ 1263 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ 1264 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1265 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) 1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") 1267 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) 1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") 1269 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") 1271 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") 1274 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 1277 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) 1278 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 1280 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") 1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") 1282 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) 1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 1284 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) 1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") 1286 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1287 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) 1288 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) 1289 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) 1290 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) 1291 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") 1292 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1293 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") 1294 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) 1295 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") 1297 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ 1298 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ 1299 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) 1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") 1301 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") 1303 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") 1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 1309 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) 1310 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 1312 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") 1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") 1314 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") 1316 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) 1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") 1319 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 1322 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) 1323 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 1325 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function") 1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") 1327 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) 1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") 1329 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) 1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) 1331 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1332 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") 1334 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 1337 #if defined(JSON_HEDLEY_DEPRECATED) 1338 #undef JSON_HEDLEY_DEPRECATED 1340 #if defined(JSON_HEDLEY_DEPRECATED_FOR) 1341 #undef JSON_HEDLEY_DEPRECATED_FOR 1344 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1345 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1346 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) 1347 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) 1349 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ 1350 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ 1351 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1352 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ 1353 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ 1354 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1355 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ 1356 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ 1357 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ 1358 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1359 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ 1360 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1361 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) 1362 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) 1363 #elif defined(__cplusplus) && (__cplusplus >= 201402L) 1364 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) 1365 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) 1367 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ 1368 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1369 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1370 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1371 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1372 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1373 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1374 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1375 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1376 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1377 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1378 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1379 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1380 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1381 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1382 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1383 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) 1384 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) 1386 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1387 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ 1388 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1389 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) 1390 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) 1391 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1392 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") 1393 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") 1395 #define JSON_HEDLEY_DEPRECATED(since) 1396 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) 1399 #if defined(JSON_HEDLEY_UNAVAILABLE) 1400 #undef JSON_HEDLEY_UNAVAILABLE 1403 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ 1404 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ 1405 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1406 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1407 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) 1409 #define JSON_HEDLEY_UNAVAILABLE(available_since) 1412 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) 1413 #undef JSON_HEDLEY_WARN_UNUSED_RESULT 1415 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) 1416 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG 1419 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ 1420 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 1421 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1422 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1423 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1424 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1425 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1426 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1427 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1428 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1429 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1430 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1431 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1432 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1433 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ 1434 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1435 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1436 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 1437 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) 1438 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) 1439 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1440 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) 1441 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) 1442 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1443 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1444 #elif defined(_Check_return_) 1445 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ 1446 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ 1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT 1449 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) 1452 #if defined(JSON_HEDLEY_SENTINEL) 1453 #undef JSON_HEDLEY_SENTINEL 1456 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ 1457 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1458 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1459 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ 1460 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1461 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) 1463 #define JSON_HEDLEY_SENTINEL(position) 1466 #if defined(JSON_HEDLEY_NO_RETURN) 1467 #undef JSON_HEDLEY_NO_RETURN 1469 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1470 #define JSON_HEDLEY_NO_RETURN __noreturn 1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1473 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1474 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) 1475 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 1476 #define JSON_HEDLEY_NO_RETURN _Noreturn 1477 #elif defined(__cplusplus) && (__cplusplus >= 201103L) 1478 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) 1480 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ 1481 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ 1482 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1483 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1484 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1485 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1486 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1487 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1488 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1489 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1490 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1491 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1492 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1493 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1494 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1495 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1496 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1497 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) 1498 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1499 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") 1501 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1502 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1503 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) 1504 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) 1505 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") 1506 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) 1507 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) 1508 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) 1509 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) 1511 #define JSON_HEDLEY_NO_RETURN 1514 #if defined(JSON_HEDLEY_NO_ESCAPE) 1515 #undef JSON_HEDLEY_NO_ESCAPE 1517 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) 1518 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) 1520 #define JSON_HEDLEY_NO_ESCAPE 1523 #if defined(JSON_HEDLEY_UNREACHABLE) 1524 #undef JSON_HEDLEY_UNREACHABLE 1526 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN) 1527 #undef JSON_HEDLEY_UNREACHABLE_RETURN 1529 #if defined(JSON_HEDLEY_ASSUME) 1530 #undef JSON_HEDLEY_ASSUME 1533 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1534 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1535 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1536 #define JSON_HEDLEY_ASSUME(expr) __assume(expr) 1537 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) 1538 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) 1540 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1541 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) 1542 #if defined(__cplusplus) 1543 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) 1545 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) 1549 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ 1550 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ 1551 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ 1552 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1553 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ 1554 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ 1555 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1556 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() 1557 #elif defined(JSON_HEDLEY_ASSUME) 1558 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) 1560 #if !defined(JSON_HEDLEY_ASSUME) 1561 #if defined(JSON_HEDLEY_UNREACHABLE) 1562 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) 1564 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) 1567 #if defined(JSON_HEDLEY_UNREACHABLE) 1569 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1570 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) 1571 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) 1573 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() 1576 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) 1578 #if !defined(JSON_HEDLEY_UNREACHABLE) 1579 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) 1583 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic") 1584 #pragma clang diagnostic ignored "-Wpedantic" 1586 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) 1587 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" 1589 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) 1590 #if defined(__clang__) 1591 #pragma clang diagnostic ignored "-Wvariadic-macros" 1592 #elif defined(JSON_HEDLEY_GCC_VERSION) 1593 #pragma GCC diagnostic ignored "-Wvariadic-macros" 1596 #if defined(JSON_HEDLEY_NON_NULL) 1597 #undef JSON_HEDLEY_NON_NULL 1600 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ 1601 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1602 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1603 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) 1604 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) 1606 #define JSON_HEDLEY_NON_NULL(...) 1610 #if defined(JSON_HEDLEY_PRINTF_FORMAT) 1611 #undef JSON_HEDLEY_PRINTF_FORMAT 1613 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) 1614 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) 1615 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) 1616 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) 1618 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ 1619 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1621 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ 1622 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1623 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1624 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1625 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1626 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1627 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1628 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1629 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1630 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1631 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1632 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1633 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1634 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1635 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) 1636 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) 1637 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) 1639 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) 1642 #if defined(JSON_HEDLEY_CONSTEXPR) 1643 #undef JSON_HEDLEY_CONSTEXPR 1645 #if defined(__cplusplus) 1646 #if __cplusplus >= 201103L 1647 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) 1650 #if !defined(JSON_HEDLEY_CONSTEXPR) 1651 #define JSON_HEDLEY_CONSTEXPR 1654 #if defined(JSON_HEDLEY_PREDICT) 1655 #undef JSON_HEDLEY_PREDICT 1657 #if defined(JSON_HEDLEY_LIKELY) 1658 #undef JSON_HEDLEY_LIKELY 1660 #if defined(JSON_HEDLEY_UNLIKELY) 1661 #undef JSON_HEDLEY_UNLIKELY 1663 #if defined(JSON_HEDLEY_UNPREDICTABLE) 1664 #undef JSON_HEDLEY_UNPREDICTABLE 1666 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) 1667 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) 1670 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ 1671 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ 1672 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1673 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) 1674 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) 1675 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) 1676 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) 1677 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) 1679 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ 1680 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ 1681 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1682 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ 1683 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1684 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1685 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1686 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ 1687 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ 1688 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ 1689 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1690 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1691 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1692 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ 1693 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 1694 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1695 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \ 1696 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) 1697 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ 1699 double hedley_probability_ = (probability); \ 1700 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ 1702 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ 1704 double hedley_probability_ = (probability); \ 1705 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ 1707 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) 1708 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) 1710 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) 1711 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) 1712 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) 1713 # define JSON_HEDLEY_LIKELY(expr) (!!(expr)) 1714 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) 1716 #if !defined(JSON_HEDLEY_UNPREDICTABLE) 1717 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) 1720 #if defined(JSON_HEDLEY_MALLOC) 1721 #undef JSON_HEDLEY_MALLOC 1724 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ 1725 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1726 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1727 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1728 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1729 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ 1730 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1731 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1732 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1733 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1734 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1735 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1736 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1737 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1738 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1739 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1740 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1741 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1742 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) 1743 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1744 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") 1746 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1747 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1748 #define JSON_HEDLEY_MALLOC __declspec(restrict) 1750 #define JSON_HEDLEY_MALLOC 1753 #if defined(JSON_HEDLEY_PURE) 1754 #undef JSON_HEDLEY_PURE 1757 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ 1758 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ 1759 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1760 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1761 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1762 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1763 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1764 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1765 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1766 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1767 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1768 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1769 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1770 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1771 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1772 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1773 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1774 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1775 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1776 # define JSON_HEDLEY_PURE __attribute__((__pure__)) 1777 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1778 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") 1779 #elif defined(__cplusplus) && \ 1781 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ 1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ 1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ 1785 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") 1787 # define JSON_HEDLEY_PURE 1790 #if defined(JSON_HEDLEY_CONST) 1791 #undef JSON_HEDLEY_CONST 1794 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ 1795 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ 1796 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1797 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1798 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1799 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1800 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1801 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1802 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1803 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1804 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1805 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1806 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1807 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1808 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1809 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1810 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1811 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1812 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1813 #define JSON_HEDLEY_CONST __attribute__((__const__)) 1815 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1816 #define JSON_HEDLEY_CONST _Pragma("no_side_effect") 1818 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE 1821 #if defined(JSON_HEDLEY_RESTRICT) 1822 #undef JSON_HEDLEY_RESTRICT 1824 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) 1825 #define JSON_HEDLEY_RESTRICT restrict 1827 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1828 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1829 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1830 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1831 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1832 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1833 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1834 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1835 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ 1836 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ 1837 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1838 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ 1839 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ 1840 defined(__clang__) || \ 1841 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1842 #define JSON_HEDLEY_RESTRICT __restrict 1843 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) 1844 #define JSON_HEDLEY_RESTRICT _Restrict 1846 #define JSON_HEDLEY_RESTRICT 1849 #if defined(JSON_HEDLEY_INLINE) 1850 #undef JSON_HEDLEY_INLINE 1853 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ 1854 (defined(__cplusplus) && (__cplusplus >= 199711L)) 1855 #define JSON_HEDLEY_INLINE inline 1857 defined(JSON_HEDLEY_GCC_VERSION) || \ 1858 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) 1859 #define JSON_HEDLEY_INLINE __inline__ 1861 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ 1862 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1863 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1864 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ 1865 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ 1866 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1867 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ 1868 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1869 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1870 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1871 #define JSON_HEDLEY_INLINE __inline 1873 #define JSON_HEDLEY_INLINE 1876 #if defined(JSON_HEDLEY_ALWAYS_INLINE) 1877 #undef JSON_HEDLEY_ALWAYS_INLINE 1880 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ 1881 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1882 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1883 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1884 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1885 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1886 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1887 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1888 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1889 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1890 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1891 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1892 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1893 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1894 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1895 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1896 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1897 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1898 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1899 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE 1901 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ 1902 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1903 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline 1904 #elif defined(__cplusplus) && \ 1906 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1907 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1908 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1909 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1910 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1911 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ 1913 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") 1914 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1915 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") 1917 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE 1920 #if defined(JSON_HEDLEY_NEVER_INLINE) 1921 #undef JSON_HEDLEY_NEVER_INLINE 1924 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ 1925 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1926 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1927 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1928 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1929 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1930 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1931 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1932 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1933 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1934 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1935 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1936 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1937 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1938 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1939 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1940 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1941 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1942 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1943 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) 1945 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1946 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1947 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) 1948 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) 1949 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") 1950 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) 1951 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") 1952 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1953 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") 1954 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) 1955 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) 1956 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) 1957 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) 1959 #define JSON_HEDLEY_NEVER_INLINE 1962 #if defined(JSON_HEDLEY_PRIVATE) 1963 #undef JSON_HEDLEY_PRIVATE 1965 #if defined(JSON_HEDLEY_PUBLIC) 1966 #undef JSON_HEDLEY_PUBLIC 1968 #if defined(JSON_HEDLEY_IMPORT) 1969 #undef JSON_HEDLEY_IMPORT 1971 #if defined(_WIN32) || defined(__CYGWIN__) 1972 # define JSON_HEDLEY_PRIVATE 1973 # define JSON_HEDLEY_PUBLIC __declspec(dllexport) 1974 # define JSON_HEDLEY_IMPORT __declspec(dllimport) 1977 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ 1978 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1979 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1980 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1981 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1982 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 1984 defined(__TI_EABI__) && \ 1986 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1987 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ 1990 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1991 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) 1992 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) 1994 # define JSON_HEDLEY_PRIVATE 1995 # define JSON_HEDLEY_PUBLIC 1997 # define JSON_HEDLEY_IMPORT extern 2000 #if defined(JSON_HEDLEY_NO_THROW) 2001 #undef JSON_HEDLEY_NO_THROW 2004 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ 2005 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 2006 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 2007 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 2008 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) 2010 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ 2011 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 2012 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) 2013 #define JSON_HEDLEY_NO_THROW __declspec(nothrow) 2015 #define JSON_HEDLEY_NO_THROW 2018 #if defined(JSON_HEDLEY_FALL_THROUGH) 2019 #undef JSON_HEDLEY_FALL_THROUGH 2022 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ 2023 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ 2024 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 2025 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) 2026 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) 2027 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) 2028 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) 2029 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) 2030 #elif defined(__fallthrough) 2031 #define JSON_HEDLEY_FALL_THROUGH __fallthrough 2033 #define JSON_HEDLEY_FALL_THROUGH 2036 #if defined(JSON_HEDLEY_RETURNS_NON_NULL) 2037 #undef JSON_HEDLEY_RETURNS_NON_NULL 2040 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ 2041 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ 2042 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 2043 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) 2044 #elif defined(_Ret_notnull_) 2045 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ 2047 #define JSON_HEDLEY_RETURNS_NON_NULL 2050 #if defined(JSON_HEDLEY_ARRAY_PARAM) 2051 #undef JSON_HEDLEY_ARRAY_PARAM 2054 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ 2055 !defined(__STDC_NO_VLA__) && \ 2056 !defined(__cplusplus) && \ 2057 !defined(JSON_HEDLEY_PGI_VERSION) && \ 2058 !defined(JSON_HEDLEY_TINYC_VERSION) 2059 #define JSON_HEDLEY_ARRAY_PARAM(name) (name) 2061 #define JSON_HEDLEY_ARRAY_PARAM(name) 2064 #if defined(JSON_HEDLEY_IS_CONSTANT) 2065 #undef JSON_HEDLEY_IS_CONSTANT 2067 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) 2068 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR 2072 #if defined(JSON_HEDLEY_IS_CONSTEXPR_) 2073 #undef JSON_HEDLEY_IS_CONSTEXPR_ 2076 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ 2077 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 2078 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 2079 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ 2080 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 2081 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 2082 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 2083 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ 2084 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 2085 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 2086 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) 2088 #if !defined(__cplusplus) 2090 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ 2091 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 2092 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 2093 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 2094 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 2095 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ 2096 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) 2097 #if defined(__INTPTR_TYPE__) 2098 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) 2101 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) 2105 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ 2106 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ 2107 !defined(JSON_HEDLEY_PGI_VERSION) && \ 2108 !defined(JSON_HEDLEY_IAR_VERSION)) || \ 2109 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ 2110 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ 2111 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ 2112 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ 2113 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) 2114 #if defined(__INTPTR_TYPE__) 2115 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) 2118 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) 2121 defined(JSON_HEDLEY_GCC_VERSION) || \ 2122 defined(JSON_HEDLEY_INTEL_VERSION) || \ 2123 defined(JSON_HEDLEY_TINYC_VERSION) || \ 2124 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ 2125 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ 2126 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ 2127 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ 2128 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ 2129 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ 2131 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ 2135 ((void*) ((expr) * 0L) ) : \ 2136 ((struct { char v[sizeof(void) * 2]; } *) 1) \ 2142 #if defined(JSON_HEDLEY_IS_CONSTEXPR_) 2143 #if !defined(JSON_HEDLEY_IS_CONSTANT) 2144 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) 2146 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) 2148 #if !defined(JSON_HEDLEY_IS_CONSTANT) 2149 #define JSON_HEDLEY_IS_CONSTANT(expr) (0) 2151 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) 2154 #if defined(JSON_HEDLEY_BEGIN_C_DECLS) 2155 #undef JSON_HEDLEY_BEGIN_C_DECLS 2157 #if defined(JSON_HEDLEY_END_C_DECLS) 2158 #undef JSON_HEDLEY_END_C_DECLS 2160 #if defined(JSON_HEDLEY_C_DECL) 2161 #undef JSON_HEDLEY_C_DECL 2163 #if defined(__cplusplus) 2164 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { 2165 #define JSON_HEDLEY_END_C_DECLS } 2166 #define JSON_HEDLEY_C_DECL extern "C" 2168 #define JSON_HEDLEY_BEGIN_C_DECLS 2169 #define JSON_HEDLEY_END_C_DECLS 2170 #define JSON_HEDLEY_C_DECL 2173 #if defined(JSON_HEDLEY_STATIC_ASSERT) 2174 #undef JSON_HEDLEY_STATIC_ASSERT 2177 !defined(__cplusplus) && ( \ 2178 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ 2179 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ 2180 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ 2181 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 2182 defined(_Static_assert) \ 2184 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) 2186 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ 2187 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ 2188 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2189 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) 2191 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) 2194 #if defined(JSON_HEDLEY_NULL) 2195 #undef JSON_HEDLEY_NULL 2197 #if defined(__cplusplus) 2198 #if __cplusplus >= 201103L 2199 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) 2201 #define JSON_HEDLEY_NULL NULL 2203 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) 2206 #define JSON_HEDLEY_NULL NULL 2208 #define JSON_HEDLEY_NULL ((void*) 0) 2211 #if defined(JSON_HEDLEY_MESSAGE) 2212 #undef JSON_HEDLEY_MESSAGE 2214 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 2215 # define JSON_HEDLEY_MESSAGE(msg) \ 2216 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2217 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ 2218 JSON_HEDLEY_PRAGMA(message msg) \ 2219 JSON_HEDLEY_DIAGNOSTIC_POP 2221 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ 2222 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 2223 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) 2224 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) 2225 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) 2226 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 2227 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2228 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) 2229 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2231 # define JSON_HEDLEY_MESSAGE(msg) 2234 #if defined(JSON_HEDLEY_WARNING) 2235 #undef JSON_HEDLEY_WARNING 2237 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 2238 # define JSON_HEDLEY_WARNING(msg) \ 2239 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2240 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ 2241 JSON_HEDLEY_PRAGMA(clang warning msg) \ 2242 JSON_HEDLEY_DIAGNOSTIC_POP 2244 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ 2245 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ 2246 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 2247 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) 2249 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ 2250 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2251 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2253 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) 2256 #if defined(JSON_HEDLEY_REQUIRE) 2257 #undef JSON_HEDLEY_REQUIRE 2259 #if defined(JSON_HEDLEY_REQUIRE_MSG) 2260 #undef JSON_HEDLEY_REQUIRE_MSG 2262 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) 2263 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") 2264 # define JSON_HEDLEY_REQUIRE(expr) \ 2265 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2266 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ 2267 __attribute__((diagnose_if(!(expr), #expr, "error"))) \ 2268 JSON_HEDLEY_DIAGNOSTIC_POP 2269 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ 2270 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2271 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ 2272 __attribute__((diagnose_if(!(expr), msg, "error"))) \ 2273 JSON_HEDLEY_DIAGNOSTIC_POP 2275 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) 2276 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) 2279 # define JSON_HEDLEY_REQUIRE(expr) 2280 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) 2283 #if defined(JSON_HEDLEY_FLAGS) 2284 #undef JSON_HEDLEY_FLAGS 2286 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) 2287 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) 2289 #define JSON_HEDLEY_FLAGS 2292 #if defined(JSON_HEDLEY_FLAGS_CAST) 2293 #undef JSON_HEDLEY_FLAGS_CAST 2295 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) 2296 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ 2297 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2298 _Pragma("warning(disable:188)") \ 2300 JSON_HEDLEY_DIAGNOSTIC_POP \ 2303 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) 2306 #if defined(JSON_HEDLEY_EMPTY_BASES) 2307 #undef JSON_HEDLEY_EMPTY_BASES 2310 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ 2311 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2312 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) 2314 #define JSON_HEDLEY_EMPTY_BASES 2319 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) 2320 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK 2322 #if defined(__clang__) 2323 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) 2325 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 2328 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) 2329 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE 2331 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 2333 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) 2334 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE 2336 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) 2338 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) 2339 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN 2341 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) 2343 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) 2344 #undef JSON_HEDLEY_CLANG_HAS_FEATURE 2346 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) 2348 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) 2349 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION 2351 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) 2353 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) 2354 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE 2356 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) 2358 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING) 2359 #undef JSON_HEDLEY_CLANG_HAS_WARNING 2361 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) 2373 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) 2374 #if defined(__clang__) 2375 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 2376 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" 2378 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) 2379 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 2380 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" 2387 #if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) 2388 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) 2389 #define JSON_HAS_CPP_20 2390 #define JSON_HAS_CPP_17 2391 #define JSON_HAS_CPP_14 2392 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 2393 #define JSON_HAS_CPP_17 2394 #define JSON_HAS_CPP_14 2395 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) 2396 #define JSON_HAS_CPP_14 2399 #define JSON_HAS_CPP_11 2402 #ifdef __has_include 2403 #if __has_include(<version>) 2408 #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) 2409 #ifdef JSON_HAS_CPP_17 2410 #if defined(__cpp_lib_filesystem) 2411 #define JSON_HAS_FILESYSTEM 1 2412 #elif defined(__cpp_lib_experimental_filesystem) 2413 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 2414 #elif !defined(__has_include) 2415 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 2416 #elif __has_include(<filesystem>) 2417 #define JSON_HAS_FILESYSTEM 1 2418 #elif __has_include(<experimental/filesystem>) 2419 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 2423 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 2424 #undef JSON_HAS_FILESYSTEM 2425 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2429 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 2430 #undef JSON_HAS_FILESYSTEM 2431 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2435 #if defined(__clang_major__) && __clang_major__ < 7 2436 #undef JSON_HAS_FILESYSTEM 2437 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2441 #if defined(_MSC_VER) && _MSC_VER < 1914 2442 #undef JSON_HAS_FILESYSTEM 2443 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2447 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 2448 #undef JSON_HAS_FILESYSTEM 2449 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2453 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 2454 #undef JSON_HAS_FILESYSTEM 2455 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2460 #ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2461 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 2464 #ifndef JSON_HAS_FILESYSTEM 2465 #define JSON_HAS_FILESYSTEM 0 2468 #ifndef JSON_HAS_THREE_WAY_COMPARISON 2469 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ 2470 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L 2471 #define JSON_HAS_THREE_WAY_COMPARISON 1 2473 #define JSON_HAS_THREE_WAY_COMPARISON 0 2477 #ifndef JSON_HAS_RANGES 2479 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 2480 #define JSON_HAS_RANGES 0 2481 #elif defined(__cpp_lib_ranges) 2482 #define JSON_HAS_RANGES 1 2484 #define JSON_HAS_RANGES 0 2488 #ifdef JSON_HAS_CPP_17 2489 #define JSON_INLINE_VARIABLE inline 2491 #define JSON_INLINE_VARIABLE 2494 #if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) 2495 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] 2497 #define JSON_NO_UNIQUE_ADDRESS 2501 #if defined(__clang__) 2502 #pragma clang diagnostic push 2503 #pragma clang diagnostic ignored "-Wdocumentation" 2504 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" 2508 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) 2509 #define JSON_THROW(exception) throw exception 2510 #define JSON_TRY try 2511 #define JSON_CATCH(exception) catch(exception) 2512 #define JSON_INTERNAL_CATCH(exception) catch(exception) 2515 #define JSON_THROW(exception) std::abort() 2516 #define JSON_TRY if(true) 2517 #define JSON_CATCH(exception) if(false) 2518 #define JSON_INTERNAL_CATCH(exception) if(false) 2522 #if defined(JSON_THROW_USER) 2524 #define JSON_THROW JSON_THROW_USER 2526 #if defined(JSON_TRY_USER) 2528 #define JSON_TRY JSON_TRY_USER 2530 #if defined(JSON_CATCH_USER) 2532 #define JSON_CATCH JSON_CATCH_USER 2533 #undef JSON_INTERNAL_CATCH 2534 #define JSON_INTERNAL_CATCH JSON_CATCH_USER 2536 #if defined(JSON_INTERNAL_CATCH_USER) 2537 #undef JSON_INTERNAL_CATCH 2538 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER 2542 #if !defined(JSON_ASSERT) 2544 #define JSON_ASSERT(x) assert(x) 2548 #if defined(JSON_TESTS_PRIVATE) 2549 #define JSON_PRIVATE_UNLESS_TESTED public 2551 #define JSON_PRIVATE_UNLESS_TESTED private 2559 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ 2560 template<typename BasicJsonType> \ 2561 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ 2563 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ 2564 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ 2565 auto it = std::find_if(std::begin(m), std::end(m), \ 2566 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ 2568 return ej_pair.first == e; \ 2570 j = ((it != std::end(m)) ? it : std::begin(m))->second; \ 2572 template<typename BasicJsonType> \ 2573 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ 2575 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ 2576 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ 2577 auto it = std::find_if(std::begin(m), std::end(m), \ 2578 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ 2580 return ej_pair.second == j; \ 2582 e = ((it != std::end(m)) ? it : std::begin(m))->first; \ 2588 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ 2589 template<template<typename, typename, typename...> class ObjectType, \ 2590 template<typename, typename...> class ArrayType, \ 2591 class StringType, class BooleanType, class NumberIntegerType, \ 2592 class NumberUnsignedType, class NumberFloatType, \ 2593 template<typename> class AllocatorType, \ 2594 template<typename, typename = void> class JSONSerializer, \ 2596 class CustomBaseClass> 2598 #define NLOHMANN_BASIC_JSON_TPL \ 2599 basic_json<ObjectType, ArrayType, StringType, BooleanType, \ 2600 NumberIntegerType, NumberUnsignedType, NumberFloatType, \ 2601 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass> 2605 #define NLOHMANN_JSON_EXPAND( x ) x 2606 #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 2607 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ 2608 NLOHMANN_JSON_PASTE64, \ 2609 NLOHMANN_JSON_PASTE63, \ 2610 NLOHMANN_JSON_PASTE62, \ 2611 NLOHMANN_JSON_PASTE61, \ 2612 NLOHMANN_JSON_PASTE60, \ 2613 NLOHMANN_JSON_PASTE59, \ 2614 NLOHMANN_JSON_PASTE58, \ 2615 NLOHMANN_JSON_PASTE57, \ 2616 NLOHMANN_JSON_PASTE56, \ 2617 NLOHMANN_JSON_PASTE55, \ 2618 NLOHMANN_JSON_PASTE54, \ 2619 NLOHMANN_JSON_PASTE53, \ 2620 NLOHMANN_JSON_PASTE52, \ 2621 NLOHMANN_JSON_PASTE51, \ 2622 NLOHMANN_JSON_PASTE50, \ 2623 NLOHMANN_JSON_PASTE49, \ 2624 NLOHMANN_JSON_PASTE48, \ 2625 NLOHMANN_JSON_PASTE47, \ 2626 NLOHMANN_JSON_PASTE46, \ 2627 NLOHMANN_JSON_PASTE45, \ 2628 NLOHMANN_JSON_PASTE44, \ 2629 NLOHMANN_JSON_PASTE43, \ 2630 NLOHMANN_JSON_PASTE42, \ 2631 NLOHMANN_JSON_PASTE41, \ 2632 NLOHMANN_JSON_PASTE40, \ 2633 NLOHMANN_JSON_PASTE39, \ 2634 NLOHMANN_JSON_PASTE38, \ 2635 NLOHMANN_JSON_PASTE37, \ 2636 NLOHMANN_JSON_PASTE36, \ 2637 NLOHMANN_JSON_PASTE35, \ 2638 NLOHMANN_JSON_PASTE34, \ 2639 NLOHMANN_JSON_PASTE33, \ 2640 NLOHMANN_JSON_PASTE32, \ 2641 NLOHMANN_JSON_PASTE31, \ 2642 NLOHMANN_JSON_PASTE30, \ 2643 NLOHMANN_JSON_PASTE29, \ 2644 NLOHMANN_JSON_PASTE28, \ 2645 NLOHMANN_JSON_PASTE27, \ 2646 NLOHMANN_JSON_PASTE26, \ 2647 NLOHMANN_JSON_PASTE25, \ 2648 NLOHMANN_JSON_PASTE24, \ 2649 NLOHMANN_JSON_PASTE23, \ 2650 NLOHMANN_JSON_PASTE22, \ 2651 NLOHMANN_JSON_PASTE21, \ 2652 NLOHMANN_JSON_PASTE20, \ 2653 NLOHMANN_JSON_PASTE19, \ 2654 NLOHMANN_JSON_PASTE18, \ 2655 NLOHMANN_JSON_PASTE17, \ 2656 NLOHMANN_JSON_PASTE16, \ 2657 NLOHMANN_JSON_PASTE15, \ 2658 NLOHMANN_JSON_PASTE14, \ 2659 NLOHMANN_JSON_PASTE13, \ 2660 NLOHMANN_JSON_PASTE12, \ 2661 NLOHMANN_JSON_PASTE11, \ 2662 NLOHMANN_JSON_PASTE10, \ 2663 NLOHMANN_JSON_PASTE9, \ 2664 NLOHMANN_JSON_PASTE8, \ 2665 NLOHMANN_JSON_PASTE7, \ 2666 NLOHMANN_JSON_PASTE6, \ 2667 NLOHMANN_JSON_PASTE5, \ 2668 NLOHMANN_JSON_PASTE4, \ 2669 NLOHMANN_JSON_PASTE3, \ 2670 NLOHMANN_JSON_PASTE2, \ 2671 NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) 2672 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1) 2673 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) 2674 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) 2675 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) 2676 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) 2677 #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) 2678 #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) 2679 #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) 2680 #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) 2681 #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) 2682 #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) 2683 #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) 2684 #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) 2685 #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) 2686 #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) 2687 #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) 2688 #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) 2689 #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) 2690 #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) 2691 #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) 2692 #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) 2693 #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) 2694 #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) 2695 #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) 2696 #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) 2697 #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) 2698 #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) 2699 #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) 2700 #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) 2701 #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) 2702 #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) 2703 #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) 2704 #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) 2705 #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) 2706 #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) 2707 #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) 2708 #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) 2709 #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) 2710 #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) 2711 #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) 2712 #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) 2713 #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) 2714 #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) 2715 #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) 2716 #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) 2717 #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) 2718 #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) 2719 #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) 2720 #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) 2721 #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) 2722 #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) 2723 #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) 2724 #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) 2725 #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) 2726 #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) 2727 #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) 2728 #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) 2729 #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) 2730 #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) 2731 #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) 2732 #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) 2733 #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) 2734 #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) 2736 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; 2737 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); 2738 #define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); 2745 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ 2746 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ 2747 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } 2749 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ 2750 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ 2751 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } 2758 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ 2759 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ 2760 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } 2762 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ 2763 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ 2764 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } 2773 #define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ 2774 namespace detail { \ 2775 using std::std_name; \ 2777 template<typename... T> \ 2778 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ 2781 namespace detail2 { \ 2782 struct std_name##_tag \ 2786 template<typename... T> \ 2787 std_name##_tag std_name(T&&...); \ 2789 template<typename... T> \ 2790 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ 2792 template<typename... T> \ 2793 struct would_call_std_##std_name \ 2795 static constexpr auto const value = ::nlohmann::detail:: \ 2796 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \ 2800 template<typename... T> \ 2801 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \ 2805 #ifndef JSON_USE_IMPLICIT_CONVERSIONS 2806 #define JSON_USE_IMPLICIT_CONVERSIONS 1 2809 #if JSON_USE_IMPLICIT_CONVERSIONS 2810 #define JSON_EXPLICIT 2812 #define JSON_EXPLICIT explicit 2815 #ifndef JSON_DISABLE_ENUM_SERIALIZATION 2816 #define JSON_DISABLE_ENUM_SERIALIZATION 0 2819 #ifndef JSON_USE_GLOBAL_UDLS 2820 #define JSON_USE_GLOBAL_UDLS 1 2823 #if JSON_HAS_THREE_WAY_COMPARISON 2886 #if JSON_HAS_THREE_WAY_COMPARISON 2887 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs) noexcept
2892 static constexpr std::array<std::uint8_t, 9> order = {{
2899 const auto l_index =
static_cast<std::size_t
>(lhs);
2900 const auto r_index =
static_cast<std::size_t
>(rhs);
2901 #if JSON_HAS_THREE_WAY_COMPARISON 2902 if (l_index < order.size() && r_index < order.size())
2904 return order[l_index] <=> order[r_index];
2906 return std::partial_ordering::unordered;
2908 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2916 #if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) 2919 return std::is_lt(lhs <=> rhs);
2957 template<
typename StringType>
2959 const StringType& t)
2962 for (
auto pos = s.find(f);
2963 pos != StringType::npos;
2964 s.replace(pos, f.size(), t),
2965 pos = s.find(f, pos + t.size()))
2976 template<
typename StringType>
2991 template<
typename StringType>
3032 constexpr
operator size_t()
const 3057 #include <type_traits> 3067 template<
typename T>
3070 #ifdef JSON_HAS_CPP_14 3081 template<
bool B,
typename T =
void>
3108 template <
typename T, T... Ints>
3112 static constexpr std::size_t
size() noexcept
3114 return sizeof...(Ints);
3123 template <
size_t... Ints>
3126 namespace utility_internal
3129 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3133 template <
typename T, T... Ints,
size_t SeqSize>
3139 template <
typename T, T... Ints,
size_t SeqSize>
3147 template <
typename T,
size_t N>
3154 template <
typename T>
3169 template <
typename T, T N>
3185 template <
typename... Ts>
3197 template<
typename T>
3203 #ifndef JSON_HAS_CPP_17 3204 template<
typename T>
3208 template<
typename T,
typename... Args>
3211 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(
args))...}};
3229 #include <type_traits> 3257 template<
typename It,
typename =
void>
3260 template<
typename It>
3264 typename It::reference, typename It::iterator_category >>
3275 template<
typename T,
typename =
void>
3280 template<
typename T>
3286 template<
typename T>
3354 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3355 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3380 template<
typename T =
void,
typename SFINAE =
void>
3385 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3387 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3388 class StringType = std::string,
class BooleanType = bool,
3389 class NumberIntegerType = std::int64_t,
3390 class NumberUnsignedType = std::uint64_t,
3391 class NumberFloatType = double,
3392 template<
typename U>
class AllocatorType = std::allocator,
3393 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3395 class BinaryType = std::vector<std::uint8_t>,
3396 class CustomBaseClass =
void>
3401 template<
typename RefStringType>
3412 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3421 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3457 template<
typename BasicJsonContext>
3459 std::integral_constant < bool,
3460 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3461 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3474 template<
typename T>
3481 template<
typename T>
3484 template<
typename T>
3487 template<
typename T>
3490 template<
typename T>
3493 template<
typename T>
3496 template<
typename T>
3499 template<
typename T>
3502 template<
typename T,
typename... Args>
3505 template<
typename T,
typename... Args>
3508 template<
typename T,
typename U>
3512 template<
typename BasicJsonType,
typename T,
typename =
void>
3519 template <
typename BasicJsonType,
typename T>
3525 template<
typename BasicJsonType,
typename T>
3528 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3532 const BasicJsonType&, T&>
::value;
3537 template<
typename BasicJsonType,
typename T,
typename =
void>
3540 template<
typename BasicJsonType,
typename T>
3543 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3552 template<
typename BasicJsonType,
typename T,
typename =
void>
3555 template<
typename BasicJsonType,
typename T>
3558 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3565 template<
typename T>
3568 template<
typename T>
3569 struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3572 template<
typename BasicJsonType>
3577 using type =
typename std::conditional < has_key_compare<object_t>::value,
3581 template<
typename BasicJsonType>
3591 template<
class B,
class... Bn>
3593 : std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>
::type {};
3596 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3601 template <
typename T>
3604 template <
typename T1,
typename T2>
3606 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3608 template <
typename T1,
typename T2>
3610 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3612 template <
typename... Ts>
3614 :
conjunction<is_default_constructible<Ts>...> {};
3616 template <
typename... Ts>
3618 :
conjunction<is_default_constructible<Ts>...> {};
3621 template <
typename T,
typename... Args>
3624 template <
typename T1,
typename T2>
3627 template <
typename T1,
typename T2>
3630 template <
typename... Ts>
3633 template <
typename... Ts>
3637 template<
typename T,
typename =
void>
3640 template<
typename T>
3655 template<
typename T>
3671 static constexpr
bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3674 template<
typename R>
3677 template<
typename T>
3684 template<
typename T,
typename =
void>
3687 template<
typename T>
3690 template<
typename BasicJsonType,
typename CompatibleObjectType,
3694 template<
typename BasicJsonType,
typename CompatibleObjectType>
3696 BasicJsonType, CompatibleObjectType,
3698 is_detected<key_type_t, CompatibleObjectType>::value >>
3705 typename CompatibleObjectType::key_type>
::value &&
3707 typename CompatibleObjectType::mapped_type>
::value;
3710 template<
typename BasicJsonType,
typename CompatibleObjectType>
3714 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3718 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3720 BasicJsonType, ConstructibleObjectType,
3722 is_detected<key_type_t, ConstructibleObjectType>::value >>
3728 (std::is_move_assignable<ConstructibleObjectType>::value ||
3729 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3731 typename object_t::key_type>::
value &&
3733 typename object_t::mapped_type,
3734 typename ConstructibleObjectType::mapped_type >::
value)) ||
3736 typename ConstructibleObjectType::mapped_type>::
value ||
3739 typename ConstructibleObjectType::mapped_type >::
value);
3742 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3745 ConstructibleObjectType> {};
3747 template<
typename BasicJsonType,
typename CompatibleStringType>
3754 template<
typename BasicJsonType,
typename ConstructibleStringType>
3758 #ifdef __INTEL_COMPILER 3759 using laundered_type = decltype(std::declval<ConstructibleStringType>());
3771 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3774 template<
typename BasicJsonType,
typename CompatibleArrayType>
3776 BasicJsonType, CompatibleArrayType,
3779 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
3782 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3789 template<
typename BasicJsonType,
typename CompatibleArrayType>
3793 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3796 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3798 BasicJsonType, ConstructibleArrayType,
3800 typename BasicJsonType::value_type>::value >>
3801 : std::true_type {};
3803 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3805 BasicJsonType, ConstructibleArrayType,
3807 typename BasicJsonType::value_type>::value&&
3810 (std::is_move_assignable<ConstructibleArrayType>::value ||
3811 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3812 is_detected<iterator_t, ConstructibleArrayType>::value&&
3813 is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3814 is_detected<range_value_t, ConstructibleArrayType>::value&&
3817 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
3819 detected_t<range_value_t, ConstructibleArrayType >>::value >>
3825 typename BasicJsonType::array_t::value_type>
::value ||
3833 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3837 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3841 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3843 RealIntegerType, CompatibleNumberIntegerType,
3845 std::is_integral<CompatibleNumberIntegerType>::value&&
3846 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3854 CompatibleNumberIntegerType>
::value &&
3855 CompatibleLimits::is_integer &&
3856 RealLimits::is_signed == CompatibleLimits::is_signed;
3859 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3862 CompatibleNumberIntegerType> {};
3864 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3867 template<
typename BasicJsonType,
typename CompatibleType>
3869 BasicJsonType, CompatibleType,
3876 template<
typename BasicJsonType,
typename CompatibleType>
3880 template<
typename T1,
typename T2>
3883 template<
typename T1,
typename... Args>
3886 template<
typename BasicJsonType,
typename T>
3889 template<
typename BasicJsonType>
3892 template<
typename BasicJsonType>
3897 template<
template <
typename...>
class Primary,
typename T>
3900 template<
template <
typename...>
class Primary,
typename... Args>
3903 template<
typename T>
3907 template<
typename Compare,
typename A,
typename B,
typename =
void>
3910 template<
typename Compare,
typename A,
typename B>
3912 decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3913 decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3914 >> : std::true_type {};
3916 template<
typename T>
3921 template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3925 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3926 ObjectKeyType>::value)
3927 && (!RequireTransparentComparator
3939 template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3943 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3944 RequireTransparentComparator, ExcludeObjectKeyType>::value
3949 template<
typename ObjectType,
typename KeyType>
3953 template<
typename BasicJsonType,
typename KeyType>
3957 typename BasicJsonType::object_t, KeyType >::value,
3963 template <
typename T>
3973 template <
typename C>
static one test( decltype(&C::capacity) ) ;
3974 template <
typename C>
static two test(...);
3976 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(char) };
3980 template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3983 return static_cast<T
>(
value);
3986 template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3992 template<
typename... Types>
3995 template<
typename... Types>
3998 template<
typename... Types>
4002 template<
typename... Types>
4003 using same_sign = std::integral_constant < bool,
4006 template<
typename OfType,
typename T>
4008 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4011 template<
typename OfType,
typename T,
4012 bool OfTypeSigned = std::is_signed<OfType>::value,
4013 bool TSigned = std::is_signed<T>::value>
4016 template<
typename OfType,
typename T>
4022 return static_cast<CommonType
>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
4026 template<
typename OfType,
typename T>
4032 return static_cast<CommonType
>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
4036 template<
typename OfType,
typename T>
4042 return val >= 0 &&
static_cast<CommonType
>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
4047 template<
typename OfType,
typename T>
4053 return static_cast<CommonType
>(val) >= static_cast<CommonType>((std::numeric_limits<OfType>::min)())
4054 &&
static_cast<CommonType
>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
4058 template<
typename OfType,
typename T,
4063 template<
typename OfType,
typename T>
4072 template<
typename OfType,
typename T>
4081 template<
typename OfType,
typename T>
4087 template<
bool Value>
4097 template<
typename T>
4105 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4106 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4112 template<
typename T>
4115 template<
typename T>
4125 template<
typename T>
4134 template<
typename T>
4171 template<
typename... Args>
4172 inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4174 template<
typename StringType,
typename... Args>
4175 inline std::size_t
concat_length(
const StringType&
str,
const Args& ... rest);
4177 template<
typename... Args>
4183 template<
typename... Args>
4190 template<
typename StringType,
typename... Args>
4196 template<
typename OutStringType>
4200 template<
typename StringType,
typename Arg>
4203 template<
typename StringType,
typename Arg>
4206 template<
typename StringType,
typename Arg>
4209 template<
typename StringType,
typename Arg>
4212 template<
typename StringType,
typename Arg>
4213 using string_can_append_iter = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4215 template<
typename StringType,
typename Arg>
4218 template<
typename StringType,
typename Arg>
4219 using string_can_append_data = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4221 template<
typename StringType,
typename Arg>
4224 template <
typename OutStringType,
typename Arg,
typename... Args,
4227 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4229 template <
typename OutStringType,
typename Arg,
typename... Args,
4233 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4235 template <
typename OutStringType,
typename Arg,
typename... Args,
4240 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4242 template<
typename OutStringType,
typename Arg,
typename... Args,
4244 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4246 out.append(std::forward<Arg>(arg));
4250 template <
typename OutStringType,
typename Arg,
typename... Args,
4253 inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4255 out += std::forward<Arg>(arg);
4259 template <
typename OutStringType,
typename Arg,
typename... Args,
4263 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4265 out.append(arg.begin(), arg.end());
4269 template <
typename OutStringType,
typename Arg,
typename... Args,
4274 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4276 out.append(arg.data(), arg.size());
4280 template<
typename OutStringType =
std::string,
typename... Args>
4308 const char*
what() const noexcept
override 4318 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
4330 template<
typename BasicJsonType>
4333 #if JSON_DIAGNOSTICS 4334 std::vector<std::string> tokens;
4335 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4337 switch (current->m_parent->type())
4341 for (std::size_t
i = 0;
i < current->m_parent->m_data.m_value.array->size(); ++
i)
4343 if (¤t->m_parent->m_data.m_value.array->operator[](
i) == current)
4354 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4356 if (&element.second == current)
4358 tokens.emplace_back(element.first.c_str());
4383 auto str = std::accumulate(tokens.rbegin(), tokens.rend(),
std::string{},
4390 static_cast<void>(leaf_element);
4397 std::runtime_error
m;
4428 return {id_, byte_, w.c_str()};
4462 return {id_, w.c_str()};
4480 return {id_, w.c_str()};
4497 return {id_, w.c_str()};
4514 return {id_, w.c_str()};
4567 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM 4568 #include <experimental/filesystem> 4572 namespace std_fs = std::experimental::filesystem;
4575 #elif JSON_HAS_FILESYSTEM 4576 #include <filesystem> 4580 namespace std_fs = std::filesystem;
4596 template<
typename BasicJsonType>
4597 inline void from_json(
const BasicJsonType&
j,
typename std::nullptr_t& n)
4607 template <
typename BasicJsonType,
typename ArithmeticType,
4608 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4609 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4613 switch (static_cast<value_t>(
j))
4617 val =
static_cast<ArithmeticType
>(*
j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4622 val =
static_cast<ArithmeticType
>(*
j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4627 val =
static_cast<ArithmeticType
>(*
j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4643 template<
typename BasicJsonType>
4644 inline void from_json(
const BasicJsonType&
j,
typename BasicJsonType::boolean_t& b)
4650 b = *
j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4653 template<
typename BasicJsonType>
4654 inline void from_json(
const BasicJsonType&
j,
typename BasicJsonType::string_t& s)
4660 s = *
j.template get_ptr<const typename BasicJsonType::string_t*>();
4664 typename BasicJsonType,
typename StringType,
4666 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4667 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4668 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4677 s = *
j.template get_ptr<const typename BasicJsonType::string_t*>();
4680 template<
typename BasicJsonType>
4681 inline void from_json(
const BasicJsonType&
j,
typename BasicJsonType::number_float_t& val)
4686 template<
typename BasicJsonType>
4687 inline void from_json(
const BasicJsonType&
j,
typename BasicJsonType::number_unsigned_t& val)
4692 template<
typename BasicJsonType>
4693 inline void from_json(
const BasicJsonType&
j,
typename BasicJsonType::number_integer_t& val)
4698 #if !JSON_DISABLE_ENUM_SERIALIZATION 4699 template<
typename BasicJsonType,
typename EnumType,
4700 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4705 e =
static_cast<EnumType
>(val);
4707 #endif // JSON_DISABLE_ENUM_SERIALIZATION 4710 template<
typename BasicJsonType,
typename T,
typename Allocator,
4712 inline void from_json(
const BasicJsonType&
j, std::forward_list<T, Allocator>&
l)
4719 std::transform(
j.rbegin(),
j.rend(),
4720 std::front_inserter(
l), [](
const BasicJsonType &
i)
4722 return i.template get<T>();
4727 template<
typename BasicJsonType,
typename T,
4736 std::transform(
j.begin(),
j.end(), std::begin(
l),
4737 [](
const BasicJsonType & elem)
4739 return elem.template get<T>();
4743 template<
typename BasicJsonType,
typename T, std::
size_t N>
4745 -> decltype(
j.template get<T>(),
void())
4747 for (std::size_t
i = 0;
i < N; ++
i)
4749 arr[
i] =
j.at(
i).template get<T>();
4753 template<
typename BasicJsonType>
4756 arr = *
j.template get_ptr<const typename BasicJsonType::array_t*>();
4759 template<
typename BasicJsonType,
typename T, std::
size_t N>
4762 -> decltype(
j.template get<T>(),
void())
4764 for (std::size_t
i = 0;
i < N; ++
i)
4766 arr[
i] =
j.at(
i).template get<T>();
4770 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4772 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4776 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4777 j.template get<typename ConstructibleArrayType::value_type>(),
4782 ConstructibleArrayType ret;
4783 ret.reserve(
j.size());
4784 std::transform(
j.begin(),
j.end(),
4785 std::inserter(ret, end(ret)), [](
const BasicJsonType &
i)
4789 return i.template get<typename ConstructibleArrayType::value_type>();
4791 arr = std::move(ret);
4794 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4796 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4803 ConstructibleArrayType ret;
4805 j.begin(),
j.end(), std::inserter(ret, end(ret)),
4806 [](
const BasicJsonType &
i)
4810 return i.template get<typename ConstructibleArrayType::value_type>();
4812 arr = std::move(ret);
4815 template <
typename BasicJsonType,
typename ConstructibleArrayType,
4820 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4823 auto from_json(
const BasicJsonType&
j, ConstructibleArrayType& arr)
4825 j.template get<typename ConstructibleArrayType::value_type>(),
4836 template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4840 return { { std::forward<BasicJsonType>(
j).at(Idx).template get<T>()... } };
4843 template <
typename BasicJsonType,
typename T, std::
size_t N >
4855 template<
typename BasicJsonType>
4856 inline void from_json(
const BasicJsonType&
j,
typename BasicJsonType::binary_t& bin)
4863 bin = *
j.template get_ptr<const typename BasicJsonType::binary_t*>();
4866 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4868 inline void from_json(
const BasicJsonType&
j, ConstructibleObjectType& obj)
4875 ConstructibleObjectType ret;
4876 const auto* inner_object =
j.template get_ptr<const typename BasicJsonType::object_t*>();
4877 using value_type =
typename ConstructibleObjectType::value_type;
4879 inner_object->begin(), inner_object->end(),
4880 std::inserter(ret, ret.begin()),
4881 [](
typename BasicJsonType::object_t::value_type
const &
p)
4883 return value_type(
p.first,
p.second.template get<typename ConstructibleObjectType::mapped_type>());
4885 obj = std::move(ret);
4892 template <
typename BasicJsonType,
typename ArithmeticType,
4894 std::is_arithmetic<ArithmeticType>::value&&
4895 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4896 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4897 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4898 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4900 inline void from_json(
const BasicJsonType&
j, ArithmeticType& val)
4902 switch (static_cast<value_t>(
j))
4906 val =
static_cast<ArithmeticType
>(*
j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4911 val =
static_cast<ArithmeticType
>(*
j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4916 val =
static_cast<ArithmeticType
>(*
j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4921 val =
static_cast<ArithmeticType
>(*
j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4936 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4939 return std::make_tuple(std::forward<BasicJsonType>(
j).at(Idx).
template get<Args>()...);
4942 template <
typename BasicJsonType,
class A1,
class A2 >
4945 return {std::forward<BasicJsonType>(
j).at(0).template get<A1>(),
4946 std::forward<BasicJsonType>(
j).at(1).template get<A2>()};
4949 template<
typename BasicJsonType,
typename A1,
typename A2>
4955 template<
typename BasicJsonType,
typename... Args>
4961 template<
typename BasicJsonType,
typename... Args>
4967 template<
typename BasicJsonType,
typename TupleRelated>
4976 return from_json_tuple_impl(std::forward<BasicJsonType>(
j), std::forward<TupleRelated>(t), priority_tag<3> {});
4979 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4981 typename BasicJsonType::string_t, Key >::value >>
4982 inline void from_json(
const BasicJsonType&
j, std::map<Key, Value, Compare, Allocator>& m)
4989 for (
const auto&
p :
j)
4995 m.emplace(
p.at(0).template get<Key>(),
p.at(1).template get<Value>());
4999 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5001 typename BasicJsonType::string_t, Key >::value >>
5002 inline void from_json(
const BasicJsonType&
j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5009 for (
const auto&
p :
j)
5015 m.emplace(
p.at(0).template get<Key>(),
p.at(1).template get<Value>());
5019 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM 5020 template<
typename BasicJsonType>
5021 inline void from_json(
const BasicJsonType&
j, std_fs::path&
p)
5027 p = *
j.template get_ptr<const typename BasicJsonType::string_t*>();
5033 template<
typename BasicJsonType,
typename T>
5035 noexcept(noexcept(
from_json(
j, std::forward<T>(val))))
5036 -> decltype(
from_json(
j, std::forward<T>(val)))
5044 #ifndef JSON_HAS_CPP_17 5053 #ifndef JSON_HAS_CPP_17 5070 #include <algorithm> 5074 #include <type_traits> 5111 template<
typename string_type>
5126 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::
type >::
type;
5143 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value 5153 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value 5156 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value 5200 switch (
anchor.m_object->type())
5232 typename IteratorType::reference
value()
const 5274 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5275 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>&
i) -> decltype(
i.key())
5282 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5283 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>&
i) -> decltype(
i.value())
5298 #if defined(__clang__) 5300 #pragma clang diagnostic push 5301 #pragma clang diagnostic ignored "-Wmismatched-tags" 5303 template<
typename IteratorType>
5304 class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5305 :
public std::integral_constant<std::size_t, 2> {};
5307 template<std::
size_t N,
typename IteratorType>
5308 class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5311 using type = decltype(
5312 get<N>(std::declval <
5313 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5315 #if defined(__clang__) 5316 #pragma clang diagnostic pop 5322 template <
typename IteratorType>
5323 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5357 template<
typename BasicJsonType>
5358 static void construct(BasicJsonType&
j,
typename BasicJsonType::boolean_t b) noexcept
5360 j.m_data.m_value.destroy(
j.m_data.m_type);
5362 j.m_data.m_value = b;
5363 j.assert_invariant();
5370 template<
typename BasicJsonType>
5371 static void construct(BasicJsonType&
j,
const typename BasicJsonType::string_t& s)
5373 j.m_data.m_value.destroy(
j.m_data.m_type);
5375 j.m_data.m_value = s;
5376 j.assert_invariant();
5379 template<
typename BasicJsonType>
5380 static void construct(BasicJsonType&
j,
typename BasicJsonType::string_t&& s)
5382 j.m_data.m_value.destroy(
j.m_data.m_type);
5384 j.m_data.m_value = std::move(s);
5385 j.assert_invariant();
5388 template <
typename BasicJsonType,
typename CompatibleStringType,
5393 j.m_data.m_value.destroy(
j.m_data.m_type);
5395 j.m_data.m_value.string =
j.template create<typename BasicJsonType::string_t>(
str);
5396 j.assert_invariant();
5403 template<
typename BasicJsonType>
5404 static void construct(BasicJsonType&
j,
const typename BasicJsonType::binary_t& b)
5406 j.m_data.m_value.destroy(
j.m_data.m_type);
5408 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5409 j.assert_invariant();
5412 template<
typename BasicJsonType>
5413 static void construct(BasicJsonType&
j,
typename BasicJsonType::binary_t&& b)
5415 j.m_data.m_value.destroy(
j.m_data.m_type);
5417 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5418 j.assert_invariant();
5425 template<
typename BasicJsonType>
5426 static void construct(BasicJsonType&
j,
typename BasicJsonType::number_float_t val) noexcept
5428 j.m_data.m_value.destroy(
j.m_data.m_type);
5430 j.m_data.m_value = val;
5431 j.assert_invariant();
5438 template<
typename BasicJsonType>
5439 static void construct(BasicJsonType&
j,
typename BasicJsonType::number_unsigned_t val) noexcept
5441 j.m_data.m_value.destroy(
j.m_data.m_type);
5443 j.m_data.m_value = val;
5444 j.assert_invariant();
5451 template<
typename BasicJsonType>
5452 static void construct(BasicJsonType&
j,
typename BasicJsonType::number_integer_t val) noexcept
5454 j.m_data.m_value.destroy(
j.m_data.m_type);
5456 j.m_data.m_value = val;
5457 j.assert_invariant();
5464 template<
typename BasicJsonType>
5465 static void construct(BasicJsonType&
j,
const typename BasicJsonType::array_t& arr)
5467 j.m_data.m_value.destroy(
j.m_data.m_type);
5469 j.m_data.m_value = arr;
5471 j.assert_invariant();
5474 template<
typename BasicJsonType>
5475 static void construct(BasicJsonType&
j,
typename BasicJsonType::array_t&& arr)
5477 j.m_data.m_value.destroy(
j.m_data.m_type);
5479 j.m_data.m_value = std::move(arr);
5481 j.assert_invariant();
5484 template <
typename BasicJsonType,
typename CompatibleArrayType,
5487 static void construct(BasicJsonType&
j,
const CompatibleArrayType& arr)
5492 j.m_data.m_value.destroy(
j.m_data.m_type);
5494 j.m_data.m_value.array =
j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5496 j.assert_invariant();
5499 template<
typename BasicJsonType>
5500 static void construct(BasicJsonType&
j,
const std::vector<bool>& arr)
5502 j.m_data.m_value.destroy(
j.m_data.m_type);
5505 j.m_data.m_value.array->reserve(arr.size());
5506 for (
const bool x : arr)
5508 j.m_data.m_value.array->push_back(x);
5509 j.set_parent(
j.m_data.m_value.array->back());
5511 j.assert_invariant();
5514 template<
typename BasicJsonType,
typename T,
5516 static void construct(BasicJsonType&
j,
const std::valarray<T>& arr)
5518 j.m_data.m_value.destroy(
j.m_data.m_type);
5521 j.m_data.m_value.array->resize(arr.size());
5524 std::copy(std::begin(arr), std::end(arr),
j.m_data.m_value.array->begin());
5527 j.assert_invariant();
5534 template<
typename BasicJsonType>
5535 static void construct(BasicJsonType&
j,
const typename BasicJsonType::object_t& obj)
5537 j.m_data.m_value.destroy(
j.m_data.m_type);
5539 j.m_data.m_value = obj;
5541 j.assert_invariant();
5544 template<
typename BasicJsonType>
5545 static void construct(BasicJsonType&
j,
typename BasicJsonType::object_t&& obj)
5547 j.m_data.m_value.destroy(
j.m_data.m_type);
5549 j.m_data.m_value = std::move(obj);
5551 j.assert_invariant();
5554 template <
typename BasicJsonType,
typename CompatibleObjectType,
5556 static void construct(BasicJsonType&
j,
const CompatibleObjectType& obj)
5561 j.m_data.m_value.destroy(
j.m_data.m_type);
5563 j.m_data.m_value.object =
j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5565 j.assert_invariant();
5573 template<
typename BasicJsonType,
typename T,
5574 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5580 template <
typename BasicJsonType,
typename BoolRef,
5582 ((std::is_same<std::vector<bool>::reference, BoolRef>::value
5583 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>::value)
5584 || (std::is_same<std::vector<bool>::const_reference, BoolRef>::value
5586 typename BasicJsonType::boolean_t >::value))
5587 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5588 inline void to_json(BasicJsonType&
j,
const BoolRef& b) noexcept
5593 template<
typename BasicJsonType,
typename CompatibleString,
5594 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5595 inline void to_json(BasicJsonType&
j,
const CompatibleString& s)
5600 template<
typename BasicJsonType>
5601 inline void to_json(BasicJsonType&
j,
typename BasicJsonType::string_t&& s)
5606 template<
typename BasicJsonType,
typename FloatType,
5607 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5608 inline void to_json(BasicJsonType&
j, FloatType val) noexcept
5613 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5614 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5615 inline void to_json(BasicJsonType&
j, CompatibleNumberUnsignedType val) noexcept
5620 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5621 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5622 inline void to_json(BasicJsonType&
j, CompatibleNumberIntegerType val) noexcept
5627 #if !JSON_DISABLE_ENUM_SERIALIZATION 5628 template<
typename BasicJsonType,
typename EnumType,
5629 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5630 inline void to_json(BasicJsonType&
j, EnumType e) noexcept
5635 #endif // JSON_DISABLE_ENUM_SERIALIZATION 5637 template<
typename BasicJsonType>
5638 inline void to_json(BasicJsonType&
j,
const std::vector<bool>& e)
5643 template <
typename BasicJsonType,
typename CompatibleArrayType,
5644 enable_if_t < is_compatible_array_type<BasicJsonType,
5645 CompatibleArrayType>::value&&
5648 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5651 inline void to_json(BasicJsonType&
j,
const CompatibleArrayType& arr)
5656 template<
typename BasicJsonType>
5657 inline void to_json(BasicJsonType&
j,
const typename BasicJsonType::binary_t& bin)
5662 template<
typename BasicJsonType,
typename T,
5663 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5664 inline void to_json(BasicJsonType&
j,
const std::valarray<T>& arr)
5669 template<
typename BasicJsonType>
5670 inline void to_json(BasicJsonType&
j,
typename BasicJsonType::array_t&& arr)
5675 template <
typename BasicJsonType,
typename CompatibleObjectType,
5677 inline void to_json(BasicJsonType&
j,
const CompatibleObjectType& obj)
5682 template<
typename BasicJsonType>
5683 inline void to_json(BasicJsonType&
j,
typename BasicJsonType::object_t&& obj)
5689 typename BasicJsonType,
typename T, std::size_t N,
5690 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5691 const T(&)[N]>::value,
5693 inline void to_json(BasicJsonType&
j,
const T(&arr)[N])
5698 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5699 inline void to_json(BasicJsonType&
j,
const std::pair<T1, T2>&
p)
5701 j = {
p.first,
p.second };
5705 template<
typename BasicJsonType,
typename T,
5706 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5709 j = { {b.key(), b.value()} };
5712 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5715 j = { std::get<Idx>(t)... };
5719 inline void to_json(BasicJsonType&
j,
const T& t)
5724 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM 5725 template<
typename BasicJsonType>
5726 inline void to_json(BasicJsonType&
j,
const std_fs::path&
p)
5734 template<
typename BasicJsonType,
typename T>
5736 -> decltype(
to_json(
j, std::forward<T>(val)),
void())
5738 return to_json(
j, std::forward<T>(val));
5743 #ifndef JSON_HAS_CPP_17 5752 #ifndef JSON_HAS_CPP_17 5764 template<
typename ValueType,
typename>
5769 template<
typename BasicJsonType,
typename TargetType = ValueType>
5770 static auto from_json(BasicJsonType &&
j, TargetType& val) noexcept(
5779 template<
typename BasicJsonType,
typename TargetType = ValueType>
5789 template<
typename BasicJsonType,
typename TargetType = ValueType>
5790 static auto to_json(BasicJsonType&
j, TargetType && val) noexcept(
5822 template<
typename BinaryType>
5866 return !(rhs == *
this);
5925 #include <functional> 5937 inline std::size_t
combine(std::size_t seed, std::size_t h) noexcept
5939 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5954 template<
typename BasicJsonType>
5955 std::size_t
hash(
const BasicJsonType&
j)
5957 using string_t =
typename BasicJsonType::string_t;
5958 using number_integer_t =
typename BasicJsonType::number_integer_t;
5959 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5960 using number_float_t =
typename BasicJsonType::number_float_t;
5962 const auto type =
static_cast<std::size_t
>(
j.type());
5965 case BasicJsonType::value_t::null:
5966 case BasicJsonType::value_t::discarded:
5971 case BasicJsonType::value_t::object:
5974 for (
const auto& element :
j.items())
5976 const auto h = std::hash<string_t> {}(element.key());
5983 case BasicJsonType::value_t::array:
5986 for (
const auto& element :
j)
5993 case BasicJsonType::value_t::string:
5995 const auto h = std::hash<string_t> {}(
j.template get_ref<const string_t&>());
5999 case BasicJsonType::value_t::boolean:
6001 const auto h = std::hash<bool> {}(
j.template get<bool>());
6005 case BasicJsonType::value_t::number_integer:
6007 const auto h = std::hash<number_integer_t> {}(
j.template get<number_integer_t>());
6011 case BasicJsonType::value_t::number_unsigned:
6013 const auto h = std::hash<number_unsigned_t> {}(
j.template get<number_unsigned_t>());
6017 case BasicJsonType::value_t::number_float:
6019 const auto h = std::hash<number_float_t> {}(
j.template get<number_float_t>());
6023 case BasicJsonType::value_t::binary:
6026 const auto h = std::hash<bool> {}(
j.get_binary().has_subtype());
6028 seed =
combine(seed, static_cast<std::size_t>(
j.get_binary().subtype()));
6029 for (
const auto byte :
j.get_binary())
6031 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6056 #include <algorithm> 6089 #include <type_traits> 6095 #endif // JSON_NO_IO 6139 return std::fgetc(
m_file);
6168 is->clear(
is->rdstate() & std::ios::eofbit);
6182 :
is(rhs.is),
sb(rhs.sb)
6193 auto res =
sb->sbumpc();
6197 is->clear(
is->rdstate() | std::ios::eofbit);
6204 std::istream*
is =
nullptr;
6205 std::streambuf*
sb =
nullptr;
6207 #endif // JSON_NO_IO 6211 template<
typename IteratorType>
6215 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6225 auto result = std::char_traits<char_type>::to_int_type(*
current);
6230 return std::char_traits<char_type>::eof();
6237 template<
typename BaseInputAdapter,
size_t T>
6247 template<
typename BaseInputAdapter,
size_t T>
6250 template<
typename BaseInputAdapter>
6255 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6256 size_t& utf8_bytes_index,
6257 size_t& utf8_bytes_filled)
6259 utf8_bytes_index = 0;
6263 utf8_bytes[0] = std::char_traits<char>::eof();
6264 utf8_bytes_filled = 1;
6269 const auto wc = input.get_character();
6274 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6275 utf8_bytes_filled = 1;
6277 else if (wc <= 0x7FF)
6279 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6280 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6281 utf8_bytes_filled = 2;
6283 else if (wc <= 0xFFFF)
6285 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6286 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6287 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6288 utf8_bytes_filled = 3;
6290 else if (wc <= 0x10FFFF)
6292 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6293 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6294 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6295 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6296 utf8_bytes_filled = 4;
6301 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6302 utf8_bytes_filled = 1;
6308 template<
typename BaseInputAdapter>
6313 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6314 size_t& utf8_bytes_index,
6315 size_t& utf8_bytes_filled)
6317 utf8_bytes_index = 0;
6321 utf8_bytes[0] = std::char_traits<char>::eof();
6322 utf8_bytes_filled = 1;
6327 const auto wc = input.get_character();
6332 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6333 utf8_bytes_filled = 1;
6335 else if (wc <= 0x7FF)
6337 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6338 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6339 utf8_bytes_filled = 2;
6341 else if (0xD800 > wc || wc >= 0xE000)
6343 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6344 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6345 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6346 utf8_bytes_filled = 3;
6352 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6353 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6354 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6355 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6356 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6357 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6358 utf8_bytes_filled = 4;
6362 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6363 utf8_bytes_filled = 1;
6371 template<
typename BaseInputAdapter,
typename W
ideCharType>
6385 fill_buffer<sizeof(WideCharType)>();
6407 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
6416 template<
typename IteratorType,
typename Enable =
void>
6420 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6425 return adapter_type(std::move(first), std::move(last));
6429 template<
typename T>
6439 template<
typename IteratorType>
6443 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6454 template<
typename IteratorType>
6458 return factory_type::create(first, last);
6465 namespace container_input_adapter_factory_impl
6471 template<
typename ContainerType,
typename Enable =
void>
6474 template<
typename ContainerType>
6476 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6488 template<
typename ContainerType>
6510 #endif // JSON_NO_IO 6515 template <
typename CharT,
6516 typename std::enable_if <
6517 std::is_pointer<CharT>::value&&
6518 !std::is_array<CharT>::value&&
6524 auto length = std::strlen(reinterpret_cast<const char*>(b));
6525 const auto* ptr =
reinterpret_cast<const char*
>(b);
6529 template<
typename T, std::
size_t N>
6541 template <
typename CharT,
6542 typename std::enable_if <
6543 std::is_pointer<CharT>::value&&
6548 : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) +
l) {}
6550 template<
class IteratorType,
6551 typename std::enable_if<
6552 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
6559 return std::move(ia);
6602 template<
typename BasicJsonType>
6615 virtual bool null() = 0;
6622 virtual bool boolean(
bool val) = 0;
6690 virtual bool start_array(std::size_t elements) = 0;
6706 const std::string& last_token,
6733 template<
typename BasicJsonType>
6749 : root(r), allow_exceptions(allow_exceptions_)
6761 handle_value(
nullptr);
6797 handle_value(std::move(val));
6803 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6805 if (
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
6819 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
6828 ref_stack.back()->set_parents();
6829 ref_stack.pop_back();
6835 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6837 if (
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
6850 ref_stack.back()->set_parents();
6851 ref_stack.pop_back();
6855 template<
class Exception>
6857 const Exception& ex)
6860 static_cast<void>(ex);
6861 if (allow_exceptions)
6880 template<
typename Value>
6884 if (ref_stack.empty())
6886 root = BasicJsonType(std::forward<Value>(v));
6890 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6892 if (ref_stack.back()->is_array())
6894 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
6895 return &(ref_stack.back()->m_data.m_value.array->back());
6900 *object_element = BasicJsonType(std::forward<Value>(v));
6901 return object_element;
6907 std::vector<BasicJsonType*> ref_stack {};
6909 BasicJsonType* object_element =
nullptr;
6911 bool errored =
false;
6913 const bool allow_exceptions =
true;
6916 template<
typename BasicJsonType>
6930 const bool allow_exceptions_ =
true)
6931 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6933 keep_stack.push_back(
true);
6945 handle_value(
nullptr);
6981 handle_value(std::move(val));
6988 const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6989 keep_stack.push_back(keep);
6991 auto val = handle_value(BasicJsonType::value_t::object,
true);
6992 ref_stack.push_back(val.second);
6995 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
7005 BasicJsonType
k = BasicJsonType(val);
7008 const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key,
k);
7009 key_keep_stack.push_back(keep);
7012 if (keep && ref_stack.back())
7014 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
7022 if (ref_stack.back())
7024 if (!callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7031 ref_stack.back()->set_parents();
7037 ref_stack.pop_back();
7038 keep_stack.pop_back();
7040 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7043 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7045 if (it->is_discarded())
7047 ref_stack.back()->erase(it);
7058 const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7059 keep_stack.push_back(keep);
7061 auto val = handle_value(BasicJsonType::value_t::array,
true);
7062 ref_stack.push_back(val.second);
7065 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
7077 if (ref_stack.back())
7079 keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7082 ref_stack.back()->set_parents();
7093 ref_stack.pop_back();
7094 keep_stack.pop_back();
7097 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7099 ref_stack.back()->m_data.m_value.array->pop_back();
7105 template<
class Exception>
7107 const Exception& ex)
7110 static_cast<void>(ex);
7111 if (allow_exceptions)
7139 template<
typename Value>
7140 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
7146 if (!keep_stack.back())
7148 return {
false,
nullptr};
7152 auto value = BasicJsonType(std::forward<Value>(v));
7155 const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
7160 return {
false,
nullptr};
7163 if (ref_stack.empty())
7165 root = std::move(
value);
7166 return {
true, &root};
7171 if (!ref_stack.back())
7173 return {
false,
nullptr};
7177 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7180 if (ref_stack.back()->is_array())
7182 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(
value));
7183 return {
true, &(ref_stack.back()->m_data.m_value.array->back())};
7190 const bool store_element = key_keep_stack.back();
7191 key_keep_stack.pop_back();
7195 return {
false,
nullptr};
7199 *object_element = std::move(
value);
7200 return {
true, object_element};
7206 std::vector<BasicJsonType*> ref_stack {};
7208 std::vector<bool> keep_stack {};
7210 std::vector<bool> key_keep_stack {};
7212 BasicJsonType* object_element =
nullptr;
7214 bool errored =
false;
7218 const bool allow_exceptions =
true;
7220 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7223 template<
typename BasicJsonType>
7318 #include <initializer_list> 7338 template<
typename BasicJsonType>
7371 case token_type::uninitialized:
7372 return "<uninitialized>";
7373 case token_type::literal_true:
7374 return "true literal";
7375 case token_type::literal_false:
7376 return "false literal";
7377 case token_type::literal_null:
7378 return "null literal";
7379 case token_type::value_string:
7380 return "string literal";
7381 case token_type::value_unsigned:
7382 case token_type::value_integer:
7383 case token_type::value_float:
7384 return "number literal";
7385 case token_type::begin_array:
7387 case token_type::begin_object:
7389 case token_type::end_array:
7391 case token_type::end_object:
7393 case token_type::name_separator:
7395 case token_type::value_separator:
7397 case token_type::parse_error:
7398 return "<parse error>";
7399 case token_type::end_of_input:
7400 return "end of input";
7401 case token_type::literal_or_value:
7402 return "'[', '{', or a literal";
7405 return "unknown token";
7415 template<
typename BasicJsonType,
typename InputAdapterType>
7428 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7429 : ia(
std::move(adapter))
7430 , ignore_comments(ignore_comments_)
7431 , decimal_point_char(static_cast<
char_int_type>(get_decimal_point()))
7450 const auto* loc = localeconv();
7452 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7480 const auto factors = { 12u, 8u, 4u, 0u };
7481 for (
const auto factor : factors)
7485 if (current >=
'0' && current <=
'9')
7487 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7489 else if (current >=
'A' && current <=
'F')
7491 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7493 else if (current >=
'a' && current <=
'f')
7495 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7503 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7524 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7527 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7536 error_message =
"invalid string: ill-formed UTF-8 byte";
7573 case std::char_traits<char_type>::eof():
7575 error_message =
"invalid string: missing closing quote";
7576 return token_type::parse_error;
7582 return token_type::value_string;
7626 const int codepoint1 = get_codepoint();
7627 int codepoint = codepoint1;
7631 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7632 return token_type::parse_error;
7636 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7641 const int codepoint2 = get_codepoint();
7645 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7646 return token_type::parse_error;
7653 codepoint =
static_cast<int>(
7655 (
static_cast<unsigned int>(codepoint1) << 10u)
7657 +
static_cast<unsigned int>(codepoint2)
7665 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7666 return token_type::parse_error;
7671 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7672 return token_type::parse_error;
7679 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7680 return token_type::parse_error;
7685 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7688 if (codepoint < 0x80)
7691 add(static_cast<char_int_type>(codepoint));
7693 else if (codepoint <= 0x7FF)
7696 add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
7697 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
7699 else if (codepoint <= 0xFFFF)
7702 add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
7703 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7704 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
7709 add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
7710 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7711 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7712 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
7720 error_message =
"invalid string: forbidden character after backslash";
7721 return token_type::parse_error;
7730 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7731 return token_type::parse_error;
7736 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7737 return token_type::parse_error;
7742 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7743 return token_type::parse_error;
7748 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7749 return token_type::parse_error;
7754 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7755 return token_type::parse_error;
7760 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7761 return token_type::parse_error;
7766 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7767 return token_type::parse_error;
7772 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7773 return token_type::parse_error;
7778 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7779 return token_type::parse_error;
7784 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7785 return token_type::parse_error;
7790 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7791 return token_type::parse_error;
7796 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7797 return token_type::parse_error;
7802 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7803 return token_type::parse_error;
7808 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7809 return token_type::parse_error;
7814 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7815 return token_type::parse_error;
7820 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7821 return token_type::parse_error;
7826 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7827 return token_type::parse_error;
7832 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7833 return token_type::parse_error;
7838 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7839 return token_type::parse_error;
7844 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7845 return token_type::parse_error;
7850 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7851 return token_type::parse_error;
7856 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7857 return token_type::parse_error;
7862 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7863 return token_type::parse_error;
7868 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7869 return token_type::parse_error;
7874 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7875 return token_type::parse_error;
7880 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7881 return token_type::parse_error;
7886 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7887 return token_type::parse_error;
7892 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7893 return token_type::parse_error;
7898 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7899 return token_type::parse_error;
7904 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7905 return token_type::parse_error;
7910 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7911 return token_type::parse_error;
7916 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7917 return token_type::parse_error;
8054 return token_type::parse_error;
8064 return token_type::parse_error;
8088 return token_type::parse_error;
8098 return token_type::parse_error;
8108 return token_type::parse_error;
8120 return token_type::parse_error;
8130 return token_type::parse_error;
8138 error_message =
"invalid string: ill-formed UTF-8 byte";
8139 return token_type::parse_error;
8162 case std::char_traits<char_type>::eof():
8179 case std::char_traits<char_type>::eof():
8182 error_message =
"invalid comment; missing closing '*/'";
8210 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8217 static
void strtof(
float& f, const
char*
str,
char** endptr) noexcept
8219 f = std::strtof(
str, endptr);
8223 static
void strtof(
double& f, const
char*
str,
char** endptr) noexcept
8225 f = std::strtod(
str, endptr);
8229 static
void strtof(
long double& f, const
char*
str,
char** endptr) noexcept
8231 f = std::strtold(
str, endptr);
8281 token_type number_type = token_type::value_unsigned;
8289 goto scan_number_minus;
8295 goto scan_number_zero;
8309 goto scan_number_any1;
8319 number_type = token_type::value_integer;
8325 goto scan_number_zero;
8339 goto scan_number_any1;
8344 error_message =
"invalid number; expected digit after '-'";
8345 return token_type::parse_error;
8355 add(decimal_point_char);
8356 goto scan_number_decimal1;
8363 goto scan_number_exponent;
8367 goto scan_number_done;
8386 goto scan_number_any1;
8391 add(decimal_point_char);
8392 goto scan_number_decimal1;
8399 goto scan_number_exponent;
8403 goto scan_number_done;
8406 scan_number_decimal1:
8408 number_type = token_type::value_float;
8423 goto scan_number_decimal2;
8428 error_message =
"invalid number; expected digit after '.'";
8429 return token_type::parse_error;
8433 scan_number_decimal2:
8449 goto scan_number_decimal2;
8456 goto scan_number_exponent;
8460 goto scan_number_done;
8463 scan_number_exponent:
8465 number_type = token_type::value_float;
8472 goto scan_number_sign;
8487 goto scan_number_any2;
8493 "invalid number; expected '+', '-', or digit after exponent";
8494 return token_type::parse_error;
8514 goto scan_number_any2;
8519 error_message =
"invalid number; expected digit after exponent sign";
8520 return token_type::parse_error;
8540 goto scan_number_any2;
8544 goto scan_number_done;
8552 char* endptr =
nullptr;
8556 if (number_type == token_type::value_unsigned)
8558 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8561 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8566 if (value_unsigned == x)
8568 return token_type::value_unsigned;
8572 else if (number_type == token_type::value_integer)
8574 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8577 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8582 if (value_integer == x)
8584 return token_type::value_integer;
8591 strtof(value_float, token_buffer.data(), &endptr);
8594 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8596 return token_type::value_float;
8608 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8609 for (std::size_t
i = 1;
i < length; ++
i)
8613 error_message =
"invalid literal";
8614 return token_type::parse_error;
8627 token_buffer.clear();
8628 token_string.clear();
8629 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8644 ++position.chars_read_total;
8645 ++position.chars_read_current_line;
8654 current = ia.get_character();
8659 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8662 if (current ==
'\n')
8664 ++position.lines_read;
8665 position.chars_read_current_line = 0;
8683 --position.chars_read_total;
8686 if (position.chars_read_current_line == 0)
8688 if (position.lines_read > 0)
8690 --position.lines_read;
8695 --position.chars_read_current_line;
8701 token_string.pop_back();
8708 token_buffer.push_back(static_cast<typename string_t::value_type>(c));
8719 return value_integer;
8725 return value_unsigned;
8737 return token_buffer;
8757 for (
const auto c : token_string)
8759 if (static_cast<unsigned char>(c) <=
'\x1F')
8762 std::array<char, 9> cs{{}};
8763 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8764 result += cs.data();
8769 result.push_back(static_cast<std::string::value_type>(c));
8780 return error_message;
8796 return get() == 0xBB &&
get() == 0xBF;
8811 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8817 if (position.chars_read_total == 0 && !skip_bom())
8819 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8820 return token_type::parse_error;
8827 while (ignore_comments && current ==
'/')
8829 if (!scan_comment())
8831 return token_type::parse_error;
8842 return token_type::begin_array;
8844 return token_type::end_array;
8846 return token_type::begin_object;
8848 return token_type::end_object;
8850 return token_type::name_separator;
8852 return token_type::value_separator;
8857 std::array<char_type, 4> true_literal = {{
static_cast<char_type>(
't'), static_cast<char_type>(
'r'),
static_cast<char_type>(
'u'), static_cast<char_type>(
'e')}};
8858 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8862 std::array<char_type, 5> false_literal = {{
static_cast<char_type>(
'f'), static_cast<char_type>(
'a'),
static_cast<char_type>(
'l'), static_cast<char_type>(
's'),
static_cast<char_type>(
'e')}};
8863 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8867 std::array<char_type, 4> null_literal = {{
static_cast<char_type>(
'n'), static_cast<char_type>(
'u'),
static_cast<char_type>(
'l'), static_cast<char_type>(
'l')}};
8868 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8873 return scan_string();
8887 return scan_number();
8892 case std::char_traits<char_type>::eof():
8893 return token_type::end_of_input;
8897 error_message =
"invalid literal";
8898 return token_type::parse_error;
8907 const bool ignore_comments =
false;
8913 bool next_unget =
false;
8919 std::vector<char_type> token_string {};
8925 const char* error_message =
"";
8967 template<
typename T>
8970 template<
typename T>
8972 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
8974 template<
typename T,
typename Integer>
8978 template<
typename T,
typename Un
signed>
8982 template<
typename T,
typename Float,
typename String>
8984 std::declval<Float>(), std::declval<const String&>()));
8986 template<
typename T,
typename String>
8988 decltype(std::declval<T&>().
string(std::declval<String&>()));
8990 template<
typename T,
typename Binary>
8992 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
8994 template<
typename T>
8998 template<
typename T,
typename String>
9000 decltype(std::declval<T&>().
key(std::declval<String&>()));
9002 template<
typename T>
9005 template<
typename T>
9007 decltype(std::declval<T&>().
start_array(std::declval<std::size_t>()));
9009 template<
typename T>
9012 template<
typename T,
typename Exception>
9014 std::declval<std::size_t>(), std::declval<const std::string&>(),
9015 std::declval<const Exception&>()));
9017 template<
typename SAX,
typename BasicJsonType>
9022 "BasicJsonType must be of type basic_json<...>");
9048 template<
typename SAX,
typename BasicJsonType>
9053 "BasicJsonType must be of type basic_json<...>");
9064 "Missing/invalid function: bool null()");
9066 "Missing/invalid function: bool boolean(bool)");
9068 "Missing/invalid function: bool boolean(bool)");
9072 "Missing/invalid function: bool number_integer(number_integer_t)");
9076 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9079 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9082 "Missing/invalid function: bool string(string_t&)");
9085 "Missing/invalid function: bool binary(binary_t&)");
9087 "Missing/invalid function: bool start_object(std::size_t)");
9089 "Missing/invalid function: bool key(string_t&)");
9091 "Missing/invalid function: bool end_object()");
9093 "Missing/invalid function: bool start_array(std::size_t)");
9095 "Missing/invalid function: bool end_array()");
9098 "Missing/invalid function: bool parse_error(std::size_t, const " 9099 "std::string&, const exception&)");
9133 return *
reinterpret_cast<char*
>(&num) == 1;
9144 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9185 const
bool strict = true,
9189 bool result =
false;
9193 case input_format_t::bson:
9194 result = parse_bson_internal();
9197 case input_format_t::cbor:
9198 result = parse_cbor_internal(
true, tag_handler);
9201 case input_format_t::msgpack:
9202 result = parse_msgpack_internal();
9205 case input_format_t::ubjson:
9206 case input_format_t::bjdata:
9207 result = parse_ubjson_internal();
9218 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9229 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
9230 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9248 std::int32_t document_size{};
9249 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9261 return sax->end_object();
9273 auto out = std::back_inserter(result);
9281 if (current == 0x00)
9285 *out++ =
static_cast<typename string_t::value_type
>(current);
9300 template<
typename NumberType>
9305 auto last_token = get_token_string();
9306 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9307 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ",
std::to_string(len)),
"string"),
nullptr));
9310 return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) &&
get() != std::char_traits<char_type>::eof();
9322 template<
typename NumberType>
9327 auto last_token = get_token_string();
9328 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9329 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ",
std::to_string(len)),
"binary"),
nullptr));
9333 std::uint8_t subtype{};
9334 get_number<std::uint8_t>(input_format_t::bson, subtype);
9335 result.set_subtype(subtype);
9337 return get_binary(input_format_t::bson, len, result);
9351 const std::size_t element_type_parse_position)
9353 switch (element_type)
9358 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9365 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len,
value) && sax->string(
value);
9370 return parse_bson_internal();
9375 return parse_bson_array();
9382 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len,
value) && sax->binary(
value);
9387 return sax->boolean(
get() != 0);
9397 std::int32_t
value{};
9398 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9403 std::int64_t
value{};
9404 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9409 std::array<char, 3> cr{{}};
9410 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9411 const std::string cr_str{cr.data()};
9412 return sax->parse_error(element_type_parse_position, cr_str,
9413 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
9434 while (
auto element_type =
get())
9441 const std::size_t element_type_parse_position = chars_read;
9447 if (!is_array && !sax->key(
key))
9452 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9470 std::int32_t document_size{};
9471 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9483 return sax->end_array();
9501 switch (get_char ?
get() : current)
9504 case std::char_traits<char_type>::eof():
9505 return unexpect_eof(input_format_t::cbor,
"value");
9532 return sax->number_unsigned(static_cast<number_unsigned_t>(current));
9536 std::uint8_t number{};
9537 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9542 std::uint16_t number{};
9543 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9548 std::uint32_t number{};
9549 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9554 std::uint64_t number{};
9555 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9583 return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
9587 std::uint8_t number{};
9588 return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
9593 std::uint16_t number{};
9594 return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
9599 std::uint32_t number{};
9600 return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
9605 std::uint64_t number{};
9606 return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1)
9607 - static_cast<number_integer_t>(number));
9642 return get_cbor_binary(b) && sax->binary(b);
9677 return get_cbor_string(s) && sax->string(s);
9705 return get_cbor_array(
9706 conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9711 return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
9716 std::uint16_t len{};
9717 return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
9722 std::uint32_t len{};
9723 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9728 std::uint64_t len{};
9729 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9733 return get_cbor_array(static_cast<std::size_t>(-1), tag_handler);
9760 return get_cbor_object(conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9765 return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
9770 std::uint16_t len{};
9771 return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
9776 std::uint32_t len{};
9777 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9782 std::uint64_t len{};
9783 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9787 return get_cbor_object(static_cast<std::size_t>(-1), tag_handler);
9809 switch (tag_handler)
9811 case cbor_tag_handler_t::error:
9813 auto last_token = get_token_string();
9814 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9815 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9818 case cbor_tag_handler_t::ignore:
9825 std::uint8_t subtype_to_ignore{};
9826 get_number(input_format_t::cbor, subtype_to_ignore);
9831 std::uint16_t subtype_to_ignore{};
9832 get_number(input_format_t::cbor, subtype_to_ignore);
9837 std::uint32_t subtype_to_ignore{};
9838 get_number(input_format_t::cbor, subtype_to_ignore);
9843 std::uint64_t subtype_to_ignore{};
9844 get_number(input_format_t::cbor, subtype_to_ignore);
9850 return parse_cbor_internal(
true, tag_handler);
9853 case cbor_tag_handler_t::store:
9861 std::uint8_t subtype{};
9862 get_number(input_format_t::cbor, subtype);
9863 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9868 std::uint16_t subtype{};
9869 get_number(input_format_t::cbor, subtype);
9870 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9875 std::uint32_t subtype{};
9876 get_number(input_format_t::cbor, subtype);
9877 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9882 std::uint64_t subtype{};
9883 get_number(input_format_t::cbor, subtype);
9884 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9888 return parse_cbor_internal(
true, tag_handler);
9891 return get_cbor_binary(b) && sax->binary(b);
9901 return sax->boolean(
false);
9904 return sax->boolean(
true);
9911 const auto byte1_raw =
get();
9916 const auto byte2_raw =
get();
9922 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9923 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9933 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9934 const double val = [&half]
9936 const int exp = (half >> 10u) & 0x1Fu;
9937 const unsigned int mant = half & 0x3FFu;
9943 return std::ldexp(mant, -24);
9946 ? std::numeric_limits<double>::infinity()
9947 : std::numeric_limits<double>::quiet_NaN();
9949 return std::ldexp(mant + 1024, exp - 25);
9952 return sax->number_float((half & 0x8000u) != 0
9953 ? static_cast<number_float_t>(-val)
9954 : static_cast<number_float_t>(val),
"");
9960 return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9966 return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9971 auto last_token = get_token_string();
9972 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9973 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10024 return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
10029 std::uint8_t len{};
10030 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10035 std::uint16_t len{};
10036 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10041 std::uint32_t len{};
10042 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10047 std::uint64_t len{};
10048 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10053 while (
get() != 0xFF)
10056 if (!get_cbor_string(chunk))
10060 result.append(chunk);
10067 auto last_token = get_token_string();
10068 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10069 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10120 return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
10125 std::uint8_t len{};
10126 return get_number(input_format_t::cbor, len) &&
10127 get_binary(input_format_t::cbor, len, result);
10132 std::uint16_t len{};
10133 return get_number(input_format_t::cbor, len) &&
10134 get_binary(input_format_t::cbor, len, result);
10139 std::uint32_t len{};
10140 return get_number(input_format_t::cbor, len) &&
10141 get_binary(input_format_t::cbor, len, result);
10146 std::uint64_t len{};
10147 return get_number(input_format_t::cbor, len) &&
10148 get_binary(input_format_t::cbor, len, result);
10153 while (
get() != 0xFF)
10156 if (!get_cbor_binary(chunk))
10160 result.insert(result.end(), chunk.begin(), chunk.end());
10167 auto last_token = get_token_string();
10168 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10169 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));
10188 if (len != static_cast<std::size_t>(-1))
10190 for (std::size_t
i = 0;
i < len; ++
i)
10200 while (
get() != 0xFF)
10209 return sax->end_array();
10229 if (len != static_cast<std::size_t>(-1))
10231 for (std::size_t
i = 0;
i < len; ++
i)
10248 while (
get() != 0xFF)
10264 return sax->end_object();
10279 case std::char_traits<char_type>::eof():
10280 return unexpect_eof(input_format_t::msgpack,
"value");
10411 return sax->number_unsigned(static_cast<number_unsigned_t>(current));
10430 return get_msgpack_object(conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
10449 return get_msgpack_array(conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
10489 return get_msgpack_string(s) && sax->string(s);
10493 return sax->null();
10496 return sax->boolean(
false);
10499 return sax->boolean(
true);
10514 return get_msgpack_binary(b) && sax->binary(b);
10520 return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number),
"");
10526 return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number),
"");
10531 std::uint8_t number{};
10532 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10537 std::uint16_t number{};
10538 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10543 std::uint32_t number{};
10544 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10549 std::uint64_t number{};
10550 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10555 std::int8_t number{};
10556 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10561 std::int16_t number{};
10562 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10567 std::int32_t number{};
10568 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10573 std::int64_t number{};
10574 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10579 std::uint16_t len{};
10580 return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast<std::size_t>(len));
10585 std::uint32_t len{};
10586 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10591 std::uint16_t len{};
10592 return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast<std::size_t>(len));
10597 std::uint32_t len{};
10598 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10634 return sax->number_integer(static_cast<std::int8_t>(current));
10638 auto last_token = get_token_string();
10639 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10640 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10698 return get_string(input_format_t::msgpack, static_cast<unsigned int>(current) & 0x1Fu, result);
10703 std::uint8_t len{};
10704 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10709 std::uint16_t len{};
10710 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10715 std::uint32_t len{};
10716 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10721 auto last_token = get_token_string();
10722 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10723 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10741 auto assign_and_return_true = [&result](std::int8_t subtype)
10743 result.set_subtype(static_cast<std::uint8_t>(subtype));
10751 std::uint8_t len{};
10752 return get_number(input_format_t::msgpack, len) &&
10753 get_binary(input_format_t::msgpack, len, result);
10758 std::uint16_t len{};
10759 return get_number(input_format_t::msgpack, len) &&
10760 get_binary(input_format_t::msgpack, len, result);
10765 std::uint32_t len{};
10766 return get_number(input_format_t::msgpack, len) &&
10767 get_binary(input_format_t::msgpack, len, result);
10772 std::uint8_t len{};
10773 std::int8_t subtype{};
10774 return get_number(input_format_t::msgpack, len) &&
10775 get_number(input_format_t::msgpack, subtype) &&
10776 get_binary(input_format_t::msgpack, len, result) &&
10777 assign_and_return_true(subtype);
10782 std::uint16_t len{};
10783 std::int8_t subtype{};
10784 return get_number(input_format_t::msgpack, len) &&
10785 get_number(input_format_t::msgpack, subtype) &&
10786 get_binary(input_format_t::msgpack, len, result) &&
10787 assign_and_return_true(subtype);
10792 std::uint32_t len{};
10793 std::int8_t subtype{};
10794 return get_number(input_format_t::msgpack, len) &&
10795 get_number(input_format_t::msgpack, subtype) &&
10796 get_binary(input_format_t::msgpack, len, result) &&
10797 assign_and_return_true(subtype);
10802 std::int8_t subtype{};
10803 return get_number(input_format_t::msgpack, subtype) &&
10804 get_binary(input_format_t::msgpack, 1, result) &&
10805 assign_and_return_true(subtype);
10810 std::int8_t subtype{};
10811 return get_number(input_format_t::msgpack, subtype) &&
10812 get_binary(input_format_t::msgpack, 2, result) &&
10813 assign_and_return_true(subtype);
10818 std::int8_t subtype{};
10819 return get_number(input_format_t::msgpack, subtype) &&
10820 get_binary(input_format_t::msgpack, 4, result) &&
10821 assign_and_return_true(subtype);
10826 std::int8_t subtype{};
10827 return get_number(input_format_t::msgpack, subtype) &&
10828 get_binary(input_format_t::msgpack, 8, result) &&
10829 assign_and_return_true(subtype);
10834 std::int8_t subtype{};
10835 return get_number(input_format_t::msgpack, subtype) &&
10836 get_binary(input_format_t::msgpack, 16, result) &&
10837 assign_and_return_true(subtype);
10856 for (std::size_t
i = 0;
i < len; ++
i)
10864 return sax->end_array();
10879 for (std::size_t
i = 0;
i < len; ++
i)
10894 return sax->end_object();
10910 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10943 std::uint8_t len{};
10944 return get_number(input_format, len) && get_string(input_format, len, result);
10950 return get_number(input_format, len) && get_string(input_format, len, result);
10955 std::int16_t len{};
10956 return get_number(input_format, len) && get_string(input_format, len, result);
10961 std::int32_t len{};
10962 return get_number(input_format, len) && get_string(input_format, len, result);
10967 std::int64_t len{};
10968 return get_number(input_format, len) && get_string(input_format, len, result);
10973 if (input_format != input_format_t::bjdata)
10977 std::uint16_t len{};
10978 return get_number(input_format, len) && get_string(input_format, len, result);
10983 if (input_format != input_format_t::bjdata)
10987 std::uint32_t len{};
10988 return get_number(input_format, len) && get_string(input_format, len, result);
10993 if (input_format != input_format_t::bjdata)
10997 std::uint64_t len{};
10998 return get_number(input_format, len) && get_string(input_format, len, result);
11004 auto last_token = get_token_string();
11005 std::string message;
11007 if (input_format != input_format_t::bjdata)
11009 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11013 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11015 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11024 std::pair<std::size_t, char_int_type> size_and_type;
11026 bool no_ndarray =
true;
11033 if (size_and_type.first != npos)
11035 if (size_and_type.second != 0)
11037 if (size_and_type.second !=
'N')
11039 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11045 dim.push_back(dimlen);
11051 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11057 dim.push_back(dimlen);
11063 while (current !=
']')
11069 dim.push_back(dimlen);
11091 prefix = get_ignore_noop();
11098 std::uint8_t number{};
11103 result =
static_cast<std::size_t
>(number);
11109 std::int8_t number{};
11116 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11117 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11119 result =
static_cast<std::size_t
>(number);
11125 std::int16_t number{};
11132 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11133 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11135 result =
static_cast<std::size_t
>(number);
11141 std::int32_t number{};
11148 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11149 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11151 result =
static_cast<std::size_t
>(number);
11157 std::int64_t number{};
11164 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11165 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11167 if (!value_in_range_of<std::size_t>(number))
11169 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11170 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11172 result =
static_cast<std::size_t
>(number);
11178 if (input_format != input_format_t::bjdata)
11182 std::uint16_t number{};
11187 result =
static_cast<std::size_t
>(number);
11193 if (input_format != input_format_t::bjdata)
11197 std::uint32_t number{};
11208 if (input_format != input_format_t::bjdata)
11212 std::uint64_t number{};
11217 if (!value_in_range_of<std::size_t>(number))
11219 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11220 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11228 if (input_format != input_format_t::bjdata)
11234 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));
11236 std::vector<size_t> dim;
11241 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11243 result = dim.at(dim.size() - 1);
11266 if (result == 0 || result == npos)
11268 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));
11276 return sax->end_array();
11285 auto last_token = get_token_string();
11286 std::string message;
11288 if (input_format != input_format_t::bjdata)
11290 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11294 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11296 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11312 result.first = npos;
11314 bool is_ndarray =
false;
11318 if (current ==
'$')
11320 result.second =
get();
11321 if (input_format == input_format_t::bjdata
11322 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
11324 auto last_token = get_token_string();
11325 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11326 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11341 auto last_token = get_token_string();
11342 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11343 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11346 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11347 if (input_format == input_format_t::bjdata && is_ndarray)
11349 if (inside_ndarray)
11351 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11352 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11354 result.second |= (1 << 8);
11359 if (current ==
'#')
11361 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11362 if (input_format == input_format_t::bjdata && is_ndarray)
11364 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11365 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11381 case std::char_traits<char_type>::eof():
11382 return unexpect_eof(input_format,
"value");
11385 return sax->boolean(
true);
11387 return sax->boolean(
false);
11390 return sax->null();
11394 std::uint8_t number{};
11395 return get_number(input_format, number) && sax->number_unsigned(number);
11400 std::int8_t number{};
11401 return get_number(input_format, number) && sax->number_integer(number);
11406 std::int16_t number{};
11407 return get_number(input_format, number) && sax->number_integer(number);
11412 std::int32_t number{};
11413 return get_number(input_format, number) && sax->number_integer(number);
11418 std::int64_t number{};
11419 return get_number(input_format, number) && sax->number_integer(number);
11424 if (input_format != input_format_t::bjdata)
11428 std::uint16_t number{};
11429 return get_number(input_format, number) && sax->number_unsigned(number);
11434 if (input_format != input_format_t::bjdata)
11438 std::uint32_t number{};
11439 return get_number(input_format, number) && sax->number_unsigned(number);
11444 if (input_format != input_format_t::bjdata)
11448 std::uint64_t number{};
11449 return get_number(input_format, number) && sax->number_unsigned(number);
11454 if (input_format != input_format_t::bjdata)
11458 const auto byte1_raw =
get();
11463 const auto byte2_raw =
get();
11469 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11470 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11480 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11481 const double val = [&half]
11483 const int exp = (half >> 10u) & 0x1Fu;
11484 const unsigned int mant = half & 0x3FFu;
11490 return std::ldexp(mant, -24);
11493 ? std::numeric_limits<double>::infinity()
11494 : std::numeric_limits<double>::quiet_NaN();
11496 return std::ldexp(mant + 1024, exp - 25);
11499 return sax->number_float((half & 0x8000u) != 0
11500 ? static_cast<number_float_t>(-val)
11501 : static_cast<number_float_t>(val),
"");
11507 return get_number(input_format, number) && sax->number_float(static_cast<number_float_t>(number),
"");
11513 return get_number(input_format, number) && sax->number_float(static_cast<number_float_t>(number),
"");
11518 return get_ubjson_high_precision_number();
11530 auto last_token = get_token_string();
11531 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11532 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11534 string_t s(1, static_cast<typename string_t::value_type>(current));
11535 return sax->string(s);
11541 return get_ubjson_string(s) && sax->string(s);
11545 return get_ubjson_array();
11548 return get_ubjson_object();
11553 auto last_token = get_token_string();
11554 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));
11562 std::pair<std::size_t, char_int_type> size_and_type;
11571 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11573 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
11574 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)
11576 return p.first < t;
11581 auto last_token = get_token_string();
11582 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11583 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11592 if (size_and_type.second ==
'C')
11594 size_and_type.second =
'U';
11597 key =
"_ArrayData_";
11603 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11611 return (sax->end_array() && sax->end_object());
11614 if (size_and_type.first != npos)
11621 if (size_and_type.second != 0)
11623 if (size_and_type.second !=
'N')
11625 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11636 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11652 while (current !=
']')
11662 return sax->end_array();
11670 std::pair<std::size_t, char_int_type> size_and_type;
11677 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11679 auto last_token = get_token_string();
11680 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11681 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11685 if (size_and_type.first != npos)
11692 if (size_and_type.second != 0)
11694 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11709 for (std::size_t
i = 0;
i < size_and_type.first; ++
i)
11730 while (current !=
'}')
11745 return sax->end_object();
11754 std::size_t size{};
11755 bool no_ndarray =
true;
11756 auto res = get_ubjson_size_value(size, no_ndarray);
11763 std::vector<char> number_vector;
11764 for (std::size_t
i = 0;
i < size; ++
i)
11771 number_vector.push_back(static_cast<char>(current));
11777 const auto result_number = number_lexer.
scan();
11778 const auto number_string = number_lexer.get_token_string();
11779 const auto result_remainder = number_lexer.scan();
11785 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11786 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11789 switch (result_number)
11791 case token_type::value_integer:
11792 return sax->number_integer(number_lexer.get_number_integer());
11793 case token_type::value_unsigned:
11794 return sax->number_unsigned(number_lexer.get_number_unsigned());
11795 case token_type::value_float:
11796 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11797 case token_type::uninitialized:
11798 case token_type::literal_true:
11799 case token_type::literal_false:
11800 case token_type::literal_null:
11801 case token_type::value_string:
11802 case token_type::begin_array:
11803 case token_type::begin_object:
11804 case token_type::end_array:
11805 case token_type::end_object:
11806 case token_type::name_separator:
11807 case token_type::value_separator:
11808 case token_type::parse_error:
11809 case token_type::end_of_input:
11810 case token_type::literal_or_value:
11812 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11813 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11833 return current = ia.get_character();
11845 while (current ==
'N');
11865 template<
typename NumberType,
bool InputIsLittleEndian = false>
11869 std::array<std::uint8_t, sizeof(NumberType)> vec{};
11870 for (std::size_t
i = 0;
i <
sizeof(NumberType); ++
i)
11879 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
11881 vec[
sizeof(NumberType) -
i - 1] = static_cast<std::uint8_t>(current);
11885 vec[
i] =
static_cast<std::uint8_t
>(current);
11890 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11908 template<
typename NumberType>
11910 const NumberType len,
11913 bool success =
true;
11914 for (NumberType
i = 0;
i < len;
i++)
11922 result.push_back(static_cast<typename string_t::value_type>(current));
11941 template<
typename NumberType>
11943 const NumberType len,
11946 bool success =
true;
11947 for (NumberType
i = 0;
i < len;
i++)
11955 result.push_back(static_cast<std::uint8_t>(current));
11970 return sax->parse_error(chars_read,
"<end of file>",
11971 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11981 std::array<char, 3> cr{{}};
11982 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11983 return std::string{cr.data()};
11993 const std::string&
detail,
11994 const std::string& context)
const 11996 std::string error_msg =
"syntax error while parsing ";
12000 case input_format_t::cbor:
12001 error_msg +=
"CBOR";
12004 case input_format_t::msgpack:
12005 error_msg +=
"MessagePack";
12008 case input_format_t::ubjson:
12009 error_msg +=
"UBJSON";
12012 case input_format_t::bson:
12013 error_msg +=
"BSON";
12016 case input_format_t::bjdata:
12017 error_msg +=
"BJData";
12038 std::size_t chars_read = 0;
12050 #define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \ 12051 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') 12053 #define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ 12054 make_array<bjd_type>( \ 12055 bjd_type{'C', "char"}, \ 12056 bjd_type{'D', "double"}, \ 12057 bjd_type{'I', "int16"}, \ 12058 bjd_type{'L', "int64"}, \ 12059 bjd_type{'M', "uint64"}, \ 12060 bjd_type{'U', "uint8"}, \ 12061 bjd_type{'d', "single"}, \ 12062 bjd_type{'i', "int8"}, \ 12063 bjd_type{'l', "int32"}, \ 12064 bjd_type{'m', "uint32"}, \ 12065 bjd_type{'u', "uint16"}) 12078 #undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ 12079 #undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ 12082 #ifndef JSON_HAS_CPP_17 12083 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12107 #include <functional> 12152 template<
typename BasicJsonType>
12161 template<
typename BasicJsonType,
typename InputAdapterType>
12175 const bool allow_exceptions_ =
true,
12176 const bool skip_comments =
false)
12178 , m_lexer(
std::move(adapter), skip_comments)
12179 , allow_exceptions(allow_exceptions_)
12195 void parse(
const bool strict, BasicJsonType& result)
12200 sax_parse_internal(&sdp);
12203 if (
strict && (get_token() != token_type::end_of_input))
12206 m_lexer.get_token_string(),
12207 parse_error::create(101, m_lexer.get_position(),
12208 exception_message(token_type::end_of_input,
"value"),
nullptr));
12214 result = value_t::discarded;
12220 if (result.is_discarded())
12228 sax_parse_internal(&sdp);
12231 if (
strict && (get_token() != token_type::end_of_input))
12234 m_lexer.get_token_string(),
12235 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12241 result = value_t::discarded;
12246 result.assert_invariant();
12258 return sax_parse(&sax_acceptor,
strict);
12261 template<
typename SAX>
12263 bool sax_parse(SAX* sax, const
bool strict = true)
12266 const bool result = sax_parse_internal(sax);
12269 if (result &&
strict && (get_token() != token_type::end_of_input))
12271 return sax->parse_error(m_lexer.get_position(),
12272 m_lexer.get_token_string(),
12273 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12280 template<
typename SAX>
12282 bool sax_parse_internal(SAX* sax)
12286 std::vector<bool> states;
12288 bool skip_to_state_evaluation =
false;
12292 if (!skip_to_state_evaluation)
12295 switch (last_token)
12297 case token_type::begin_object:
12305 if (get_token() == token_type::end_object)
12317 return sax->parse_error(m_lexer.get_position(),
12318 m_lexer.get_token_string(),
12319 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12329 return sax->parse_error(m_lexer.get_position(),
12330 m_lexer.get_token_string(),
12331 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12335 states.push_back(
false);
12342 case token_type::begin_array:
12350 if (get_token() == token_type::end_array)
12360 states.push_back(
true);
12366 case token_type::value_float:
12368 const auto res = m_lexer.get_number_float();
12372 return sax->parse_error(m_lexer.get_position(),
12373 m_lexer.get_token_string(),
12374 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
12385 case token_type::literal_false:
12394 case token_type::literal_null:
12403 case token_type::literal_true:
12412 case token_type::value_integer:
12421 case token_type::value_string:
12430 case token_type::value_unsigned:
12439 case token_type::parse_error:
12442 return sax->parse_error(m_lexer.get_position(),
12443 m_lexer.get_token_string(),
12444 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12447 case token_type::uninitialized:
12448 case token_type::end_array:
12449 case token_type::end_object:
12450 case token_type::name_separator:
12451 case token_type::value_separator:
12452 case token_type::end_of_input:
12453 case token_type::literal_or_value:
12456 return sax->parse_error(m_lexer.get_position(),
12457 m_lexer.get_token_string(),
12458 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12464 skip_to_state_evaluation =
false;
12468 if (states.empty())
12477 if (get_token() == token_type::value_separator)
12498 skip_to_state_evaluation =
true;
12502 return sax->parse_error(m_lexer.get_position(),
12503 m_lexer.get_token_string(),
12504 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12510 if (get_token() == token_type::value_separator)
12515 return sax->parse_error(m_lexer.get_position(),
12516 m_lexer.get_token_string(),
12517 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12528 return sax->parse_error(m_lexer.get_position(),
12529 m_lexer.get_token_string(),
12530 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12552 skip_to_state_evaluation =
true;
12556 return sax->parse_error(m_lexer.get_position(),
12557 m_lexer.get_token_string(),
12558 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12565 return last_token = m_lexer.scan();
12570 std::string error_msg =
"syntax error ";
12572 if (!context.empty())
12574 error_msg +=
concat(
"while parsing ", context,
' ');
12579 if (last_token == token_type::parse_error)
12581 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12582 m_lexer.get_token_string(),
'\'');
12586 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
12589 if (expected != token_type::uninitialized)
12591 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
12605 const bool allow_exceptions =
true;
12674 m_it = begin_value;
12686 return m_it == begin_value;
12692 return m_it == end_value;
12697 return lhs.m_it == rhs.m_it;
12702 return lhs.m_it < rhs.m_it;
12707 auto result = *
this;
12714 return lhs.m_it - rhs.m_it;
12725 auto result = *
this;
12738 auto result = *
this;
12773 typename BasicJsonType::object_t::iterator object_iterator {};
12775 typename BasicJsonType::array_t::iterator array_iterator {};
12794 #include <iterator> 12795 #include <type_traits> 12817 template<
typename IteratorType>
class iteration_proxy;
12818 template<
typename IteratorType>
class iteration_proxy_value;
12836 template<
typename BasicJsonType>
12851 "iter_impl only accepts (const) basic_json");
12853 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12854 && std::is_base_of<std::bidirectional_iterator_tag,
typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value,
12855 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12870 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12871 typename BasicJsonType::const_pointer,
12875 typename std::conditional<std::is_const<BasicJsonType>::value,
12876 typename BasicJsonType::const_reference,
12894 switch (m_object->m_data.m_type)
12896 case value_t::object:
12898 m_it.object_iterator =
typename object_t::iterator();
12902 case value_t::array:
12904 m_it.array_iterator =
typename array_t::iterator();
12908 case value_t::null:
12909 case value_t::string:
12910 case value_t::boolean:
12911 case value_t::number_integer:
12912 case value_t::number_unsigned:
12913 case value_t::number_float:
12914 case value_t::binary:
12915 case value_t::discarded:
12941 : m_object(other.m_object), m_it(other.m_it)
12952 if (&other !=
this)
12954 m_object = other.m_object;
12966 : m_object(other.m_object), m_it(other.m_it)
12977 m_object = other.m_object;
12987 void set_begin() noexcept
12991 switch (m_object->m_data.m_type)
12993 case value_t::object:
12995 m_it.object_iterator = m_object->m_data.m_value.object->begin();
12999 case value_t::array:
13001 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13005 case value_t::null:
13008 m_it.primitive_iterator.set_end();
13012 case value_t::string:
13013 case value_t::boolean:
13014 case value_t::number_integer:
13015 case value_t::number_unsigned:
13016 case value_t::number_float:
13017 case value_t::binary:
13018 case value_t::discarded:
13021 m_it.primitive_iterator.set_begin();
13035 switch (m_object->m_data.m_type)
13037 case value_t::object:
13039 m_it.object_iterator = m_object->m_data.m_value.object->end();
13043 case value_t::array:
13045 m_it.array_iterator = m_object->m_data.m_value.array->end();
13049 case value_t::null:
13050 case value_t::string:
13051 case value_t::boolean:
13052 case value_t::number_integer:
13053 case value_t::number_unsigned:
13054 case value_t::number_float:
13055 case value_t::binary:
13056 case value_t::discarded:
13059 m_it.primitive_iterator.set_end();
13074 switch (m_object->m_data.m_type)
13076 case value_t::object:
13078 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13079 return m_it.object_iterator->second;
13082 case value_t::array:
13084 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13085 return *m_it.array_iterator;
13088 case value_t::null:
13089 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13091 case value_t::string:
13092 case value_t::boolean:
13093 case value_t::number_integer:
13094 case value_t::number_unsigned:
13095 case value_t::number_float:
13096 case value_t::binary:
13097 case value_t::discarded:
13105 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13118 switch (m_object->m_data.m_type)
13120 case value_t::object:
13122 JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end());
13123 return &(m_it.object_iterator->second);
13126 case value_t::array:
13128 JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end());
13129 return &*m_it.array_iterator;
13132 case value_t::null:
13133 case value_t::string:
13134 case value_t::boolean:
13135 case value_t::number_integer:
13136 case value_t::number_unsigned:
13137 case value_t::number_float:
13138 case value_t::binary:
13139 case value_t::discarded:
13147 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13158 auto result = *
this;
13171 switch (m_object->m_data.m_type)
13173 case value_t::object:
13175 std::advance(m_it.object_iterator, 1);
13179 case value_t::array:
13181 std::advance(m_it.array_iterator, 1);
13185 case value_t::null:
13186 case value_t::string:
13187 case value_t::boolean:
13188 case value_t::number_integer:
13189 case value_t::number_unsigned:
13190 case value_t::number_float:
13191 case value_t::binary:
13192 case value_t::discarded:
13195 ++m_it.primitive_iterator;
13209 auto result = *
this;
13222 switch (m_object->m_data.m_type)
13224 case value_t::object:
13226 std::advance(m_it.object_iterator, -1);
13230 case value_t::array:
13232 std::advance(m_it.array_iterator, -1);
13236 case value_t::null:
13237 case value_t::string:
13238 case value_t::boolean:
13239 case value_t::number_integer:
13240 case value_t::number_unsigned:
13241 case value_t::number_float:
13242 case value_t::binary:
13243 case value_t::discarded:
13246 --m_it.primitive_iterator;
13258 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 >
13259 bool operator==(
const IterImpl& other)
const 13264 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13269 switch (m_object->m_data.m_type)
13271 case value_t::object:
13272 return (m_it.object_iterator == other.m_it.object_iterator);
13274 case value_t::array:
13275 return (m_it.array_iterator == other.m_it.array_iterator);
13277 case value_t::null:
13278 case value_t::string:
13279 case value_t::boolean:
13280 case value_t::number_integer:
13281 case value_t::number_unsigned:
13282 case value_t::number_float:
13283 case value_t::binary:
13284 case value_t::discarded:
13286 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
13294 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 >
13295 bool operator!=(
const IterImpl& other)
const 13309 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13314 switch (m_object->m_data.m_type)
13316 case value_t::object:
13317 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
13319 case value_t::array:
13322 case value_t::null:
13323 case value_t::string:
13324 case value_t::boolean:
13325 case value_t::number_integer:
13326 case value_t::number_unsigned:
13327 case value_t::number_float:
13328 case value_t::binary:
13329 case value_t::discarded:
13341 return !other.operator < (*this);
13350 return !operator<=(other);
13370 switch (m_object->m_data.m_type)
13372 case value_t::object:
13373 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13375 case value_t::array:
13377 std::advance(m_it.array_iterator,
i);
13381 case value_t::null:
13382 case value_t::string:
13383 case value_t::boolean:
13384 case value_t::number_integer:
13385 case value_t::number_unsigned:
13386 case value_t::number_float:
13387 case value_t::binary:
13388 case value_t::discarded:
13391 m_it.primitive_iterator +=
i;
13405 return operator+=(-
i);
13414 auto result = *
this;
13436 auto result = *
this;
13449 switch (m_object->m_data.m_type)
13451 case value_t::object:
13452 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13454 case value_t::array:
13457 case value_t::null:
13458 case value_t::string:
13459 case value_t::boolean:
13460 case value_t::number_integer:
13461 case value_t::number_unsigned:
13462 case value_t::number_float:
13463 case value_t::binary:
13464 case value_t::discarded:
13478 switch (m_object->m_data.m_type)
13480 case value_t::object:
13481 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
13483 case value_t::array:
13484 return *std::next(m_it.array_iterator, n);
13486 case value_t::null:
13487 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13489 case value_t::string:
13490 case value_t::boolean:
13491 case value_t::number_integer:
13492 case value_t::number_unsigned:
13493 case value_t::number_float:
13494 case value_t::binary:
13495 case value_t::discarded:
13503 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13512 const typename object_t::key_type&
key()
const 13518 return m_it.object_iterator->first;
13521 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
13530 return operator*();
13557 #include <iterator> 13589 template<
typename Base>
13657 return *(this->operator+(n));
13663 auto it = --this->base();
13670 auto it = --this->base();
13671 return it.operator * ();
13683 #include <type_traits> 13706 std::is_same<T, void>::value,
13725 #include <algorithm> 13731 #endif // JSON_NO_IO 13753 template<
typename RefStringType>
13763 template<
typename T>
13782 : reference_tokens(split(s))
13789 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13806 friend std::ostream& operator<<(std::ostream& o,
const json_pointer& ptr)
13819 reference_tokens.insert(reference_tokens.end(),
13829 push_back(std::move(token));
13885 reference_tokens.pop_back();
13897 return reference_tokens.back();
13904 reference_tokens.push_back(token);
13911 reference_tokens.push_back(std::move(token));
13918 return reference_tokens.empty();
13932 template<
typename BasicJsonType>
13935 using size_type =
typename BasicJsonType::size_type;
13949 const char*
p = s.c_str();
13950 char* p_end =
nullptr;
13952 const unsigned long long res = std::strtoull(
p, &p_end, 10);
13962 if (res >= static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13967 return static_cast<size_type
>(res);
13992 template<
typename BasicJsonType>
13999 for (
const auto& reference_token : reference_tokens)
14001 switch (result->type())
14005 if (reference_token ==
"0")
14008 result = &result->operator[](0);
14013 result = &result->operator[](reference_token);
14021 result = &result->operator[](reference_token);
14028 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14072 template<
typename BasicJsonType>
14075 for (
const auto& reference_token : reference_tokens)
14078 if (ptr->is_null())
14082 std::all_of(reference_token.begin(), reference_token.end(),
14083 [](
const unsigned char x)
14085 return std::isdigit(x);
14089 *ptr = (nums || reference_token ==
"-")
14094 switch (ptr->type())
14099 ptr = &ptr->operator[](reference_token);
14105 if (reference_token ==
"-")
14108 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14113 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14140 template<
typename BasicJsonType>
14143 for (
const auto& reference_token : reference_tokens)
14145 switch (ptr->type())
14150 ptr = &ptr->at(reference_token);
14160 "array index '-' (",
std::to_string(ptr->m_data.m_value.array->size()),
14161 ") is out of range"), ptr));
14165 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14198 template<
typename BasicJsonType>
14201 for (
const auto& reference_token : reference_tokens)
14203 switch (ptr->type())
14208 ptr = &ptr->operator[](reference_token);
14221 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14247 template<
typename BasicJsonType>
14250 for (
const auto& reference_token : reference_tokens)
14252 switch (ptr->type())
14257 ptr = &ptr->at(reference_token);
14267 "array index '-' (",
std::to_string(ptr->m_data.m_value.array->size()),
14268 ") is out of range"), ptr));
14272 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14296 template<
typename BasicJsonType>
14299 for (
const auto& reference_token : reference_tokens)
14301 switch (ptr->type())
14305 if (!ptr->contains(reference_token))
14311 ptr = &ptr->operator[](reference_token);
14322 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14334 for (std::size_t
i = 1;
i < reference_token.size();
i++)
14344 const auto idx = array_index<BasicJsonType>(reference_token);
14345 if (idx >= ptr->size())
14351 ptr = &ptr->operator[](idx);
14387 std::vector<string_t> result;
14390 if (reference_string.empty())
14406 std::size_t slash = reference_string.find_first_of(
'/', 1),
14413 start = (slash == string_t::npos) ? 0 : slash + 1,
14415 slash = reference_string.find_first_of(
'/', start))
14419 auto reference_token = reference_string.substr(start, slash - start);
14422 for (std::size_t pos = reference_token.find_first_of(
'~');
14423 pos != string_t::npos;
14424 pos = reference_token.find_first_of(
'~', pos + 1))
14430 (reference_token[pos + 1] !=
'0' &&
14431 reference_token[pos + 1] !=
'1')))
14439 result.push_back(reference_token);
14453 template<
typename BasicJsonType>
14455 const BasicJsonType& value,
14456 BasicJsonType& result)
14458 switch (value.type())
14462 if (value.m_data.m_value.array->empty())
14465 result[reference_string] =
nullptr;
14470 for (std::size_t
i = 0;
i < value.m_data.m_value.array->size(); ++
i)
14473 value.m_data.m_value.array->operator[](
i), result);
14481 if (value.m_data.m_value.object->empty())
14484 result[reference_string] =
nullptr;
14489 for (
const auto& element : *value.m_data.m_value.object)
14508 result[reference_string] = value;
14524 template<
typename BasicJsonType>
14525 static BasicJsonType
14533 BasicJsonType result;
14536 for (
const auto& element : *value.m_data.m_value.object)
14569 #if JSON_HAS_THREE_WAY_COMPARISON 14570 template<
typename RefStringTypeRhs>
14575 return reference_tokens == rhs.reference_tokens;
14587 template<
typename RefStringTypeRhs>
14590 return reference_tokens <=> rhs.reference_tokens;
14593 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14602 template<
typename RefStringTypeLhs,
typename StringType>
14605 const StringType& rhs);
14609 template<
typename RefStringTypeRhs,
typename StringType>
14611 friend bool operator==(
const StringType& lhs,
14616 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14623 template<
typename RefStringTypeLhs,
typename StringType>
14626 const StringType& rhs);
14630 template<
typename RefStringTypeRhs,
typename StringType>
14632 friend bool operator!=(
const StringType& lhs,
14636 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14638 friend bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
14647 #if !JSON_HAS_THREE_WAY_COMPARISON 14649 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14653 return lhs.reference_tokens == rhs.reference_tokens;
14656 template<
typename RefStringTypeLhs,
14660 const StringType& rhs)
14665 template<
typename RefStringTypeRhs,
14668 inline
bool operator==(const StringType& lhs,
14674 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14678 return !(lhs == rhs);
14681 template<
typename RefStringTypeLhs,
14685 const StringType& rhs)
14687 return !(lhs == rhs);
14690 template<
typename RefStringTypeRhs,
14693 inline
bool operator!=(const StringType& lhs,
14696 return !(lhs == rhs);
14699 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14700 inline bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
14720 #include <initializer_list> 14732 template<
typename BasicJsonType>
14743 : value_ref(&
value)
14747 : owned_value(init)
14752 enable_if_t<std::is_constructible<value_type, Args...>::value,
int> = 0 >
14754 : owned_value(
std::forward<Args>(
args)...)
14766 if (value_ref ==
nullptr)
14768 return std::move(owned_value);
14775 return value_ref ? *value_ref : owned_value;
14812 #include <algorithm> 14838 #include <algorithm> 14840 #include <iterator> 14848 #endif // JSON_NO_IO 14860 virtual void write_character(CharType c) = 0;
14861 virtual void write_characters(
const CharType* s, std::size_t length) = 0;
14872 template<
typename CharType>
14876 template<
typename CharType,
typename AllocatorType = std::allocator<CharType>>
14890 void write_characters(const CharType* s,
std::
size_t length)
override 14892 v.insert(v.end(), s, s + length);
14896 std::vector<CharType, AllocatorType>&
v;
14900 template<
typename CharType>
14915 void write_characters(const CharType* s,
std::
size_t length)
override 14917 stream.write(s, static_cast<std::streamsize>(length));
14923 #endif // JSON_NO_IO 14926 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14940 void write_characters(const CharType* s,
std::
size_t length)
override 14942 str.append(s, length);
14949 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14953 template<
typename AllocatorType = std::allocator<CharType>>
14960 #endif // JSON_NO_IO 14991 template<
typename BasicJsonType,
typename CharType>
15017 case value_t::object:
15019 write_bson_object(*
j.m_data.m_value.object);
15023 case value_t::null:
15024 case value_t::array:
15025 case value_t::string:
15026 case value_t::boolean:
15027 case value_t::number_integer:
15028 case value_t::number_unsigned:
15029 case value_t::number_float:
15030 case value_t::binary:
15031 case value_t::discarded:
15034 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ",
j.type_name()), &
j));
15046 case value_t::null:
15048 oa->write_character(to_char_type(0xF6));
15052 case value_t::boolean:
15054 oa->write_character(
j.m_data.m_value.boolean
15055 ? to_char_type(0xF5)
15056 : to_char_type(0xF4));
15060 case value_t::number_integer:
15062 if (
j.m_data.m_value.number_integer >= 0)
15067 if (
j.m_data.m_value.number_integer <= 0x17)
15069 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_integer));
15071 else if (
j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15073 oa->write_character(to_char_type(0x18));
15074 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_integer));
15076 else if (
j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15078 oa->write_character(to_char_type(0x19));
15079 write_number(static_cast<std::uint16_t>(
j.m_data.m_value.number_integer));
15081 else if (
j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15083 oa->write_character(to_char_type(0x1A));
15084 write_number(static_cast<std::uint32_t>(
j.m_data.m_value.number_integer));
15088 oa->write_character(to_char_type(0x1B));
15089 write_number(static_cast<std::uint64_t>(
j.m_data.m_value.number_integer));
15096 const auto positive_number = -1 -
j.m_data.m_value.number_integer;
15097 if (
j.m_data.m_value.number_integer >= -24)
15099 write_number(static_cast<std::uint8_t>(0x20 + positive_number));
15101 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15103 oa->write_character(to_char_type(0x38));
15104 write_number(static_cast<std::uint8_t>(positive_number));
15106 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15108 oa->write_character(to_char_type(0x39));
15109 write_number(static_cast<std::uint16_t>(positive_number));
15111 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15113 oa->write_character(to_char_type(0x3A));
15114 write_number(static_cast<std::uint32_t>(positive_number));
15118 oa->write_character(to_char_type(0x3B));
15119 write_number(static_cast<std::uint64_t>(positive_number));
15125 case value_t::number_unsigned:
15127 if (
j.m_data.m_value.number_unsigned <= 0x17)
15129 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_unsigned));
15131 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15133 oa->write_character(to_char_type(0x18));
15134 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_unsigned));
15136 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15138 oa->write_character(to_char_type(0x19));
15139 write_number(static_cast<std::uint16_t>(
j.m_data.m_value.number_unsigned));
15141 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15143 oa->write_character(to_char_type(0x1A));
15144 write_number(static_cast<std::uint32_t>(
j.m_data.m_value.number_unsigned));
15148 oa->write_character(to_char_type(0x1B));
15149 write_number(static_cast<std::uint64_t>(
j.m_data.m_value.number_unsigned));
15154 case value_t::number_float:
15156 if (std::isnan(
j.m_data.m_value.number_float))
15159 oa->write_character(to_char_type(0xF9));
15160 oa->write_character(to_char_type(0x7E));
15161 oa->write_character(to_char_type(0x00));
15163 else if (std::isinf(
j.m_data.m_value.number_float))
15166 oa->write_character(to_char_type(0xf9));
15167 oa->write_character(
j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15168 oa->write_character(to_char_type(0x00));
15177 case value_t::string:
15180 const auto N =
j.m_data.m_value.string->size();
15183 write_number(static_cast<std::uint8_t>(0x60 + N));
15185 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15187 oa->write_character(to_char_type(0x78));
15188 write_number(static_cast<std::uint8_t>(N));
15190 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15192 oa->write_character(to_char_type(0x79));
15193 write_number(static_cast<std::uint16_t>(N));
15195 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15197 oa->write_character(to_char_type(0x7A));
15198 write_number(static_cast<std::uint32_t>(N));
15201 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15203 oa->write_character(to_char_type(0x7B));
15204 write_number(static_cast<std::uint64_t>(N));
15209 oa->write_characters(
15210 reinterpret_cast<const CharType*>(
j.m_data.m_value.string->c_str()),
15211 j.m_data.m_value.string->size());
15215 case value_t::array:
15218 const auto N =
j.m_data.m_value.array->size();
15221 write_number(static_cast<std::uint8_t>(0x80 + N));
15223 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15225 oa->write_character(to_char_type(0x98));
15226 write_number(static_cast<std::uint8_t>(N));
15228 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15230 oa->write_character(to_char_type(0x99));
15231 write_number(static_cast<std::uint16_t>(N));
15233 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15235 oa->write_character(to_char_type(0x9A));
15236 write_number(static_cast<std::uint32_t>(N));
15239 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15241 oa->write_character(to_char_type(0x9B));
15242 write_number(static_cast<std::uint64_t>(N));
15247 for (
const auto& el : *
j.m_data.m_value.array)
15254 case value_t::binary:
15256 if (
j.m_data.m_value.binary->has_subtype())
15258 if (
j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15260 write_number(static_cast<std::uint8_t>(0xd8));
15261 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.binary->subtype()));
15263 else if (
j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15265 write_number(static_cast<std::uint8_t>(0xd9));
15266 write_number(static_cast<std::uint16_t>(
j.m_data.m_value.binary->subtype()));
15268 else if (
j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15270 write_number(static_cast<std::uint8_t>(0xda));
15271 write_number(static_cast<std::uint32_t>(
j.m_data.m_value.binary->subtype()));
15273 else if (
j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15275 write_number(static_cast<std::uint8_t>(0xdb));
15276 write_number(static_cast<std::uint64_t>(
j.m_data.m_value.binary->subtype()));
15281 const auto N =
j.m_data.m_value.binary->size();
15284 write_number(static_cast<std::uint8_t>(0x40 + N));
15286 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15288 oa->write_character(to_char_type(0x58));
15289 write_number(static_cast<std::uint8_t>(N));
15291 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15293 oa->write_character(to_char_type(0x59));
15294 write_number(static_cast<std::uint16_t>(N));
15296 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15298 oa->write_character(to_char_type(0x5A));
15299 write_number(static_cast<std::uint32_t>(N));
15302 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15304 oa->write_character(to_char_type(0x5B));
15305 write_number(static_cast<std::uint64_t>(N));
15310 oa->write_characters(
15311 reinterpret_cast<const CharType*>(
j.m_data.m_value.binary->data()),
15317 case value_t::object:
15320 const auto N =
j.m_data.m_value.object->size();
15323 write_number(static_cast<std::uint8_t>(0xA0 + N));
15325 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15327 oa->write_character(to_char_type(0xB8));
15328 write_number(static_cast<std::uint8_t>(N));
15330 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15332 oa->write_character(to_char_type(0xB9));
15333 write_number(static_cast<std::uint16_t>(N));
15335 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15337 oa->write_character(to_char_type(0xBA));
15338 write_number(static_cast<std::uint32_t>(N));
15341 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15343 oa->write_character(to_char_type(0xBB));
15344 write_number(static_cast<std::uint64_t>(N));
15349 for (
const auto& el : *
j.m_data.m_value.object)
15351 write_cbor(el.first);
15352 write_cbor(el.second);
15357 case value_t::discarded:
15370 case value_t::null:
15372 oa->write_character(to_char_type(0xC0));
15376 case value_t::boolean:
15378 oa->write_character(
j.m_data.m_value.boolean
15379 ? to_char_type(0xC3)
15380 : to_char_type(0xC2));
15384 case value_t::number_integer:
15386 if (
j.m_data.m_value.number_integer >= 0)
15391 if (
j.m_data.m_value.number_unsigned < 128)
15394 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_integer));
15396 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15399 oa->write_character(to_char_type(0xCC));
15400 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_integer));
15402 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15405 oa->write_character(to_char_type(0xCD));
15406 write_number(static_cast<std::uint16_t>(
j.m_data.m_value.number_integer));
15408 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15411 oa->write_character(to_char_type(0xCE));
15412 write_number(static_cast<std::uint32_t>(
j.m_data.m_value.number_integer));
15414 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15417 oa->write_character(to_char_type(0xCF));
15418 write_number(static_cast<std::uint64_t>(
j.m_data.m_value.number_integer));
15423 if (
j.m_data.m_value.number_integer >= -32)
15426 write_number(static_cast<std::int8_t>(
j.m_data.m_value.number_integer));
15428 else if (
j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15429 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15432 oa->write_character(to_char_type(0xD0));
15433 write_number(static_cast<std::int8_t>(
j.m_data.m_value.number_integer));
15435 else if (
j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15436 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15439 oa->write_character(to_char_type(0xD1));
15440 write_number(static_cast<std::int16_t>(
j.m_data.m_value.number_integer));
15442 else if (
j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15443 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15446 oa->write_character(to_char_type(0xD2));
15447 write_number(static_cast<std::int32_t>(
j.m_data.m_value.number_integer));
15449 else if (
j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15450 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15453 oa->write_character(to_char_type(0xD3));
15454 write_number(static_cast<std::int64_t>(
j.m_data.m_value.number_integer));
15460 case value_t::number_unsigned:
15462 if (
j.m_data.m_value.number_unsigned < 128)
15465 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_integer));
15467 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15470 oa->write_character(to_char_type(0xCC));
15471 write_number(static_cast<std::uint8_t>(
j.m_data.m_value.number_integer));
15473 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15476 oa->write_character(to_char_type(0xCD));
15477 write_number(static_cast<std::uint16_t>(
j.m_data.m_value.number_integer));
15479 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15482 oa->write_character(to_char_type(0xCE));
15483 write_number(static_cast<std::uint32_t>(
j.m_data.m_value.number_integer));
15485 else if (
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15488 oa->write_character(to_char_type(0xCF));
15489 write_number(static_cast<std::uint64_t>(
j.m_data.m_value.number_integer));
15494 case value_t::number_float:
15500 case value_t::string:
15503 const auto N =
j.m_data.m_value.string->size();
15507 write_number(static_cast<std::uint8_t>(0xA0 | N));
15509 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15512 oa->write_character(to_char_type(0xD9));
15513 write_number(static_cast<std::uint8_t>(N));
15515 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15518 oa->write_character(to_char_type(0xDA));
15519 write_number(static_cast<std::uint16_t>(N));
15521 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15524 oa->write_character(to_char_type(0xDB));
15525 write_number(static_cast<std::uint32_t>(N));
15529 oa->write_characters(
15530 reinterpret_cast<const CharType*>(
j.m_data.m_value.string->c_str()),
15531 j.m_data.m_value.string->size());
15535 case value_t::array:
15538 const auto N =
j.m_data.m_value.array->size();
15542 write_number(static_cast<std::uint8_t>(0x90 | N));
15544 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15547 oa->write_character(to_char_type(0xDC));
15548 write_number(static_cast<std::uint16_t>(N));
15550 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15553 oa->write_character(to_char_type(0xDD));
15554 write_number(static_cast<std::uint32_t>(N));
15558 for (
const auto& el : *
j.m_data.m_value.array)
15565 case value_t::binary:
15569 const bool use_ext =
j.m_data.m_value.binary->has_subtype();
15572 const auto N =
j.m_data.m_value.binary->size();
15573 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15575 std::uint8_t output_type{};
15582 output_type = 0xD4;
15585 output_type = 0xD5;
15588 output_type = 0xD6;
15591 output_type = 0xD7;
15594 output_type = 0xD8;
15597 output_type = 0xC7;
15605 output_type = 0xC4;
15609 oa->write_character(to_char_type(output_type));
15612 write_number(static_cast<std::uint8_t>(N));
15615 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15617 const std::uint8_t output_type = use_ext
15621 oa->write_character(to_char_type(output_type));
15622 write_number(static_cast<std::uint16_t>(N));
15624 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15626 const std::uint8_t output_type = use_ext
15630 oa->write_character(to_char_type(output_type));
15631 write_number(static_cast<std::uint32_t>(N));
15637 write_number(static_cast<std::int8_t>(
j.m_data.m_value.binary->subtype()));
15641 oa->write_characters(
15642 reinterpret_cast<const CharType*>(
j.m_data.m_value.binary->data()),
15648 case value_t::object:
15651 const auto N =
j.m_data.m_value.object->size();
15655 write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
15657 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15660 oa->write_character(to_char_type(0xDE));
15661 write_number(static_cast<std::uint16_t>(N));
15663 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15666 oa->write_character(to_char_type(0xDF));
15667 write_number(static_cast<std::uint32_t>(N));
15671 for (
const auto& el : *
j.m_data.m_value.object)
15673 write_msgpack(el.first);
15674 write_msgpack(el.second);
15679 case value_t::discarded:
15693 const bool use_type,
const bool add_prefix =
true,
15694 const bool use_bjdata =
false)
15698 case value_t::null:
15702 oa->write_character(to_char_type(
'Z'));
15707 case value_t::boolean:
15711 oa->write_character(
j.m_data.m_value.boolean
15712 ? to_char_type(
'T')
15713 : to_char_type(
'F'));
15718 case value_t::number_integer:
15720 write_number_with_ubjson_prefix(
j.m_data.m_value.number_integer, add_prefix, use_bjdata);
15724 case value_t::number_unsigned:
15726 write_number_with_ubjson_prefix(
j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
15730 case value_t::number_float:
15732 write_number_with_ubjson_prefix(
j.m_data.m_value.number_float, add_prefix, use_bjdata);
15736 case value_t::string:
15740 oa->write_character(to_char_type(
'S'));
15742 write_number_with_ubjson_prefix(
j.m_data.m_value.string->size(),
true, use_bjdata);
15743 oa->write_characters(
15744 reinterpret_cast<const CharType*>(
j.m_data.m_value.string->c_str()),
15745 j.m_data.m_value.string->size());
15749 case value_t::array:
15753 oa->write_character(to_char_type(
'['));
15756 bool prefix_required =
true;
15757 if (use_type && !
j.m_data.m_value.array->empty())
15760 const CharType first_prefix = ubjson_prefix(
j.front(), use_bjdata);
15761 const bool same_prefix = std::all_of(
j.begin() + 1,
j.end(),
15762 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15764 return ubjson_prefix(v, use_bjdata) == first_prefix;
15767 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15769 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15771 prefix_required =
false;
15772 oa->write_character(to_char_type(
'$'));
15773 oa->write_character(first_prefix);
15779 oa->write_character(to_char_type(
'#'));
15780 write_number_with_ubjson_prefix(
j.m_data.m_value.array->size(),
true, use_bjdata);
15783 for (
const auto& el : *
j.m_data.m_value.array)
15785 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15790 oa->write_character(to_char_type(
']'));
15796 case value_t::binary:
15800 oa->write_character(to_char_type(
'['));
15803 if (use_type && !
j.m_data.m_value.binary->empty())
15806 oa->write_character(to_char_type(
'$'));
15807 oa->write_character(
'U');
15812 oa->write_character(to_char_type(
'#'));
15813 write_number_with_ubjson_prefix(
j.m_data.m_value.binary->size(),
true, use_bjdata);
15818 oa->write_characters(
15819 reinterpret_cast<const CharType*>(
j.m_data.m_value.binary->data()),
15820 j.m_data.m_value.binary->size());
15824 for (
size_t i = 0;
i <
j.m_data.m_value.binary->size(); ++
i)
15826 oa->write_character(to_char_type(
'U'));
15827 oa->write_character(
j.m_data.m_value.binary->data()[
i]);
15833 oa->write_character(to_char_type(
']'));
15839 case value_t::object:
15841 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())
15843 if (!write_bjdata_ndarray(*
j.m_data.m_value.object, use_count, use_type))
15851 oa->write_character(to_char_type(
'{'));
15854 bool prefix_required =
true;
15855 if (use_type && !
j.m_data.m_value.object->empty())
15858 const CharType first_prefix = ubjson_prefix(
j.front(), use_bjdata);
15859 const bool same_prefix = std::all_of(
j.begin(),
j.end(),
15860 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15862 return ubjson_prefix(v, use_bjdata) == first_prefix;
15865 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15867 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15869 prefix_required =
false;
15870 oa->write_character(to_char_type(
'$'));
15871 oa->write_character(first_prefix);
15877 oa->write_character(to_char_type(
'#'));
15878 write_number_with_ubjson_prefix(
j.m_data.m_value.object->size(),
true, use_bjdata);
15881 for (
const auto& el : *
j.m_data.m_value.object)
15883 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15884 oa->write_characters(
15885 reinterpret_cast<const CharType*>(el.first.c_str()),
15887 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15892 oa->write_character(to_char_type(
'}'));
15898 case value_t::discarded:
15915 const auto it = name.find(static_cast<typename string_t::value_type>(0));
15919 static_cast<void>(
j);
15922 return 1ul + name.size() + 1u;
15929 const std::uint8_t element_type)
15931 oa->write_character(to_char_type(element_type));
15932 oa->write_characters(
15933 reinterpret_cast<const CharType*>(name.c_str()),
15943 write_bson_entry_header(name, 0x08);
15944 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
15951 const double value)
15953 write_bson_entry_header(name, 0x01);
15954 write_number<double>(
value,
true);
15962 return sizeof(std::int32_t) +
value.size() + 1ul;
15971 write_bson_entry_header(name, 0x02);
15973 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15974 oa->write_characters(
15975 reinterpret_cast<const CharType*>(
value.c_str()),
15984 write_bson_entry_header(name, 0x0A);
15992 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
15993 ?
sizeof(std::int32_t)
15994 :
sizeof(std::int64_t);
16001 const std::int64_t value)
16003 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
16005 write_bson_entry_header(name, 0x10);
16006 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
16010 write_bson_entry_header(name, 0x12);
16011 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
16020 return (
value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
16021 ?
sizeof(std::int32_t)
16022 :
sizeof(std::int64_t);
16029 const BasicJsonType&
j)
16031 if (
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
16033 write_bson_entry_header(name, 0x10 );
16034 write_number<std::int32_t>(
static_cast<std::int32_t
>(
j.m_data.m_value.number_unsigned),
true);
16036 else if (
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
16038 write_bson_entry_header(name, 0x12 );
16039 write_number<std::int64_t>(
static_cast<std::int64_t
>(
j.m_data.m_value.number_unsigned),
true);
16043 JSON_THROW(out_of_range::create(407,
concat(
"integer number ",
std::to_string(
j.m_data.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &
j));
16051 const typename BasicJsonType::object_t& value)
16053 write_bson_entry_header(name, 0x03);
16054 write_bson_object(
value);
16062 std::size_t array_index = 0ul;
16064 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)
16066 return result + calc_bson_element_size(
std::to_string(array_index++), el);
16069 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16077 return sizeof(std::int32_t) +
value.size() + 1ul;
16084 const typename BasicJsonType::array_t& value)
16086 write_bson_entry_header(name, 0x04);
16087 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
16089 std::size_t array_index = 0ul;
16091 for (
const auto& el :
value)
16096 oa->write_character(to_char_type(0x00));
16105 write_bson_entry_header(name, 0x05);
16107 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16108 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) : static_cast<std::uint8_t>(0x00));
16110 oa->write_characters(reinterpret_cast<const CharType*>(
value.data()),
value.size());
16118 const BasicJsonType&
j)
16120 const auto header_size = calc_bson_entry_header_size(name,
j);
16123 case value_t::object:
16124 return header_size + calc_bson_object_size(*
j.m_data.m_value.object);
16126 case value_t::array:
16127 return header_size + calc_bson_array_size(*
j.m_data.m_value.array);
16129 case value_t::binary:
16130 return header_size + calc_bson_binary_size(*
j.m_data.m_value.binary);
16132 case value_t::boolean:
16133 return header_size + 1ul;
16135 case value_t::number_float:
16136 return header_size + 8ul;
16138 case value_t::number_integer:
16139 return header_size + calc_bson_integer_size(
j.m_data.m_value.number_integer);
16141 case value_t::number_unsigned:
16142 return header_size + calc_bson_unsigned_size(
j.m_data.m_value.number_unsigned);
16144 case value_t::string:
16145 return header_size + calc_bson_string_size(*
j.m_data.m_value.string);
16147 case value_t::null:
16148 return header_size + 0ul;
16151 case value_t::discarded:
16166 const BasicJsonType&
j)
16170 case value_t::object:
16171 return write_bson_object_entry(name, *
j.m_data.m_value.object);
16173 case value_t::array:
16174 return write_bson_array(name, *
j.m_data.m_value.array);
16176 case value_t::binary:
16177 return write_bson_binary(name, *
j.m_data.m_value.binary);
16179 case value_t::boolean:
16180 return write_bson_boolean(name,
j.m_data.m_value.boolean);
16182 case value_t::number_float:
16183 return write_bson_double(name,
j.m_data.m_value.number_float);
16185 case value_t::number_integer:
16186 return write_bson_integer(name,
j.m_data.m_value.number_integer);
16188 case value_t::number_unsigned:
16189 return write_bson_unsigned(name,
j);
16191 case value_t::string:
16192 return write_bson_string(name, *
j.m_data.m_value.string);
16194 case value_t::null:
16195 return write_bson_null(name);
16198 case value_t::discarded:
16214 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
16215 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
16217 return result += calc_bson_element_size(el.first, el.second);
16220 return sizeof(std::int32_t) + document_size + 1ul;
16229 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
16231 for (
const auto& el :
value)
16233 write_bson_element(el.first, el.second);
16236 oa->write_character(to_char_type(0x00));
16245 return to_char_type(0xFA);
16250 return to_char_type(0xFB);
16259 return to_char_type(0xCA);
16264 return to_char_type(0xCB);
16272 template<
typename NumberType,
typename std::enable_if<
16273 std::is_floating_point<NumberType>::value,
int>
::type = 0>
16275 const bool add_prefix,
16276 const bool use_bjdata)
16280 oa->write_character(get_ubjson_float_prefix(n));
16282 write_number(n, use_bjdata);
16286 template<
typename NumberType,
typename std::enable_if<
16287 std::is_unsigned<NumberType>::value,
int>
::type = 0>
16289 const bool add_prefix,
16290 const bool use_bjdata)
16292 if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
16296 oa->write_character(to_char_type(
'i'));
16298 write_number(static_cast<std::uint8_t>(n), use_bjdata);
16300 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16304 oa->write_character(to_char_type(
'U'));
16306 write_number(static_cast<std::uint8_t>(n), use_bjdata);
16308 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
16312 oa->write_character(to_char_type(
'I'));
16314 write_number(static_cast<std::int16_t>(n), use_bjdata);
16316 else if (use_bjdata && n <= static_cast<uint64_t>((std::numeric_limits<uint16_t>::max)()))
16320 oa->write_character(to_char_type(
'u'));
16322 write_number(static_cast<std::uint16_t>(n), use_bjdata);
16324 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
16328 oa->write_character(to_char_type(
'l'));
16330 write_number(static_cast<std::int32_t>(n), use_bjdata);
16332 else if (use_bjdata && n <= static_cast<uint64_t>((std::numeric_limits<uint32_t>::max)()))
16336 oa->write_character(to_char_type(
'm'));
16338 write_number(static_cast<std::uint32_t>(n), use_bjdata);
16340 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
16344 oa->write_character(to_char_type(
'L'));
16346 write_number(static_cast<std::int64_t>(n), use_bjdata);
16348 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16352 oa->write_character(to_char_type(
'M'));
16354 write_number(static_cast<std::uint64_t>(n), use_bjdata);
16360 oa->write_character(to_char_type(
'H'));
16363 const auto number = BasicJsonType(n).dump();
16364 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16365 for (std::size_t
i = 0;
i < number.size(); ++
i)
16367 oa->write_character(to_char_type(static_cast<std::uint8_t>(number[
i])));
16373 template <
typename NumberType,
typename std::enable_if <
16374 std::is_signed<NumberType>::value&&
16375 !std::is_floating_point<NumberType>::value,
int >
::type = 0 >
16377 const bool add_prefix,
16378 const bool use_bjdata)
16380 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16384 oa->write_character(to_char_type(
'i'));
16386 write_number(static_cast<std::int8_t>(n), use_bjdata);
16388 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)()))
16392 oa->write_character(to_char_type(
'U'));
16394 write_number(static_cast<std::uint8_t>(n), use_bjdata);
16396 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16400 oa->write_character(to_char_type(
'I'));
16402 write_number(static_cast<std::int16_t>(n), use_bjdata);
16404 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)())))
16408 oa->write_character(to_char_type(
'u'));
16410 write_number(static_cast<uint16_t>(n), use_bjdata);
16412 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16416 oa->write_character(to_char_type(
'l'));
16418 write_number(static_cast<std::int32_t>(n), use_bjdata);
16420 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)())))
16424 oa->write_character(to_char_type(
'm'));
16426 write_number(static_cast<uint32_t>(n), use_bjdata);
16428 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16432 oa->write_character(to_char_type(
'L'));
16434 write_number(static_cast<std::int64_t>(n), use_bjdata);
16441 oa->write_character(to_char_type(
'H'));
16444 const auto number = BasicJsonType(n).dump();
16445 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16446 for (std::size_t
i = 0;
i < number.size(); ++
i)
16448 oa->write_character(to_char_type(static_cast<std::uint8_t>(number[
i])));
16461 case value_t::null:
16464 case value_t::boolean:
16465 return j.m_data.m_value.boolean ?
'T' :
'F';
16467 case value_t::number_integer:
16469 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)())
16473 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)())
16477 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)())
16481 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)()))
16485 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)())
16489 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)()))
16493 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)())
16501 case value_t::number_unsigned:
16503 if (
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
16507 if (
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
16511 if (
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
16515 if (use_bjdata &&
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint16_t>::max)()))
16519 if (
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
16523 if (use_bjdata &&
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint32_t>::max)()))
16527 if (
j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
16531 if (use_bjdata &&
j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16539 case value_t::number_float:
16540 return get_ubjson_float_prefix(
j.m_data.m_value.number_float);
16542 case value_t::string:
16545 case value_t::array:
16546 case value_t::binary:
16549 case value_t::object:
16552 case value_t::discarded:
16573 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16574 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16578 auto it = bjdtype.find(static_cast<string_t>(
value.at(
key)));
16579 if (it == bjdtype.end())
16583 CharType dtype = it->second;
16585 key =
"_ArraySize_";
16586 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
16587 for (
const auto& el :
value.at(
key))
16589 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
16592 key =
"_ArrayData_";
16598 oa->write_character(
'[');
16599 oa->write_character(
'$');
16600 oa->write_character(dtype);
16601 oa->write_character(
'#');
16603 key =
"_ArraySize_";
16604 write_ubjson(
value.at(
key), use_count, use_type,
true,
true);
16606 key =
"_ArrayData_";
16607 if (dtype ==
'U' || dtype ==
'C')
16609 for (
const auto& el :
value.at(
key))
16611 write_number(static_cast<std::uint8_t>(el.m_data.m_value.number_unsigned),
true);
16614 else if (dtype ==
'i')
16616 for (
const auto& el :
value.at(
key))
16618 write_number(static_cast<std::int8_t>(el.m_data.m_value.number_integer),
true);
16621 else if (dtype ==
'u')
16623 for (
const auto& el :
value.at(
key))
16625 write_number(static_cast<std::uint16_t>(el.m_data.m_value.number_unsigned),
true);
16628 else if (dtype ==
'I')
16630 for (
const auto& el :
value.at(
key))
16632 write_number(static_cast<std::int16_t>(el.m_data.m_value.number_integer),
true);
16635 else if (dtype ==
'm')
16637 for (
const auto& el :
value.at(
key))
16639 write_number(static_cast<std::uint32_t>(el.m_data.m_value.number_unsigned),
true);
16642 else if (dtype ==
'l')
16644 for (
const auto& el :
value.at(
key))
16646 write_number(static_cast<std::int32_t>(el.m_data.m_value.number_integer),
true);
16649 else if (dtype ==
'M')
16651 for (
const auto& el :
value.at(
key))
16653 write_number(static_cast<std::uint64_t>(el.m_data.m_value.number_unsigned),
true);
16656 else if (dtype ==
'L')
16658 for (
const auto& el :
value.at(
key))
16660 write_number(static_cast<std::int64_t>(el.m_data.m_value.number_integer),
true);
16663 else if (dtype ==
'd')
16665 for (
const auto& el :
value.at(
key))
16667 write_number(static_cast<float>(el.m_data.m_value.number_float),
true);
16670 else if (dtype ==
'D')
16672 for (
const auto& el :
value.at(
key))
16674 write_number(static_cast<double>(el.m_data.m_value.number_float),
true);
16697 template<
typename NumberType>
16701 std::array<CharType, sizeof(NumberType)> vec{};
16702 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16705 if (is_little_endian != OutputIsLittleEndian)
16708 std::reverse(vec.begin(), vec.end());
16711 oa->write_characters(vec.data(),
sizeof(NumberType));
16717 #pragma GCC diagnostic push 16718 #pragma GCC diagnostic ignored "-Wfloat-equal" 16720 if (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
16721 static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
16722 static_cast<double>(static_cast<float>(n)) == static_cast<double>(n))
16725 ? get_cbor_float_prefix(static_cast<float>(n))
16726 : get_msgpack_float_prefix(static_cast<float>(n)));
16727 write_number(static_cast<float>(n));
16732 ? get_cbor_float_prefix(n)
16733 : get_msgpack_float_prefix(n));
16737 #pragma GCC diagnostic pop 16746 template <
typename C = CharType,
16750 return *
reinterpret_cast<char*
>(&x);
16753 template <
typename C = CharType,
16757 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16758 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16760 std::memcpy(&result, &x,
sizeof(x));
16764 template<
typename C = CharType,
16771 template <
typename InputCharType,
typename C = CharType,
16773 std::is_signed<C>::value &&
16774 std::is_signed<char>::value &&
16807 #include <algorithm> 16817 #include <type_traits> 16837 #include <type_traits> 16865 namespace dtoa_impl
16868 template<
typename Target,
typename Source>
16871 static_assert(
sizeof(
Target) ==
sizeof(Source),
"size mismatch");
16874 std::memcpy(&target, &source,
sizeof(Source));
16880 static constexpr
int kPrecision = 64;
16882 std::uint64_t f = 0;
16885 constexpr
diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
16896 return {x.f - y.f, x.e};
16905 static_assert(kPrecision == 64,
"internal error");
16930 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
16931 const std::uint64_t u_hi = x.f >> 32u;
16932 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
16933 const std::uint64_t v_hi = y.f >> 32u;
16935 const std::uint64_t p0 = u_lo * v_lo;
16936 const std::uint64_t p1 = u_lo * v_hi;
16937 const std::uint64_t p2 = u_hi * v_lo;
16938 const std::uint64_t p3 = u_hi * v_hi;
16940 const std::uint64_t p0_hi = p0 >> 32u;
16941 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
16942 const std::uint64_t p1_hi = p1 >> 32u;
16943 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
16944 const std::uint64_t p2_hi = p2 >> 32u;
16946 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16957 Q += std::uint64_t{1} << (64u - 32u - 1u);
16959 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16961 return {h, x.e + y.e + 64};
16972 while ((x.f >> 63u) == 0)
16987 const int delta = x.
e - target_exponent;
16992 return {x.f << delta, target_exponent};
17009 template<
typename FloatType>
17022 static_assert(std::numeric_limits<FloatType>::is_iec559,
17023 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17025 constexpr
int kPrecision = std::numeric_limits<FloatType>::digits;
17026 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17027 constexpr
int kMinExp = 1 - kBias;
17028 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17032 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
17033 const std::uint64_t E = bits >> (kPrecision - 1);
17034 const std::uint64_t F = bits & (kHiddenBit - 1);
17036 const bool is_denormal = E == 0;
17037 const diyfp v = is_denormal
17038 ?
diyfp(F, kMinExp)
17039 :
diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
17062 const bool lower_boundary_is_closer = F == 0 && E > 1;
17064 const diyfp m_minus = lower_boundary_is_closer
17065 ?
diyfp(4 * v.
f - 1, v.
e - 2)
17066 :
diyfp(2 * v.
f - 1, v.
e - 1);
17069 const diyfp w_plus = diyfp::normalize(m_plus);
17072 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
17074 return {diyfp::normalize(v), w_minus, w_plus};
17201 constexpr
int kCachedPowersMinDecExp = -300;
17202 constexpr
int kCachedPowersDecStep = 8;
17204 static constexpr std::array<cached_power, 79> kCachedPowers =
17207 { 0xAB70FE17C79AC6CA, -1060, -300 },
17208 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17209 { 0xBE5691EF416BD60C, -1007, -284 },
17210 { 0x8DD01FAD907FFC3C, -980, -276 },
17211 { 0xD3515C2831559A83, -954, -268 },
17212 { 0x9D71AC8FADA6C9B5, -927, -260 },
17213 { 0xEA9C227723EE8BCB, -901, -252 },
17214 { 0xAECC49914078536D, -874, -244 },
17215 { 0x823C12795DB6CE57, -847, -236 },
17216 { 0xC21094364DFB5637, -821, -228 },
17217 { 0x9096EA6F3848984F, -794, -220 },
17218 { 0xD77485CB25823AC7, -768, -212 },
17219 { 0xA086CFCD97BF97F4, -741, -204 },
17220 { 0xEF340A98172AACE5, -715, -196 },
17221 { 0xB23867FB2A35B28E, -688, -188 },
17222 { 0x84C8D4DFD2C63F3B, -661, -180 },
17223 { 0xC5DD44271AD3CDBA, -635, -172 },
17224 { 0x936B9FCEBB25C996, -608, -164 },
17225 { 0xDBAC6C247D62A584, -582, -156 },
17226 { 0xA3AB66580D5FDAF6, -555, -148 },
17227 { 0xF3E2F893DEC3F126, -529, -140 },
17228 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17229 { 0x87625F056C7C4A8B, -475, -124 },
17230 { 0xC9BCFF6034C13053, -449, -116 },
17231 { 0x964E858C91BA2655, -422, -108 },
17232 { 0xDFF9772470297EBD, -396, -100 },
17233 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17234 { 0xF8A95FCF88747D94, -343, -84 },
17235 { 0xB94470938FA89BCF, -316, -76 },
17236 { 0x8A08F0F8BF0F156B, -289, -68 },
17237 { 0xCDB02555653131B6, -263, -60 },
17238 { 0x993FE2C6D07B7FAC, -236, -52 },
17239 { 0xE45C10C42A2B3B06, -210, -44 },
17240 { 0xAA242499697392D3, -183, -36 },
17241 { 0xFD87B5F28300CA0E, -157, -28 },
17242 { 0xBCE5086492111AEB, -130, -20 },
17243 { 0x8CBCCC096F5088CC, -103, -12 },
17244 { 0xD1B71758E219652C, -77, -4 },
17245 { 0x9C40000000000000, -50, 4 },
17246 { 0xE8D4A51000000000, -24, 12 },
17247 { 0xAD78EBC5AC620000, 3, 20 },
17248 { 0x813F3978F8940984, 30, 28 },
17249 { 0xC097CE7BC90715B3, 56, 36 },
17250 { 0x8F7E32CE7BEA5C70, 83, 44 },
17251 { 0xD5D238A4ABE98068, 109, 52 },
17252 { 0x9F4F2726179A2245, 136, 60 },
17253 { 0xED63A231D4C4FB27, 162, 68 },
17254 { 0xB0DE65388CC8ADA8, 189, 76 },
17255 { 0x83C7088E1AAB65DB, 216, 84 },
17256 { 0xC45D1DF942711D9A, 242, 92 },
17257 { 0x924D692CA61BE758, 269, 100 },
17258 { 0xDA01EE641A708DEA, 295, 108 },
17259 { 0xA26DA3999AEF774A, 322, 116 },
17260 { 0xF209787BB47D6B85, 348, 124 },
17261 { 0xB454E4A179DD1877, 375, 132 },
17262 { 0x865B86925B9BC5C2, 402, 140 },
17263 { 0xC83553C5C8965D3D, 428, 148 },
17264 { 0x952AB45CFA97A0B3, 455, 156 },
17265 { 0xDE469FBD99A05FE3, 481, 164 },
17266 { 0xA59BC234DB398C25, 508, 172 },
17267 { 0xF6C69A72A3989F5C, 534, 180 },
17268 { 0xB7DCBF5354E9BECE, 561, 188 },
17269 { 0x88FCF317F22241E2, 588, 196 },
17270 { 0xCC20CE9BD35C78A5, 614, 204 },
17271 { 0x98165AF37B2153DF, 641, 212 },
17272 { 0xE2A0B5DC971F303A, 667, 220 },
17273 { 0xA8D9D1535CE3B396, 694, 228 },
17274 { 0xFB9B7CD9A4A7443C, 720, 236 },
17275 { 0xBB764C4CA7A44410, 747, 244 },
17276 { 0x8BAB8EEFB6409C1A, 774, 252 },
17277 { 0xD01FEF10A657842C, 800, 260 },
17278 { 0x9B10A4E5E9913129, 827, 268 },
17279 { 0xE7109BFBA19C0C9D, 853, 276 },
17280 { 0xAC2820D9623BF429, 880, 284 },
17281 { 0x80444B5E7AA7CF85, 907, 292 },
17282 { 0xBF21E44003ACDD2D, 933, 300 },
17283 { 0x8E679C2F5E44FF8F, 960, 308 },
17284 { 0xD433179D9C8CB841, 986, 316 },
17285 { 0x9E19DB92B4E31BA9, 1013, 324 },
17295 const int f =
kAlpha - e - 1;
17296 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
17298 const int index = (-kCachedPowersMinDecExp +
k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17300 JSON_ASSERT(static_cast<std::size_t>(index) < kCachedPowers.size());
17302 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
17316 if (n >= 1000000000)
17318 pow10 = 1000000000;
17322 if (n >= 100000000)
17367 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17368 std::uint64_t rest, std::uint64_t ten_k)
17395 && delta - rest >= ten_k
17396 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17411 static_assert(
kAlpha >= -60,
"internal error");
17412 static_assert(
kGamma <= -32,
"internal error");
17429 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
17430 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
17439 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
17441 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
17442 std::uint64_t p2 = M_plus.
f & (one.f - 1);
17450 std::uint32_t pow10{};
17478 const std::uint32_t d = p1 / pow10;
17479 const std::uint32_t r = p1 % pow10;
17485 buffer[length++] =
static_cast<char>(
'0' + d);
17504 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17509 decimal_exponent += n;
17520 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17521 grisu2_round(buffer, length, dist, delta, rest, ten_n);
17582 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17584 const std::uint64_t d = p2 >> -one.e;
17585 const std::uint64_t r = p2 & (one.f - 1);
17592 buffer[length++] =
static_cast<char>(
'0' + d);
17617 decimal_exponent -= m;
17625 const std::uint64_t ten_m = one.f;
17649 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17666 const diyfp c_minus_k(cached.
f, cached.
e);
17669 const diyfp w = diyfp::mul(v, c_minus_k);
17670 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
17671 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
17694 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17695 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
17697 decimal_exponent = -cached.
k;
17707 template<
typename FloatType>
17709 void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
17711 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
17712 "internal error: not enough precision");
17733 #if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if) 17764 auto k =
static_cast<std::uint32_t
>(e);
17770 *buf++ =
static_cast<char>(
'0' +
k);
17774 *buf++ =
static_cast<char>(
'0' +
k / 10);
17776 *buf++ =
static_cast<char>(
'0' +
k);
17780 *buf++ =
static_cast<char>(
'0' +
k / 100);
17782 *buf++ =
static_cast<char>(
'0' +
k / 10);
17784 *buf++ =
static_cast<char>(
'0' +
k);
17802 int min_exp,
int max_exp)
17808 const int n = len + decimal_exponent;
17814 if (
k <= n && n <= max_exp)
17819 std::memset(buf +
k,
'0', static_cast<size_t>(n) - static_cast<size_t>(
k));
17823 return buf + (
static_cast<size_t>(n) + 2);
17826 if (0 < n && n <= max_exp)
17833 std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(
k) - static_cast<size_t>(n));
17835 return buf + (
static_cast<size_t>(
k) + 1U);
17838 if (min_exp < n && n <= 0)
17843 std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(
k));
17846 std::memset(buf + 2,
'0', static_cast<size_t>(-n));
17847 return buf + (2U +
static_cast<size_t>(-n) + static_cast<size_t>(
k));
17862 std::memmove(buf + 2, buf + 1, static_cast<size_t>(
k) - 1);
17864 buf += 1 +
static_cast<size_t>(
k);
17883 template<
typename FloatType>
17886 char*
to_chars(
char* first, const
char* last, FloatType value)
17888 static_cast<void>(last);
17892 if (std::signbit(
value))
17899 #pragma GCC diagnostic push 17900 #pragma GCC diagnostic ignored "-Wfloat-equal" 17911 #pragma GCC diagnostic pop 17914 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
17921 int decimal_exponent = 0;
17924 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
17927 constexpr
int kMinExp = -4;
17929 constexpr
int kMaxExp = std::numeric_limits<FloatType>::digits10;
17932 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17933 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17972 template<
typename BasicJsonType>
17980 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17981 static constexpr std::uint8_t UTF8_REJECT = 1;
17992 , loc(
std::localeconv())
17993 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
17994 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->decimal_point)))
17995 , indent_char(ichar)
17996 , indent_string(512, indent_char)
17997 , error_handler(error_handler_)
18030 const bool pretty_print,
18031 const bool ensure_ascii,
18032 const unsigned int indent_step,
18033 const unsigned int current_indent = 0)
18035 switch (val.m_data.m_type)
18037 case value_t::object:
18039 if (val.m_data.m_value.object->empty())
18041 o->write_characters(
"{}", 2);
18047 o->write_characters(
"{\n", 2);
18050 const auto new_indent = current_indent + indent_step;
18053 indent_string.resize(indent_string.size() * 2,
' ');
18057 auto i = val.m_data.m_value.object->cbegin();
18058 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++
i)
18060 o->write_characters(indent_string.c_str(), new_indent);
18061 o->write_character(
'\"');
18062 dump_escaped(
i->first, ensure_ascii);
18063 o->write_characters(
"\": ", 3);
18064 dump(
i->second,
true, ensure_ascii, indent_step, new_indent);
18065 o->write_characters(
",\n", 2);
18070 JSON_ASSERT(std::next(
i) == val.m_data.m_value.object->cend());
18071 o->write_characters(indent_string.c_str(), new_indent);
18072 o->write_character(
'\"');
18073 dump_escaped(
i->first, ensure_ascii);
18074 o->write_characters(
"\": ", 3);
18075 dump(
i->second,
true, ensure_ascii, indent_step, new_indent);
18077 o->write_character(
'\n');
18078 o->write_characters(indent_string.c_str(), current_indent);
18079 o->write_character(
'}');
18083 o->write_character(
'{');
18086 auto i = val.m_data.m_value.object->cbegin();
18087 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++
i)
18089 o->write_character(
'\"');
18090 dump_escaped(
i->first, ensure_ascii);
18091 o->write_characters(
"\":", 2);
18092 dump(
i->second,
false, ensure_ascii, indent_step, current_indent);
18093 o->write_character(
',');
18098 JSON_ASSERT(std::next(
i) == val.m_data.m_value.object->cend());
18099 o->write_character(
'\"');
18100 dump_escaped(
i->first, ensure_ascii);
18101 o->write_characters(
"\":", 2);
18102 dump(
i->second,
false, ensure_ascii, indent_step, current_indent);
18104 o->write_character(
'}');
18110 case value_t::array:
18112 if (val.m_data.m_value.array->empty())
18114 o->write_characters(
"[]", 2);
18120 o->write_characters(
"[\n", 2);
18123 const auto new_indent = current_indent + indent_step;
18126 indent_string.resize(indent_string.size() * 2,
' ');
18130 for (
auto i = val.m_data.m_value.array->cbegin();
18131 i != val.m_data.m_value.array->cend() - 1; ++
i)
18133 o->write_characters(indent_string.c_str(), new_indent);
18134 dump(*
i,
true, ensure_ascii, indent_step, new_indent);
18135 o->write_characters(
",\n", 2);
18140 o->write_characters(indent_string.c_str(), new_indent);
18141 dump(val.m_data.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
18143 o->write_character(
'\n');
18144 o->write_characters(indent_string.c_str(), current_indent);
18145 o->write_character(
']');
18149 o->write_character(
'[');
18152 for (
auto i = val.m_data.m_value.array->cbegin();
18153 i != val.m_data.m_value.array->cend() - 1; ++
i)
18155 dump(*
i,
false, ensure_ascii, indent_step, current_indent);
18156 o->write_character(
',');
18161 dump(val.m_data.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
18163 o->write_character(
']');
18169 case value_t::string:
18171 o->write_character(
'\"');
18172 dump_escaped(*val.m_data.m_value.string, ensure_ascii);
18173 o->write_character(
'\"');
18177 case value_t::binary:
18181 o->write_characters(
"{\n", 2);
18184 const auto new_indent = current_indent + indent_step;
18187 indent_string.resize(indent_string.size() * 2,
' ');
18190 o->write_characters(indent_string.c_str(), new_indent);
18192 o->write_characters(
"\"bytes\": [", 10);
18194 if (!val.m_data.m_value.binary->empty())
18196 for (
auto i = val.m_data.m_value.binary->cbegin();
18197 i != val.m_data.m_value.binary->cend() - 1; ++
i)
18200 o->write_characters(
", ", 2);
18202 dump_integer(val.m_data.m_value.binary->back());
18205 o->write_characters(
"],\n", 3);
18206 o->write_characters(indent_string.c_str(), new_indent);
18208 o->write_characters(
"\"subtype\": ", 11);
18209 if (val.m_data.m_value.binary->has_subtype())
18211 dump_integer(val.m_data.m_value.binary->subtype());
18215 o->write_characters(
"null", 4);
18217 o->write_character(
'\n');
18218 o->write_characters(indent_string.c_str(), current_indent);
18219 o->write_character(
'}');
18223 o->write_characters(
"{\"bytes\":[", 10);
18225 if (!val.m_data.m_value.binary->empty())
18227 for (
auto i = val.m_data.m_value.binary->cbegin();
18228 i != val.m_data.m_value.binary->cend() - 1; ++
i)
18231 o->write_character(
',');
18233 dump_integer(val.m_data.m_value.binary->back());
18236 o->write_characters(
"],\"subtype\":", 12);
18237 if (val.m_data.m_value.binary->has_subtype())
18239 dump_integer(val.m_data.m_value.binary->subtype());
18240 o->write_character(
'}');
18244 o->write_characters(
"null}", 5);
18250 case value_t::boolean:
18252 if (val.m_data.m_value.boolean)
18254 o->write_characters(
"true", 4);
18258 o->write_characters(
"false", 5);
18263 case value_t::number_integer:
18265 dump_integer(val.m_data.m_value.number_integer);
18269 case value_t::number_unsigned:
18271 dump_integer(val.m_data.m_value.number_unsigned);
18275 case value_t::number_float:
18277 dump_float(val.m_data.m_value.number_float);
18281 case value_t::discarded:
18283 o->write_characters(
"<discarded>", 11);
18287 case value_t::null:
18289 o->write_characters(
"null", 4);
18313 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
18315 std::uint32_t codepoint{};
18316 std::uint8_t state = UTF8_ACCEPT;
18317 std::size_t bytes = 0;
18320 std::size_t bytes_after_last_accept = 0;
18321 std::size_t undumped_chars = 0;
18323 for (std::size_t
i = 0;
i < s.size(); ++
i)
18325 const auto byte =
static_cast<std::uint8_t
>(s[
i]);
18327 switch (decode(state, codepoint, byte))
18335 string_buffer[bytes++] =
'\\';
18336 string_buffer[bytes++] =
'b';
18342 string_buffer[bytes++] =
'\\';
18343 string_buffer[bytes++] =
't';
18349 string_buffer[bytes++] =
'\\';
18350 string_buffer[bytes++] =
'n';
18356 string_buffer[bytes++] =
'\\';
18357 string_buffer[bytes++] =
'f';
18363 string_buffer[bytes++] =
'\\';
18364 string_buffer[bytes++] =
'r';
18370 string_buffer[bytes++] =
'\\';
18371 string_buffer[bytes++] =
'\"';
18377 string_buffer[bytes++] =
'\\';
18378 string_buffer[bytes++] =
'\\';
18386 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
18388 if (codepoint <= 0xFFFF)
18391 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
18392 static_cast<std::uint16_t
>(codepoint)));
18398 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
18399 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18400 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18408 string_buffer[bytes++] = s[
i];
18417 if (string_buffer.size() - bytes < 13)
18419 o->write_characters(string_buffer.data(), bytes);
18424 bytes_after_last_accept = bytes;
18425 undumped_chars = 0;
18431 switch (error_handler)
18433 case error_handler_t::strict:
18438 case error_handler_t::ignore:
18439 case error_handler_t::replace:
18445 if (undumped_chars > 0)
18452 bytes = bytes_after_last_accept;
18454 if (error_handler == error_handler_t::replace)
18459 string_buffer[bytes++] =
'\\';
18460 string_buffer[bytes++] =
'u';
18461 string_buffer[bytes++] =
'f';
18462 string_buffer[bytes++] =
'f';
18463 string_buffer[bytes++] =
'f';
18464 string_buffer[bytes++] =
'd';
18476 if (string_buffer.size() - bytes < 13)
18478 o->write_characters(string_buffer.data(), bytes);
18482 bytes_after_last_accept = bytes;
18485 undumped_chars = 0;
18488 state = UTF8_ACCEPT;
18503 string_buffer[bytes++] = s[
i];
18517 o->write_characters(string_buffer.data(), bytes);
18523 switch (error_handler)
18525 case error_handler_t::strict:
18527 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));
18530 case error_handler_t::ignore:
18533 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18537 case error_handler_t::replace:
18540 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18544 o->write_characters(
"\\ufffd", 6);
18548 o->write_characters(
"\xEF\xBF\xBD", 3);
18570 unsigned int n_digits = 1;
18579 return n_digits + 1;
18583 return n_digits + 2;
18587 return n_digits + 3;
18599 static std::string hex_bytes(std::uint8_t byte)
18601 std::string result =
"FF";
18602 constexpr
const char* nibble_to_hex =
"0123456789ABCDEF";
18603 result[0] = nibble_to_hex[byte / 16];
18604 result[1] = nibble_to_hex[byte % 16];
18609 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18610 bool is_negative_number(NumberType x)
18615 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18616 bool is_negative_number(NumberType )
18631 std::is_integral<NumberType>::value ||
18632 std::is_same<NumberType, number_unsigned_t>::value ||
18633 std::is_same<NumberType, number_integer_t>::value ||
18634 std::is_same<NumberType, binary_char_t>::value,
18636 void dump_integer(NumberType x)
18638 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18641 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18642 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18643 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18644 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18645 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18646 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18647 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18648 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18649 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18650 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18657 o->write_character(
'0');
18662 auto buffer_ptr = number_buffer.begin();
18666 unsigned int n_chars{};
18668 if (is_negative_number(x))
18671 abs_value = remove_sign(static_cast<number_integer_t>(x));
18674 n_chars = 1 + count_digits(abs_value);
18679 n_chars = count_digits(abs_value);
18687 buffer_ptr += n_chars;
18691 while (abs_value >= 100)
18693 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18695 *(--buffer_ptr) = digits_to_99[digits_index][1];
18696 *(--buffer_ptr) = digits_to_99[digits_index][0];
18699 if (abs_value >= 10)
18701 const auto digits_index =
static_cast<unsigned>(abs_value);
18702 *(--buffer_ptr) = digits_to_99[digits_index][1];
18703 *(--buffer_ptr) = digits_to_99[digits_index][0];
18707 *(--buffer_ptr) = static_cast<char>(
'0' + abs_value);
18710 o->write_characters(number_buffer.data(), n_chars);
18724 if (!std::isfinite(x))
18726 o->write_characters(
"null", 4);
18735 static constexpr
bool is_ieee_single_or_double
18736 = (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) ||
18737 (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);
18739 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18744 auto* begin = number_buffer.data();
18747 o->write_characters(begin, static_cast<size_t>(end - begin));
18753 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
18757 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
18762 JSON_ASSERT(static_cast<std::size_t>(len) < number_buffer.size());
18765 if (thousands_sep !=
'\0')
18768 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
18769 std::fill(end, number_buffer.end(),
'\0');
18770 JSON_ASSERT((end - number_buffer.begin()) <= len);
18771 len = (end - number_buffer.begin());
18775 if (decimal_point !=
'\0' && decimal_point !=
'.')
18778 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
18779 if (dec_pos != number_buffer.end())
18785 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
18788 const bool value_is_int_like =
18789 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
18792 return c ==
'.' || c ==
'e';
18795 if (value_is_int_like)
18797 o->write_characters(
".0", 2);
18822 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t byte) noexcept
18824 static const std::array<std::uint8_t, 400> utf8d =
18827 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,
18828 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,
18829 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,
18830 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,
18831 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,
18832 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,
18833 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,
18834 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18835 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18836 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18837 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,
18838 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,
18839 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,
18840 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
18845 const std::uint8_t
type = utf8d[byte];
18847 codep = (state != UTF8_ACCEPT)
18848 ? (byte & 0x3fu) | (codep << 6u)
18849 : (0xFFu >>
type) & (byte);
18851 const std::size_t index = 256u +
static_cast<size_t>(state) * 16u + static_cast<size_t>(
type);
18853 state = utf8d[index];
18879 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18885 output_adapter_t<char> o =
nullptr;
18888 std::array<char, 64> number_buffer{{}};
18891 const std::lconv* loc =
nullptr;
18893 const char thousands_sep =
'\0';
18895 const char decimal_point =
'\0';
18898 std::array<char, 512> string_buffer{{}};
18927 #include <functional> 18928 #include <initializer_list> 18929 #include <iterator> 18931 #include <stdexcept> 18932 #include <type_traits> 18945 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18946 class Allocator = std::allocator<std::pair<const Key, T>>>
18947 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
18951 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18956 #ifdef JSON_HAS_CPP_14 18966 template <
class It>
18969 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
18974 for (
auto it = this->begin(); it != this->end(); ++it)
18976 if (m_compare(it->first,
key))
18978 return {it,
false};
18981 Container::emplace_back(
key, std::forward<T>(t));
18982 return {std::prev(this->end()),
true};
18989 for (
auto it = this->begin(); it != this->end(); ++it)
18991 if (m_compare(it->first,
key))
18993 return {it,
false};
18996 Container::emplace_back(std::forward<KeyType>(
key), std::forward<T>(t));
18997 return {std::prev(this->end()),
true};
19002 return emplace(
key, T{}).first->second;
19009 return emplace(std::forward<KeyType>(
key), T{}).first->second;
19021 return at(std::forward<KeyType>(
key));
19026 for (
auto it = this->begin(); it != this->end(); ++it)
19028 if (m_compare(it->first,
key))
19034 JSON_THROW(std::out_of_range(
"key not found"));
19041 for (
auto it = this->begin(); it != this->end(); ++it)
19043 if (m_compare(it->first,
key))
19049 JSON_THROW(std::out_of_range(
"key not found"));
19054 for (
auto it = this->begin(); it != this->end(); ++it)
19056 if (m_compare(it->first,
key))
19062 JSON_THROW(std::out_of_range(
"key not found"));
19069 for (
auto it = this->begin(); it != this->end(); ++it)
19071 if (m_compare(it->first,
key))
19077 JSON_THROW(std::out_of_range(
"key not found"));
19082 for (
auto it = this->begin(); it != this->end(); ++it)
19084 if (m_compare(it->first,
key))
19087 for (
auto next = it; ++next != this->end(); ++it)
19092 Container::pop_back();
19103 for (
auto it = this->begin(); it != this->end(); ++it)
19105 if (m_compare(it->first,
key))
19108 for (
auto next = it; ++next != this->end(); ++it)
19113 Container::pop_back();
19122 return erase(pos, std::next(pos));
19132 const auto elements_affected = std::distance(first, last);
19133 const auto offset = std::distance(Container::begin(), first);
19155 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
19158 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19166 Container::resize(this->size() - static_cast<size_type>(elements_affected));
19175 return Container::begin() + offset;
19180 for (
auto it = this->begin(); it != this->end(); ++it)
19182 if (m_compare(it->first,
key))
19194 for (
auto it = this->begin(); it != this->end(); ++it)
19196 if (m_compare(it->first,
key))
19206 for (
auto it = this->begin(); it != this->end(); ++it)
19208 if (m_compare(it->first,
key))
19213 return Container::end();
19220 for (
auto it = this->begin(); it != this->end(); ++it)
19222 if (m_compare(it->first,
key))
19227 return Container::end();
19232 for (
auto it = this->begin(); it != this->end(); ++it)
19234 if (m_compare(it->first,
key))
19239 return Container::end();
19244 return emplace(value.first, std::move(value.second));
19249 for (
auto it = this->begin(); it != this->end(); ++it)
19251 if (m_compare(it->first, value.first))
19253 return {it,
false};
19256 Container::push_back(value);
19257 return {--this->end(),
true};
19260 template<
typename InputIt>
19261 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19264 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19267 for (
auto it = first; it != last; ++it)
19280 #if defined(JSON_HAS_CPP_17) 19282 #include <string_view> 19318 friend class ::nlohmann::json_pointer;
19322 template<
typename BasicJsonType,
typename InputType>
19324 friend ::nlohmann::detail::serializer<basic_json>;
19325 template<
typename BasicJsonType>
19326 friend class ::nlohmann::detail::iter_impl;
19327 template<
typename BasicJsonType,
typename CharType>
19328 friend class ::nlohmann::detail::binary_writer;
19329 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19330 friend class ::nlohmann::detail::binary_reader;
19331 template<
typename BasicJsonType>
19332 friend class ::nlohmann::detail::json_sax_dom_parser;
19333 template<
typename BasicJsonType>
19334 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19335 friend class ::nlohmann::detail::exception;
19343 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19345 template<
typename InputAdapterType>
19346 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19347 InputAdapterType adapter,
19349 const bool allow_exceptions =
true,
19350 const bool ignore_comments =
false 19353 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19354 std::move(cb), allow_exceptions, ignore_comments);
19359 template<
typename BasicJsonType>
19361 template<
typename BasicJsonType>
19363 template<
typename Iterator>
19367 template<
typename CharType>
19370 template<
typename InputType>
19372 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19375 using serializer = ::nlohmann::detail::serializer<basic_json>;
19381 template<
typename T,
typename SFINAE>
19438 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19440 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19468 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
19469 result[
"name"] =
"JSON for Modern C++";
19470 result[
"url"] =
"https://github.com/nlohmann/json";
19471 result[
"version"][
"string"] =
19480 result[
"platform"] =
"win32";
19481 #elif defined __linux__ 19482 result[
"platform"] =
"linux";
19483 #elif defined __APPLE__ 19484 result[
"platform"] =
"apple";
19485 #elif defined __unix__ 19486 result[
"platform"] =
"unix";
19488 result[
"platform"] =
"unknown";
19491 #if defined(__ICC) || defined(__INTEL_COMPILER) 19492 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19493 #elif defined(__clang__) 19494 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19495 #elif defined(__GNUC__) || defined(__GNUG__) 19496 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19502 #elif defined(__HP_cc) || defined(__HP_aCC) 19503 result[
"compiler"] =
"hp" 19504 #elif defined(__IBMCPP__) 19505 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19506 #elif defined(_MSC_VER) 19507 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19508 #elif defined(__PGI) 19509 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19510 #elif defined(__SUNPRO_CC) 19511 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19513 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19517 #if defined(_MSVC_LANG) 19519 #elif defined(__cplusplus) 19522 result[
"compiler"][
"c++"] =
"unknown";
19541 #if defined(JSON_HAS_CPP_14) 19544 using default_object_comparator_t = std::less<>;
19551 using object_t = ObjectType<StringType,
19554 AllocatorType<std::pair<
const StringType,
19559 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19583 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19594 template<
typename T,
typename... Args>
19598 AllocatorType<T> alloc;
19599 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19601 auto deleter = [&](T * obj)
19603 AllocatorTraits::deallocate(alloc, obj, 1);
19605 std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19606 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(
args)...);
19608 return obj.release();
19661 json_value() =
default;
19675 case value_t::object:
19677 object = create<object_t>();
19681 case value_t::array:
19683 array = create<array_t>();
19687 case value_t::string:
19689 string = create<string_t>(
"");
19693 case value_t::binary:
19695 binary = create<binary_t>();
19699 case value_t::boolean:
19701 boolean =
static_cast<boolean_t>(
false);
19705 case value_t::number_integer:
19711 case value_t::number_unsigned:
19717 case value_t::number_float:
19723 case value_t::null:
19729 case value_t::discarded:
19735 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.11.2",
nullptr));
19775 (t == value_t::object &&
object ==
nullptr) ||
19776 (t == value_t::array && array ==
nullptr) ||
19777 (t == value_t::string &&
string ==
nullptr) ||
19778 (t == value_t::binary &&
binary ==
nullptr)
19784 if (t == value_t::array || t == value_t::object)
19787 std::vector<basic_json> stack;
19790 if (t == value_t::array)
19792 stack.reserve(array->size());
19793 std::move(array->begin(), array->end(), std::back_inserter(stack));
19797 stack.reserve(object->size());
19798 for (
auto&& it : *
object)
19800 stack.push_back(std::move(it.second));
19804 while (!stack.empty())
19807 basic_json current_item(std::move(stack.back()));
19814 std::move(current_item.
m_data.m_value.array->begin(), current_item.
m_data.m_value.array->end(), std::back_inserter(stack));
19816 current_item.
m_data.m_value.array->clear();
19820 for (
auto&& it : *current_item.
m_data.m_value.object)
19822 stack.push_back(std::move(it.second));
19825 current_item.
m_data.m_value.object->clear();
19835 case value_t::object:
19837 AllocatorType<object_t> alloc;
19838 std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
19839 std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
19843 case value_t::array:
19845 AllocatorType<array_t> alloc;
19846 std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
19847 std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
19851 case value_t::string:
19853 AllocatorType<string_t> alloc;
19854 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
19855 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
19859 case value_t::binary:
19861 AllocatorType<binary_t> alloc;
19862 std::allocator_traits<decltype(alloc)>::destroy(alloc,
binary);
19863 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
binary, 1);
19867 case value_t::null:
19868 case value_t::boolean:
19869 case value_t::number_integer:
19870 case value_t::number_unsigned:
19871 case value_t::number_float:
19872 case value_t::discarded:
19902 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
19903 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
19904 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
19905 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
19907 #if JSON_DIAGNOSTICS 19911 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json &
j)
19913 return j.m_parent ==
this;
19918 static_cast<void>(check_parents);
19923 #if JSON_DIAGNOSTICS 19924 switch (m_data.m_type)
19926 case value_t::array:
19928 for (
auto& element : *m_data.m_value.array)
19930 element.m_parent =
this;
19935 case value_t::object:
19937 for (
auto& element : *m_data.m_value.object)
19939 element.second.m_parent =
this;
19944 case value_t::null:
19945 case value_t::string:
19946 case value_t::boolean:
19947 case value_t::number_integer:
19948 case value_t::number_unsigned:
19949 case value_t::number_float:
19950 case value_t::binary:
19951 case value_t::discarded:
19960 #if JSON_DIAGNOSTICS 19961 for (
typename iterator::difference_type
i = 0;
i < count_set_parents; ++
i)
19963 (it +
i)->m_parent =
this;
19966 static_cast<void>(count_set_parents);
19973 #if JSON_DIAGNOSTICS 19974 if (old_capacity != static_cast<std::size_t>(-1))
19988 #ifdef JSON_HEDLEY_MSVC_VERSION 19989 #pragma warning(push ) 19990 #pragma warning(disable : 4127) // ignore warning to replace if with if constexpr 19997 #ifdef JSON_HEDLEY_MSVC_VERSION 19998 #pragma warning( pop ) 20003 static_cast<void>(
j);
20004 static_cast<void>(old_capacity);
20036 assert_invariant();
20044 assert_invariant();
20049 template <
typename CompatibleType,
20055 std::forward<CompatibleType>(val))))
20059 assert_invariant();
20064 template <
typename BasicJsonType,
20069 using other_boolean_t =
typename BasicJsonType::boolean_t;
20070 using other_number_float_t =
typename BasicJsonType::number_float_t;
20071 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20072 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20073 using other_string_t =
typename BasicJsonType::string_t;
20074 using other_object_t =
typename BasicJsonType::object_t;
20075 using other_array_t =
typename BasicJsonType::array_t;
20076 using other_binary_t =
typename BasicJsonType::binary_t;
20078 switch (val.type())
20080 case value_t::boolean:
20083 case value_t::number_float:
20086 case value_t::number_integer:
20089 case value_t::number_unsigned:
20092 case value_t::string:
20095 case value_t::object:
20098 case value_t::array:
20101 case value_t::binary:
20104 case value_t::null:
20107 case value_t::discarded:
20108 m_data.m_type = value_t::discarded;
20115 assert_invariant();
20121 bool type_deduction =
true,
20122 value_t manual_type = value_t::array)
20126 bool is_an_object = std::all_of(init.begin(), init.end(),
20129 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
20133 if (!type_deduction)
20136 if (manual_type == value_t::array)
20138 is_an_object =
false;
20144 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
20151 m_data.m_type = value_t::object;
20152 m_data.m_value = value_t::object;
20154 for (
auto& element_ref : init)
20156 auto element = element_ref.moved_or_copied();
20157 m_data.m_value.object->emplace(
20158 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
20159 std::move((*element.m_data.m_value.array)[1]));
20165 m_data.m_type = value_t::array;
20166 m_data.m_value.array = create<array_t>(init.begin(), init.end());
20170 assert_invariant();
20179 res.m_data.m_type = value_t::binary;
20180 res.m_data.m_value = init;
20187 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20190 res.m_data.m_type = value_t::binary;
20191 res.m_data.m_value =
binary_t(init, subtype);
20201 res.m_data.m_type = value_t::binary;
20202 res.m_data.m_value = std::move(init);
20209 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
20212 res.m_data.m_type = value_t::binary;
20213 res.m_data.m_value =
binary_t(std::move(init), subtype);
20222 return basic_json(init,
false, value_t::array);
20230 return basic_json(init,
false, value_t::object);
20239 assert_invariant();
20244 template <
class InputIT,
typename std::enable_if <
20245 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
20246 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
20255 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
20259 m_data.m_type = first.m_object->m_data.m_type;
20262 switch (m_data.m_type)
20264 case value_t::boolean:
20265 case value_t::number_float:
20266 case value_t::number_integer:
20267 case value_t::number_unsigned:
20268 case value_t::string:
20271 || !last.m_it.primitive_iterator.is_end()))
20273 JSON_THROW(invalid_iterator::create(204,
"iterators out of range", first.m_object));
20278 case value_t::null:
20279 case value_t::object:
20280 case value_t::array:
20281 case value_t::binary:
20282 case value_t::discarded:
20287 switch (m_data.m_type)
20289 case value_t::number_integer:
20291 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
20295 case value_t::number_unsigned:
20297 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
20301 case value_t::number_float:
20303 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
20307 case value_t::boolean:
20309 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
20313 case value_t::string:
20315 m_data.m_value = *first.m_object->m_data.m_value.string;
20319 case value_t::object:
20321 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
20322 last.m_it.object_iterator);
20326 case value_t::array:
20328 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
20329 last.m_it.array_iterator);
20333 case value_t::binary:
20335 m_data.m_value = *first.m_object->m_data.m_value.binary;
20339 case value_t::null:
20340 case value_t::discarded:
20342 JSON_THROW(invalid_iterator::create(206,
detail::concat(
"cannot construct with iterators from ", first.m_object->type_name()), first.m_object));
20346 assert_invariant();
20354 template<
typename JsonRef,
20356 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
20364 m_data.m_type = other.
m_data.m_type;
20368 switch (m_data.m_type)
20370 case value_t::object:
20372 m_data.m_value = *other.
m_data.m_value.object;
20376 case value_t::array:
20378 m_data.m_value = *other.
m_data.m_value.array;
20382 case value_t::string:
20384 m_data.m_value = *other.
m_data.m_value.string;
20388 case value_t::boolean:
20390 m_data.m_value = other.
m_data.m_value.boolean;
20394 case value_t::number_integer:
20396 m_data.m_value = other.
m_data.m_value.number_integer;
20400 case value_t::number_unsigned:
20402 m_data.m_value = other.
m_data.m_value.number_unsigned;
20406 case value_t::number_float:
20408 m_data.m_value = other.
m_data.m_value.number_float;
20412 case value_t::binary:
20414 m_data.m_value = *other.
m_data.m_value.binary;
20418 case value_t::null:
20419 case value_t::discarded:
20425 assert_invariant();
20432 m_data(std::move(other.m_data))
20435 other.assert_invariant(
false);
20438 other.m_data.m_type = value_t::null;
20439 other.m_data.m_value = {};
20442 assert_invariant();
20448 std::is_nothrow_move_constructible<value_t>::value&&
20449 std::is_nothrow_move_assignable<value_t>::value&&
20450 std::is_nothrow_move_constructible<json_value>::value&&
20451 std::is_nothrow_move_assignable<json_value>::value&&
20452 std::is_nothrow_move_assignable<json_base_class_t>::value
20459 swap(m_data.m_type, other.m_data.m_type);
20460 swap(m_data.m_value, other.m_data.m_value);
20461 json_base_class_t::operator=(std::move(other));
20464 assert_invariant();
20472 assert_invariant(
false);
20489 const char indent_char =
' ',
20490 const bool ensure_ascii =
false,
20498 s.dump(*
this,
true, ensure_ascii, static_cast<unsigned int>(indent));
20502 s.dump(*
this,
false, ensure_ascii, 0);
20512 return m_data.m_type;
20519 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
20526 return is_array() || is_object();
20533 return m_data.m_type == value_t::null;
20540 return m_data.m_type == value_t::boolean;
20547 return is_number_integer() || is_number_float();
20554 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
20561 return m_data.m_type == value_t::number_unsigned;
20568 return m_data.m_type == value_t::number_float;
20575 return m_data.m_type == value_t::object;
20582 return m_data.m_type == value_t::array;
20589 return m_data.m_type == value_t::string;
20596 return m_data.m_type == value_t::binary;
20603 return m_data.m_type == value_t::discarded;
20610 return m_data.m_type;
20625 return m_data.m_value.boolean;
20634 return is_object() ? m_data.m_value.object :
nullptr;
20640 return is_object() ? m_data.m_value.object :
nullptr;
20646 return is_array() ? m_data.m_value.array :
nullptr;
20652 return is_array() ? m_data.m_value.array :
nullptr;
20658 return is_string() ? m_data.m_value.string :
nullptr;
20664 return is_string() ? m_data.m_value.string :
nullptr;
20670 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
20676 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
20682 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
20688 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
20694 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
20700 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
20706 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
20712 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
20718 return is_binary() ? m_data.m_value.binary :
nullptr;
20724 return is_binary() ? m_data.m_value.binary :
nullptr;
20738 template<
typename ReferenceType,
typename ThisType>
20749 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
20759 template<
typename PointerType,
typename std::enable_if<
20760 std::is_pointer<PointerType>::value,
int>
::type = 0>
20764 return get_impl_ptr(static_cast<PointerType>(
nullptr));
20769 template <
typename PointerType,
typename std::enable_if <
20770 std::is_pointer<PointerType>::value&&
20775 return get_impl_ptr(static_cast<PointerType>(
nullptr));
20817 template <
typename ValueType,
20825 auto ret = ValueType();
20860 template <
typename ValueType,
20885 template <
typename BasicJsonType,
20908 template<
typename BasicJsonType,
20910 std::is_same<BasicJsonType, basic_json_t>::value,
20921 template<
typename PointerType,
20923 std::is_pointer<PointerType>::value,
20926 -> decltype(std::declval<const basic_json_t&>().
template get_ptr<PointerType>())
20929 return get_ptr<PointerType>();
20956 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20957 #if defined(JSON_HAS_CPP_14) 20960 auto get()
const noexcept(
20967 static_assert(!std::is_reference<ValueTypeCV>::value,
20968 "get() cannot be used with reference types, you might want to use get_ref()");
20999 template<
typename PointerType,
typename std::enable_if<
21000 std::is_pointer<PointerType>::value,
int>
::type = 0>
21001 auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
21004 return get_ptr<PointerType>();
21009 template <
typename ValueType,
21014 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
21023 template<
typename ValueType,
21034 typename T, std::size_t N,
21035 typename Array = T (&)[N],
21040 std::declval<const basic_json_t&>(), v)))
21048 template<
typename ReferenceType,
typename std::enable_if<
21049 std::is_reference<ReferenceType>::value,
int>
::type = 0>
21053 return get_ref_impl<ReferenceType>(*this);
21058 template <
typename ReferenceType,
typename std::enable_if <
21059 std::is_reference<ReferenceType>::value&&
21064 return get_ref_impl<ReferenceType>(*this);
21096 template <
typename ValueType,
typename std::enable_if <
21104 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) 21107 #if defined(JSON_HAS_CPP_17) 21111 >::value,
int >
::type = 0 >
21115 return get<ValueType>();
21127 return *get_ptr<binary_t*>();
21139 return *get_ptr<const binary_t*>();
21162 return set_parent(m_data.m_value.array->at(idx));
21185 return m_data.m_value.array->at(idx);
21209 auto it = m_data.m_value.object->find(
key);
21210 if (it == m_data.m_value.object->end())
21214 return set_parent(it->second);
21229 auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
21230 if (it == m_data.m_value.object->end())
21234 return set_parent(it->second);
21247 auto it = m_data.m_value.object->find(
key);
21248 if (it == m_data.m_value.object->end())
21267 auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
21268 if (it == m_data.m_value.object->end())
21282 m_data.m_type = value_t::array;
21283 m_data.
m_value.array = create<array_t>();
21284 assert_invariant();
21291 if (idx >= m_data.m_value.array->size())
21293 #if JSON_DIAGNOSTICS 21295 const auto old_size = m_data.m_value.array->size();
21296 const auto old_capacity = m_data.m_value.array->capacity();
21298 m_data.m_value.array->resize(idx + 1);
21300 #if JSON_DIAGNOSTICS 21309 set_parents(begin() + static_cast<typename iterator::difference_type>(old_size), static_cast<typename iterator::difference_type>(idx + 1 - old_size));
21312 assert_invariant();
21315 return m_data.m_value.array->operator[](idx);
21318 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21328 return m_data.
m_value.array->operator[](idx);
21331 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21341 m_data.m_type = value_t::object;
21342 m_data.
m_value.object = create<object_t>();
21343 assert_invariant();
21349 auto result = m_data.m_value.object->emplace(std::move(
key),
nullptr);
21350 return set_parent(result.first->second);
21353 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21368 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21373 template<
typename T>
21376 return operator[](
typename object_t::key_type(
key));
21379 template<
typename T>
21382 return operator[](
typename object_t::key_type(
key));
21394 m_data.m_type = value_t::object;
21395 m_data.
m_value.object = create<object_t>();
21396 assert_invariant();
21402 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
21403 return set_parent(result.first->second);
21406 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21418 auto it = m_data.
m_value.object->find(std::forward<KeyType>(
key));
21423 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21427 template<
typename KeyType>
21431 template<
typename ValueType>
21442 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21443 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const 21449 const auto it = find(
key);
21452 return it->template get<ValueType>();
21455 return default_value;
21467 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21468 ReturnType
value(
const typename object_t::key_type&
key, ValueType && default_value)
const 21474 const auto it = find(
key);
21477 return it->template get<ReturnType>();
21480 return std::forward<ValueType>(default_value);
21491 && is_comparable_with_object_key<KeyType>::value
21493 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21494 ValueType
value(KeyType &&
key,
const ValueType& default_value)
const 21500 const auto it = find(std::forward<KeyType>(
key));
21503 return it->template get<ValueType>();
21506 return default_value;
21518 && is_comparable_with_object_key<KeyType>::value
21520 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21521 ReturnType
value(KeyType &&
key, ValueType && default_value)
const 21527 const auto it = find(std::forward<KeyType>(
key));
21530 return it->template get<ReturnType>();
21533 return std::forward<ValueType>(default_value);
21543 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21552 return ptr.
get_checked(
this).template get<ValueType>();
21556 return default_value;
21568 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21577 return ptr.
get_checked(
this).template get<ReturnType>();
21581 return std::forward<ValueType>(default_value);
21591 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21593 ValueType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr,
const ValueType& default_value)
const 21595 return value(ptr.convert(), default_value);
21602 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21604 ReturnType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const 21606 return value(ptr.convert(), std::forward<ValueType>(default_value));
21644 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21645 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21651 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
21654 IteratorType result = end();
21656 switch (m_data.m_type)
21658 case value_t::boolean:
21659 case value_t::number_float:
21660 case value_t::number_integer:
21661 case value_t::number_unsigned:
21662 case value_t::string:
21663 case value_t::binary:
21667 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
21672 AllocatorType<string_t> alloc;
21673 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string);
21674 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
21675 m_data.m_value.string =
nullptr;
21677 else if (is_binary())
21679 AllocatorType<binary_t> alloc;
21680 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
21681 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
21682 m_data.m_value.binary =
nullptr;
21685 m_data.m_type = value_t::null;
21686 assert_invariant();
21690 case value_t::object:
21692 result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator);
21696 case value_t::array:
21698 result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator);
21702 case value_t::null:
21703 case value_t::discarded:
21714 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21715 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21716 IteratorType
erase(IteratorType first, IteratorType last)
21721 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
21724 IteratorType result = end();
21726 switch (m_data.m_type)
21728 case value_t::boolean:
21729 case value_t::number_float:
21730 case value_t::number_integer:
21731 case value_t::number_unsigned:
21732 case value_t::string:
21733 case value_t::binary:
21736 || !last.m_it.primitive_iterator.is_end()))
21738 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
21743 AllocatorType<string_t> alloc;
21744 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string);
21745 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
21746 m_data.m_value.string =
nullptr;
21748 else if (is_binary())
21750 AllocatorType<binary_t> alloc;
21751 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
21752 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
21753 m_data.m_value.binary =
nullptr;
21756 m_data.m_type = value_t::null;
21757 assert_invariant();
21761 case value_t::object:
21763 result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator,
21764 last.m_it.object_iterator);
21768 case value_t::array:
21770 result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator,
21771 last.m_it.array_iterator);
21775 case value_t::null:
21776 case value_t::discarded:
21795 return m_data.m_value.object->erase(std::forward<KeyType>(
key));
21808 const auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
21809 if (it != m_data.m_value.object->end())
21811 m_data.m_value.object->erase(it);
21825 return erase_internal(
key);
21834 return erase_internal(std::forward<KeyType>(
key));
21849 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
21871 auto result = end();
21875 result.m_it.object_iterator = m_data.m_value.object->find(
key);
21885 auto result = cend();
21889 result.m_it.object_iterator = m_data.m_value.object->find(
key);
21901 auto result = end();
21905 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
21917 auto result = cend();
21921 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(
key));
21932 return is_object() ? m_data.m_value.object->count(
key) : 0;
21942 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(
key)) : 0;
21949 return is_object() && m_data.m_value.object->find(
key) != m_data.m_value.object->end();
21958 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(
key)) != m_data.m_value.object->end();
21968 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
21970 bool contains(
const typename ::nlohmann::json_pointer<BasicJsonType>& ptr)
const 21972 return ptr.contains(
this);
21987 iterator begin() noexcept
21989 iterator result(
this);
21990 result.set_begin();
21996 const_iterator begin() const noexcept
22003 const_iterator cbegin() const noexcept
22005 const_iterator result(
this);
22006 result.set_begin();
22012 iterator end() noexcept
22014 iterator result(
this);
22021 const_iterator end() const noexcept
22028 const_iterator cend() const noexcept
22030 const_iterator result(
this);
22037 reverse_iterator rbegin() noexcept
22039 return reverse_iterator(end());
22044 const_reverse_iterator rbegin() const noexcept
22051 reverse_iterator rend() noexcept
22053 return reverse_iterator(begin());
22058 const_reverse_iterator rend() const noexcept
22065 const_reverse_iterator crbegin() const noexcept
22067 return const_reverse_iterator(cend());
22072 const_reverse_iterator crend() const noexcept
22074 return const_reverse_iterator(cbegin());
22084 static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
22086 return ref.items();
22095 static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
22097 return ref.items();
22102 iteration_proxy<iterator> items() noexcept
22104 return iteration_proxy<iterator>(*this);
22109 iteration_proxy<const_iterator> items() const noexcept
22111 return iteration_proxy<const_iterator>(*this);
22126 bool empty() const noexcept
22128 switch (m_data.m_type)
22130 case value_t::null:
22136 case value_t::array:
22139 return m_data.m_value.array->empty();
22142 case value_t::object:
22145 return m_data.m_value.object->empty();
22148 case value_t::string:
22149 case value_t::boolean:
22150 case value_t::number_integer:
22151 case value_t::number_unsigned:
22152 case value_t::number_float:
22153 case value_t::binary:
22154 case value_t::discarded:
22165 size_type size() const noexcept
22167 switch (m_data.m_type)
22169 case value_t::null:
22175 case value_t::array:
22178 return m_data.m_value.array->size();
22181 case value_t::object:
22184 return m_data.m_value.object->size();
22187 case value_t::string:
22188 case value_t::boolean:
22189 case value_t::number_integer:
22190 case value_t::number_unsigned:
22191 case value_t::number_float:
22192 case value_t::binary:
22193 case value_t::discarded:
22204 size_type max_size() const noexcept
22206 switch (m_data.m_type)
22208 case value_t::array:
22211 return m_data.m_value.array->max_size();
22214 case value_t::object:
22217 return m_data.m_value.object->max_size();
22220 case value_t::null:
22221 case value_t::string:
22222 case value_t::boolean:
22223 case value_t::number_integer:
22224 case value_t::number_unsigned:
22225 case value_t::number_float:
22226 case value_t::binary:
22227 case value_t::discarded:
22248 void clear() noexcept
22250 switch (m_data.m_type)
22252 case value_t::number_integer:
22254 m_data.m_value.number_integer = 0;
22258 case value_t::number_unsigned:
22260 m_data.m_value.number_unsigned = 0;
22264 case value_t::number_float:
22266 m_data.m_value.number_float = 0.0;
22270 case value_t::boolean:
22272 m_data.m_value.boolean =
false;
22276 case value_t::string:
22278 m_data.m_value.string->clear();
22282 case value_t::binary:
22284 m_data.m_value.binary->clear();
22288 case value_t::array:
22290 m_data.m_value.array->clear();
22294 case value_t::object:
22296 m_data.m_value.object->clear();
22300 case value_t::null:
22301 case value_t::discarded:
22320 m_data.m_type = value_t::array;
22321 m_data.m_value = value_t::array;
22322 assert_invariant();
22326 const auto old_capacity = m_data.m_value.array->capacity();
22327 m_data.m_value.array->push_back(std::move(val));
22328 set_parent(m_data.m_value.array->back(), old_capacity);
22336 push_back(std::move(val));
22353 m_data.m_type = value_t::array;
22354 m_data.m_value = value_t::array;
22355 assert_invariant();
22359 const auto old_capacity = m_data.m_value.array->capacity();
22360 m_data.m_value.array->push_back(val);
22361 set_parent(m_data.m_value.array->back(), old_capacity);
22385 m_data.m_type = value_t::object;
22386 m_data.m_value = value_t::object;
22387 assert_invariant();
22391 auto res = m_data.m_value.object->insert(val);
22392 set_parent(res.first->second);
22407 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22410 push_back(
typename object_t::value_type(
22411 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22429 template<
class... Args>
22441 m_data.m_type = value_t::array;
22442 m_data.m_value = value_t::array;
22443 assert_invariant();
22447 const auto old_capacity = m_data.m_value.array->capacity();
22448 m_data.m_value.array->emplace_back(std::forward<Args>(
args)...);
22449 return set_parent(m_data.m_value.array->back(), old_capacity);
22454 template<
class... Args>
22466 m_data.m_type = value_t::object;
22467 m_data.m_value = value_t::object;
22468 assert_invariant();
22472 auto res = m_data.m_value.object->emplace(std::forward<Args>(
args)...);
22473 set_parent(res.first->second);
22477 it.m_it.object_iterator = res.first;
22480 return {it, res.second};
22486 template<
typename... Args>
22492 auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator);
22493 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(
args)...);
22494 result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos;
22514 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22518 return insert_iterator(pos, val);
22528 return insert(pos, val);
22541 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22545 return insert_iterator(pos, cnt, val);
22564 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22570 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22575 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
22579 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22595 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22599 return insert_iterator(pos, ilist.begin(), ilist.end());
22615 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22621 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
22624 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22631 update(
j.begin(),
j.end(), merge_objects);
22641 m_data.m_type = value_t::object;
22642 m_data.m_value.object = create<object_t>();
22643 assert_invariant();
22654 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22660 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
22663 for (
auto it = first; it != last; ++it)
22665 if (merge_objects && it.value().is_object())
22667 auto it2 = m_data.m_value.object->find(it.key());
22668 if (it2 != m_data.m_value.object->end())
22670 it2->second.update(it.value(),
true);
22674 m_data.m_value.object->operator[](it.key()) = it.value();
22675 #if JSON_DIAGNOSTICS 22676 m_data.m_value.object->operator[](it.key()).m_parent =
this;
22684 std::is_nothrow_move_constructible<value_t>::value&&
22685 std::is_nothrow_move_assignable<value_t>::value&&
22686 std::is_nothrow_move_constructible<json_value>::value&&
22687 std::is_nothrow_move_assignable<json_value>::value
22690 std::swap(m_data.m_type, other.m_data.m_type);
22691 std::swap(m_data.m_value, other.m_data.m_value);
22694 other.set_parents();
22695 assert_invariant();
22701 std::is_nothrow_move_constructible<value_t>::value&&
22702 std::is_nothrow_move_assignable<value_t>::value&&
22703 std::is_nothrow_move_constructible<json_value>::value&&
22704 std::is_nothrow_move_assignable<json_value>::value
22718 swap(*(m_data.m_value.array), other);
22734 swap(*(m_data.m_value.object), other);
22750 swap(*(m_data.m_value.string), other);
22766 swap(*(m_data.m_value.binary), other);
22776 void swap(
typename binary_t::container_type& other)
22782 swap(*(m_data.m_value.binary), other);
22786 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
22801 #define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \ 22802 const auto lhs_type = lhs.type(); \ 22803 const auto rhs_type = rhs.type(); \ 22805 if (lhs_type == rhs_type) \ 22807 switch (lhs_type) \ 22809 case value_t::array: \ 22810 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \ 22812 case value_t::object: \ 22813 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \ 22815 case value_t::null: \ 22816 return (null_result); \ 22818 case value_t::string: \ 22819 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \ 22821 case value_t::boolean: \ 22822 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \ 22824 case value_t::number_integer: \ 22825 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \ 22827 case value_t::number_unsigned: \ 22828 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \ 22830 case value_t::number_float: \ 22831 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \ 22833 case value_t::binary: \ 22834 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \ 22836 case value_t::discarded: \ 22838 return (unordered_result); \ 22841 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \ 22843 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \ 22845 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \ 22847 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \ 22849 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \ 22851 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \ 22853 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \ 22855 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \ 22857 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \ 22859 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \ 22861 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \ 22863 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \ 22865 else if(compares_unordered(lhs, rhs))\ 22867 return (unordered_result);\ 22870 return (default_result); 22885 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 22888 static_cast<void>(inverse);
22894 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
22896 return compares_unordered(*
this, rhs, inverse);
22900 #if JSON_HAS_THREE_WAY_COMPARISON 22901 bool operator==(const_reference rhs)
const noexcept
22906 #pragma GCC diagnostic push 22907 #pragma GCC diagnostic ignored "-Wfloat-equal" 22909 const_reference lhs = *
this;
22912 #pragma GCC diagnostic pop 22918 template<
typename ScalarType>
22919 requires std::is_scalar_v<ScalarType>
22920 bool operator==(ScalarType rhs)
const noexcept
22927 bool operator!=(const_reference rhs)
const noexcept
22929 if (compares_unordered(rhs,
true))
22938 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
22940 const_reference lhs = *
this;
22944 std::partial_ordering::equivalent,
22945 std::partial_ordering::unordered,
22946 lhs_type <=> rhs_type)
22951 template<
typename ScalarType>
22952 requires std::is_scalar_v<ScalarType>
22953 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
22958 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 22965 bool operator<=(const_reference rhs)
const noexcept
22967 if (compares_unordered(rhs,
true))
22971 return !(rhs < *
this);
22976 template<
typename ScalarType>
22977 requires std::is_scalar_v<ScalarType>
22978 bool operator<=(ScalarType rhs)
const noexcept
22986 bool operator>=(const_reference rhs)
const noexcept
22988 if (compares_unordered(rhs,
true))
22992 return !(*
this < rhs);
22997 template<
typename ScalarType>
22998 requires std::is_scalar_v<ScalarType>
22999 bool operator>=(ScalarType rhs)
const noexcept
23005 friend bool operator==(const_reference lhs, const_reference rhs) noexcept
23010 #pragma GCC diagnostic push 23011 #pragma GCC diagnostic ignored "-Wfloat-equal" 23015 #pragma GCC diagnostic pop 23021 template<
typename ScalarType,
typename std::enable_if<
23022 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23023 friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
23030 template<
typename ScalarType,
typename std::enable_if<
23031 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23032 friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
23039 friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
23041 if (compares_unordered(lhs, rhs,
true))
23045 return !(lhs == rhs);
23050 template<
typename ScalarType,
typename std::enable_if<
23051 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23052 friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
23059 template<
typename ScalarType,
typename std::enable_if<
23060 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23061 friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
23068 friend bool operator<(const_reference lhs, const_reference rhs) noexcept
23078 template<
typename ScalarType,
typename std::enable_if<
23079 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23080 friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
23087 template<
typename ScalarType,
typename std::enable_if<
23088 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23089 friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
23096 friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
23098 if (compares_unordered(lhs, rhs,
true))
23102 return !(rhs < lhs);
23107 template<
typename ScalarType,
typename std::enable_if<
23108 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23109 friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
23116 template<
typename ScalarType,
typename std::enable_if<
23117 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23118 friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
23125 friend bool operator>(const_reference lhs, const_reference rhs) noexcept
23128 if (compares_unordered(lhs, rhs))
23132 return !(lhs <= rhs);
23137 template<
typename ScalarType,
typename std::enable_if<
23138 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23139 friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
23146 template<
typename ScalarType,
typename std::enable_if<
23147 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23148 friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
23155 friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
23157 if (compares_unordered(lhs, rhs,
true))
23161 return !(lhs < rhs);
23166 template<
typename ScalarType,
typename std::enable_if<
23167 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23168 friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
23175 template<
typename ScalarType,
typename std::enable_if<
23176 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23177 friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
23183 #undef JSON_IMPLEMENT_OPERATOR 23194 friend std::ostream& operator<<(std::ostream& o,
const basic_json&
j)
23199 const bool pretty_print = o.width() > 0;
23200 const auto indentation = pretty_print ? o.width() : 0;
23207 s.
dump(
j, pretty_print,
false, static_cast<unsigned int>(indentation));
23218 friend std::ostream& operator>>(
const basic_json&
j, std::ostream& o)
23222 #endif // JSON_NO_IO 23235 template<
typename InputType>
23239 const bool allow_exceptions =
true,
23240 const bool ignore_comments =
false)
23249 template<
typename IteratorType>
23254 const bool allow_exceptions =
true,
23255 const bool ignore_comments =
false)
23266 const bool allow_exceptions =
true,
23267 const bool ignore_comments =
false)
23270 parser(
i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23276 template<
typename InputType>
23277 static bool accept(InputType&&
i,
23278 const bool ignore_comments =
false)
23285 template<
typename IteratorType>
23286 static bool accept(IteratorType first, IteratorType last,
23287 const bool ignore_comments =
false)
23295 const bool ignore_comments =
false)
23297 return parser(
i.get(),
nullptr,
false, ignore_comments).accept(
true);
23302 template <
typename InputType,
typename SAX>
23304 static
bool sax_parse(InputType&&
i, SAX* sax,
23306 const
bool strict = true,
23307 const
bool ignore_comments = false)
23311 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23317 template<
class IteratorType,
class SAX>
23319 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23321 const
bool strict = true,
23322 const
bool ignore_comments = false)
23326 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23335 template <
typename SAX>
23338 static
bool sax_parse(
detail::span_input_adapter&&
i, SAX* sax,
23340 const
bool strict = true,
23341 const
bool ignore_comments = false)
23346 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23360 return operator>>(
i,
j);
23370 #endif // JSON_NO_IO 23382 switch (m_data.m_type)
23384 case value_t::null:
23386 case value_t::object:
23388 case value_t::array:
23390 case value_t::string:
23392 case value_t::boolean:
23394 case value_t::binary:
23396 case value_t::discarded:
23397 return "discarded";
23398 case value_t::number_integer:
23399 case value_t::number_unsigned:
23400 case value_t::number_float:
23418 json_value m_value = {};
23421 : m_type(v), m_value(v)
23428 m_value.array = create<array_t>(cnt, val);
23432 data(data&&) noexcept =
default;
23433 data(const data&) noexcept = delete;
23434 data& operator=(data&&) noexcept = delete;
23435 data& operator=(const data&) noexcept = delete;
23439 m_value.destroy(m_type);
23445 #if JSON_DIAGNOSTICS 23462 std::vector<std::uint8_t> result;
23463 to_cbor(
j, result);
23485 std::vector<std::uint8_t> result;
23486 to_msgpack(
j, result);
23507 const bool use_size =
false,
23508 const bool use_type =
false)
23510 std::vector<std::uint8_t> result;
23511 to_ubjson(
j, result, use_size, use_type);
23518 const bool use_size =
false,
const bool use_type =
false)
23526 const bool use_size =
false,
const bool use_type =
false)
23534 const bool use_size =
false,
23535 const bool use_type =
false)
23537 std::vector<std::uint8_t> result;
23538 to_bjdata(
j, result, use_size, use_type);
23545 const bool use_size =
false,
const bool use_type =
false)
23553 const bool use_size =
false,
const bool use_type =
false)
23562 std::vector<std::uint8_t> result;
23563 to_bson(
j, result);
23583 template<
typename InputType>
23586 const bool strict =
true,
23587 const bool allow_exceptions =
true,
23593 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23594 return res ? result :
basic_json(value_t::discarded);
23599 template<
typename IteratorType>
23602 const bool strict =
true,
23603 const bool allow_exceptions =
true,
23609 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23610 return res ? result :
basic_json(value_t::discarded);
23613 template<
typename T>
23617 const
bool strict = true,
23618 const
bool allow_exceptions = true,
23621 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23628 const
bool strict = true,
23629 const
bool allow_exceptions = true,
23636 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23637 return res ? result :
basic_json(value_t::discarded);
23642 template<
typename InputType>
23645 const bool strict =
true,
23646 const bool allow_exceptions =
true)
23651 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23652 return res ? result :
basic_json(value_t::discarded);
23657 template<
typename IteratorType>
23660 const bool strict =
true,
23661 const bool allow_exceptions =
true)
23666 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23667 return res ? result :
basic_json(value_t::discarded);
23670 template<
typename T>
23674 const
bool strict = true,
23675 const
bool allow_exceptions = true)
23677 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23683 const
bool strict = true,
23684 const
bool allow_exceptions = true)
23690 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23691 return res ? result :
basic_json(value_t::discarded);
23696 template<
typename InputType>
23699 const bool strict =
true,
23700 const bool allow_exceptions =
true)
23705 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23706 return res ? result :
basic_json(value_t::discarded);
23711 template<
typename IteratorType>
23714 const bool strict =
true,
23715 const bool allow_exceptions =
true)
23720 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23721 return res ? result :
basic_json(value_t::discarded);
23724 template<
typename T>
23728 const
bool strict = true,
23729 const
bool allow_exceptions = true)
23731 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23737 const
bool strict = true,
23738 const
bool allow_exceptions = true)
23744 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23745 return res ? result :
basic_json(value_t::discarded);
23751 template<
typename InputType>
23754 const bool strict =
true,
23755 const bool allow_exceptions =
true)
23760 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23761 return res ? result :
basic_json(value_t::discarded);
23766 template<
typename IteratorType>
23769 const bool strict =
true,
23770 const bool allow_exceptions =
true)
23775 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23776 return res ? result :
basic_json(value_t::discarded);
23781 template<
typename InputType>
23784 const bool strict =
true,
23785 const bool allow_exceptions =
true)
23791 return res ? result :
basic_json(value_t::discarded);
23796 template<
typename IteratorType>
23799 const bool strict =
true,
23800 const bool allow_exceptions =
true)
23806 return res ? result :
basic_json(value_t::discarded);
23809 template<
typename T>
23813 const
bool strict = true,
23814 const
bool allow_exceptions = true)
23816 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23822 const
bool strict = true,
23823 const
bool allow_exceptions = true)
23830 return res ? result :
basic_json(value_t::discarded);
23848 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23850 reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
23852 return ptr.get_unchecked(
this);
23862 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23864 const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const 23866 return ptr.get_unchecked(
this);
23876 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23878 reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
23880 return ptr.get_checked(
this);
23890 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23892 const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const 23894 return ptr.get_checked(
this);
23924 void patch_inplace(
const basic_json& json_patch)
23928 enum class patch_operations {add,
remove,
replace, move, copy, test, invalid};
23930 const auto get_op = [](
const std::string & op)
23934 return patch_operations::add;
23936 if (op ==
"remove")
23938 return patch_operations::remove;
23940 if (op ==
"replace")
23942 return patch_operations::replace;
23946 return patch_operations::move;
23950 return patch_operations::copy;
23954 return patch_operations::test;
23957 return patch_operations::invalid;
23972 if (top_pointer != ptr)
23974 result.
at(top_pointer);
23978 const auto last_path = ptr.
back();
23983 switch (parent.
m_data.m_type)
23985 case value_t::null:
23986 case value_t::object:
23989 parent[last_path] = val;
23993 case value_t::array:
23995 if (last_path ==
"-")
24002 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24010 parent.
insert(parent.begin() +
static_cast<difference_type
>(idx), val);
24016 case value_t::string:
24017 case value_t::boolean:
24018 case value_t::number_integer:
24019 case value_t::number_unsigned:
24020 case value_t::number_float:
24021 case value_t::binary:
24022 case value_t::discarded:
24029 const auto operation_remove = [
this, &result](
json_pointer & ptr)
24032 const auto last_path = ptr.
back();
24040 auto it = parent.
find(last_path);
24053 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24060 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
24064 for (
const auto& val : json_patch)
24067 const auto get_value = [&val](
const std::string & op,
24068 const std::string & member,
24072 auto it = val.
m_data.m_value.object->find(member);
24075 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24088 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
24098 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
24102 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24103 const auto path = get_value(op,
"path",
true).template get<std::string>();
24106 switch (get_op(op))
24108 case patch_operations::add:
24110 operation_add(ptr, get_value(
"add",
"value",
false));
24114 case patch_operations::remove:
24116 operation_remove(ptr);
24120 case patch_operations::replace:
24123 result.
at(ptr) = get_value(
"replace",
"value",
false);
24127 case patch_operations::move:
24129 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24139 operation_remove(from_ptr);
24140 operation_add(ptr, v);
24144 case patch_operations::copy:
24146 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24155 operation_add(ptr, v);
24159 case patch_operations::test:
24161 bool success =
false;
24166 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24182 case patch_operations::invalid:
24198 result.patch_inplace(json_patch);
24206 const std::string& path =
"")
24212 if (source == target)
24217 if (source.
type() != target.
type())
24222 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24227 switch (source.
type())
24229 case value_t::array:
24233 while (
i < source.size() &&
i < target.size())
24237 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
24246 while (
i < source.size())
24250 result.
insert(result.begin() + end_index, object(
24259 while (
i < target.size())
24265 {
"value", target[
i]}
24273 case value_t::object:
24276 for (
auto it = source.cbegin(); it != source.cend(); ++it)
24281 if (target.
find(it.key()) != target.end())
24284 auto temp_diff = diff(it.value(), target[it.key()], path_key);
24285 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
24292 {
"op",
"remove"}, {
"path", path_key}
24298 for (
auto it = target.cbegin(); it != target.cend(); ++it)
24300 if (source.
find(it.key()) == source.end())
24306 {
"op",
"add"}, {
"path", path_key},
24307 {
"value", it.value()}
24315 case value_t::null:
24316 case value_t::string:
24317 case value_t::boolean:
24318 case value_t::number_integer:
24319 case value_t::number_unsigned:
24320 case value_t::number_float:
24321 case value_t::binary:
24322 case value_t::discarded:
24328 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24355 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
24357 if (it.value().is_null())
24363 operator[](it.key()).merge_patch(it.value());
24369 *
this = apply_patch;
24386 inline namespace json_literals
24392 inline nlohmann::
json operator "" _json(const
char* s,
std::
size_t n)
24394 return nlohmann::json::parse(s, s + n);
24402 return nlohmann::json::json_pointer(std::string(s, n));
24438 #if JSON_HAS_THREE_WAY_COMPARISON 24439 return std::is_lt(lhs <=> rhs);
24447 #ifndef JSON_HAS_CPP_20 24453 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24454 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24463 #if JSON_USE_GLOBAL_UDLS 24464 using nlohmann::literals::json_literals::operator
"" _json;
24465 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24480 #if defined(__clang__) 24481 #pragma clang diagnostic pop 24486 #undef JSON_INTERNAL_CATCH 24488 #undef JSON_PRIVATE_UNLESS_TESTED 24489 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION 24490 #undef NLOHMANN_BASIC_JSON_TPL 24491 #undef JSON_EXPLICIT 24492 #undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL 24493 #undef JSON_INLINE_VARIABLE 24494 #undef JSON_NO_UNIQUE_ADDRESS 24495 #undef JSON_DISABLE_ENUM_SERIALIZATION 24496 #undef JSON_USE_GLOBAL_UDLS 24498 #ifndef JSON_TEST_KEEP_MACROS 24501 #undef JSON_HAS_CPP_11 24502 #undef JSON_HAS_CPP_14 24503 #undef JSON_HAS_CPP_17 24504 #undef JSON_HAS_CPP_20 24505 #undef JSON_HAS_FILESYSTEM 24506 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 24507 #undef JSON_HAS_THREE_WAY_COMPARISON 24508 #undef JSON_HAS_RANGES 24509 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 24523 #undef JSON_HEDLEY_ALWAYS_INLINE 24524 #undef JSON_HEDLEY_ARM_VERSION 24525 #undef JSON_HEDLEY_ARM_VERSION_CHECK 24526 #undef JSON_HEDLEY_ARRAY_PARAM 24527 #undef JSON_HEDLEY_ASSUME 24528 #undef JSON_HEDLEY_BEGIN_C_DECLS 24529 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE 24530 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN 24531 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE 24532 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE 24533 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION 24534 #undef JSON_HEDLEY_CLANG_HAS_FEATURE 24535 #undef JSON_HEDLEY_CLANG_HAS_WARNING 24536 #undef JSON_HEDLEY_COMPCERT_VERSION 24537 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK 24538 #undef JSON_HEDLEY_CONCAT 24539 #undef JSON_HEDLEY_CONCAT3 24540 #undef JSON_HEDLEY_CONCAT3_EX 24541 #undef JSON_HEDLEY_CONCAT_EX 24542 #undef JSON_HEDLEY_CONST 24543 #undef JSON_HEDLEY_CONSTEXPR 24544 #undef JSON_HEDLEY_CONST_CAST 24545 #undef JSON_HEDLEY_CPP_CAST 24546 #undef JSON_HEDLEY_CRAY_VERSION 24547 #undef JSON_HEDLEY_CRAY_VERSION_CHECK 24548 #undef JSON_HEDLEY_C_DECL 24549 #undef JSON_HEDLEY_DEPRECATED 24550 #undef JSON_HEDLEY_DEPRECATED_FOR 24551 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 24552 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ 24553 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 24554 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 24555 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 24556 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 24557 #undef JSON_HEDLEY_DIAGNOSTIC_POP 24558 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH 24559 #undef JSON_HEDLEY_DMC_VERSION 24560 #undef JSON_HEDLEY_DMC_VERSION_CHECK 24561 #undef JSON_HEDLEY_EMPTY_BASES 24562 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION 24563 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK 24564 #undef JSON_HEDLEY_END_C_DECLS 24565 #undef JSON_HEDLEY_FLAGS 24566 #undef JSON_HEDLEY_FLAGS_CAST 24567 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE 24568 #undef JSON_HEDLEY_GCC_HAS_BUILTIN 24569 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE 24570 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE 24571 #undef JSON_HEDLEY_GCC_HAS_EXTENSION 24572 #undef JSON_HEDLEY_GCC_HAS_FEATURE 24573 #undef JSON_HEDLEY_GCC_HAS_WARNING 24574 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK 24575 #undef JSON_HEDLEY_GCC_VERSION 24576 #undef JSON_HEDLEY_GCC_VERSION_CHECK 24577 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE 24578 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN 24579 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE 24580 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE 24581 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION 24582 #undef JSON_HEDLEY_GNUC_HAS_FEATURE 24583 #undef JSON_HEDLEY_GNUC_HAS_WARNING 24584 #undef JSON_HEDLEY_GNUC_VERSION 24585 #undef JSON_HEDLEY_GNUC_VERSION_CHECK 24586 #undef JSON_HEDLEY_HAS_ATTRIBUTE 24587 #undef JSON_HEDLEY_HAS_BUILTIN 24588 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE 24589 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS 24590 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE 24591 #undef JSON_HEDLEY_HAS_EXTENSION 24592 #undef JSON_HEDLEY_HAS_FEATURE 24593 #undef JSON_HEDLEY_HAS_WARNING 24594 #undef JSON_HEDLEY_IAR_VERSION 24595 #undef JSON_HEDLEY_IAR_VERSION_CHECK 24596 #undef JSON_HEDLEY_IBM_VERSION 24597 #undef JSON_HEDLEY_IBM_VERSION_CHECK 24598 #undef JSON_HEDLEY_IMPORT 24599 #undef JSON_HEDLEY_INLINE 24600 #undef JSON_HEDLEY_INTEL_CL_VERSION 24601 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK 24602 #undef JSON_HEDLEY_INTEL_VERSION 24603 #undef JSON_HEDLEY_INTEL_VERSION_CHECK 24604 #undef JSON_HEDLEY_IS_CONSTANT 24605 #undef JSON_HEDLEY_IS_CONSTEXPR_ 24606 #undef JSON_HEDLEY_LIKELY 24607 #undef JSON_HEDLEY_MALLOC 24608 #undef JSON_HEDLEY_MCST_LCC_VERSION 24609 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK 24610 #undef JSON_HEDLEY_MESSAGE 24611 #undef JSON_HEDLEY_MSVC_VERSION 24612 #undef JSON_HEDLEY_MSVC_VERSION_CHECK 24613 #undef JSON_HEDLEY_NEVER_INLINE 24614 #undef JSON_HEDLEY_NON_NULL 24615 #undef JSON_HEDLEY_NO_ESCAPE 24616 #undef JSON_HEDLEY_NO_RETURN 24617 #undef JSON_HEDLEY_NO_THROW 24618 #undef JSON_HEDLEY_NULL 24619 #undef JSON_HEDLEY_PELLES_VERSION 24620 #undef JSON_HEDLEY_PELLES_VERSION_CHECK 24621 #undef JSON_HEDLEY_PGI_VERSION 24622 #undef JSON_HEDLEY_PGI_VERSION_CHECK 24623 #undef JSON_HEDLEY_PREDICT 24624 #undef JSON_HEDLEY_PRINTF_FORMAT 24625 #undef JSON_HEDLEY_PRIVATE 24626 #undef JSON_HEDLEY_PUBLIC 24627 #undef JSON_HEDLEY_PURE 24628 #undef JSON_HEDLEY_REINTERPRET_CAST 24629 #undef JSON_HEDLEY_REQUIRE 24630 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR 24631 #undef JSON_HEDLEY_REQUIRE_MSG 24632 #undef JSON_HEDLEY_RESTRICT 24633 #undef JSON_HEDLEY_RETURNS_NON_NULL 24634 #undef JSON_HEDLEY_SENTINEL 24635 #undef JSON_HEDLEY_STATIC_ASSERT 24636 #undef JSON_HEDLEY_STATIC_CAST 24637 #undef JSON_HEDLEY_STRINGIFY 24638 #undef JSON_HEDLEY_STRINGIFY_EX 24639 #undef JSON_HEDLEY_SUNPRO_VERSION 24640 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK 24641 #undef JSON_HEDLEY_TINYC_VERSION 24642 #undef JSON_HEDLEY_TINYC_VERSION_CHECK 24643 #undef JSON_HEDLEY_TI_ARMCL_VERSION 24644 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK 24645 #undef JSON_HEDLEY_TI_CL2000_VERSION 24646 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK 24647 #undef JSON_HEDLEY_TI_CL430_VERSION 24648 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK 24649 #undef JSON_HEDLEY_TI_CL6X_VERSION 24650 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK 24651 #undef JSON_HEDLEY_TI_CL7X_VERSION 24652 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK 24653 #undef JSON_HEDLEY_TI_CLPRU_VERSION 24654 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK 24655 #undef JSON_HEDLEY_TI_VERSION 24656 #undef JSON_HEDLEY_TI_VERSION_CHECK 24657 #undef JSON_HEDLEY_UNAVAILABLE 24658 #undef JSON_HEDLEY_UNLIKELY 24659 #undef JSON_HEDLEY_UNPREDICTABLE 24660 #undef JSON_HEDLEY_UNREACHABLE 24661 #undef JSON_HEDLEY_UNREACHABLE_RETURN 24662 #undef JSON_HEDLEY_VERSION 24663 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR 24664 #undef JSON_HEDLEY_VERSION_DECODE_MINOR 24665 #undef JSON_HEDLEY_VERSION_DECODE_REVISION 24666 #undef JSON_HEDLEY_VERSION_ENCODE 24667 #undef JSON_HEDLEY_WARNING 24668 #undef JSON_HEDLEY_WARN_UNUSED_RESULT 24669 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG 24670 #undef JSON_HEDLEY_FALL_THROUGH 24674 #endif // INCLUDE_NLOHMANN_JSON_HPP_ static std::size_t calc_bson_integer_size(const std::int64_t value)
std::size_t concat_length()
typename It::difference_type difference_type
binary_t * binary
binary (stored with pointer to save storage)
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::number_integer_t number_integer_t
#define NLOHMANN_JSON_NAMESPACE_BEGIN
static constexpr auto value
typename BasicJsonType::object_t object_t
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
difference_type operator-(const json_reverse_iterator &other) const
return difference
static std::size_t calc_bson_string_size(const string_t &value)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
general exception of the basic_json class
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
typename BasicJsonType::number_float_t number_float_t
constexpr bool is_null() const noexcept
return whether value is null
Target reinterpret_bits(const Source source)
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
string_t indent_string
the indentation string
virtual bool binary(binary_t &val)=0
a binary value was read
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
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.
void insert(InputIt first, InputIt last)
const_reference operator[](size_type idx) const
access specified array element
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
void swap(typename binary_t::container_type &other)
exchanges the values
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
array (ordered collection of values)
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
static constexpr bool test(T)
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
static constexpr bool test(T val)
typename BasicJsonType::string_t string_t
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
typename It::iterator_category iterator_category
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
static constexpr auto value
integer_sequence< size_t, Ints... > index_sequence
reference operator[](difference_type n) const
access to successor
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)))
void write_cbor(const BasicJsonType &j)
void clear_subtype() noexcept
clears the binary subtype
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
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.
typename T::key_type key_type_t
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
constexpr bool is_binary() const noexcept
return whether value is a binary array
StringType string_t
a type for a string
BooleanType boolean_t
a type for a boolean
const binary_t & get_binary() const
get a binary value
json_reverse_iterator operator+(difference_type i) const
add to iterator
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
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
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
BasicJsonType & root
the parsed JSON value
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t &>().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
typename It::reference reference
reference set_parent(reference j, std::size_t old_capacity=static_cast< std::size_t >(-1))
boundaries compute_boundaries(FloatType value)
input_format_t
the supported input formats
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
bool number_unsigned(number_unsigned_t val)
#define JSON_CATCH(exception)
typename BasicJsonType::number_float_t number_float_t
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
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
static constexpr bool test(T val)
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
json_value(string_t &&value)
constructor for rvalue strings
const char * what() const noexcept override
returns the explanatory string
bool number_unsigned(number_unsigned_t val)
decltype(T::from_json(std::declval< Args >()...)) from_json_function
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
bool get_number(const input_format_t format, NumberType &result)
BinaryType container_type
#define JSON_HEDLEY_DIAGNOSTIC_POP
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
virtual bool string(string_t &val)=0
a string value was read
typename BasicJsonType::number_integer_t number_integer_t
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
constexpr bool is_string() const noexcept
return whether value is a string
output_adapter(std::basic_ostream< CharType > &s)
void swap(array_t &other)
exchanges the values
typename T::key_compare detect_key_compare
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
typename BasicJsonType::number_unsigned_t number_unsigned_t
void push_back(initializer_list_t init)
add an object to an object
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
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
::nlohmann::detail::internal_iterator< BasicJsonType > internal_iterator
~basic_json() noexcept
destructor
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
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
number value (unsigned integer)
typename BasicJsonType::binary_t binary_t
json_ref(Args &&... args)
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
typename BasicJsonType::number_float_t number_float_t
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
reference operator[](size_type idx)
access specified array element
iteration_proxy_value operator++(int) &
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
json_ref(value_type &&value)
void reset() noexcept
reset token_buffer; current character is beginning of token
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
bool get_msgpack_object(const std::size_t len)
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
byte_container_with_subtype() noexcept(noexcept(container_type()))
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
ValueType & get_to(ValueType &v) const
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)
a minimal map-like container that preserves insertion order
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
typename BasicJsonType::exception exception_t
bool number_float(number_float_t, const string_t &)
static one test(decltype(&C::capacity))
const string_type & key() const
return key of the iterator
reference operator[](typename object_t::key_type key)
access specified object element
#define JSON_NO_UNIQUE_ADDRESS
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
typename BasicJsonType::string_t string_t
const int id
the id of the exception
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
std::string get_token_string() const
static constexpr bool test(T val)
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
static void flatten(const string_t &reference_string, const BasicJsonType &value, BasicJsonType &result)
static std::string name(const std::string &ename, int id_)
store tags as binary type
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
typename BasicJsonType::default_object_comparator_t object_comparator_t
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
bool get_ubjson_value(const char_int_type prefix)
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
bool string(string_t &val)
typename BasicJsonType::number_unsigned_t number_unsigned_t
static CharType to_char_type(std::uint8_t x) noexcept
typename BasicJsonType::binary_t binary_t
const_reference front() const
access the first element
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
constexpr bool is_c_string()
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
token_type scan_string()
scan a string literal
difference_type operator-(const iter_impl &other) const
return difference
json_pointer(const string_t &s="")
create JSON pointer
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
parse_error(int id_, std::size_t byte_, const char *what_arg)
namespace for Niels Lohmann
reference value() const
return the value of an iterator
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
std::conditional< detail::is_c_string_uncvref< ValueType >::value, string_t, typename std::decay< ValueType >::type > value_return_type
reference operator+=(const basic_json &val)
add an object to an array
typename lexer_base< BasicJsonType >::token_type token_type
size_type erase(KeyType &&key)
remove element from a JSON object given a key
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
bool empty() const noexcept
return whether pointer points to the root document
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
typename BasicJsonType::number_unsigned_t number_unsigned_t
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
constexpr bool is_object() const noexcept
return whether value is an object
iterator find(KeyType &&key)
find an element in a JSON object
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
json_reverse_iterator & operator--()
pre-decrement (–it)
void pop_back()
remove last reference token
void operator=(nonesuch const &)=delete
std::ptrdiff_t difference_type
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
virtual bool number_integer(number_integer_t val)=0
an integer number was read
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).
proxy class for the items() function
typename BasicJsonType::binary_t::value_type binary_char_t
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
void push_back(const typename object_t::value_type &val)
add an object to an object
typename BasicJsonType::object_t object_t
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
json_reverse_iterator & operator++()
pre-increment (++it)
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
std::vector< string_t > reference_tokens
the reference tokens
iter_impl operator+(difference_type i) const
add to iterator
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
#define JSON_HEDLEY_WARN_UNUSED_RESULT
static constexpr std::size_t size() noexcept
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
bool start_object(std::size_t len)
typename BasicJsonType::template json_serializer< T, void > serializer
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
static BasicJsonType unflatten(const BasicJsonType &value)
#define JSON_INTERNAL_CATCH(exception)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
std::numeric_limits< RealIntegerType > RealLimits
bool skip_bom()
skip the UTF-8 byte order mark
constexpr bool is_errored() const
a template for a reverse iterator class
json_value(boolean_t v) noexcept
constructor for booleans
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.
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)
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)>>, index_sequence< Idx... >)
number_integer_t number_integer
number (integer)
bool start_array(std::size_t=static_cast< std::size_t >(-1))
void write_character(CharType c) override
void swap(object_t &other)
exchanges the values
iter_impl & operator-=(difference_type i)
subtract from iterator
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
size_type erase(KeyType &&key)
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
typename BasicJsonType::string_t string_t
typename BasicJsonType::exception exception_t
output_adapter(std::vector< CharType, AllocatorType > &vec)
iter_impl< basic_json > iterator
an iterator for a basic_json container
constexpr bool is_array() const noexcept
return whether value is an array
typename BasicJsonType::template json_serializer< T, void > serializer
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
::nlohmann::detail::iteration_proxy< Iterator > iteration_proxy
static constexpr CharType to_char_type(std::uint8_t x) noexcept
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
the parser read { and started to process a JSON object
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
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
typename BasicJsonType::number_unsigned_t number_unsigned_t
binary array (ordered collection of bytes)
typename make_void< Ts... >::type void_t
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
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
decltype(std::declval< T & >().end_array()) end_array_function_t
reference at(KeyType &&key)
access specified object element with bounds checking
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
object (unordered set of name/value pairs)
bool get_ubjson_size_value(std::size_t &result, bool &is_ndarray, char_int_type prefix=0)
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
bool operator>(const iter_impl &other) const
comparison: greater than
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
std::size_t array_index_last
last stringified array index
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
cbor_tag_handler_t
how to treat CBOR tags
iterator erase(iterator pos)
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
void set_begin() noexcept
set iterator to a defined beginning
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
detected_t< result_of_begin, t_ref > iterator
iteration_proxy & operator=(iteration_proxy const &)=default
typename It::pointer pointer
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
typename Base::reference reference
the reference type for the pointed-to element
the parser finished reading a JSON value
std::input_iterator_tag iterator_category
bool number_float(number_float_t val, const string_t &)
token_type scan_number()
scan a number literal
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
json_pointer< string_t > convert() &&
basic_json(const JsonRef &ref)
typename BasicJsonType::string_t string_t
constexpr number_float_t get_number_float() const noexcept
return floating-point value
throw a parse_error exception in case of a tag
std::random_access_iterator_tag iterator_category
typename BasicJsonType::parse_event_t parse_event_t
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
friend other_iter_impl
allow basic_json to access private members
const T & operator[](KeyType &&key) const
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
void write_character(CharType c) override
bool number_float(number_float_t val, const string_t &)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
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
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
bool contains(const BasicJsonType *ptr) const
void write_bson_object(const typename BasicJsonType::object_t &value)
exception indicating other library errors
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
std::basic_ostream< CharType > & stream
typename BasicJsonType::number_float_t number_float_t
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
size_type count(KeyType &&key) const
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
static std::string position_string(const position_t &pos)
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
const T & at(const key_type &key) const
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
typename BasicJsonType::binary_t binary_t
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
reference operator+=(initializer_list_t init)
add an object to an object
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
typename BasicJsonType::binary_t binary_t
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
json_sax & operator=(const json_sax &)=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
constexpr bool value_in_range_of(T val)
output adapter for basic_string
static constexpr CharType get_msgpack_float_prefix(float)
const_reference at(size_type idx) const
access specified array element with bounds checking
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
json_value(const binary_t &value)
constructor for binary arrays (internal type)
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
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
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.
reference emplace_back(Args &&... args)
add an object to an array
bool get_msgpack_string(string_t &result)
reads a MessagePack string
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
output_adapter(StringType &s)
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
iterator erase(iterator first, iterator last)
static constexpr CharType get_msgpack_float_prefix(double)
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference operator[](const
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
static void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
json_value(const string_t &value)
constructor for strings
size_type erase(const key_type &key)
const_reference operator[](KeyType &&key) const
access specified object element
std::ptrdiff_t difference_type
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
static std::string diagnostics(std::nullptr_t)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
IteratorType::pointer container
the container to iterate
json_pointer parent_pointer() const
returns the parent of this JSON pointer
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
static constexpr CharType get_ubjson_float_prefix(float)
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
value_type const & operator*() const
typename T::pointer pointer_t
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
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
void to_json(BasicJsonType &j, const T &b)
std::size_t size_type
a type to represent container sizes
NumberFloatType number_float_t
a type for a number (floating-point)
std::bidirectional_iterator_tag iterator_category
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
bool get_ubjson_high_precision_number()
string_type empty_str
an empty string (to return a reference for primitive values)
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
typename BasicJsonType::number_unsigned_t number_unsigned_t
json_value(const array_t &value)
constructor for arrays
#define JSON_THROW(exception)
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
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)
an internal type for a backed binary type
iteration_proxy_value()=default
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
typename BasicJsonType::number_integer_t number_integer_t
T & operator[](const key_type &key)
constexpr position_t get_position() const noexcept
return position of last read token
#define NLOHMANN_JSON_NAMESPACE_END
#define JSON_HEDLEY_RETURNS_NON_NULL
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
virtual bool end_object()=0
the end of an object was read
const std::size_t byte
byte index of the parse error
bool scan_comment()
scan a comment
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
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
the parser read ] and finished processing a JSON array
IteratorType anchor
the iterator
bool parse_ubjson_internal(const bool get_char=true)
typename It::value_type value_type
::nlohmann::detail::json_base_class< CustomBaseClass > json_base_class_t
static void construct(BasicJsonType &j, const CompatibleStringType &str)
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
typename std::char_traits< char_type >::int_type char_int_type
decltype(T::to_json(std::declval< Args >()...)) to_json_function
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
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)
static std::vector< string_t > split(const string_t &reference_string)
split the string input to reference tokens
typename InputAdapterType::char_type char_type
iter_impl operator++(int) &
post-increment (it++)
decltype(std::declval< T >().template get< U >()) get_template_function
iter_impl & operator++()
pre-increment (++it)
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
pointer operator->() const
dereference the iterator
bool write_bjdata_ndarray(const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type)
static constexpr bool value
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
detail namespace with internal helper functions
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
json_value m_value
the value of the current element
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
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
bool string(string_t &val)
iter_impl operator-(difference_type i) const
subtract from iterator
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
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
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)
typename BasicJsonType::binary_t binary_t
const T & at(KeyType &&key) const
serialization to CBOR and MessagePack values
exception indicating errors with iterators
constexpr bool is_number() const noexcept
return whether value is a number
bool operator<(const iter_impl &other) const
comparison: smaller
value_type_t< iterator_traits< iterator_t< T > >> range_value_t
primitive_iterator_t operator+(difference_type n) noexcept
iteration_proxy()=default
bool parse_msgpack_internal()
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
void write_character(CharType c) override
::nlohmann::detail::binary_writer< basic_json, CharType > binary_writer
std::ptrdiff_t difference_type
a type to represent differences between iterators
detected_t< result_of_end, t_ref > sentinel
std::size_t chars_read_total
the total number of characters read
string_t * string
string (stored with pointer to save storage)
value_t
the JSON type enumeration
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
typename InputAdapterType::char_type char_type
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
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
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
cached_power get_cached_power_for_binary_exponent(int e)
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
primitive_iterator_t & operator+=(difference_type n) noexcept
primitive_iterator_t operator++(int) &noexcept
reference operator[](KeyType &&key)
access specified object element
#define JSON_HEDLEY_CONST
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
json_value(value_t t)
constructor for empty values of a given type
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
const_reference back() const
access the last element
const char indent_char
the indentation character
static JSON_INLINE_VARIABLE constexpr T value
reference value() const
return the value of an iterator
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t &>(), v)))
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 >>, priority_tag< 0 >)
typename BasicJsonType::number_integer_t number_integer_t
binary_t & get_binary()
get a binary value
BasicJsonType & root
the parsed JSON value
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
void write_bson(const BasicJsonType &j)
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
typename Container::size_type size_type
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
bool parse_error(std::size_t, const std::string &, const Exception &ex)
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
typename T::value_type value_type_t
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
#define NLOHMANN_BASIC_JSON_TPL
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
bool binary(binary_t &val)
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
typename BasicJsonType::number_integer_t number_integer_t
replace invalid UTF-8 sequences with U+FFFD
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
string_t to_string() const
return a string representation of the JSON pointer
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
void int_to_string(string_type &target, std::size_t value)
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
#define NLOHMANN_JSON_VERSION_PATCH
iter_impl & operator--()
pre-decrement (–it)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
void write_msgpack(const BasicJsonType &j)
is_detected< string_can_append, StringType, Arg > detect_string_can_append
make_index_sequence< sizeof...(Ts)> index_sequence_for
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
::nlohmann::detail::iter_impl< BasicJsonType > iter_impl
bool accept(const bool strict=true)
public accept interface
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
typename T::is_transparent detect_is_transparent
value_type const * operator->() const
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
typename BasicJsonType::number_integer_t number_integer_t
ptrdiff_t difference_type
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
virtual bool end_array()=0
the end of an array was read
the parser read } and finished processing a JSON object
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
number_float_t number_float
number (floating-point)
void swap(binary_t &other)
exchanges the values
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
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
reference operator+=(const typename object_t::value_type &val)
add an object to an object
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
basic_json<> json
default specialization
ConstructibleStringType laundered_type
#define JSON_HEDLEY_NON_NULL(...)
constexpr subtype_type subtype() const noexcept
return the binary subtype
primitive_iterator_t operator--(int) &noexcept
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
ReferenceType get_ref() const
get a reference value (implicit)
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
typename BasicJsonType::number_integer_t number_integer_t
std::size_t hash(const BasicJsonType &j)
hash a JSON value
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::string_t string_t
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
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) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
primitive_iterator_t & operator++() noexcept
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
const string_t & back() const
return last reference token
iter_impl & operator+=(difference_type i)
add to iterator
typename T::mapped_type mapped_type_t
bool start_array(std::size_t len)
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference at(const
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
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
virtual bool boolean(bool val)=0
a boolean value was read
typename BasicJsonType::number_integer_t number_integer_t
typename T::reference reference_t
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
T conditional_static_cast(U value)
typename BasicJsonType::number_integer_t number_integer_t
number_unsigned_t number_unsigned
number (unsigned integer)
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
number value (floating-point)
const_iterator find(KeyType &&key) const
find an element in a JSON object
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.
discarded by the parser callback function
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
static constexpr bool value
IteratorType erase(IteratorType pos)
remove element given an iterator
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
primitive_iterator_t primitive_iterator
generic iterator for all other types
char_int_type get_ignore_noop()
static constexpr CharType get_cbor_float_prefix(double)
void to_json(BasicJsonType &j, T b) noexcept
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
SAX implementation to create a JSON value from SAX events.
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
static bool little_endianness(int num=1) noexcept
determine system byte order
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
ordered_map() noexcept(noexcept(Container()))
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
constexpr difference_type get_value() const noexcept
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 ...
iterator find(const key_type &key)
typename BasicJsonType::string_t string_t
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
#define JSON_HEDLEY_LIKELY(expr)
error_handler_t
how to treat decoding errors
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
bool get_cbor_string(string_t &result)
reads a CBOR string
#define JSON_PRIVATE_UNLESS_TESTED
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
void add(char_int_type c)
add a character to token_buffer
bool parse_error(std::size_t, const std::string &, const Exception &ex)
std::equal_to< Key > key_compare
json_value(object_t &&value)
constructor for rvalue objects
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
OutStringType concat(Args &&... args)
#define NLOHMANN_JSON_VERSION_MINOR
bool start_array(std::size_t len)
typename BasicJsonType::number_float_t number_float_t
std::size_t array_index
an index for arrays (used to create key names)
typename BasicJsonType::number_float_t number_float_t
typename Container::const_iterator const_iterator
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
json_value(array_t &&value)
constructor for rvalue arrays
void set_end() noexcept
set iterator to a defined past the end
bool number_integer(number_integer_t val)
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
constexpr bool is_structured() const noexcept
return whether type is structured
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
bool number_integer(number_integer_t)
static constexpr CharType get_cbor_float_prefix(float)
bool number_integer(number_integer_t val)
struct to capture the start position of the current token
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
iterator insert_iterator(const_iterator pos, Args &&... args)
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
typename BasicJsonType::template json_serializer< T, void > serializer
void set_end() noexcept
set the iterator past the last value
virtual bool null()=0
a null value was read
typename BasicJsonType::number_float_t number_float_t
virtual bool key(string_t &val)=0
an object key was read
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::object_t object_t
typename utility_internal::Gen< T, N >::type make_integer_sequence
int get_codepoint()
get codepoint from 4 hex characters following \u
void concat_into(OutStringType &)
make_integer_sequence< size_t, N > make_index_sequence
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
const_reference operator[](T *key) const
void erase(const size_type idx)
remove element from a JSON array given an index
const T & operator[](const key_type &key) const
std::pair< iterator, bool > insert(value_type &&value)
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
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)
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
reference back()
access the last element
typename BasicJsonType::string_t string_t
static constexpr bool test(T val)
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
ordered_map(It first, It last, const Allocator &alloc=Allocator())
basic_json(basic_json &&other) noexcept
move constructor
reference operator+=(basic_json &&val)
add an object to an array
typename BasicJsonType::number_unsigned_t number_unsigned_t
exception indicating access out of the defined range
bool operator<=(const iter_impl &other) const
comparison: less than or equal
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
void push_back(const basic_json &val)
add an object to an array
typename BasicJsonType::array_t array_t
typename BasicJsonType::number_float_t number_float_t
iter_impl operator--(int) &
post-decrement (it–)
const_reference at(KeyType &&key) const
access specified object element with bounds checking
std::pair< char_int_type, string_t > bjd_type
number value (signed integer)
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
output adapter for output streams
lexer< BasicJsonType, InputAdapterType > lexer_t
InputAdapterType ia
input adapter
reference operator[](difference_type n) const
access to successor
output_string_adapter(StringType &s) noexcept
throw a type_error exception in case of invalid UTF-8
typename BasicJsonType::binary_t binary_t
iterator find(KeyType &&key)
decltype(std::declval< StringType & >()+=std::declval< Arg &&>()) string_can_append_op
json_ref(std::initializer_list< json_ref > init)
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
typename Container::iterator iterator
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
basic_json(const value_t v)
create an empty value with a given type
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)
typename BasicJsonType::string_t string_t
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
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
reference at(size_type idx)
access specified array element with bounds checking
the parser read [ and started to process a JSON array
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
bool operator==(const byte_container_with_subtype &rhs) const
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
JSONSerializer< T, SFINAE > json_serializer
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
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
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
typename BasicJsonType::string_t string_t
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
bool operator!=(const byte_container_with_subtype &rhs) const
data(size_type cnt, const basic_json &val)
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
constexpr bool is_end() const noexcept
return whether the iterator is at end
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t &>().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
decltype(std::declval< StringType & >().append(std::declval< Arg &&>())) string_can_append
IteratorType::reference value() const
return value of the iterator
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
::nlohmann::detail::binary_reader< basic_json, InputType > binary_reader
typename T::difference_type difference_type_t
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
primitive_iterator_t & operator-=(difference_type n) noexcept
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
typename detector< nonesuch, void, Op, Args... >::type detected_t
typename BasicJsonType::string_t string_t
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
typename BasicJsonType::string_t string_t
bool parse_error(std::size_t, const std::string &, const detail::exception &)
ReferenceType get_ref()
get a reference value (implicit)
void write_number(const NumberType n, const bool OutputIsLittleEndian=false)
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
bool get_msgpack_array(const std::size_t len)
decltype(std::declval< T & >().end_object()) end_object_function_t
typename std::char_traits< char_type >::int_type char_int_type
token_type
token types for the parser
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
std::string get_token_string() const
const_iterator find(const key_type &key) const
typename BasicJsonType::number_float_t number_float_t
CharType ubjson_prefix(const BasicJsonType &j, const bool use_bjdata) const noexcept
determine the type prefix of container values
typename BasicJsonType::object_t object_t
reference operator*() const
return a reference to the value pointed to by the iterator
Default base class of the basic_json class.
std::uint64_t subtype_type
size_type erase_internal(KeyType &&key)
basic_json(const basic_json &other)
copy constructor
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
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)
constexpr bool is_errored() const
typename BasicJsonType::parser_callback_t parser_callback_t
::nlohmann::detail::primitive_iterator_t primitive_iterator_t
array_t * array
array (stored with pointer to save storage)
static constexpr bool test(T val)
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
typename std::enable_if< B, T >::type enable_if_t
string_type array_index_str
a string representation of the array index
std::ptrdiff_t difference_type
static constexpr CharType get_ubjson_float_prefix(double)
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
std::vector< std::pair< const Key, T >, Allocator > Container
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
JSON Pointer defines a string syntax for identifying a specific value within a JSON document...
primitive_iterator_t & operator--() noexcept
void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value)
bool start_object(std::size_t len)
size_type count(const key_type &key) const
void swap(string_t &other)
exchanges the values
InputAdapterType ia
input adapter
constexpr bool is_primitive() const noexcept
return whether type is primitive
static constexpr CharType to_char_type(InputCharType x) noexcept
json_ref(const value_type &value)
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
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
typename BasicJsonType::binary_t binary_t
typename std::iterator_traits< T >::value_type value_type
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
typename Container::value_type value_type
T & at(const key_type &key)
static BasicJsonType::size_type array_index(const string_t &s)
deserialization of CBOR, MessagePack, and UBJSON values
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
std::string exception_message(const token_type expected, const std::string &context)
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 ...
T & operator[](KeyType &&key)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
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 ...
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
void unget()
unget current character (read it again on next get)
typename std::add_lvalue_reference< T >::type t_ref
output adapter for byte vectors
decltype(std::declval< T & >().null()) null_function_t
constexpr bool is_transparent()
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
abstract output adapter interface
typename BasicJsonType::number_float_t number_float_t
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
const error_handler_t error_handler
error_handler how to react on decoding errors
exception indicating a parse error
json_reverse_iterator & operator+=(difference_type i)
add to iterator
reference operator[](T *key)
static allocator_type get_allocator()
returns the allocator associated with the container
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static std::string diagnostics(const BasicJsonType *leaf_element)
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
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
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
constexpr bool is_discarded() const noexcept
return whether value is discarded
#define JSON_INLINE_VARIABLE
std::runtime_error m
an exception object as storage for error messages
typename T::iterator_category iterator_category_t
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
std::size_t combine(std::size_t seed, std::size_t h) noexcept
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
::nlohmann::detail::json_reverse_iterator< Base > json_reverse_iterator
#define JSON_HEDLEY_UNLIKELY(expr)
static constexpr auto is_iterator_begin
json_reverse_iterator operator--(int) &
post-decrement (it–)
std::size_t chars_read_current_line
the number of characters read in the current line
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)
BasicJsonType & get_checked(BasicJsonType *ptr) const
constexpr bool is_boolean() const noexcept
return whether value is a boolean
bool binary(binary_t &val)
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
typename lexer_t::token_type token_type
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
namespace for Niels Lohmann
const object_t::key_type & key() const
return the key of an object iterator
json_pointer< string_t > convert() const &
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
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
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
bool start_object(std::size_t=static_cast< std::size_t >(-1))
void write_compact_float(const number_float_t n, detail::input_format_t format)
bool number_unsigned(number_unsigned_t)
std::pair< iterator, bool > insert(const value_type &value)
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
typename string_t_helper< RefStringType >::type string_t
constexpr number_integer_t get_number_integer() const noexcept
return integer value
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t &>(), v)))
get a value (explicit)
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
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.
json_value(const object_t &value)
constructor for objects
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
static 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
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
std::size_t lines_read
the number of lines read
NumberIntegerType number_integer_t
a type for a number (integer)
json_reverse_iterator operator++(int) &
post-increment (it++)
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
bool get_ubjson_ndarray_size(std::vector< size_t > &dim)
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
#define NLOHMANN_JSON_VERSION_MAJOR
exception indicating executing a member function with a wrong type
AllocatorType< basic_json > allocator_type
the allocator type
token_type get_token()
get next token from lexer
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
void parse(const bool strict, BasicJsonType &result)
public parser interface
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
std::vector< CharType, AllocatorType > & v