39 #ifndef INCLUDE_NLOHMANN_JSON_HPP_ 40 #define INCLUDE_NLOHMANN_JSON_HPP_ 42 #define NLOHMANN_JSON_VERSION_MAJOR 3 43 #define NLOHMANN_JSON_VERSION_MINOR 10 44 #define NLOHMANN_JSON_VERSION_PATCH 5 49 #include <initializer_list> 63 #include <type_traits> 71 #include <forward_list> 76 #include <type_traits> 77 #include <unordered_map> 158 static constexpr std::array<std::uint8_t, 9> order = {{
165 const auto l_index =
static_cast<std::size_t>(lhs);
166 const auto r_index =
static_cast<std::size_t>(rhs);
167 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
195 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) 196 #if defined(JSON_HEDLEY_VERSION) 197 #undef JSON_HEDLEY_VERSION 199 #define JSON_HEDLEY_VERSION 15 201 #if defined(JSON_HEDLEY_STRINGIFY_EX) 202 #undef JSON_HEDLEY_STRINGIFY_EX 204 #define JSON_HEDLEY_STRINGIFY_EX(x) #x 206 #if defined(JSON_HEDLEY_STRINGIFY) 207 #undef JSON_HEDLEY_STRINGIFY 209 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) 211 #if defined(JSON_HEDLEY_CONCAT_EX) 212 #undef JSON_HEDLEY_CONCAT_EX 214 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b 216 #if defined(JSON_HEDLEY_CONCAT) 217 #undef JSON_HEDLEY_CONCAT 219 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) 221 #if defined(JSON_HEDLEY_CONCAT3_EX) 222 #undef JSON_HEDLEY_CONCAT3_EX 224 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c 226 #if defined(JSON_HEDLEY_CONCAT3) 227 #undef JSON_HEDLEY_CONCAT3 229 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) 231 #if defined(JSON_HEDLEY_VERSION_ENCODE) 232 #undef JSON_HEDLEY_VERSION_ENCODE 234 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) 236 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) 237 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR 239 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) 241 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) 242 #undef JSON_HEDLEY_VERSION_DECODE_MINOR 244 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) 246 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) 247 #undef JSON_HEDLEY_VERSION_DECODE_REVISION 249 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) 251 #if defined(JSON_HEDLEY_GNUC_VERSION) 252 #undef JSON_HEDLEY_GNUC_VERSION 254 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) 255 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) 256 #elif defined(__GNUC__) 257 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) 260 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) 261 #undef JSON_HEDLEY_GNUC_VERSION_CHECK 263 #if defined(JSON_HEDLEY_GNUC_VERSION) 264 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 266 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) 269 #if defined(JSON_HEDLEY_MSVC_VERSION) 270 #undef JSON_HEDLEY_MSVC_VERSION 272 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) 273 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) 274 #elif defined(_MSC_FULL_VER) && !defined(__ICL) 275 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) 276 #elif defined(_MSC_VER) && !defined(__ICL) 277 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) 280 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) 281 #undef JSON_HEDLEY_MSVC_VERSION_CHECK 283 #if !defined(JSON_HEDLEY_MSVC_VERSION) 284 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) 285 #elif defined(_MSC_VER) && (_MSC_VER >= 1400) 286 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) 287 #elif defined(_MSC_VER) && (_MSC_VER >= 1200) 288 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) 290 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) 293 #if defined(JSON_HEDLEY_INTEL_VERSION) 294 #undef JSON_HEDLEY_INTEL_VERSION 296 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) 297 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) 298 #elif defined(__INTEL_COMPILER) && !defined(__ICL) 299 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) 302 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) 303 #undef JSON_HEDLEY_INTEL_VERSION_CHECK 305 #if defined(JSON_HEDLEY_INTEL_VERSION) 306 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 308 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) 311 #if defined(JSON_HEDLEY_INTEL_CL_VERSION) 312 #undef JSON_HEDLEY_INTEL_CL_VERSION 314 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) 315 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) 318 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) 319 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK 321 #if defined(JSON_HEDLEY_INTEL_CL_VERSION) 322 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 324 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) 327 #if defined(JSON_HEDLEY_PGI_VERSION) 328 #undef JSON_HEDLEY_PGI_VERSION 330 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) 331 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) 334 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK) 335 #undef JSON_HEDLEY_PGI_VERSION_CHECK 337 #if defined(JSON_HEDLEY_PGI_VERSION) 338 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 340 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) 343 #if defined(JSON_HEDLEY_SUNPRO_VERSION) 344 #undef JSON_HEDLEY_SUNPRO_VERSION 346 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) 347 #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) 348 #elif defined(__SUNPRO_C) 349 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) 350 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) 351 #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) 352 #elif defined(__SUNPRO_CC) 353 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) 356 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) 357 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK 359 #if defined(JSON_HEDLEY_SUNPRO_VERSION) 360 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 362 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) 365 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) 366 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION 368 #if defined(__EMSCRIPTEN__) 369 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) 372 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) 373 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK 375 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) 376 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 378 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) 381 #if defined(JSON_HEDLEY_ARM_VERSION) 382 #undef JSON_HEDLEY_ARM_VERSION 384 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) 385 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) 386 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) 387 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) 390 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK) 391 #undef JSON_HEDLEY_ARM_VERSION_CHECK 393 #if defined(JSON_HEDLEY_ARM_VERSION) 394 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 396 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) 399 #if defined(JSON_HEDLEY_IBM_VERSION) 400 #undef JSON_HEDLEY_IBM_VERSION 402 #if defined(__ibmxl__) 403 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) 404 #elif defined(__xlC__) && defined(__xlC_ver__) 405 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) 406 #elif defined(__xlC__) 407 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) 410 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK) 411 #undef JSON_HEDLEY_IBM_VERSION_CHECK 413 #if defined(JSON_HEDLEY_IBM_VERSION) 414 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 416 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) 419 #if defined(JSON_HEDLEY_TI_VERSION) 420 #undef JSON_HEDLEY_TI_VERSION 423 defined(__TI_COMPILER_VERSION__) && \ 425 defined(__TMS470__) || defined(__TI_ARM__) || \ 426 defined(__MSP430__) || \ 427 defined(__TMS320C2000__) \ 429 #if (__TI_COMPILER_VERSION__ >= 16000000) 430 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 434 #if defined(JSON_HEDLEY_TI_VERSION_CHECK) 435 #undef JSON_HEDLEY_TI_VERSION_CHECK 437 #if defined(JSON_HEDLEY_TI_VERSION) 438 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 440 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) 443 #if defined(JSON_HEDLEY_TI_CL2000_VERSION) 444 #undef JSON_HEDLEY_TI_CL2000_VERSION 446 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) 447 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 450 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) 451 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK 453 #if defined(JSON_HEDLEY_TI_CL2000_VERSION) 454 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 456 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) 459 #if defined(JSON_HEDLEY_TI_CL430_VERSION) 460 #undef JSON_HEDLEY_TI_CL430_VERSION 462 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) 463 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 466 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) 467 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK 469 #if defined(JSON_HEDLEY_TI_CL430_VERSION) 470 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 472 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) 475 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) 476 #undef JSON_HEDLEY_TI_ARMCL_VERSION 478 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) 479 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 482 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) 483 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK 485 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) 486 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 488 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) 491 #if defined(JSON_HEDLEY_TI_CL6X_VERSION) 492 #undef JSON_HEDLEY_TI_CL6X_VERSION 494 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) 495 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 498 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) 499 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK 501 #if defined(JSON_HEDLEY_TI_CL6X_VERSION) 502 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 504 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) 507 #if defined(JSON_HEDLEY_TI_CL7X_VERSION) 508 #undef JSON_HEDLEY_TI_CL7X_VERSION 510 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) 511 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 514 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) 515 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK 517 #if defined(JSON_HEDLEY_TI_CL7X_VERSION) 518 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 520 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) 523 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) 524 #undef JSON_HEDLEY_TI_CLPRU_VERSION 526 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) 527 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 530 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) 531 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK 533 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) 534 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 536 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) 539 #if defined(JSON_HEDLEY_CRAY_VERSION) 540 #undef JSON_HEDLEY_CRAY_VERSION 543 #if defined(_RELEASE_PATCHLEVEL) 544 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) 546 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) 550 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) 551 #undef JSON_HEDLEY_CRAY_VERSION_CHECK 553 #if defined(JSON_HEDLEY_CRAY_VERSION) 554 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 556 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) 559 #if defined(JSON_HEDLEY_IAR_VERSION) 560 #undef JSON_HEDLEY_IAR_VERSION 562 #if defined(__IAR_SYSTEMS_ICC__) 564 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) 566 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) 570 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK) 571 #undef JSON_HEDLEY_IAR_VERSION_CHECK 573 #if defined(JSON_HEDLEY_IAR_VERSION) 574 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 576 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) 579 #if defined(JSON_HEDLEY_TINYC_VERSION) 580 #undef JSON_HEDLEY_TINYC_VERSION 582 #if defined(__TINYC__) 583 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) 586 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) 587 #undef JSON_HEDLEY_TINYC_VERSION_CHECK 589 #if defined(JSON_HEDLEY_TINYC_VERSION) 590 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 592 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) 595 #if defined(JSON_HEDLEY_DMC_VERSION) 596 #undef JSON_HEDLEY_DMC_VERSION 599 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) 602 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK) 603 #undef JSON_HEDLEY_DMC_VERSION_CHECK 605 #if defined(JSON_HEDLEY_DMC_VERSION) 606 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 608 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) 611 #if defined(JSON_HEDLEY_COMPCERT_VERSION) 612 #undef JSON_HEDLEY_COMPCERT_VERSION 614 #if defined(__COMPCERT_VERSION__) 615 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) 618 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) 619 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK 621 #if defined(JSON_HEDLEY_COMPCERT_VERSION) 622 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 624 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) 627 #if defined(JSON_HEDLEY_PELLES_VERSION) 628 #undef JSON_HEDLEY_PELLES_VERSION 630 #if defined(__POCC__) 631 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) 634 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) 635 #undef JSON_HEDLEY_PELLES_VERSION_CHECK 637 #if defined(JSON_HEDLEY_PELLES_VERSION) 638 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 640 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) 643 #if defined(JSON_HEDLEY_MCST_LCC_VERSION) 644 #undef JSON_HEDLEY_MCST_LCC_VERSION 646 #if defined(__LCC__) && defined(__LCC_MINOR__) 647 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) 650 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) 651 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK 653 #if defined(JSON_HEDLEY_MCST_LCC_VERSION) 654 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 656 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) 659 #if defined(JSON_HEDLEY_GCC_VERSION) 660 #undef JSON_HEDLEY_GCC_VERSION 663 defined(JSON_HEDLEY_GNUC_VERSION) && \ 664 !defined(__clang__) && \ 665 !defined(JSON_HEDLEY_INTEL_VERSION) && \ 666 !defined(JSON_HEDLEY_PGI_VERSION) && \ 667 !defined(JSON_HEDLEY_ARM_VERSION) && \ 668 !defined(JSON_HEDLEY_CRAY_VERSION) && \ 669 !defined(JSON_HEDLEY_TI_VERSION) && \ 670 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ 671 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ 672 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ 673 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ 674 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ 675 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ 676 !defined(__COMPCERT__) && \ 677 !defined(JSON_HEDLEY_MCST_LCC_VERSION) 678 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION 681 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK) 682 #undef JSON_HEDLEY_GCC_VERSION_CHECK 684 #if defined(JSON_HEDLEY_GCC_VERSION) 685 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 687 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) 690 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) 691 #undef JSON_HEDLEY_HAS_ATTRIBUTE 694 defined(__has_attribute) && \ 696 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ 698 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) 700 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) 703 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) 704 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE 706 #if defined(__has_attribute) 707 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 709 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 712 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) 713 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE 715 #if defined(__has_attribute) 716 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 718 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 721 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) 722 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE 725 defined(__has_cpp_attribute) && \ 726 defined(__cplusplus) && \ 727 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) 728 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) 730 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) 733 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) 734 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS 736 #if !defined(__cplusplus) || !defined(__has_cpp_attribute) 737 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) 739 !defined(JSON_HEDLEY_PGI_VERSION) && \ 740 !defined(JSON_HEDLEY_IAR_VERSION) && \ 741 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ 742 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) 743 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) 745 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) 748 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) 749 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE 751 #if defined(__has_cpp_attribute) && defined(__cplusplus) 752 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) 754 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 757 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) 758 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE 760 #if defined(__has_cpp_attribute) && defined(__cplusplus) 761 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) 763 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 766 #if defined(JSON_HEDLEY_HAS_BUILTIN) 767 #undef JSON_HEDLEY_HAS_BUILTIN 769 #if defined(__has_builtin) 770 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) 772 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) 775 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) 776 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN 778 #if defined(__has_builtin) 779 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) 781 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 784 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) 785 #undef JSON_HEDLEY_GCC_HAS_BUILTIN 787 #if defined(__has_builtin) 788 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) 790 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 793 #if defined(JSON_HEDLEY_HAS_FEATURE) 794 #undef JSON_HEDLEY_HAS_FEATURE 796 #if defined(__has_feature) 797 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) 799 #define JSON_HEDLEY_HAS_FEATURE(feature) (0) 802 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) 803 #undef JSON_HEDLEY_GNUC_HAS_FEATURE 805 #if defined(__has_feature) 806 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) 808 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 811 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE) 812 #undef JSON_HEDLEY_GCC_HAS_FEATURE 814 #if defined(__has_feature) 815 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) 817 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 820 #if defined(JSON_HEDLEY_HAS_EXTENSION) 821 #undef JSON_HEDLEY_HAS_EXTENSION 823 #if defined(__has_extension) 824 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) 826 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) 829 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) 830 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION 832 #if defined(__has_extension) 833 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) 835 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 838 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) 839 #undef JSON_HEDLEY_GCC_HAS_EXTENSION 841 #if defined(__has_extension) 842 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) 844 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 847 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) 848 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE 850 #if defined(__has_declspec_attribute) 851 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) 853 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) 856 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) 857 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE 859 #if defined(__has_declspec_attribute) 860 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) 862 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 865 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) 866 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE 868 #if defined(__has_declspec_attribute) 869 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) 871 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 874 #if defined(JSON_HEDLEY_HAS_WARNING) 875 #undef JSON_HEDLEY_HAS_WARNING 877 #if defined(__has_warning) 878 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) 880 #define JSON_HEDLEY_HAS_WARNING(warning) (0) 883 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING) 884 #undef JSON_HEDLEY_GNUC_HAS_WARNING 886 #if defined(__has_warning) 887 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) 889 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 892 #if defined(JSON_HEDLEY_GCC_HAS_WARNING) 893 #undef JSON_HEDLEY_GCC_HAS_WARNING 895 #if defined(__has_warning) 896 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) 898 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 902 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ 903 defined(__clang__) || \ 904 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ 905 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 906 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ 907 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ 908 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 909 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 910 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ 911 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ 912 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ 913 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ 914 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 915 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 916 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ 917 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ 918 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ 919 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) 920 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) 921 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 922 #define JSON_HEDLEY_PRAGMA(value) __pragma(value) 924 #define JSON_HEDLEY_PRAGMA(value) 927 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) 928 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH 930 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP) 931 #undef JSON_HEDLEY_DIAGNOSTIC_POP 933 #if defined(__clang__) 934 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 935 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 936 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 937 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") 938 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") 939 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) 940 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 941 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 943 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ 944 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 945 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) 946 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) 947 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) 948 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") 949 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") 951 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 952 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 953 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ 954 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ 955 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 956 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) 957 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") 958 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") 959 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) 960 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") 961 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") 963 #define JSON_HEDLEY_DIAGNOSTIC_PUSH 964 #define JSON_HEDLEY_DIAGNOSTIC_POP 969 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) 970 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ 972 #if defined(__cplusplus) 973 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") 974 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") 975 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") 976 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 977 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 978 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 979 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ 980 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ 982 JSON_HEDLEY_DIAGNOSTIC_POP 984 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 985 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 986 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 987 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ 989 JSON_HEDLEY_DIAGNOSTIC_POP 992 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 993 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 994 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 996 JSON_HEDLEY_DIAGNOSTIC_POP 1000 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) 1001 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x 1004 #if defined(JSON_HEDLEY_CONST_CAST) 1005 #undef JSON_HEDLEY_CONST_CAST 1007 #if defined(__cplusplus) 1008 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr)) 1010 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ 1011 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ 1012 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1013 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ 1014 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1015 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ 1017 JSON_HEDLEY_DIAGNOSTIC_POP \ 1020 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) 1023 #if defined(JSON_HEDLEY_REINTERPRET_CAST) 1024 #undef JSON_HEDLEY_REINTERPRET_CAST 1026 #if defined(__cplusplus) 1027 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr)) 1029 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) 1032 #if defined(JSON_HEDLEY_STATIC_CAST) 1033 #undef JSON_HEDLEY_STATIC_CAST 1035 #if defined(__cplusplus) 1036 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr)) 1038 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) 1041 #if defined(JSON_HEDLEY_CPP_CAST) 1042 #undef JSON_HEDLEY_CPP_CAST 1044 #if defined(__cplusplus) 1045 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") 1046 # define JSON_HEDLEY_CPP_CAST(T, expr) \ 1047 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1048 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ 1050 JSON_HEDLEY_DIAGNOSTIC_POP 1051 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) 1052 # define JSON_HEDLEY_CPP_CAST(T, expr) \ 1053 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1054 _Pragma("diag_suppress=Pe137") \ 1055 JSON_HEDLEY_DIAGNOSTIC_POP 1057 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) 1060 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr) 1063 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) 1064 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 1066 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") 1067 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") 1068 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1069 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") 1070 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1071 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) 1072 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) 1073 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") 1074 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1075 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") 1076 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) 1077 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 1078 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 1079 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) 1080 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1081 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") 1083 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1084 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1085 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1086 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1087 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1088 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1089 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1090 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1091 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1092 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1093 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) 1094 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") 1095 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) 1096 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") 1097 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) 1098 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") 1099 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1100 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") 1101 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) 1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") 1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 1107 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) 1108 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 1110 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 1111 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") 1112 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1113 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") 1114 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1115 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) 1116 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1117 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") 1118 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) 1119 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") 1120 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 1121 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) 1123 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ 1124 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ 1125 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1126 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) 1127 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") 1128 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) 1129 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") 1130 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1131 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") 1132 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1133 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") 1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 1138 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) 1139 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 1141 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") 1142 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") 1143 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) 1144 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 1145 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) 1146 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") 1147 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1148 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) 1149 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) 1150 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) 1151 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) 1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") 1153 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") 1155 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) 1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") 1158 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ 1159 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ 1160 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) 1161 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") 1162 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1163 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") 1164 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1165 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") 1167 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 1170 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) 1171 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 1173 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") 1174 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") 1175 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1176 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") 1177 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) 1178 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") 1180 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 1183 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) 1184 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 1186 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function") 1187 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") 1188 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) 1189 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") 1190 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) 1191 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) 1192 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1193 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") 1195 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 1198 #if defined(JSON_HEDLEY_DEPRECATED) 1199 #undef JSON_HEDLEY_DEPRECATED 1201 #if defined(JSON_HEDLEY_DEPRECATED_FOR) 1202 #undef JSON_HEDLEY_DEPRECATED_FOR 1205 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1206 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1207 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) 1208 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) 1210 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ 1211 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ 1212 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1213 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ 1214 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ 1215 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1216 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ 1217 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ 1218 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ 1219 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1220 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ 1221 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1222 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) 1223 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) 1224 #elif defined(__cplusplus) && (__cplusplus >= 201402L) 1225 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) 1226 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) 1228 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ 1229 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1230 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1231 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1232 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1233 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1234 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1235 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1236 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1237 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1238 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1239 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1240 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1241 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1242 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1243 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1244 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) 1245 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) 1247 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1248 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ 1249 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1250 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) 1251 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) 1252 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1253 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") 1254 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") 1256 #define JSON_HEDLEY_DEPRECATED(since) 1257 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) 1260 #if defined(JSON_HEDLEY_UNAVAILABLE) 1261 #undef JSON_HEDLEY_UNAVAILABLE 1264 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ 1265 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ 1266 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1267 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1268 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) 1270 #define JSON_HEDLEY_UNAVAILABLE(available_since) 1273 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) 1274 #undef JSON_HEDLEY_WARN_UNUSED_RESULT 1276 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) 1277 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG 1280 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ 1281 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 1282 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1283 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1284 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1285 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1286 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1287 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1288 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1289 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1290 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1291 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1292 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1293 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1294 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ 1295 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1296 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1297 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 1298 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) 1299 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) 1300 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1301 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) 1302 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) 1303 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1304 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1305 #elif defined(_Check_return_) 1306 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ 1307 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ 1309 #define JSON_HEDLEY_WARN_UNUSED_RESULT 1310 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) 1313 #if defined(JSON_HEDLEY_SENTINEL) 1314 #undef JSON_HEDLEY_SENTINEL 1317 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ 1318 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1319 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1320 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ 1321 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1322 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) 1324 #define JSON_HEDLEY_SENTINEL(position) 1327 #if defined(JSON_HEDLEY_NO_RETURN) 1328 #undef JSON_HEDLEY_NO_RETURN 1330 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1331 #define JSON_HEDLEY_NO_RETURN __noreturn 1333 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1334 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1335 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) 1336 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 1337 #define JSON_HEDLEY_NO_RETURN _Noreturn 1338 #elif defined(__cplusplus) && (__cplusplus >= 201103L) 1339 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) 1341 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ 1342 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ 1343 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1344 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1345 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1346 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1347 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1348 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1349 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1350 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1351 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1352 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1353 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1354 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1355 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1356 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1357 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1358 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) 1359 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1360 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") 1362 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1363 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1364 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) 1365 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) 1366 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") 1367 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) 1368 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) 1369 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) 1370 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) 1372 #define JSON_HEDLEY_NO_RETURN 1375 #if defined(JSON_HEDLEY_NO_ESCAPE) 1376 #undef JSON_HEDLEY_NO_ESCAPE 1378 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) 1379 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) 1381 #define JSON_HEDLEY_NO_ESCAPE 1384 #if defined(JSON_HEDLEY_UNREACHABLE) 1385 #undef JSON_HEDLEY_UNREACHABLE 1387 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN) 1388 #undef JSON_HEDLEY_UNREACHABLE_RETURN 1390 #if defined(JSON_HEDLEY_ASSUME) 1391 #undef JSON_HEDLEY_ASSUME 1394 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1395 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1396 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1397 #define JSON_HEDLEY_ASSUME(expr) __assume(expr) 1398 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) 1399 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) 1401 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1402 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) 1403 #if defined(__cplusplus) 1404 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) 1406 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) 1410 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ 1411 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ 1412 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ 1413 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1414 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ 1415 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ 1416 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1417 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() 1418 #elif defined(JSON_HEDLEY_ASSUME) 1419 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) 1421 #if !defined(JSON_HEDLEY_ASSUME) 1422 #if defined(JSON_HEDLEY_UNREACHABLE) 1423 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) 1425 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) 1428 #if defined(JSON_HEDLEY_UNREACHABLE) 1430 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1431 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) 1432 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) 1434 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() 1437 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) 1439 #if !defined(JSON_HEDLEY_UNREACHABLE) 1440 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) 1444 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic") 1445 #pragma clang diagnostic ignored "-Wpedantic" 1447 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) 1448 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" 1450 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) 1451 #if defined(__clang__) 1452 #pragma clang diagnostic ignored "-Wvariadic-macros" 1453 #elif defined(JSON_HEDLEY_GCC_VERSION) 1454 #pragma GCC diagnostic ignored "-Wvariadic-macros" 1457 #if defined(JSON_HEDLEY_NON_NULL) 1458 #undef JSON_HEDLEY_NON_NULL 1461 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ 1462 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1463 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1464 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) 1465 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) 1467 #define JSON_HEDLEY_NON_NULL(...) 1471 #if defined(JSON_HEDLEY_PRINTF_FORMAT) 1472 #undef JSON_HEDLEY_PRINTF_FORMAT 1474 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) 1475 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) 1476 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) 1477 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) 1479 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ 1480 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1481 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1482 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ 1483 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1484 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1485 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1486 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1487 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1488 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1489 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1490 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1491 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1492 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1493 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1494 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1495 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1496 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) 1497 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) 1498 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) 1500 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) 1503 #if defined(JSON_HEDLEY_CONSTEXPR) 1504 #undef JSON_HEDLEY_CONSTEXPR 1506 #if defined(__cplusplus) 1507 #if __cplusplus >= 201103L 1508 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) 1511 #if !defined(JSON_HEDLEY_CONSTEXPR) 1512 #define JSON_HEDLEY_CONSTEXPR 1515 #if defined(JSON_HEDLEY_PREDICT) 1516 #undef JSON_HEDLEY_PREDICT 1518 #if defined(JSON_HEDLEY_LIKELY) 1519 #undef JSON_HEDLEY_LIKELY 1521 #if defined(JSON_HEDLEY_UNLIKELY) 1522 #undef JSON_HEDLEY_UNLIKELY 1524 #if defined(JSON_HEDLEY_UNPREDICTABLE) 1525 #undef JSON_HEDLEY_UNPREDICTABLE 1527 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) 1528 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) 1531 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ 1532 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ 1533 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1534 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) 1535 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) 1536 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) 1537 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) 1538 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) 1540 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ 1541 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ 1542 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1543 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ 1544 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1545 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1546 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1547 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ 1548 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ 1549 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ 1550 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1551 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1552 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1553 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ 1554 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 1555 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1556 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \ 1557 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) 1558 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ 1560 double hedley_probability_ = (probability); \ 1561 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ 1563 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ 1565 double hedley_probability_ = (probability); \ 1566 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ 1568 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) 1569 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) 1571 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) 1572 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) 1573 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) 1574 # define JSON_HEDLEY_LIKELY(expr) (!!(expr)) 1575 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) 1577 #if !defined(JSON_HEDLEY_UNPREDICTABLE) 1578 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) 1581 #if defined(JSON_HEDLEY_MALLOC) 1582 #undef JSON_HEDLEY_MALLOC 1585 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ 1586 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1587 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1588 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1589 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1590 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ 1591 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1592 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1593 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1594 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1595 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1596 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1597 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1598 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1599 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1600 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1601 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1602 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1603 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) 1604 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1605 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") 1607 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1608 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1609 #define JSON_HEDLEY_MALLOC __declspec(restrict) 1611 #define JSON_HEDLEY_MALLOC 1614 #if defined(JSON_HEDLEY_PURE) 1615 #undef JSON_HEDLEY_PURE 1618 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ 1619 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ 1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1621 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1622 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1623 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1624 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1625 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1626 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1627 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1628 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1629 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1630 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1631 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1632 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1633 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1634 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1635 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1636 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1637 # define JSON_HEDLEY_PURE __attribute__((__pure__)) 1638 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1639 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") 1640 #elif defined(__cplusplus) && \ 1642 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ 1643 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ 1644 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ 1646 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") 1648 # define JSON_HEDLEY_PURE 1651 #if defined(JSON_HEDLEY_CONST) 1652 #undef JSON_HEDLEY_CONST 1655 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ 1656 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ 1657 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1658 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1659 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1660 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1661 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1662 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1663 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1664 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1665 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1666 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1667 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1668 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1669 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1670 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1671 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1672 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1673 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1674 #define JSON_HEDLEY_CONST __attribute__((__const__)) 1676 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1677 #define JSON_HEDLEY_CONST _Pragma("no_side_effect") 1679 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE 1682 #if defined(JSON_HEDLEY_RESTRICT) 1683 #undef JSON_HEDLEY_RESTRICT 1685 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) 1686 #define JSON_HEDLEY_RESTRICT restrict 1688 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1689 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1690 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1691 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1692 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1693 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1694 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1695 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1696 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ 1697 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ 1698 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1699 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ 1700 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ 1701 defined(__clang__) || \ 1702 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1703 #define JSON_HEDLEY_RESTRICT __restrict 1704 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) 1705 #define JSON_HEDLEY_RESTRICT _Restrict 1707 #define JSON_HEDLEY_RESTRICT 1710 #if defined(JSON_HEDLEY_INLINE) 1711 #undef JSON_HEDLEY_INLINE 1714 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ 1715 (defined(__cplusplus) && (__cplusplus >= 199711L)) 1716 #define JSON_HEDLEY_INLINE inline 1718 defined(JSON_HEDLEY_GCC_VERSION) || \ 1719 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) 1720 #define JSON_HEDLEY_INLINE __inline__ 1722 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ 1723 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1724 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1725 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ 1726 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ 1727 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1728 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ 1729 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1730 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1731 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1732 #define JSON_HEDLEY_INLINE __inline 1734 #define JSON_HEDLEY_INLINE 1737 #if defined(JSON_HEDLEY_ALWAYS_INLINE) 1738 #undef JSON_HEDLEY_ALWAYS_INLINE 1741 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ 1742 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1743 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1744 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1745 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1746 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1747 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1748 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1749 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1750 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1751 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1752 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1753 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1754 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1755 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1756 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1757 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1758 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1759 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1760 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE 1762 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ 1763 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1764 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline 1765 #elif defined(__cplusplus) && \ 1767 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1768 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1769 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1770 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1771 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1772 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ 1774 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") 1775 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1776 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") 1778 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE 1781 #if defined(JSON_HEDLEY_NEVER_INLINE) 1782 #undef JSON_HEDLEY_NEVER_INLINE 1785 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ 1786 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1787 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1788 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1789 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1790 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1791 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1792 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1793 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1794 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1795 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1796 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1797 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1798 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1799 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1800 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1801 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1802 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1803 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1804 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) 1806 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1807 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1808 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) 1809 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) 1810 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") 1811 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) 1812 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") 1813 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1814 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") 1815 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) 1816 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) 1817 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) 1818 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) 1820 #define JSON_HEDLEY_NEVER_INLINE 1823 #if defined(JSON_HEDLEY_PRIVATE) 1824 #undef JSON_HEDLEY_PRIVATE 1826 #if defined(JSON_HEDLEY_PUBLIC) 1827 #undef JSON_HEDLEY_PUBLIC 1829 #if defined(JSON_HEDLEY_IMPORT) 1830 #undef JSON_HEDLEY_IMPORT 1832 #if defined(_WIN32) || defined(__CYGWIN__) 1833 # define JSON_HEDLEY_PRIVATE 1834 # define JSON_HEDLEY_PUBLIC __declspec(dllexport) 1835 # define JSON_HEDLEY_IMPORT __declspec(dllimport) 1838 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ 1839 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1840 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1841 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1842 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1843 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 1845 defined(__TI_EABI__) && \ 1847 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1848 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ 1851 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1852 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) 1853 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) 1855 # define JSON_HEDLEY_PRIVATE 1856 # define JSON_HEDLEY_PUBLIC 1858 # define JSON_HEDLEY_IMPORT extern 1861 #if defined(JSON_HEDLEY_NO_THROW) 1862 #undef JSON_HEDLEY_NO_THROW 1865 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ 1866 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1867 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1868 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1869 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) 1871 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ 1872 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1873 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) 1874 #define JSON_HEDLEY_NO_THROW __declspec(nothrow) 1876 #define JSON_HEDLEY_NO_THROW 1879 #if defined(JSON_HEDLEY_FALL_THROUGH) 1880 #undef JSON_HEDLEY_FALL_THROUGH 1883 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ 1884 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ 1885 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1886 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) 1887 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) 1888 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) 1889 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) 1890 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) 1891 #elif defined(__fallthrough) 1892 #define JSON_HEDLEY_FALL_THROUGH __fallthrough 1894 #define JSON_HEDLEY_FALL_THROUGH 1897 #if defined(JSON_HEDLEY_RETURNS_NON_NULL) 1898 #undef JSON_HEDLEY_RETURNS_NON_NULL 1901 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ 1902 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ 1903 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1904 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) 1905 #elif defined(_Ret_notnull_) 1906 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ 1908 #define JSON_HEDLEY_RETURNS_NON_NULL 1911 #if defined(JSON_HEDLEY_ARRAY_PARAM) 1912 #undef JSON_HEDLEY_ARRAY_PARAM 1915 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ 1916 !defined(__STDC_NO_VLA__) && \ 1917 !defined(__cplusplus) && \ 1918 !defined(JSON_HEDLEY_PGI_VERSION) && \ 1919 !defined(JSON_HEDLEY_TINYC_VERSION) 1920 #define JSON_HEDLEY_ARRAY_PARAM(name) (name) 1922 #define JSON_HEDLEY_ARRAY_PARAM(name) 1925 #if defined(JSON_HEDLEY_IS_CONSTANT) 1926 #undef JSON_HEDLEY_IS_CONSTANT 1928 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) 1929 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR 1933 #if defined(JSON_HEDLEY_IS_CONSTEXPR_) 1934 #undef JSON_HEDLEY_IS_CONSTEXPR_ 1937 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ 1938 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 1939 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1940 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ 1941 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1942 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 1943 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1944 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ 1945 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 1946 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1947 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) 1949 #if !defined(__cplusplus) 1951 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ 1952 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 1953 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1954 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 1955 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 1956 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ 1957 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) 1958 #if defined(__INTPTR_TYPE__) 1959 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) 1962 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) 1966 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ 1967 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ 1968 !defined(JSON_HEDLEY_PGI_VERSION) && \ 1969 !defined(JSON_HEDLEY_IAR_VERSION)) || \ 1970 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ 1971 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ 1972 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ 1973 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ 1974 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) 1975 #if defined(__INTPTR_TYPE__) 1976 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) 1979 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) 1982 defined(JSON_HEDLEY_GCC_VERSION) || \ 1983 defined(JSON_HEDLEY_INTEL_VERSION) || \ 1984 defined(JSON_HEDLEY_TINYC_VERSION) || \ 1985 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ 1986 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ 1987 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ 1988 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ 1989 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ 1990 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ 1992 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ 1996 ((void*) ((expr) * 0L) ) : \ 1997 ((struct { char v[sizeof(void) * 2]; } *) 1) \ 2003 #if defined(JSON_HEDLEY_IS_CONSTEXPR_) 2004 #if !defined(JSON_HEDLEY_IS_CONSTANT) 2005 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) 2007 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) 2009 #if !defined(JSON_HEDLEY_IS_CONSTANT) 2010 #define JSON_HEDLEY_IS_CONSTANT(expr) (0) 2012 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) 2015 #if defined(JSON_HEDLEY_BEGIN_C_DECLS) 2016 #undef JSON_HEDLEY_BEGIN_C_DECLS 2018 #if defined(JSON_HEDLEY_END_C_DECLS) 2019 #undef JSON_HEDLEY_END_C_DECLS 2021 #if defined(JSON_HEDLEY_C_DECL) 2022 #undef JSON_HEDLEY_C_DECL 2024 #if defined(__cplusplus) 2025 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { 2026 #define JSON_HEDLEY_END_C_DECLS } 2027 #define JSON_HEDLEY_C_DECL extern "C" 2029 #define JSON_HEDLEY_BEGIN_C_DECLS 2030 #define JSON_HEDLEY_END_C_DECLS 2031 #define JSON_HEDLEY_C_DECL 2034 #if defined(JSON_HEDLEY_STATIC_ASSERT) 2035 #undef JSON_HEDLEY_STATIC_ASSERT 2038 !defined(__cplusplus) && ( \ 2039 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ 2040 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ 2041 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ 2042 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 2043 defined(_Static_assert) \ 2045 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) 2047 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ 2048 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ 2049 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2050 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) 2052 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) 2055 #if defined(JSON_HEDLEY_NULL) 2056 #undef JSON_HEDLEY_NULL 2058 #if defined(__cplusplus) 2059 #if __cplusplus >= 201103L 2060 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) 2062 #define JSON_HEDLEY_NULL NULL 2064 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) 2067 #define JSON_HEDLEY_NULL NULL 2069 #define JSON_HEDLEY_NULL ((void*) 0) 2072 #if defined(JSON_HEDLEY_MESSAGE) 2073 #undef JSON_HEDLEY_MESSAGE 2075 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 2076 # define JSON_HEDLEY_MESSAGE(msg) \ 2077 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2078 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ 2079 JSON_HEDLEY_PRAGMA(message msg) \ 2080 JSON_HEDLEY_DIAGNOSTIC_POP 2082 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ 2083 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 2084 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) 2085 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) 2086 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) 2087 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 2088 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2089 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) 2090 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2092 # define JSON_HEDLEY_MESSAGE(msg) 2095 #if defined(JSON_HEDLEY_WARNING) 2096 #undef JSON_HEDLEY_WARNING 2098 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 2099 # define JSON_HEDLEY_WARNING(msg) \ 2100 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2101 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ 2102 JSON_HEDLEY_PRAGMA(clang warning msg) \ 2103 JSON_HEDLEY_DIAGNOSTIC_POP 2105 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ 2106 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ 2107 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 2108 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) 2110 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ 2111 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2112 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2114 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) 2117 #if defined(JSON_HEDLEY_REQUIRE) 2118 #undef JSON_HEDLEY_REQUIRE 2120 #if defined(JSON_HEDLEY_REQUIRE_MSG) 2121 #undef JSON_HEDLEY_REQUIRE_MSG 2123 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) 2124 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") 2125 # define JSON_HEDLEY_REQUIRE(expr) \ 2126 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2127 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ 2128 __attribute__((diagnose_if(!(expr), #expr, "error"))) \ 2129 JSON_HEDLEY_DIAGNOSTIC_POP 2130 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ 2131 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2132 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ 2133 __attribute__((diagnose_if(!(expr), msg, "error"))) \ 2134 JSON_HEDLEY_DIAGNOSTIC_POP 2136 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) 2137 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) 2140 # define JSON_HEDLEY_REQUIRE(expr) 2141 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) 2144 #if defined(JSON_HEDLEY_FLAGS) 2145 #undef JSON_HEDLEY_FLAGS 2147 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) 2148 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) 2150 #define JSON_HEDLEY_FLAGS 2153 #if defined(JSON_HEDLEY_FLAGS_CAST) 2154 #undef JSON_HEDLEY_FLAGS_CAST 2156 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) 2157 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ 2158 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2159 _Pragma("warning(disable:188)") \ 2161 JSON_HEDLEY_DIAGNOSTIC_POP \ 2164 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) 2167 #if defined(JSON_HEDLEY_EMPTY_BASES) 2168 #undef JSON_HEDLEY_EMPTY_BASES 2171 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ 2172 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2173 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) 2175 #define JSON_HEDLEY_EMPTY_BASES 2180 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) 2181 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK 2183 #if defined(__clang__) 2184 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) 2186 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 2189 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) 2190 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE 2192 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 2194 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) 2195 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE 2197 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) 2199 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) 2200 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN 2202 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) 2204 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) 2205 #undef JSON_HEDLEY_CLANG_HAS_FEATURE 2207 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) 2209 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) 2210 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION 2212 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) 2214 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) 2215 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE 2217 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) 2219 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING) 2220 #undef JSON_HEDLEY_CLANG_HAS_WARNING 2222 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) 2229 #include <type_traits> 2258 void operator=(
nonesuch const&) =
delete;
2259 void operator=(
nonesuch&&) =
delete;
2262 template<
class Default,
2264 template<
class...>
class Op,
2272 template<
class Default,
template<
class...>
class Op,
class... Args>
2279 template<
template<
class...>
class Op,
class... Args>
2282 template<
template<
class...>
class Op,
class... Args>
2285 template<
template<
class...>
class Op,
class... Args>
2288 template<
class Default,
template<
class...>
class Op,
class... Args>
2291 template<
class Default,
template<
class...>
class Op,
class... Args>
2294 template<
class Expected,
template<
class...>
class Op,
class... Args>
2297 template<
class To,
template<
class...>
class Op,
class... Args>
2308 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) 2309 #if defined(__clang__) 2310 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 2311 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" 2313 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) 2314 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 2315 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" 2322 #if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) 2323 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) 2324 #define JSON_HAS_CPP_20 2325 #define JSON_HAS_CPP_17 2326 #define JSON_HAS_CPP_14 2327 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 2328 #define JSON_HAS_CPP_17 2329 #define JSON_HAS_CPP_14 2330 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) 2331 #define JSON_HAS_CPP_14 2334 #define JSON_HAS_CPP_11 2337 #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) 2338 #ifdef JSON_HAS_CPP_17 2339 #if defined(__cpp_lib_filesystem) 2340 #define JSON_HAS_FILESYSTEM 1 2341 #elif defined(__cpp_lib_experimental_filesystem) 2342 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 2343 #elif !defined(__has_include) 2344 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 2345 #elif __has_include(<filesystem>) 2346 #define JSON_HAS_FILESYSTEM 1 2347 #elif __has_include(<experimental/filesystem>) 2348 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 2352 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 2353 #undef JSON_HAS_FILESYSTEM 2354 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2358 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 2359 #undef JSON_HAS_FILESYSTEM 2360 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2364 #if defined(__clang_major__) && __clang_major__ < 7 2365 #undef JSON_HAS_FILESYSTEM 2366 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2370 #if defined(_MSC_VER) && _MSC_VER < 1940 2371 #undef JSON_HAS_FILESYSTEM 2372 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2376 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 2377 #undef JSON_HAS_FILESYSTEM 2378 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2382 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 2383 #undef JSON_HAS_FILESYSTEM 2384 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2389 #ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM 2390 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 2393 #ifndef JSON_HAS_FILESYSTEM 2394 #define JSON_HAS_FILESYSTEM 0 2398 #if defined(__clang__) 2399 #pragma clang diagnostic push 2400 #pragma clang diagnostic ignored "-Wdocumentation" 2401 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" 2405 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) 2406 #define JSON_THROW(exception) throw exception 2407 #define JSON_TRY try 2408 #define JSON_CATCH(exception) catch(exception) 2409 #define JSON_INTERNAL_CATCH(exception) catch(exception) 2412 #define JSON_THROW(exception) std::abort() 2413 #define JSON_TRY if(true) 2414 #define JSON_CATCH(exception) if(false) 2415 #define JSON_INTERNAL_CATCH(exception) if(false) 2419 #if defined(JSON_THROW_USER) 2421 #define JSON_THROW JSON_THROW_USER 2423 #if defined(JSON_TRY_USER) 2425 #define JSON_TRY JSON_TRY_USER 2427 #if defined(JSON_CATCH_USER) 2429 #define JSON_CATCH JSON_CATCH_USER 2430 #undef JSON_INTERNAL_CATCH 2431 #define JSON_INTERNAL_CATCH JSON_CATCH_USER 2433 #if defined(JSON_INTERNAL_CATCH_USER) 2434 #undef JSON_INTERNAL_CATCH 2435 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER 2439 #if !defined(JSON_ASSERT) 2441 #define JSON_ASSERT(x) assert(x) 2445 #if defined(JSON_TESTS_PRIVATE) 2446 #define JSON_PRIVATE_UNLESS_TESTED public 2448 #define JSON_PRIVATE_UNLESS_TESTED private 2456 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ 2457 template<typename BasicJsonType> \ 2458 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ 2460 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ 2461 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ 2462 auto it = std::find_if(std::begin(m), std::end(m), \ 2463 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ 2465 return ej_pair.first == e; \ 2467 j = ((it != std::end(m)) ? it : std::begin(m))->second; \ 2469 template<typename BasicJsonType> \ 2470 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ 2472 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ 2473 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ 2474 auto it = std::find_if(std::begin(m), std::end(m), \ 2475 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ 2477 return ej_pair.second == j; \ 2479 e = ((it != std::end(m)) ? it : std::begin(m))->first; \ 2485 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ 2486 template<template<typename, typename, typename...> class ObjectType, \ 2487 template<typename, typename...> class ArrayType, \ 2488 class StringType, class BooleanType, class NumberIntegerType, \ 2489 class NumberUnsignedType, class NumberFloatType, \ 2490 template<typename> class AllocatorType, \ 2491 template<typename, typename = void> class JSONSerializer, \ 2494 #define NLOHMANN_BASIC_JSON_TPL \ 2495 basic_json<ObjectType, ArrayType, StringType, BooleanType, \ 2496 NumberIntegerType, NumberUnsignedType, NumberFloatType, \ 2497 AllocatorType, JSONSerializer, BinaryType> 2501 #define NLOHMANN_JSON_EXPAND( x ) x 2502 #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 2503 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ 2504 NLOHMANN_JSON_PASTE64, \ 2505 NLOHMANN_JSON_PASTE63, \ 2506 NLOHMANN_JSON_PASTE62, \ 2507 NLOHMANN_JSON_PASTE61, \ 2508 NLOHMANN_JSON_PASTE60, \ 2509 NLOHMANN_JSON_PASTE59, \ 2510 NLOHMANN_JSON_PASTE58, \ 2511 NLOHMANN_JSON_PASTE57, \ 2512 NLOHMANN_JSON_PASTE56, \ 2513 NLOHMANN_JSON_PASTE55, \ 2514 NLOHMANN_JSON_PASTE54, \ 2515 NLOHMANN_JSON_PASTE53, \ 2516 NLOHMANN_JSON_PASTE52, \ 2517 NLOHMANN_JSON_PASTE51, \ 2518 NLOHMANN_JSON_PASTE50, \ 2519 NLOHMANN_JSON_PASTE49, \ 2520 NLOHMANN_JSON_PASTE48, \ 2521 NLOHMANN_JSON_PASTE47, \ 2522 NLOHMANN_JSON_PASTE46, \ 2523 NLOHMANN_JSON_PASTE45, \ 2524 NLOHMANN_JSON_PASTE44, \ 2525 NLOHMANN_JSON_PASTE43, \ 2526 NLOHMANN_JSON_PASTE42, \ 2527 NLOHMANN_JSON_PASTE41, \ 2528 NLOHMANN_JSON_PASTE40, \ 2529 NLOHMANN_JSON_PASTE39, \ 2530 NLOHMANN_JSON_PASTE38, \ 2531 NLOHMANN_JSON_PASTE37, \ 2532 NLOHMANN_JSON_PASTE36, \ 2533 NLOHMANN_JSON_PASTE35, \ 2534 NLOHMANN_JSON_PASTE34, \ 2535 NLOHMANN_JSON_PASTE33, \ 2536 NLOHMANN_JSON_PASTE32, \ 2537 NLOHMANN_JSON_PASTE31, \ 2538 NLOHMANN_JSON_PASTE30, \ 2539 NLOHMANN_JSON_PASTE29, \ 2540 NLOHMANN_JSON_PASTE28, \ 2541 NLOHMANN_JSON_PASTE27, \ 2542 NLOHMANN_JSON_PASTE26, \ 2543 NLOHMANN_JSON_PASTE25, \ 2544 NLOHMANN_JSON_PASTE24, \ 2545 NLOHMANN_JSON_PASTE23, \ 2546 NLOHMANN_JSON_PASTE22, \ 2547 NLOHMANN_JSON_PASTE21, \ 2548 NLOHMANN_JSON_PASTE20, \ 2549 NLOHMANN_JSON_PASTE19, \ 2550 NLOHMANN_JSON_PASTE18, \ 2551 NLOHMANN_JSON_PASTE17, \ 2552 NLOHMANN_JSON_PASTE16, \ 2553 NLOHMANN_JSON_PASTE15, \ 2554 NLOHMANN_JSON_PASTE14, \ 2555 NLOHMANN_JSON_PASTE13, \ 2556 NLOHMANN_JSON_PASTE12, \ 2557 NLOHMANN_JSON_PASTE11, \ 2558 NLOHMANN_JSON_PASTE10, \ 2559 NLOHMANN_JSON_PASTE9, \ 2560 NLOHMANN_JSON_PASTE8, \ 2561 NLOHMANN_JSON_PASTE7, \ 2562 NLOHMANN_JSON_PASTE6, \ 2563 NLOHMANN_JSON_PASTE5, \ 2564 NLOHMANN_JSON_PASTE4, \ 2565 NLOHMANN_JSON_PASTE3, \ 2566 NLOHMANN_JSON_PASTE2, \ 2567 NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) 2568 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1) 2569 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) 2570 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) 2571 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) 2572 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) 2573 #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) 2574 #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) 2575 #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) 2576 #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) 2577 #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) 2578 #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) 2579 #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) 2580 #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) 2581 #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) 2582 #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) 2583 #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) 2584 #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) 2585 #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) 2586 #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) 2587 #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) 2588 #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) 2589 #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) 2590 #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) 2591 #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) 2592 #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) 2593 #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) 2594 #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) 2595 #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) 2596 #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) 2597 #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) 2598 #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) 2599 #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) 2600 #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) 2601 #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) 2602 #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) 2603 #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) 2604 #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) 2605 #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) 2606 #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) 2607 #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) 2608 #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) 2609 #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) 2610 #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) 2611 #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) 2612 #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) 2613 #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) 2614 #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) 2615 #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) 2616 #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) 2617 #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) 2618 #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) 2619 #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) 2620 #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) 2621 #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) 2622 #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) 2623 #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) 2624 #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) 2625 #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) 2626 #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) 2627 #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) 2628 #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) 2629 #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) 2630 #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) 2632 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; 2633 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); 2640 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ 2641 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__)) } \ 2642 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__)) } 2649 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ 2650 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__)) } \ 2651 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__)) } 2660 #define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ 2661 namespace detail { \ 2662 using std::std_name; \ 2664 template<typename... T> \ 2665 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ 2668 namespace detail2 { \ 2669 struct std_name##_tag \ 2673 template<typename... T> \ 2674 std_name##_tag std_name(T&&...); \ 2676 template<typename... T> \ 2677 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ 2679 template<typename... T> \ 2680 struct would_call_std_##std_name \ 2682 static constexpr auto const value = ::nlohmann::detail:: \ 2683 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \ 2687 template<typename... T> \ 2688 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \ 2692 #ifndef JSON_USE_IMPLICIT_CONVERSIONS 2693 #define JSON_USE_IMPLICIT_CONVERSIONS 1 2696 #if JSON_USE_IMPLICIT_CONVERSIONS 2697 #define JSON_EXPLICIT 2699 #define JSON_EXPLICIT explicit 2702 #ifndef JSON_DIAGNOSTICS 2703 #define JSON_DIAGNOSTICS 0 2729 for (
auto pos = s.find(f);
2730 pos != std::string::npos;
2731 s.replace(pos, f.size(), t),
2732 pos = s.find(f, pos + t.size()))
2788 return chars_read_total;
2812 const char*
what() const noexcept
override 2822 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
2826 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
2829 template<
typename BasicJsonType>
2832 #if JSON_DIAGNOSTICS 2833 std::vector<std::string> tokens;
2834 for (
const auto* current = &leaf_element; current->m_parent !=
nullptr; current = current->m_parent)
2836 switch (current->m_parent->type())
2840 for (
std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2842 if (¤t->m_parent->m_value.array->operator[](i) == current)
2844 tokens.emplace_back(std::to_string(i));
2853 for (
const auto& element : *current->m_parent->m_value.object)
2855 if (&element.second == current)
2857 tokens.emplace_back(element.first.c_str());
2882 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(),
std::string{},
2888 static_cast<void>(leaf_element);
2895 std::runtime_error
m;
2912 template<
typename BasicJsonType>
2920 template<
typename BasicJsonType>
2924 (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
2926 return {id_, byte_, w.c_str()};
2942 :
exception(id_, what_arg), byte(byte_) {}
2946 return " at line " + std::to_string(pos.
lines_read + 1) +
2956 template<
typename BasicJsonType>
2960 return {id_, w.c_str()};
2974 template<
typename BasicJsonType>
2978 return {id_, w.c_str()};
2991 template<
typename BasicJsonType>
2995 return {id_, w.c_str()};
3008 template<
typename BasicJsonType>
3012 return {id_, w.c_str()};
3029 #include <type_traits> 3040 template<
typename T>
3043 #ifdef JSON_HAS_CPP_14 3054 template<
bool B,
typename T =
void>
3081 template <
typename T, T... Ints>
3087 return sizeof...(Ints);
3096 template <
size_t... Ints>
3099 namespace utility_internal
3102 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3106 template <
typename T, T... Ints,
size_t SeqSize>
3112 template <
typename T, T... Ints,
size_t SeqSize>
3120 template <
typename T,
size_t N>
3124 typename Extend <
typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
3127 template <
typename T>
3142 template <
typename T, T N>
3158 template <
typename... Ts>
3170 template<
typename T>
3176 template<
typename T>
3198 #include <type_traits> 3219 template<
typename It,
typename =
void>
3222 template<
typename It>
3237 template<
typename T,
typename =
void>
3242 template<
typename T>
3248 template<
typename T>
3287 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3288 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3310 template<
typename T =
void,
typename SFINAE =
void>
3315 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3317 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3318 class StringType =
std::string,
class BooleanType = bool,
3319 class NumberIntegerType = std::int64_t,
3320 class NumberUnsignedType = std::uint64_t,
3321 class NumberFloatType = double,
3323 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3325 class BinaryType = std::vector<std::uint8_t>>
3330 template<
typename BasicJsonType>
3341 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3350 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3393 template<
typename T>
3400 template<
typename T>
3403 template<
typename T>
3406 template<
typename T>
3409 template<
typename T>
3412 template<
typename T>
3415 template<
typename T>
3418 template<
typename T>
3421 template<
typename T,
typename... Args>
3424 template<
typename T,
typename... Args>
3427 template<
typename T,
typename U>
3431 template<
typename BasicJsonType,
typename T,
typename =
void>
3438 template <
typename BasicJsonType,
typename T>
3444 template<
typename BasicJsonType,
typename T>
3447 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3451 const BasicJsonType&, T&>
::value;
3456 template<
typename BasicJsonType,
typename T,
typename =
void>
3459 template<
typename BasicJsonType,
typename T>
3462 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3471 template<
typename BasicJsonType,
typename T,
typename =
void>
3474 template<
typename BasicJsonType,
typename T>
3477 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3492 template<
class B1,
class... Bn>
3494 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>
::type {};
3497 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3502 template <
typename T>
3505 template <
typename T1,
typename T2>
3507 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3509 template <
typename T1,
typename T2>
3511 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3513 template <
typename... Ts>
3515 :
conjunction<is_default_constructible<Ts>...> {};
3517 template <
typename... Ts>
3519 :
conjunction<is_default_constructible<Ts>...> {};
3522 template <
typename T,
typename... Args>
3525 template <
typename T1,
typename T2>
3528 template <
typename T1,
typename T2>
3531 template <
typename... Ts>
3534 template <
typename... Ts>
3538 template<
typename T,
typename =
void>
3541 template<
typename T>
3556 template<
typename T>
3568 static constexpr
auto is_iterator_begin =
3572 static constexpr
bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3575 template<
typename R>
3578 template<
typename T>
3585 template<
typename T,
typename =
void>
3588 template<
typename T>
3591 template<
typename BasicJsonType,
typename CompatibleObjectType,
3595 template<
typename BasicJsonType,
typename CompatibleObjectType>
3597 BasicJsonType, CompatibleObjectType,
3606 typename CompatibleObjectType::key_type>
::value &&
3608 typename CompatibleObjectType::mapped_type>
::value;
3611 template<
typename BasicJsonType,
typename CompatibleObjectType>
3615 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3619 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3621 BasicJsonType, ConstructibleObjectType,
3629 (std::is_move_assignable<ConstructibleObjectType>::value ||
3630 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3632 typename object_t::key_type>::value &&
3634 typename object_t::mapped_type,
3635 typename ConstructibleObjectType::mapped_type >::value)) ||
3637 typename ConstructibleObjectType::mapped_type>::value ||
3640 typename ConstructibleObjectType::mapped_type >::value);
3643 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3646 ConstructibleObjectType> {};
3648 template<
typename BasicJsonType,
typename CompatibleStringType>
3651 static constexpr
auto value =
3655 template<
typename BasicJsonType,
typename ConstructibleStringType>
3658 static constexpr
auto value =
3660 typename BasicJsonType::string_t>
::value;
3663 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3666 template<
typename BasicJsonType,
typename CompatibleArrayType>
3668 BasicJsonType, CompatibleArrayType,
3674 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3676 static constexpr
bool value =
3681 template<
typename BasicJsonType,
typename CompatibleArrayType>
3685 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3688 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3690 BasicJsonType, ConstructibleArrayType,
3692 typename BasicJsonType::value_type>
::value >>
3695 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3697 BasicJsonType, ConstructibleArrayType,
3698 enable_if_t < !std::is_same<ConstructibleArrayType,
3699 typename BasicJsonType::value_type>
::value&&
3702 (std::is_move_assignable<ConstructibleArrayType>::value ||
3703 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3709 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3711 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3715 static constexpr
bool value =
3725 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3729 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3733 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3735 RealIntegerType, CompatibleNumberIntegerType,
3737 std::is_integral<CompatibleNumberIntegerType>
::value&&
3738 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3744 static constexpr
auto value =
3746 CompatibleNumberIntegerType>
::value &&
3751 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3754 CompatibleNumberIntegerType> {};
3756 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3759 template<
typename BasicJsonType,
typename CompatibleType>
3761 BasicJsonType, CompatibleType,
3764 static constexpr
bool value =
3768 template<
typename BasicJsonType,
typename CompatibleType>
3772 template<
typename T1,
typename T2>
3775 template<
typename T1,
typename... Args>
3780 template <
typename T>
3790 template <
typename C>
static one test( decltype(&C::capacity) ) ;
3791 template <
typename C>
static two test(...);
3793 enum { value =
sizeof(test<T>(
nullptr)) ==
sizeof(char) };
3797 template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3800 return static_cast<T
>(
value);
3803 template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3815 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM 3816 #include <experimental/filesystem> 3819 namespace std_fs = std::experimental::filesystem;
3821 #elif JSON_HAS_FILESYSTEM 3822 #include <filesystem> 3825 namespace std_fs = std::filesystem;
3833 template<
typename BasicJsonType>
3834 void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
3844 template <
typename BasicJsonType,
typename ArithmeticType,
3846 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3850 switch (static_cast<value_t>(j))
3854 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3859 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3864 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3880 template<
typename BasicJsonType>
3881 void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
3887 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3890 template<
typename BasicJsonType>
3891 void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
3897 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3901 typename BasicJsonType,
typename ConstructibleStringType,
3904 !std::is_same<
typename BasicJsonType::string_t,
3905 ConstructibleStringType>
::value,
3907 void from_json(
const BasicJsonType& j, ConstructibleStringType& s)
3914 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3917 template<
typename BasicJsonType>
3918 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
3923 template<
typename BasicJsonType>
3924 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
3929 template<
typename BasicJsonType>
3930 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
3935 template<
typename BasicJsonType,
typename EnumType,
3941 e =
static_cast<EnumType
>(val);
3945 template<
typename BasicJsonType,
typename T,
typename Allocator,
3947 void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
3954 std::transform(j.rbegin(), j.rend(),
3955 std::front_inserter(l), [](
const BasicJsonType & i)
3957 return i.template get<T>();
3962 template<
typename BasicJsonType,
typename T,
3963 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3971 std::transform(j.begin(), j.end(), std::begin(l),
3972 [](
const BasicJsonType & elem)
3974 return elem.template get<T>();
3978 template<
typename BasicJsonType,
typename T, std::
size_t N>
3980 -> decltype(j.template get<T>(),
void())
3984 arr[i] = j.at(i).template get<T>();
3988 template<
typename BasicJsonType>
3991 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
3994 template<
typename BasicJsonType,
typename T, std::
size_t N>
3997 -> decltype(j.template get<T>(),
void())
4001 arr[i] = j.at(i).template get<T>();
4005 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4007 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4011 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4012 j.template get<typename ConstructibleArrayType::value_type>(),
4017 ConstructibleArrayType
ret;
4018 ret.reserve(j.size());
4019 std::transform(j.begin(), j.end(),
4020 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4024 return i.template get<typename ConstructibleArrayType::value_type>();
4029 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4031 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4038 ConstructibleArrayType
ret;
4040 j.begin(), j.end(), std::inserter(ret, end(ret)),
4041 [](
const BasicJsonType & i)
4045 return i.template get<typename ConstructibleArrayType::value_type>();
4050 template <
typename BasicJsonType,
typename ConstructibleArrayType,
4055 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4058 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4060 j.template get<typename ConstructibleArrayType::value_type>(),
4071 template <
typename BasicJsonType,
typename T,
std::size_t... Idx >
4075 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4078 template <
typename BasicJsonType,
typename T, std::
size_t N >
4090 template<
typename BasicJsonType>
4091 void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4098 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4101 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4103 void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4110 ConstructibleObjectType
ret;
4111 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4114 inner_object->begin(), inner_object->end(),
4115 std::inserter(ret, ret.begin()),
4118 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4127 template <
typename BasicJsonType,
typename ArithmeticType,
4129 std::is_arithmetic<ArithmeticType>::value&&
4130 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4131 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4132 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4133 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4137 switch (static_cast<value_t>(j))
4141 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4146 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4151 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4156 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4171 template<
typename BasicJsonType,
typename... Args,
std::size_t... Idx>
4174 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4177 template <
typename BasicJsonType,
class A1,
class A2 >
4180 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4181 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4184 template<
typename BasicJsonType,
typename A1,
typename A2>
4190 template<
typename BasicJsonType,
typename... Args>
4196 template<
typename BasicJsonType,
typename... Args>
4202 template<
typename BasicJsonType,
typename TupleRelated>
4214 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4216 typename BasicJsonType::string_t, Key >::value >>
4217 void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4224 for (
const auto& p : j)
4230 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4234 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4236 typename BasicJsonType::string_t, Key >::value >>
4237 void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4244 for (
const auto& p : j)
4250 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4254 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM 4255 template<
typename BasicJsonType>
4256 void from_json(
const BasicJsonType& j, std_fs::path& p)
4262 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4268 template<
typename BasicJsonType,
typename T>
4270 noexcept(noexcept(
from_json(j, std::forward<T>(val))))
4271 -> decltype(
from_json(j, std::forward<T>(val)))
4273 return from_json(j, std::forward<T>(val));
4290 #include <algorithm> 4294 #include <type_traits> 4319 template<
typename string_type>
4323 using std::to_string;
4324 target = to_string(value);
4334 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::
type >::
type;
4371 return anchor == o.
anchor;
4377 return anchor != o.
anchor;
4385 switch (anchor.m_object->type())
4390 if (array_index != array_index_last)
4393 array_index_last = array_index;
4395 return array_index_str;
4400 return anchor.key();
4419 return anchor.value();
4433 : container(cont) {}
4450 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4458 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4472 #if defined(__clang__) 4474 #pragma clang diagnostic push 4475 #pragma clang diagnostic ignored "-Wmismatched-tags" 4477 template<
typename IteratorType>
4479 :
public std::integral_constant<std::size_t, 2> {};
4481 template<std::
size_t N,
typename IteratorType>
4485 using type = decltype(
4486 get<N>(std::declval <
4489 #if defined(__clang__) 4490 #pragma clang diagnostic pop 4501 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM 4502 #include <experimental/filesystem> 4505 namespace std_fs = std::experimental::filesystem;
4507 #elif JSON_HAS_FILESYSTEM 4508 #include <filesystem> 4511 namespace std_fs = std::filesystem;
4535 template<
typename BasicJsonType>
4536 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b) noexcept
4538 j.m_value.destroy(j.m_type);
4541 j.assert_invariant();
4548 template<
typename BasicJsonType>
4549 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4551 j.m_value.destroy(j.m_type);
4554 j.assert_invariant();
4557 template<
typename BasicJsonType>
4558 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4560 j.m_value.destroy(j.m_type);
4563 j.assert_invariant();
4566 template <
typename BasicJsonType,
typename CompatibleStringType,
4569 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4571 j.m_value.destroy(j.m_type);
4573 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4574 j.assert_invariant();
4581 template<
typename BasicJsonType>
4582 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4584 j.m_value.destroy(j.m_type);
4586 j.m_value =
typename BasicJsonType::binary_t(b);
4587 j.assert_invariant();
4590 template<
typename BasicJsonType>
4591 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4593 j.m_value.destroy(j.m_type);
4595 j.m_value =
typename BasicJsonType::binary_t(
std::move(b));
4596 j.assert_invariant();
4603 template<
typename BasicJsonType>
4604 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val) noexcept
4606 j.m_value.destroy(j.m_type);
4609 j.assert_invariant();
4616 template<
typename BasicJsonType>
4617 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val) noexcept
4619 j.m_value.destroy(j.m_type);
4622 j.assert_invariant();
4629 template<
typename BasicJsonType>
4630 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val) noexcept
4632 j.m_value.destroy(j.m_type);
4635 j.assert_invariant();
4642 template<
typename BasicJsonType>
4643 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4645 j.m_value.destroy(j.m_type);
4649 j.assert_invariant();
4652 template<
typename BasicJsonType>
4653 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4655 j.m_value.destroy(j.m_type);
4659 j.assert_invariant();
4662 template <
typename BasicJsonType,
typename CompatibleArrayType,
4665 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4670 j.m_value.destroy(j.m_type);
4672 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4674 j.assert_invariant();
4677 template<
typename BasicJsonType>
4678 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4680 j.m_value.destroy(j.m_type);
4683 j.m_value.array->reserve(arr.size());
4684 for (
const bool x : arr)
4686 j.m_value.array->push_back(
x);
4687 j.set_parent(j.m_value.array->back());
4689 j.assert_invariant();
4692 template<
typename BasicJsonType,
typename T,
4694 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4696 j.m_value.destroy(j.m_type);
4699 j.m_value.array->resize(arr.size());
4702 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4705 j.assert_invariant();
4712 template<
typename BasicJsonType>
4713 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
4715 j.m_value.destroy(j.m_type);
4719 j.assert_invariant();
4722 template<
typename BasicJsonType>
4723 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4725 j.m_value.destroy(j.m_type);
4729 j.assert_invariant();
4732 template <
typename BasicJsonType,
typename CompatibleObjectType,
4734 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
4739 j.m_value.destroy(j.m_type);
4741 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4743 j.assert_invariant();
4751 template<
typename BasicJsonType,
typename T,
4758 template<
typename BasicJsonType,
typename CompatibleString,
4760 void to_json(BasicJsonType& j,
const CompatibleString& s)
4765 template<
typename BasicJsonType>
4766 void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4771 template<
typename BasicJsonType,
typename FloatType,
4773 void to_json(BasicJsonType& j, FloatType val) noexcept
4778 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
4780 void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
4785 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
4787 void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
4792 template<
typename BasicJsonType,
typename EnumType,
4793 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4794 void to_json(BasicJsonType& j, EnumType e) noexcept
4800 template<
typename BasicJsonType>
4801 void to_json(BasicJsonType& j,
const std::vector<bool>& e)
4806 template <
typename BasicJsonType,
typename CompatibleArrayType,
4808 CompatibleArrayType>::value&&
4811 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4814 void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
4819 template<
typename BasicJsonType>
4820 void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
4825 template<
typename BasicJsonType,
typename T,
4827 void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
4832 template<
typename BasicJsonType>
4833 void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4838 template <
typename BasicJsonType,
typename CompatibleObjectType,
4840 void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
4845 template<
typename BasicJsonType>
4846 void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4852 typename BasicJsonType,
typename T,
std::size_t N,
4853 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
4861 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
4862 void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
4864 j = { p.first, p.second };
4868 template<
typename BasicJsonType,
typename T,
4872 j = { {b.key(), b.value()} };
4875 template<
typename BasicJsonType,
typename Tuple,
std::size_t... Idx>
4878 j = { std::get<Idx>(t)... };
4882 void to_json(BasicJsonType& j,
const T& t)
4887 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM 4888 template<
typename BasicJsonType>
4889 void to_json(BasicJsonType& j,
const std_fs::path& p)
4897 template<
typename BasicJsonType,
typename T>
4898 auto operator()(BasicJsonType& j, T&& val)
const noexcept(noexcept(
to_json(j, std::forward<T>(val))))
4899 -> decltype(
to_json(j, std::forward<T>(val)),
void())
4901 return to_json(j, std::forward<T>(val));
4924 template<
typename ValueType,
typename>
4929 template<
typename BasicJsonType,
typename TargetType = ValueType>
4930 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
4939 template<
typename BasicJsonType,
typename TargetType = ValueType>
4949 template<
typename BasicJsonType,
typename TargetType = ValueType>
4950 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
4971 template<
typename BinaryType>
4996 , m_subtype(subtype_)
4997 , m_has_subtype(true)
5003 , m_subtype(subtype_)
5004 , m_has_subtype(true)
5009 return std::tie(static_cast<const BinaryType&>(*
this), m_subtype, m_has_subtype) ==
5015 return !(rhs == *
this);
5022 m_subtype = subtype_;
5023 m_has_subtype =
true;
5030 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5037 return m_has_subtype;
5045 m_has_subtype =
false;
5050 bool m_has_subtype =
false;
5066 #include <functional> 5081 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5096 template<
typename BasicJsonType>
5099 using string_t =
typename BasicJsonType::string_t;
5100 using number_integer_t =
typename BasicJsonType::number_integer_t;
5101 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5102 using number_float_t =
typename BasicJsonType::number_float_t;
5107 case BasicJsonType::value_t::null:
5108 case BasicJsonType::value_t::discarded:
5116 for (
const auto& element : j.items())
5118 const auto h = std::hash<string_t> {}(element.key());
5125 case BasicJsonType::value_t::array:
5128 for (
const auto& element : j)
5135 case BasicJsonType::value_t::string:
5137 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5143 const auto h = std::hash<bool> {}(j.template get<bool>());
5147 case BasicJsonType::value_t::number_integer:
5149 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5153 case BasicJsonType::value_t::number_unsigned:
5155 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5159 case BasicJsonType::value_t::number_float:
5161 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5165 case BasicJsonType::value_t::binary:
5168 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5170 seed =
combine(seed, static_cast<std::size_t>(j.get_binary().subtype()));
5171 for (
const auto byte : j.get_binary())
5173 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
5190 #include <algorithm> 5215 #include <type_traits> 5221 #endif // JSON_NO_IO 5263 return std::fgetc(m_file);
5292 is->clear(is->rdstate() & std::ios::eofbit);
5297 : is(&i), sb(i.rdbuf())
5306 : is(rhs.is), sb(rhs.sb)
5317 auto res = sb->sbumpc();
5321 is->clear(is->rdstate() | std::ios::eofbit);
5328 std::istream* is =
nullptr;
5329 std::streambuf* sb =
nullptr;
5331 #endif // JSON_NO_IO 5335 template<
typename IteratorType>
5349 auto result = std::char_traits<char_type>::to_int_type(*current);
5350 std::advance(current, 1);
5354 return std::char_traits<char_type>::eof();
5361 template<
typename BaseInputAdapter,
size_t T>
5366 return current == end;
5371 template<
typename BaseInputAdapter,
size_t T>
5374 template<
typename BaseInputAdapter>
5379 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5380 size_t& utf8_bytes_index,
5381 size_t& utf8_bytes_filled)
5383 utf8_bytes_index = 0;
5387 utf8_bytes[0] = std::char_traits<char>::eof();
5388 utf8_bytes_filled = 1;
5393 const auto wc = input.get_character();
5398 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5399 utf8_bytes_filled = 1;
5401 else if (wc <= 0x7FF)
5403 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5404 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5405 utf8_bytes_filled = 2;
5407 else if (wc <= 0xFFFF)
5409 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5410 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5411 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5412 utf8_bytes_filled = 3;
5414 else if (wc <= 0x10FFFF)
5416 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5417 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5418 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5419 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5420 utf8_bytes_filled = 4;
5425 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5426 utf8_bytes_filled = 1;
5432 template<
typename BaseInputAdapter>
5437 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5438 size_t& utf8_bytes_index,
5439 size_t& utf8_bytes_filled)
5441 utf8_bytes_index = 0;
5445 utf8_bytes[0] = std::char_traits<char>::eof();
5446 utf8_bytes_filled = 1;
5451 const auto wc = input.get_character();
5456 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5457 utf8_bytes_filled = 1;
5459 else if (wc <= 0x7FF)
5461 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5462 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5463 utf8_bytes_filled = 2;
5465 else if (0xD800 > wc || wc >= 0xE000)
5467 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5468 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5469 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5470 utf8_bytes_filled = 3;
5476 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5477 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5478 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5479 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5480 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5481 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5482 utf8_bytes_filled = 4;
5486 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5487 utf8_bytes_filled = 1;
5495 template<
typename BaseInputAdapter,
typename W
ideCharType>
5502 : base_adapter(base) {}
5507 if (utf8_bytes_index == utf8_bytes_filled)
5509 fill_buffer<sizeof(WideCharType)>();
5517 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
5518 return utf8_bytes[utf8_bytes_index++];
5531 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
5540 template<
typename IteratorType,
typename Enable =
void>
5553 template<
typename T>
5563 template<
typename IteratorType>
5578 template<
typename IteratorType>
5589 namespace container_input_adapter_factory_impl
5595 template<
typename ContainerType,
typename Enable =
void>
5598 template<
typename ContainerType>
5600 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5612 template<
typename ContainerType>
5634 #endif // JSON_NO_IO 5639 template <
typename CharT,
5640 typename std::enable_if <
5641 std::is_pointer<CharT>::value&&
5642 !std::is_array<CharT>::value&&
5648 auto length = std::strlen(reinterpret_cast<const char*>(b));
5649 const auto*
ptr =
reinterpret_cast<const char*
>(b);
5653 template<
typename T, std::
size_t N>
5665 template <
typename CharT,
5666 typename std::enable_if <
5667 std::is_pointer<CharT>::value&&
5672 : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
5674 template<
class IteratorType,
5675 typename std::enable_if<
5676 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
5716 template<
typename BasicJsonType>
5729 virtual bool null() = 0;
5736 virtual bool boolean(
bool val) = 0;
5782 virtual bool start_object(
std::size_t elements) = 0;
5796 virtual bool end_object() = 0;
5804 virtual bool start_array(
std::size_t elements) = 0;
5810 virtual bool end_array() = 0;
5847 template<
typename BasicJsonType>
5863 : root(r), allow_exceptions(allow_exceptions_)
5875 handle_value(
nullptr);
5919 if (
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
5930 object_element = &(ref_stack.back()->m_value.object->operator[](val));
5936 ref_stack.back()->set_parents();
5937 ref_stack.pop_back();
5943 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
5945 if (
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
5955 ref_stack.back()->set_parents();
5956 ref_stack.pop_back();
5960 template<
class Exception>
5962 const Exception& ex)
5965 static_cast<void>(ex);
5966 if (allow_exceptions)
5985 template<
typename Value>
5989 if (ref_stack.empty())
5991 root = BasicJsonType(std::forward<Value>(v));
5995 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
5997 if (ref_stack.back()->is_array())
5999 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6000 return &(ref_stack.back()->m_value.array->back());
6005 *object_element = BasicJsonType(std::forward<Value>(v));
6006 return object_element;
6012 std::vector<BasicJsonType*> ref_stack {};
6014 BasicJsonType* object_element =
nullptr;
6016 bool errored =
false;
6018 const bool allow_exceptions =
true;
6021 template<
typename BasicJsonType>
6035 const bool allow_exceptions_ =
true)
6036 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6038 keep_stack.push_back(
true);
6050 handle_value(
nullptr);
6094 keep_stack.push_back(keep);
6097 ref_stack.push_back(val.second);
6100 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
6110 BasicJsonType k = BasicJsonType(val);
6113 const bool keep = callback(static_cast<int>(ref_stack.size()),
parse_event_t::key, k);
6114 key_keep_stack.push_back(keep);
6117 if (keep && ref_stack.back())
6119 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6127 if (ref_stack.back())
6136 ref_stack.back()->set_parents();
6142 ref_stack.pop_back();
6143 keep_stack.pop_back();
6145 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6148 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6150 if (it->is_discarded())
6152 ref_stack.back()->erase(it);
6164 keep_stack.push_back(keep);
6166 auto val = handle_value(BasicJsonType::value_t::array,
true);
6167 ref_stack.push_back(val.second);
6170 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != static_cast<std::size_t>(-1) && len > ref_stack.back()->max_size()))
6182 if (ref_stack.back())
6187 ref_stack.back()->set_parents();
6198 ref_stack.pop_back();
6199 keep_stack.pop_back();
6202 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6204 ref_stack.back()->m_value.array->pop_back();
6210 template<
class Exception>
6212 const Exception& ex)
6215 static_cast<void>(ex);
6216 if (allow_exceptions)
6244 template<
typename Value>
6245 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
6251 if (!keep_stack.back())
6253 return {
false,
nullptr};
6257 auto value = BasicJsonType(std::forward<Value>(v));
6265 return {
false,
nullptr};
6268 if (ref_stack.empty())
6271 return {
true, &root};
6276 if (!ref_stack.back())
6278 return {
false,
nullptr};
6282 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6285 if (ref_stack.back()->is_array())
6288 return {
true, &(ref_stack.back()->m_value.array->back())};
6295 const bool store_element = key_keep_stack.back();
6296 key_keep_stack.pop_back();
6300 return {
false,
nullptr};
6305 return {
true, object_element};
6311 std::vector<BasicJsonType*> ref_stack {};
6313 std::vector<bool> keep_stack {};
6315 std::vector<bool> key_keep_stack {};
6317 BasicJsonType* object_element =
nullptr;
6319 bool errored =
false;
6323 const bool allow_exceptions =
true;
6325 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6328 template<
typename BasicJsonType>
6415 #include <initializer_list> 6435 template<
typename BasicJsonType>
6468 case token_type::uninitialized:
6469 return "<uninitialized>";
6470 case token_type::literal_true:
6471 return "true literal";
6472 case token_type::literal_false:
6473 return "false literal";
6474 case token_type::literal_null:
6475 return "null literal";
6476 case token_type::value_string:
6477 return "string literal";
6478 case token_type::value_unsigned:
6479 case token_type::value_integer:
6480 case token_type::value_float:
6481 return "number literal";
6482 case token_type::begin_array:
6484 case token_type::begin_object:
6486 case token_type::end_array:
6488 case token_type::end_object:
6490 case token_type::name_separator:
6492 case token_type::value_separator:
6494 case token_type::parse_error:
6495 return "<parse error>";
6496 case token_type::end_of_input:
6497 return "end of input";
6498 case token_type::literal_or_value:
6499 return "'[', '{', or a literal";
6502 return "unknown token";
6512 template<
typename BasicJsonType,
typename InputAdapterType>
6525 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6527 , ignore_comments(ignore_comments_)
6528 , decimal_point_char(static_cast<
char_int_type>(get_decimal_point()))
6547 const auto* loc = localeconv();
6549 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6577 const auto factors = { 12u, 8u, 4u, 0u };
6578 for (
const auto factor : factors)
6582 if (current >=
'0' && current <=
'9')
6584 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
6586 else if (current >=
'A' && current <=
'F')
6588 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
6590 else if (current >=
'a' && current <=
'f')
6592 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
6600 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6621 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6624 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6633 error_message =
"invalid string: ill-formed UTF-8 byte";
6670 case std::char_traits<char_type>::eof():
6672 error_message =
"invalid string: missing closing quote";
6673 return token_type::parse_error;
6679 return token_type::value_string;
6723 const int codepoint1 = get_codepoint();
6728 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6729 return token_type::parse_error;
6733 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6738 const int codepoint2 = get_codepoint();
6742 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6743 return token_type::parse_error;
6750 codepoint =
static_cast<int>(
6752 (
static_cast<unsigned int>(codepoint1) << 10u)
6754 +
static_cast<unsigned int>(codepoint2)
6762 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6763 return token_type::parse_error;
6768 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6769 return token_type::parse_error;
6776 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6777 return token_type::parse_error;
6782 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
6785 if (codepoint < 0x80)
6788 add(static_cast<char_int_type>(codepoint));
6790 else if (codepoint <= 0x7FF)
6793 add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
6794 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6796 else if (codepoint <= 0xFFFF)
6799 add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
6800 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6801 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6806 add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
6807 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
6808 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6809 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6817 error_message =
"invalid string: forbidden character after backslash";
6818 return token_type::parse_error;
6827 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6828 return token_type::parse_error;
6833 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6834 return token_type::parse_error;
6839 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6840 return token_type::parse_error;
6845 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6846 return token_type::parse_error;
6851 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6852 return token_type::parse_error;
6857 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6858 return token_type::parse_error;
6863 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6864 return token_type::parse_error;
6869 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6870 return token_type::parse_error;
6875 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6876 return token_type::parse_error;
6881 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6882 return token_type::parse_error;
6887 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6888 return token_type::parse_error;
6893 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
6894 return token_type::parse_error;
6899 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
6900 return token_type::parse_error;
6905 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
6906 return token_type::parse_error;
6911 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
6912 return token_type::parse_error;
6917 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
6918 return token_type::parse_error;
6923 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
6924 return token_type::parse_error;
6929 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
6930 return token_type::parse_error;
6935 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
6936 return token_type::parse_error;
6941 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
6942 return token_type::parse_error;
6947 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
6948 return token_type::parse_error;
6953 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
6954 return token_type::parse_error;
6959 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
6960 return token_type::parse_error;
6965 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
6966 return token_type::parse_error;
6971 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
6972 return token_type::parse_error;
6977 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
6978 return token_type::parse_error;
6983 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
6984 return token_type::parse_error;
6989 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
6990 return token_type::parse_error;
6995 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
6996 return token_type::parse_error;
7001 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7002 return token_type::parse_error;
7007 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7008 return token_type::parse_error;
7013 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7014 return token_type::parse_error;
7151 return token_type::parse_error;
7161 return token_type::parse_error;
7185 return token_type::parse_error;
7195 return token_type::parse_error;
7205 return token_type::parse_error;
7217 return token_type::parse_error;
7227 return token_type::parse_error;
7235 error_message =
"invalid string: ill-formed UTF-8 byte";
7236 return token_type::parse_error;
7259 case std::char_traits<char_type>::eof():
7276 case std::char_traits<char_type>::eof():
7279 error_message =
"invalid comment; missing closing '*/'";
7307 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7314 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7316 f = std::strtof(str, endptr);
7320 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7322 f = std::strtod(str, endptr);
7326 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7328 f = std::strtold(str, endptr);
7378 token_type number_type = token_type::value_unsigned;
7386 goto scan_number_minus;
7392 goto scan_number_zero;
7406 goto scan_number_any1;
7416 number_type = token_type::value_integer;
7422 goto scan_number_zero;
7436 goto scan_number_any1;
7441 error_message =
"invalid number; expected digit after '-'";
7442 return token_type::parse_error;
7452 add(decimal_point_char);
7453 goto scan_number_decimal1;
7460 goto scan_number_exponent;
7464 goto scan_number_done;
7483 goto scan_number_any1;
7488 add(decimal_point_char);
7489 goto scan_number_decimal1;
7496 goto scan_number_exponent;
7500 goto scan_number_done;
7503 scan_number_decimal1:
7505 number_type = token_type::value_float;
7520 goto scan_number_decimal2;
7525 error_message =
"invalid number; expected digit after '.'";
7526 return token_type::parse_error;
7530 scan_number_decimal2:
7546 goto scan_number_decimal2;
7553 goto scan_number_exponent;
7557 goto scan_number_done;
7560 scan_number_exponent:
7562 number_type = token_type::value_float;
7569 goto scan_number_sign;
7584 goto scan_number_any2;
7590 "invalid number; expected '+', '-', or digit after exponent";
7591 return token_type::parse_error;
7611 goto scan_number_any2;
7616 error_message =
"invalid number; expected digit after exponent sign";
7617 return token_type::parse_error;
7637 goto scan_number_any2;
7641 goto scan_number_done;
7649 char* endptr =
nullptr;
7653 if (number_type == token_type::value_unsigned)
7655 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
7658 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7663 if (value_unsigned ==
x)
7665 return token_type::value_unsigned;
7669 else if (number_type == token_type::value_integer)
7671 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
7674 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7679 if (value_integer ==
x)
7681 return token_type::value_integer;
7688 strtof(value_float, token_buffer.data(), &endptr);
7691 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7693 return token_type::value_float;
7705 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
7710 error_message =
"invalid literal";
7711 return token_type::parse_error;
7724 token_buffer.clear();
7725 token_string.clear();
7726 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7741 ++position.chars_read_total;
7742 ++position.chars_read_current_line;
7751 current = ia.get_character();
7756 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7759 if (current ==
'\n')
7761 ++position.lines_read;
7762 position.chars_read_current_line = 0;
7780 --position.chars_read_total;
7783 if (position.chars_read_current_line == 0)
7785 if (position.lines_read > 0)
7787 --position.lines_read;
7792 --position.chars_read_current_line;
7798 token_string.pop_back();
7805 token_buffer.push_back(static_cast<typename string_t::value_type>(c));
7816 return value_integer;
7822 return value_unsigned;
7834 return token_buffer;
7854 for (
const auto c : token_string)
7856 if (static_cast<unsigned char>(c) <=
'\x1F')
7859 std::array<char, 9> cs{{}};
7860 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
7861 result += cs.data();
7866 result.push_back(static_cast<std::string::value_type>(c));
7877 return error_message;
7893 return get() == 0xBB &&
get() == 0xBF;
7908 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
7914 if (position.chars_read_total == 0 && !skip_bom())
7916 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
7917 return token_type::parse_error;
7924 while (ignore_comments && current ==
'/')
7926 if (!scan_comment())
7928 return token_type::parse_error;
7939 return token_type::begin_array;
7941 return token_type::end_array;
7943 return token_type::begin_object;
7945 return token_type::end_object;
7947 return token_type::name_separator;
7949 return token_type::value_separator;
7954 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')}};
7955 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
7959 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')}};
7960 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
7964 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')}};
7965 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
7970 return scan_string();
7984 return scan_number();
7989 case std::char_traits<char_type>::eof():
7990 return token_type::end_of_input;
7994 error_message =
"invalid literal";
7995 return token_type::parse_error;
8004 const bool ignore_comments =
false;
8010 bool next_unget =
false;
8016 std::vector<char_type> token_string {};
8022 const char* error_message =
"";
8053 template<
typename T>
8056 template<
typename T>
8058 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
8060 template<
typename T,
typename Integer>
8064 template<
typename T,
typename Un
signed>
8068 template<
typename T,
typename Float,
typename String>
8070 std::declval<Float>(), std::declval<const String&>()));
8072 template<
typename T,
typename String>
8074 decltype(std::declval<T&>().
string(std::declval<String&>()));
8076 template<
typename T,
typename Binary>
8078 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
8080 template<
typename T>
8082 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8084 template<
typename T,
typename String>
8086 decltype(std::declval<T&>().
key(std::declval<String&>()));
8088 template<
typename T>
8091 template<
typename T>
8093 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8095 template<
typename T>
8098 template<
typename T,
typename Exception>
8100 std::declval<std::size_t>(), std::declval<const std::string&>(),
8101 std::declval<const Exception&>()));
8103 template<
typename SAX,
typename BasicJsonType>
8108 "BasicJsonType must be of type basic_json<...>");
8134 template<
typename SAX,
typename BasicJsonType>
8139 "BasicJsonType must be of type basic_json<...>");
8150 "Missing/invalid function: bool null()");
8152 "Missing/invalid function: bool boolean(bool)");
8154 "Missing/invalid function: bool boolean(bool)");
8158 "Missing/invalid function: bool number_integer(number_integer_t)");
8162 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8165 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8168 "Missing/invalid function: bool string(string_t&)");
8171 "Missing/invalid function: bool binary(binary_t&)");
8173 "Missing/invalid function: bool start_object(std::size_t)");
8175 "Missing/invalid function: bool key(string_t&)");
8177 "Missing/invalid function: bool end_object()");
8179 "Missing/invalid function: bool start_array(std::size_t)");
8181 "Missing/invalid function: bool end_array()");
8184 "Missing/invalid function: bool parse_error(std::size_t, const " 8185 "std::string&, const exception&)");
8217 return *
reinterpret_cast<char*
>(&num) == 1;
8228 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8269 const
bool strict = true,
8278 result = parse_bson_internal();
8282 result = parse_cbor_internal(
true, tag_handler);
8286 result = parse_msgpack_internal();
8290 result = parse_ubjson_internal();
8312 return sax->parse_error(chars_read, get_token_string(),
8313 parse_error::create(110, chars_read, exception_message(format,
"expected end of input; last byte: 0x" + get_token_string(),
"value"), BasicJsonType()));
8331 std::int32_t document_size{};
8344 return sax->end_object();
8356 auto out = std::back_inserter(result);
8364 if (current == 0x00)
8383 template<
typename NumberType>
8388 auto last_token = get_token_string();
8389 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(
input_format_t::bson,
"string length must be at least 1, is " + std::to_string(len),
"string"), BasicJsonType()));
8392 return get_string(
input_format_t::bson, len - static_cast<NumberType>(1), result) &&
get() != std::char_traits<char_type>::eof();
8404 template<
typename NumberType>
8409 auto last_token = get_token_string();
8410 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(
input_format_t::bson,
"byte array length cannot be negative, is " + std::to_string(len),
"binary"), BasicJsonType()));
8414 std::uint8_t subtype{};
8416 result.set_subtype(subtype);
8418 return get_binary(input_format_t::bson, len, result);
8434 switch (element_type)
8439 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number),
"");
8446 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
8451 return parse_bson_internal();
8456 return parse_bson_array();
8463 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
8468 return sax->boolean(
get() != 0);
8478 std::int32_t
value{};
8484 std::int64_t
value{};
8490 std::array<char, 3> cr{{}};
8491 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
8492 return sax->parse_error(element_type_parse_position,
std::string(cr.data()),
parse_error::create(114, element_type_parse_position,
"Unsupported BSON record type 0x" +
std::string(cr.data()), BasicJsonType()));
8513 while (
auto element_type =
get())
8520 const std::size_t element_type_parse_position = chars_read;
8526 if (!is_array && !sax->key(key))
8531 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
8549 std::int32_t document_size{};
8562 return sax->end_array();
8580 switch (get_char ?
get() : current)
8583 case std::char_traits<char_type>::eof():
8611 return sax->number_unsigned(static_cast<number_unsigned_t>(current));
8615 std::uint8_t number{};
8621 std::uint16_t number{};
8627 std::uint32_t number{};
8633 std::uint64_t number{};
8662 return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
8666 std::uint8_t number{};
8667 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8672 std::uint16_t number{};
8673 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8678 std::uint32_t number{};
8679 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8684 std::uint64_t number{};
8685 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1)
8686 - static_cast<number_integer_t>(number));
8721 return get_cbor_binary(b) && sax->binary(b);
8756 return get_cbor_string(s) && sax->string(s);
8784 return get_cbor_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8789 return get_number(
input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8794 std::uint16_t len{};
8795 return get_number(
input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8800 std::uint32_t len{};
8801 return get_number(
input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8806 std::uint64_t len{};
8807 return get_number(
input_format_t::cbor, len) && get_cbor_array(detail::conditional_static_cast<std::size_t>(len), tag_handler);
8811 return get_cbor_array(static_cast<std::size_t>(-1), tag_handler);
8838 return get_cbor_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8843 return get_number(
input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8848 std::uint16_t len{};
8849 return get_number(
input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8854 std::uint32_t len{};
8855 return get_number(
input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8860 std::uint64_t len{};
8861 return get_number(
input_format_t::cbor, len) && get_cbor_object(detail::conditional_static_cast<std::size_t>(len), tag_handler);
8865 return get_cbor_object(static_cast<std::size_t>(-1), tag_handler);
8887 switch (tag_handler)
8891 auto last_token = get_token_string();
8902 std::uint8_t subtype_to_ignore{};
8908 std::uint16_t subtype_to_ignore{};
8914 std::uint32_t subtype_to_ignore{};
8920 std::uint64_t subtype_to_ignore{};
8927 return parse_cbor_internal(
true, tag_handler);
8938 std::uint8_t subtype{};
8940 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8945 std::uint16_t subtype{};
8947 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8952 std::uint32_t subtype{};
8954 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8959 std::uint64_t subtype{};
8961 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8965 return parse_cbor_internal(
true, tag_handler);
8968 return get_cbor_binary(b) && sax->binary(b);
8978 return sax->boolean(
false);
8981 return sax->boolean(
true);
8988 const auto byte1_raw =
get();
8993 const auto byte2_raw =
get();
8999 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9000 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9010 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9011 const double val = [&half]
9013 const int exp = (half >> 10u) & 0x1Fu;
9014 const unsigned int mant = half & 0x3FFu;
9020 return std::ldexp(mant, -24);
9023 ? std::numeric_limits<double>::infinity()
9024 : std::numeric_limits<double>::quiet_NaN();
9026 return std::ldexp(mant + 1024, exp - 25);
9029 return sax->number_float((half & 0x8000u) != 0
9030 ? static_cast<number_float_t>(-val)
9031 : static_cast<number_float_t>(val),
"");
9037 return get_number(
input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9043 return get_number(
input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9048 auto last_token = get_token_string();
9111 std::uint16_t len{};
9117 std::uint32_t len{};
9123 std::uint64_t len{};
9129 while (
get() != 0xFF)
9132 if (!get_cbor_string(chunk))
9136 result.append(chunk);
9143 auto last_token = get_token_string();
9144 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(
input_format_t::cbor,
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token,
"string"), BasicJsonType()));
9207 std::uint16_t len{};
9214 std::uint32_t len{};
9221 std::uint64_t len{};
9228 while (
get() != 0xFF)
9231 if (!get_cbor_binary(chunk))
9235 result.insert(result.end(), chunk.begin(), chunk.end());
9242 auto last_token = get_token_string();
9243 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(
input_format_t::cbor,
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token,
"binary"), BasicJsonType()));
9262 if (len != static_cast<std::size_t>(-1))
9274 while (
get() != 0xFF)
9283 return sax->end_array();
9303 if (len != static_cast<std::size_t>(-1))
9322 while (
get() != 0xFF)
9338 return sax->end_object();
9353 case std::char_traits<char_type>::eof():
9485 return sax->number_unsigned(static_cast<number_unsigned_t>(current));
9504 return get_msgpack_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
9523 return get_msgpack_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
9563 return get_msgpack_string(s) && sax->string(s);
9570 return sax->boolean(
false);
9573 return sax->boolean(
true);
9588 return get_msgpack_binary(b) && sax->binary(b);
9594 return get_number(
input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9600 return get_number(
input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9605 std::uint8_t number{};
9611 std::uint16_t number{};
9617 std::uint32_t number{};
9623 std::uint64_t number{};
9629 std::int8_t number{};
9635 std::int16_t number{};
9641 std::int32_t number{};
9647 std::int64_t number{};
9653 std::uint16_t len{};
9659 std::uint32_t len{};
9665 std::uint16_t len{};
9671 std::uint32_t len{};
9708 return sax->number_integer(static_cast<std::int8_t>(current));
9712 auto last_token = get_token_string();
9782 std::uint16_t len{};
9788 std::uint32_t len{};
9794 auto last_token = get_token_string();
9795 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(
input_format_t::msgpack,
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token,
"string"), BasicJsonType()));
9813 auto assign_and_return_true = [&
result](std::int8_t subtype)
9815 result.set_subtype(static_cast<std::uint8_t>(subtype));
9830 std::uint16_t len{};
9837 std::uint32_t len{};
9845 std::int8_t subtype{};
9849 assign_and_return_true(subtype);
9854 std::uint16_t len{};
9855 std::int8_t subtype{};
9859 assign_and_return_true(subtype);
9864 std::uint32_t len{};
9865 std::int8_t subtype{};
9869 assign_and_return_true(subtype);
9874 std::int8_t subtype{};
9877 assign_and_return_true(subtype);
9882 std::int8_t subtype{};
9885 assign_and_return_true(subtype);
9890 std::int8_t subtype{};
9893 assign_and_return_true(subtype);
9898 std::int8_t subtype{};
9901 assign_and_return_true(subtype);
9906 std::int8_t subtype{};
9909 assign_and_return_true(subtype);
9936 return sax->end_array();
9966 return sax->end_object();
9982 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10015 std::uint8_t len{};
10027 std::int16_t len{};
10033 std::int32_t len{};
10039 std::int64_t len{};
10044 auto last_token = get_token_string();
10045 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token,
"string"), BasicJsonType()));
10055 switch (get_ignore_noop())
10059 std::uint8_t number{};
10070 std::int8_t number{};
10081 std::int16_t number{};
10092 std::int32_t number{};
10103 std::int64_t number{};
10114 auto last_token = get_token_string();
10115 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token,
"size"), BasicJsonType()));
10132 result.first = string_t::npos;
10137 if (current ==
'$')
10139 result.second =
get();
10152 auto last_token = get_token_string();
10153 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(
input_format_t::ubjson,
"expected '#' after type information; last byte: 0x" + last_token,
"size"), BasicJsonType()));
10156 return get_ubjson_size_value(result.first);
10159 if (current ==
'#')
10161 return get_ubjson_size_value(result.first);
10175 case std::char_traits<char_type>::eof():
10179 return sax->boolean(
true);
10181 return sax->boolean(
false);
10184 return sax->null();
10188 std::uint8_t number{};
10194 std::int8_t number{};
10200 std::int16_t number{};
10206 std::int32_t number{};
10212 std::int64_t number{};
10219 return get_number(
input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number),
"");
10225 return get_number(
input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number),
"");
10230 return get_ubjson_high_precision_number();
10242 auto last_token = get_token_string();
10243 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(
input_format_t::ubjson,
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token,
"char"), BasicJsonType()));
10245 string_t s(1, static_cast<typename string_t::value_type>(current));
10246 return sax->string(s);
10252 return get_ubjson_string(s) && sax->string(s);
10256 return get_ubjson_array();
10259 return get_ubjson_object();
10263 auto last_token = get_token_string();
10274 std::pair<std::size_t, char_int_type> size_and_type;
10280 if (size_and_type.first != string_t::npos)
10287 if (size_and_type.second != 0)
10289 if (size_and_type.second !=
'N')
10291 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10302 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10318 while (current !=
']')
10328 return sax->end_array();
10336 std::pair<std::size_t, char_int_type> size_and_type;
10343 if (size_and_type.first != string_t::npos)
10350 if (size_and_type.second != 0)
10352 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10367 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10388 while (current !=
'}')
10403 return sax->end_object();
10413 auto res = get_ubjson_size_value(
size);
10420 std::vector<char> number_vector;
10428 number_vector.push_back(static_cast<char>(current));
10434 const auto result_number = number_lexer.
scan();
10435 const auto number_string = number_lexer.get_token_string();
10436 const auto result_remainder = number_lexer.scan();
10442 return sax->parse_error(chars_read, number_string,
parse_error::create(115, chars_read, exception_message(
input_format_t::ubjson,
"invalid number text: " + number_lexer.get_token_string(),
"high-precision number"), BasicJsonType()));
10445 switch (result_number)
10447 case token_type::value_integer:
10448 return sax->number_integer(number_lexer.get_number_integer());
10449 case token_type::value_unsigned:
10450 return sax->number_unsigned(number_lexer.get_number_unsigned());
10451 case token_type::value_float:
10452 return sax->number_float(number_lexer.get_number_float(),
std::move(number_string));
10453 case token_type::uninitialized:
10454 case token_type::literal_true:
10455 case token_type::literal_false:
10456 case token_type::literal_null:
10457 case token_type::value_string:
10458 case token_type::begin_array:
10459 case token_type::begin_object:
10460 case token_type::end_array:
10461 case token_type::end_object:
10462 case token_type::name_separator:
10463 case token_type::value_separator:
10464 case token_type::parse_error:
10465 case token_type::end_of_input:
10466 case token_type::literal_or_value:
10468 return sax->parse_error(chars_read, number_string,
parse_error::create(115, chars_read, exception_message(
input_format_t::ubjson,
"invalid number text: " + number_lexer.get_token_string(),
"high-precision number"), BasicJsonType()));
10488 return current = ia.get_character();
10500 while (current ==
'N');
10518 template<
typename NumberType,
bool InputIsLittleEndian = false>
10522 std::array<std::uint8_t, sizeof(NumberType)> vec{};
10523 for (
std::size_t i = 0; i <
sizeof(NumberType); ++i)
10532 if (is_little_endian != InputIsLittleEndian)
10534 vec[
sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
10538 vec[i] =
static_cast<std::uint8_t
>(current);
10543 std::memcpy(&result, vec.data(),
sizeof(NumberType));
10561 template<
typename NumberType>
10563 const NumberType len,
10566 bool success =
true;
10567 for (NumberType i = 0; i < len; i++)
10575 result.push_back(static_cast<typename string_t::value_type>(current));
10594 template<
typename NumberType>
10596 const NumberType len,
10599 bool success =
true;
10600 for (NumberType i = 0; i < len; i++)
10608 result.push_back(static_cast<std::uint8_t>(current));
10623 return sax->parse_error(chars_read,
"<end of file>",
10624 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context), BasicJsonType()));
10634 std::array<char, 3> cr{{}};
10635 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
10649 std::string error_msg =
"syntax error while parsing ";
10654 error_msg +=
"CBOR";
10658 error_msg +=
"MessagePack";
10662 error_msg +=
"UBJSON";
10666 error_msg +=
"BSON";
10674 return error_msg +
" " + context +
": " + detail;
10705 #include <functional> 10749 template<
typename BasicJsonType>
10758 template<
typename BasicJsonType,
typename InputAdapterType>
10772 const bool allow_exceptions_ =
true,
10773 const bool skip_comments =
false)
10775 , m_lexer(
std::
move(adapter), skip_comments)
10776 , allow_exceptions(allow_exceptions_)
10797 sax_parse_internal(&sdp);
10800 if (strict && (get_token() != token_type::end_of_input))
10803 m_lexer.get_token_string(),
10805 exception_message(token_type::end_of_input,
"value"), BasicJsonType()));
10817 if (result.is_discarded())
10825 sax_parse_internal(&sdp);
10828 if (strict && (get_token() != token_type::end_of_input))
10831 m_lexer.get_token_string(),
10832 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"), BasicJsonType()));
10843 result.assert_invariant();
10855 return sax_parse(&sax_acceptor,
strict);
10858 template<
typename SAX>
10860 bool sax_parse(SAX* sax, const
bool strict = true)
10863 const bool result = sax_parse_internal(sax);
10866 if (result &&
strict && (get_token() != token_type::end_of_input))
10868 return sax->parse_error(m_lexer.get_position(),
10869 m_lexer.get_token_string(),
10870 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"), BasicJsonType()));
10877 template<
typename SAX>
10879 bool sax_parse_internal(SAX* sax)
10883 std::vector<bool> states;
10885 bool skip_to_state_evaluation =
false;
10889 if (!skip_to_state_evaluation)
10892 switch (last_token)
10894 case token_type::begin_object:
10902 if (get_token() == token_type::end_object)
10914 return sax->parse_error(m_lexer.get_position(),
10915 m_lexer.get_token_string(),
10916 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"), BasicJsonType()));
10926 return sax->parse_error(m_lexer.get_position(),
10927 m_lexer.get_token_string(),
10928 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"), BasicJsonType()));
10932 states.push_back(
false);
10939 case token_type::begin_array:
10947 if (get_token() == token_type::end_array)
10957 states.push_back(
true);
10963 case token_type::value_float:
10965 const auto res = m_lexer.get_number_float();
10969 return sax->parse_error(m_lexer.get_position(),
10970 m_lexer.get_token_string(),
10971 out_of_range::create(406,
"number overflow parsing '" + m_lexer.get_token_string() +
"'", BasicJsonType()));
10982 case token_type::literal_false:
10991 case token_type::literal_null:
11000 case token_type::literal_true:
11009 case token_type::value_integer:
11018 case token_type::value_string:
11027 case token_type::value_unsigned:
11036 case token_type::parse_error:
11039 return sax->parse_error(m_lexer.get_position(),
11040 m_lexer.get_token_string(),
11041 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"), BasicJsonType()));
11044 case token_type::uninitialized:
11045 case token_type::end_array:
11046 case token_type::end_object:
11047 case token_type::name_separator:
11048 case token_type::value_separator:
11049 case token_type::end_of_input:
11050 case token_type::literal_or_value:
11053 return sax->parse_error(m_lexer.get_position(),
11054 m_lexer.get_token_string(),
11055 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"), BasicJsonType()));
11061 skip_to_state_evaluation =
false;
11065 if (states.empty())
11074 if (get_token() == token_type::value_separator)
11095 skip_to_state_evaluation =
true;
11099 return sax->parse_error(m_lexer.get_position(),
11100 m_lexer.get_token_string(),
11101 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"), BasicJsonType()));
11107 if (get_token() == token_type::value_separator)
11112 return sax->parse_error(m_lexer.get_position(),
11113 m_lexer.get_token_string(),
11114 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"), BasicJsonType()));
11125 return sax->parse_error(m_lexer.get_position(),
11126 m_lexer.get_token_string(),
11127 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"), BasicJsonType()));
11149 skip_to_state_evaluation =
true;
11153 return sax->parse_error(m_lexer.get_position(),
11154 m_lexer.get_token_string(),
11155 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"), BasicJsonType()));
11162 return last_token = m_lexer.scan();
11169 if (!context.empty())
11171 error_msg +=
"while parsing " + context +
" ";
11176 if (last_token == token_type::parse_error)
11178 error_msg +=
std::string(m_lexer.get_error_message()) +
"; last read: '" +
11179 m_lexer.get_token_string() +
"'";
11183 error_msg +=
"unexpected " +
std::string(lexer_t::token_type_name(last_token));
11186 if (expected != token_type::uninitialized)
11188 error_msg +=
"; expected " +
std::string(lexer_t::token_type_name(expected));
11202 const bool allow_exceptions =
true;
11253 m_it = begin_value;
11265 return m_it == begin_value;
11271 return m_it == end_value;
11276 return lhs.m_it == rhs.m_it;
11281 return lhs.m_it < rhs.m_it;
11293 return lhs.m_it - rhs.m_it;
11351 typename BasicJsonType::object_t::iterator object_iterator {};
11353 typename BasicJsonType::array_t::iterator array_iterator {};
11363 #include <iterator> 11364 #include <type_traits> 11405 template<
typename BasicJsonType>
11419 static_assert(
is_basic_json<
typename std::remove_const<BasicJsonType>::type>::
value,
11420 "iter_impl only accepts (const) basic_json");
11436 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
11437 typename BasicJsonType::const_pointer,
11438 typename BasicJsonType::pointer>::type;
11441 typename std::conditional<std::is_const<BasicJsonType>::value,
11442 typename BasicJsonType::const_reference,
11460 switch (m_object->m_type)
11464 m_it.object_iterator =
typename object_t::iterator();
11470 m_it.array_iterator =
typename array_t::iterator();
11507 : m_object(other.m_object), m_it(other.m_it)
11518 if (&other !=
this)
11520 m_object = other.m_object;
11532 : m_object(other.m_object), m_it(other.m_it)
11543 m_object = other.m_object;
11553 void set_begin() noexcept
11557 switch (m_object->m_type)
11561 m_it.object_iterator = m_object->m_value.object->begin();
11567 m_it.array_iterator = m_object->m_value.array->begin();
11574 m_it.primitive_iterator.set_end();
11587 m_it.primitive_iterator.set_begin();
11601 switch (m_object->m_type)
11605 m_it.object_iterator = m_object->m_value.object->end();
11611 m_it.array_iterator = m_object->m_value.array->end();
11625 m_it.primitive_iterator.set_end();
11640 switch (m_object->m_type)
11644 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
11645 return m_it.object_iterator->second;
11650 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
11651 return *m_it.array_iterator;
11684 switch (m_object->m_type)
11688 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
11689 return &(m_it.object_iterator->second);
11694 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
11695 return &*m_it.array_iterator;
11737 switch (m_object->m_type)
11741 std::advance(m_it.object_iterator, 1);
11747 std::advance(m_it.array_iterator, 1);
11761 ++m_it.primitive_iterator;
11788 switch (m_object->m_type)
11792 std::advance(m_it.object_iterator, -1);
11798 std::advance(m_it.array_iterator, -1);
11812 --m_it.primitive_iterator;
11824 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 >
11825 bool operator==(
const IterImpl& other)
const 11835 switch (m_object->m_type)
11838 return (m_it.object_iterator == other.m_it.object_iterator);
11841 return (m_it.array_iterator == other.m_it.array_iterator);
11852 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
11860 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 >
11861 bool operator!=(
const IterImpl& other)
const 11880 switch (m_object->m_type)
11907 return !other.operator < (*this);
11936 switch (m_object->m_type)
11943 std::advance(m_it.array_iterator, i);
11957 m_it.primitive_iterator += i;
11971 return operator+=(-i);
12015 switch (m_object->m_type)
12044 switch (m_object->m_type)
12050 return *std::next(m_it.array_iterator, n);
12078 const typename object_t::key_type&
key()
const 12084 return m_it.object_iterator->first;
12114 #include <iterator> 12143 template<
typename Base>
12217 auto it = --this->base();
12224 auto it = --this->base();
12225 return it.operator * ();
12236 #include <algorithm> 12258 template<
typename BasicJsonType>
12269 : reference_tokens(split(
s))
12276 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
12295 reference_tokens.insert(reference_tokens.end(),
12313 return *
this /= std::to_string(array_idx);
12361 reference_tokens.pop_back();
12373 return reference_tokens.back();
12380 reference_tokens.push_back(token);
12387 reference_tokens.push_back(
std::move(token));
12394 return reference_tokens.empty();
12410 using size_type =
typename BasicJsonType::size_type;
12425 unsigned long long res = 0;
12428 res = std::stoull(s, &processed_chars);
12443 if (res >= static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
12448 return static_cast<size_type
>(res);
12479 for (
const auto& reference_token : reference_tokens)
12485 if (reference_token ==
"0")
12508 result = &
result->operator[](array_index(reference_token));
12554 for (
const auto& reference_token : reference_tokens)
12557 if (ptr->is_null())
12561 std::all_of(reference_token.begin(), reference_token.end(),
12562 [](
const unsigned char x)
12564 return std::isdigit(
x);
12568 *ptr = (nums || reference_token ==
"-")
12573 switch (ptr->type())
12578 ptr = &ptr->operator[](reference_token);
12584 if (reference_token ==
"-")
12587 ptr = &ptr->operator[](ptr->m_value.array->size());
12592 ptr = &ptr->operator[](array_index(reference_token));
12621 for (
const auto& reference_token : reference_tokens)
12623 switch (ptr->type())
12628 ptr = &ptr->at(reference_token);
12638 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12639 ") is out of range", *ptr));
12643 ptr = &ptr->at(array_index(reference_token));
12678 for (
const auto& reference_token : reference_tokens)
12680 switch (ptr->type())
12685 ptr = &ptr->operator[](reference_token);
12698 ptr = &ptr->operator[](array_index(reference_token));
12726 for (
const auto& reference_token : reference_tokens)
12728 switch (ptr->type())
12733 ptr = &ptr->at(reference_token);
12743 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12744 ") is out of range", *ptr));
12748 ptr = &ptr->at(array_index(reference_token));
12774 for (
const auto& reference_token : reference_tokens)
12776 switch (ptr->type())
12780 if (!ptr->contains(reference_token))
12786 ptr = &ptr->operator[](reference_token);
12797 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
12809 for (
std::size_t i = 1; i < reference_token.size(); i++)
12819 const auto idx = array_index(reference_token);
12820 if (idx >= ptr->size())
12826 ptr = &ptr->operator[](idx);
12862 std::vector<std::string>
result;
12865 if (reference_string.empty())
12881 std::size_t slash = reference_string.find_first_of(
'/', 1),
12888 start = (slash == std::string::npos) ? 0 : slash + 1,
12890 slash = reference_string.find_first_of(
'/',
start))
12894 auto reference_token = reference_string.substr(
start, slash -
start);
12897 for (
std::size_t pos = reference_token.find_first_of(
'~');
12898 pos != std::string::npos;
12899 pos = reference_token.find_first_of(
'~', pos + 1))
12905 (reference_token[pos + 1] !=
'0' &&
12906 reference_token[pos + 1] !=
'1')))
12914 result.push_back(reference_token);
12929 const BasicJsonType&
value,
12932 switch (value.type())
12936 if (value.m_value.array->empty())
12939 result[reference_string] =
nullptr;
12944 for (
std::size_t i = 0; i < value.m_value.array->size(); ++i)
12946 flatten(reference_string +
"/" + std::to_string(i),
12947 value.m_value.array->operator[](i), result);
12955 if (value.m_value.object->empty())
12958 result[reference_string] =
nullptr;
12963 for (
const auto& element : *value.m_value.object)
12965 flatten(reference_string +
"/" +
detail::escape(element.first), element.second, result);
12982 result[reference_string] =
value;
12998 static BasicJsonType
13009 for (
const auto& element : *value.m_value.object)
13040 return lhs.reference_tokens == rhs.reference_tokens;
13057 return !(lhs == rhs);
13068 #include <initializer_list> 13078 template<
typename BasicJsonType>
13089 : value_ref(&value)
13093 : owned_value(init)
13100 : owned_value(
std::forward<Args>(
args)...)
13112 if (value_ref ==
nullptr)
13121 return value_ref ? *value_ref : owned_value;
13130 mutable value_type owned_value =
nullptr;
13131 value_type
const* value_ref =
nullptr;
13147 #include <algorithm> 13163 #include <algorithm> 13165 #include <iterator> 13173 #endif // JSON_NO_IO 13185 virtual void write_character(CharType c) = 0;
13186 virtual void write_characters(
const CharType*
s,
std::size_t length) = 0;
13197 template<
typename CharType>
13201 template<
typename CharType,
typename AllocatorType = std::allocator<CharType>>
13215 void write_characters(const CharType* s,
std::
size_t length)
override 13217 std::copy(s, s + length, std::back_inserter(v));
13221 std::vector<CharType, AllocatorType>&
v;
13225 template<
typename CharType>
13240 void write_characters(const CharType* s,
std::
size_t length)
override 13242 stream.write(s, static_cast<std::streamsize>(length));
13248 #endif // JSON_NO_IO 13251 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13265 void write_characters(const CharType* s,
std::
size_t length)
override 13267 str.append(s, length);
13274 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13278 template<
typename AllocatorType = std::allocator<CharType>>
13285 #endif // JSON_NO_IO 13313 template<
typename BasicJsonType,
typename CharType>
13341 write_bson_object(*j.m_value.object);
13370 oa->write_character(to_char_type(0xF6));
13376 oa->write_character(j.m_value.boolean
13377 ? to_char_type(0xF5)
13378 : to_char_type(0xF4));
13384 if (j.m_value.number_integer >= 0)
13389 if (j.m_value.number_integer <= 0x17)
13391 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13393 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
13395 oa->write_character(to_char_type(0x18));
13396 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13398 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
13400 oa->write_character(to_char_type(0x19));
13401 write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13403 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
13405 oa->write_character(to_char_type(0x1A));
13406 write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13410 oa->write_character(to_char_type(0x1B));
13411 write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
13418 const auto positive_number = -1 - j.m_value.number_integer;
13419 if (j.m_value.number_integer >= -24)
13421 write_number(static_cast<std::uint8_t>(0x20 + positive_number));
13423 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
13425 oa->write_character(to_char_type(0x38));
13426 write_number(static_cast<std::uint8_t>(positive_number));
13428 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
13430 oa->write_character(to_char_type(0x39));
13431 write_number(static_cast<std::uint16_t>(positive_number));
13433 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
13435 oa->write_character(to_char_type(0x3A));
13436 write_number(static_cast<std::uint32_t>(positive_number));
13440 oa->write_character(to_char_type(0x3B));
13441 write_number(static_cast<std::uint64_t>(positive_number));
13449 if (j.m_value.number_unsigned <= 0x17)
13451 write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
13453 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13455 oa->write_character(to_char_type(0x18));
13456 write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
13458 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13460 oa->write_character(to_char_type(0x19));
13461 write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
13463 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13465 oa->write_character(to_char_type(0x1A));
13466 write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
13470 oa->write_character(to_char_type(0x1B));
13471 write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
13481 oa->write_character(to_char_type(0xF9));
13482 oa->write_character(to_char_type(0x7E));
13483 oa->write_character(to_char_type(0x00));
13485 else if (std::isinf(j.m_value.number_float))
13488 oa->write_character(to_char_type(0xf9));
13489 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
13490 oa->write_character(to_char_type(0x00));
13502 const auto N = j.m_value.string->size();
13505 write_number(static_cast<std::uint8_t>(0x60 + N));
13507 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13509 oa->write_character(to_char_type(0x78));
13510 write_number(static_cast<std::uint8_t>(N));
13512 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13514 oa->write_character(to_char_type(0x79));
13515 write_number(static_cast<std::uint16_t>(N));
13517 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13519 oa->write_character(to_char_type(0x7A));
13520 write_number(static_cast<std::uint32_t>(N));
13523 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13525 oa->write_character(to_char_type(0x7B));
13526 write_number(static_cast<std::uint64_t>(N));
13531 oa->write_characters(
13532 reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
13533 j.m_value.string->size());
13540 const auto N = j.m_value.array->size();
13543 write_number(static_cast<std::uint8_t>(0x80 + N));
13545 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13547 oa->write_character(to_char_type(0x98));
13548 write_number(static_cast<std::uint8_t>(N));
13550 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13552 oa->write_character(to_char_type(0x99));
13553 write_number(static_cast<std::uint16_t>(N));
13555 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13557 oa->write_character(to_char_type(0x9A));
13558 write_number(static_cast<std::uint32_t>(N));
13561 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13563 oa->write_character(to_char_type(0x9B));
13564 write_number(static_cast<std::uint64_t>(N));
13569 for (
const auto& el : *j.m_value.array)
13578 if (j.m_value.binary->has_subtype())
13580 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
13582 write_number(static_cast<std::uint8_t>(0xd8));
13583 write_number(static_cast<std::uint8_t>(j.m_value.binary->subtype()));
13585 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
13587 write_number(static_cast<std::uint8_t>(0xd9));
13588 write_number(static_cast<std::uint16_t>(j.m_value.binary->subtype()));
13590 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
13592 write_number(static_cast<std::uint8_t>(0xda));
13593 write_number(static_cast<std::uint32_t>(j.m_value.binary->subtype()));
13595 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
13597 write_number(static_cast<std::uint8_t>(0xdb));
13598 write_number(static_cast<std::uint64_t>(j.m_value.binary->subtype()));
13603 const auto N = j.m_value.binary->size();
13606 write_number(static_cast<std::uint8_t>(0x40 + N));
13608 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13610 oa->write_character(to_char_type(0x58));
13611 write_number(static_cast<std::uint8_t>(N));
13613 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13615 oa->write_character(to_char_type(0x59));
13616 write_number(static_cast<std::uint16_t>(N));
13618 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13620 oa->write_character(to_char_type(0x5A));
13621 write_number(static_cast<std::uint32_t>(N));
13624 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13626 oa->write_character(to_char_type(0x5B));
13627 write_number(static_cast<std::uint64_t>(N));
13632 oa->write_characters(
13633 reinterpret_cast<const CharType*>(j.m_value.binary->data()),
13642 const auto N = j.m_value.object->size();
13645 write_number(static_cast<std::uint8_t>(0xA0 + N));
13647 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13649 oa->write_character(to_char_type(0xB8));
13650 write_number(static_cast<std::uint8_t>(N));
13652 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13654 oa->write_character(to_char_type(0xB9));
13655 write_number(static_cast<std::uint16_t>(N));
13657 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13659 oa->write_character(to_char_type(0xBA));
13660 write_number(static_cast<std::uint32_t>(N));
13663 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13665 oa->write_character(to_char_type(0xBB));
13666 write_number(static_cast<std::uint64_t>(N));
13671 for (
const auto& el : *j.m_value.object)
13673 write_cbor(el.first);
13674 write_cbor(el.second);
13694 oa->write_character(to_char_type(0xC0));
13700 oa->write_character(j.m_value.boolean
13701 ? to_char_type(0xC3)
13702 : to_char_type(0xC2));
13708 if (j.m_value.number_integer >= 0)
13713 if (j.m_value.number_unsigned < 128)
13716 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13718 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13721 oa->write_character(to_char_type(0xCC));
13722 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13724 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13727 oa->write_character(to_char_type(0xCD));
13728 write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13730 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13733 oa->write_character(to_char_type(0xCE));
13734 write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13736 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13739 oa->write_character(to_char_type(0xCF));
13740 write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
13745 if (j.m_value.number_integer >= -32)
13748 write_number(static_cast<std::int8_t>(j.m_value.number_integer));
13750 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
13751 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13754 oa->write_character(to_char_type(0xD0));
13755 write_number(static_cast<std::int8_t>(j.m_value.number_integer));
13757 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
13758 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13761 oa->write_character(to_char_type(0xD1));
13762 write_number(static_cast<std::int16_t>(j.m_value.number_integer));
13764 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
13765 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13768 oa->write_character(to_char_type(0xD2));
13769 write_number(static_cast<std::int32_t>(j.m_value.number_integer));
13771 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
13772 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13775 oa->write_character(to_char_type(0xD3));
13776 write_number(static_cast<std::int64_t>(j.m_value.number_integer));
13784 if (j.m_value.number_unsigned < 128)
13787 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13789 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13792 oa->write_character(to_char_type(0xCC));
13793 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13795 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13798 oa->write_character(to_char_type(0xCD));
13799 write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13801 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13804 oa->write_character(to_char_type(0xCE));
13805 write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13807 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13810 oa->write_character(to_char_type(0xCF));
13811 write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
13825 const auto N = j.m_value.string->size();
13829 write_number(static_cast<std::uint8_t>(0xA0 | N));
13831 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13834 oa->write_character(to_char_type(0xD9));
13835 write_number(static_cast<std::uint8_t>(N));
13837 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13840 oa->write_character(to_char_type(0xDA));
13841 write_number(static_cast<std::uint16_t>(N));
13843 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13846 oa->write_character(to_char_type(0xDB));
13847 write_number(static_cast<std::uint32_t>(N));
13851 oa->write_characters(
13852 reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
13853 j.m_value.string->size());
13860 const auto N = j.m_value.array->size();
13864 write_number(static_cast<std::uint8_t>(0x90 | N));
13866 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13869 oa->write_character(to_char_type(0xDC));
13870 write_number(static_cast<std::uint16_t>(N));
13872 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13875 oa->write_character(to_char_type(0xDD));
13876 write_number(static_cast<std::uint32_t>(N));
13880 for (
const auto& el : *j.m_value.array)
13891 const bool use_ext = j.m_value.binary->has_subtype();
13894 const auto N = j.m_value.binary->size();
13895 if (N <= (std::numeric_limits<std::uint8_t>::max)())
13897 std::uint8_t output_type{};
13904 output_type = 0xD4;
13907 output_type = 0xD5;
13910 output_type = 0xD6;
13913 output_type = 0xD7;
13916 output_type = 0xD8;
13919 output_type = 0xC7;
13927 output_type = 0xC4;
13931 oa->write_character(to_char_type(output_type));
13934 write_number(static_cast<std::uint8_t>(N));
13937 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13939 std::uint8_t output_type = use_ext
13943 oa->write_character(to_char_type(output_type));
13944 write_number(static_cast<std::uint16_t>(N));
13946 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13948 std::uint8_t output_type = use_ext
13952 oa->write_character(to_char_type(output_type));
13953 write_number(static_cast<std::uint32_t>(N));
13959 write_number(static_cast<std::int8_t>(j.m_value.binary->subtype()));
13963 oa->write_characters(
13964 reinterpret_cast<const CharType*>(j.m_value.binary->data()),
13973 const auto N = j.m_value.object->size();
13977 write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
13979 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13982 oa->write_character(to_char_type(0xDE));
13983 write_number(static_cast<std::uint16_t>(N));
13985 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13988 oa->write_character(to_char_type(0xDF));
13989 write_number(static_cast<std::uint32_t>(N));
13993 for (
const auto& el : *j.m_value.object)
13995 write_msgpack(el.first);
13996 write_msgpack(el.second);
14014 const bool use_type,
const bool add_prefix =
true)
14022 oa->write_character(to_char_type(
'Z'));
14031 oa->write_character(j.m_value.boolean
14032 ? to_char_type(
'T')
14033 : to_char_type(
'F'));
14040 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
14046 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
14052 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
14060 oa->write_character(to_char_type(
'S'));
14062 write_number_with_ubjson_prefix(j.m_value.string->size(),
true);
14063 oa->write_characters(
14064 reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
14065 j.m_value.string->size());
14073 oa->write_character(to_char_type(
'['));
14076 bool prefix_required =
true;
14077 if (use_type && !j.m_value.array->empty())
14080 const CharType first_prefix = ubjson_prefix(j.front());
14081 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14082 [
this, first_prefix](
const BasicJsonType & v)
14084 return ubjson_prefix(v) == first_prefix;
14089 prefix_required =
false;
14090 oa->write_character(to_char_type(
'$'));
14091 oa->write_character(first_prefix);
14097 oa->write_character(to_char_type(
'#'));
14098 write_number_with_ubjson_prefix(j.m_value.array->size(),
true);
14101 for (
const auto& el : *j.m_value.array)
14103 write_ubjson(el, use_count, use_type, prefix_required);
14108 oa->write_character(to_char_type(
']'));
14118 oa->write_character(to_char_type(
'['));
14121 if (use_type && !j.m_value.binary->empty())
14124 oa->write_character(to_char_type(
'$'));
14125 oa->write_character(
'U');
14130 oa->write_character(to_char_type(
'#'));
14131 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true);
14136 oa->write_characters(
14137 reinterpret_cast<const CharType*>(j.m_value.binary->data()),
14138 j.m_value.binary->size());
14142 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
14144 oa->write_character(to_char_type(
'U'));
14145 oa->write_character(j.m_value.binary->data()[i]);
14151 oa->write_character(to_char_type(
']'));
14161 oa->write_character(to_char_type(
'{'));
14164 bool prefix_required =
true;
14165 if (use_type && !j.m_value.object->empty())
14168 const CharType first_prefix = ubjson_prefix(j.front());
14169 const bool same_prefix = std::all_of(j.begin(), j.end(),
14170 [
this, first_prefix](
const BasicJsonType & v)
14172 return ubjson_prefix(v) == first_prefix;
14177 prefix_required =
false;
14178 oa->write_character(to_char_type(
'$'));
14179 oa->write_character(first_prefix);
14185 oa->write_character(to_char_type(
'#'));
14186 write_number_with_ubjson_prefix(j.m_value.object->size(),
true);
14189 for (
const auto& el : *j.m_value.object)
14191 write_number_with_ubjson_prefix(el.first.size(),
true);
14192 oa->write_characters(
14193 reinterpret_cast<const CharType*>(el.first.c_str()),
14195 write_ubjson(el.second, use_count, use_type, prefix_required);
14200 oa->write_character(to_char_type(
'}'));
14223 const auto it = name.find(static_cast<typename string_t::value_type>(0));
14227 static_cast<void>(j);
14230 return 1ul + name.size() + 1u;
14237 const std::uint8_t element_type)
14239 oa->write_character(to_char_type(element_type));
14240 oa->write_characters(
14241 reinterpret_cast<const CharType*>(name.c_str()),
14251 write_bson_entry_header(name, 0x08);
14252 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
14259 const double value)
14261 write_bson_entry_header(name, 0x01);
14262 write_number<double, true>(
value);
14270 return sizeof(std::int32_t) + value.size() + 1ul;
14279 write_bson_entry_header(name, 0x02);
14281 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(value.size() + 1ul));
14282 oa->write_characters(
14283 reinterpret_cast<const CharType*>(value.c_str()),
14292 write_bson_entry_header(name, 0x0A);
14300 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
14301 ?
sizeof(std::int32_t)
14302 :
sizeof(std::int64_t);
14309 const std::int64_t
value)
14311 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
14313 write_bson_entry_header(name, 0x10);
14314 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value));
14318 write_bson_entry_header(name, 0x12);
14319 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(
value));
14328 return (
value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14329 ?
sizeof(std::int32_t)
14330 :
sizeof(std::int64_t);
14337 const BasicJsonType& j)
14339 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14341 write_bson_entry_header(name, 0x10 );
14342 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(j.m_value.number_unsigned));
14344 else if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14346 write_bson_entry_header(name, 0x12 );
14347 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(j.m_value.number_unsigned));
14351 JSON_THROW(
out_of_range::create(407,
"integer number " + std::to_string(j.m_value.number_unsigned) +
" cannot be represented by BSON as it does not fit int64", j));
14359 const typename BasicJsonType::object_t&
value)
14361 write_bson_entry_header(name, 0x03);
14362 write_bson_object(value);
14374 return result + calc_bson_element_size(std::to_string(array_index++), el);
14377 return sizeof(std::int32_t) + embedded_document_size + 1ul;
14385 return sizeof(std::int32_t) + value.size() + 1ul;
14392 const typename BasicJsonType::array_t&
value)
14394 write_bson_entry_header(name, 0x04);
14395 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_array_size(value)));
14399 for (
const auto& el : value)
14401 write_bson_element(std::to_string(array_index++), el);
14404 oa->write_character(to_char_type(0x00));
14413 write_bson_entry_header(name, 0x05);
14415 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(value.size()));
14416 write_number(value.has_subtype() ?
static_cast<std::uint8_t
>(value.subtype()) : static_cast<std::uint8_t>(0x00));
14418 oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
14426 const BasicJsonType& j)
14428 const auto header_size = calc_bson_entry_header_size(name, j);
14432 return header_size + calc_bson_object_size(*j.m_value.object);
14435 return header_size + calc_bson_array_size(*j.m_value.array);
14438 return header_size + calc_bson_binary_size(*j.m_value.binary);
14441 return header_size + 1ul;
14444 return header_size + 8ul;
14447 return header_size + calc_bson_integer_size(j.m_value.number_integer);
14450 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
14453 return header_size + calc_bson_string_size(*j.m_value.string);
14456 return header_size + 0ul;
14474 const BasicJsonType& j)
14479 return write_bson_object_entry(name, *j.m_value.object);
14482 return write_bson_array(name, *j.m_value.array);
14485 return write_bson_binary(name, *j.m_value.binary);
14488 return write_bson_boolean(name, j.m_value.boolean);
14491 return write_bson_double(name, j.m_value.number_float);
14494 return write_bson_integer(name, j.m_value.number_integer);
14497 return write_bson_unsigned(name, j);
14500 return write_bson_string(name, *j.m_value.string);
14503 return write_bson_null(name);
14525 return result += calc_bson_element_size(el.first, el.second);
14528 return sizeof(std::int32_t) + document_size + 1ul;
14537 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_object_size(value)));
14539 for (
const auto& el : value)
14541 write_bson_element(el.first, el.second);
14544 oa->write_character(to_char_type(0x00));
14553 return to_char_type(0xFA);
14558 return to_char_type(0xFB);
14567 return to_char_type(0xCA);
14572 return to_char_type(0xCB);
14580 template<
typename NumberType,
typename std::enable_if<
14581 std::is_floating_point<NumberType>::value,
int>
::type = 0>
14583 const bool add_prefix)
14587 oa->write_character(get_ubjson_float_prefix(n));
14593 template<
typename NumberType,
typename std::enable_if<
14594 std::is_unsigned<NumberType>::value,
int>::type = 0>
14596 const bool add_prefix)
14598 if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
14602 oa->write_character(to_char_type(
'i'));
14604 write_number(static_cast<std::uint8_t>(n));
14606 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14610 oa->write_character(to_char_type(
'U'));
14612 write_number(static_cast<std::uint8_t>(n));
14614 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
14618 oa->write_character(to_char_type(
'I'));
14620 write_number(static_cast<std::int16_t>(n));
14622 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14626 oa->write_character(to_char_type(
'l'));
14628 write_number(static_cast<std::int32_t>(n));
14630 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14634 oa->write_character(to_char_type(
'L'));
14636 write_number(static_cast<std::int64_t>(n));
14642 oa->write_character(to_char_type(
'H'));
14645 const auto number = BasicJsonType(n).dump();
14646 write_number_with_ubjson_prefix(number.size(),
true);
14649 oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
14655 template <
typename NumberType,
typename std::enable_if <
14656 std::is_signed<NumberType>::value&&
14657 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
14659 const bool add_prefix)
14661 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
14665 oa->write_character(to_char_type(
'i'));
14667 write_number(static_cast<std::int8_t>(n));
14669 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)()))
14673 oa->write_character(to_char_type(
'U'));
14675 write_number(static_cast<std::uint8_t>(n));
14677 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
14681 oa->write_character(to_char_type(
'I'));
14683 write_number(static_cast<std::int16_t>(n));
14685 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
14689 oa->write_character(to_char_type(
'l'));
14691 write_number(static_cast<std::int32_t>(n));
14693 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
14697 oa->write_character(to_char_type(
'L'));
14699 write_number(static_cast<std::int64_t>(n));
14706 oa->write_character(to_char_type(
'H'));
14709 const auto number = BasicJsonType(n).dump();
14710 write_number_with_ubjson_prefix(number.size(),
true);
14713 oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
14730 return j.m_value.boolean ?
'T' :
'F';
14734 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14738 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14742 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14746 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14750 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14760 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
14764 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
14768 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
14772 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14776 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14785 return get_ubjson_float_prefix(j.m_value.number_float);
14828 template<
typename NumberType,
bool OutputIsLittleEndian = false>
14832 std::array<CharType, sizeof(NumberType)> vec{};
14833 std::memcpy(vec.data(), &n,
sizeof(NumberType));
14836 if (is_little_endian != OutputIsLittleEndian)
14842 oa->write_characters(vec.data(),
sizeof(NumberType));
14848 #pragma GCC diagnostic push 14849 #pragma GCC diagnostic ignored "-Wfloat-equal" 14851 if (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
14852 static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
14853 static_cast<double>(static_cast<float>(n)) == static_cast<double>(n))
14856 ? get_cbor_float_prefix(static_cast<float>(n))
14857 : get_msgpack_float_prefix(static_cast<float>(n)));
14858 write_number(static_cast<float>(n));
14863 ? get_cbor_float_prefix(n)
14864 : get_msgpack_float_prefix(n));
14868 #pragma GCC diagnostic pop 14877 template <
typename C = CharType,
14881 return *
reinterpret_cast<char*
>(&
x);
14884 template <
typename C = CharType,
14888 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
14889 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
14891 std::memcpy(&result, &
x,
sizeof(
x));
14895 template<
typename C = CharType,
14902 template <
typename InputCharType,
typename C = CharType,
14904 std::is_signed<C>::value &&
14905 std::is_signed<char>::value &&
14928 #include <algorithm> 14939 #include <type_traits> 14950 #include <type_traits> 14979 namespace dtoa_impl
14982 template<
typename Target,
typename Source>
14985 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
14988 std::memcpy(&target, &source,
sizeof(Source));
14994 static constexpr
int kPrecision = 64;
14999 constexpr
diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
15010 return {
x.f -
y.f,
x.e};
15019 static_assert(kPrecision == 64,
"internal error");
15044 const std::uint64_t u_lo =
x.f & 0xFFFFFFFFu;
15045 const std::uint64_t u_hi =
x.f >> 32u;
15046 const std::uint64_t v_lo =
y.f & 0xFFFFFFFFu;
15047 const std::uint64_t v_hi =
y.f >> 32u;
15049 const std::uint64_t p0 = u_lo * v_lo;
15050 const std::uint64_t p1 = u_lo * v_hi;
15051 const std::uint64_t p2 = u_hi * v_lo;
15052 const std::uint64_t p3 = u_hi * v_hi;
15054 const std::uint64_t p0_hi = p0 >> 32u;
15055 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
15056 const std::uint64_t p1_hi = p1 >> 32u;
15057 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
15058 const std::uint64_t p2_hi = p2 >> 32u;
15060 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
15071 Q += std::uint64_t{1} << (64u - 32u - 1u);
15073 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
15075 return {h,
x.e +
y.e + 64};
15086 while ((
x.f >> 63u) == 0)
15101 const int delta =
x.e - target_exponent;
15106 return {
x.f << delta, target_exponent};
15123 template<
typename FloatType>
15136 static_assert(std::numeric_limits<FloatType>::is_iec559,
15137 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
15139 constexpr
int kPrecision = std::numeric_limits<FloatType>::digits;
15140 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
15141 constexpr
int kMinExp = 1 - kBias;
15142 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
15146 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
15147 const std::uint64_t E = bits >> (kPrecision - 1);
15148 const std::uint64_t F = bits & (kHiddenBit - 1);
15150 const bool is_denormal = E == 0;
15151 const diyfp v = is_denormal
15152 ?
diyfp(F, kMinExp)
15153 : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
15176 const bool lower_boundary_is_closer = F == 0 && E > 1;
15177 const diyfp m_plus = diyfp(2 * v.
f + 1, v.
e - 1);
15178 const diyfp m_minus = lower_boundary_is_closer
15179 ? diyfp(4 * v.
f - 1, v.
e - 2)
15180 : diyfp(2 * v.
f - 1, v.
e - 1);
15186 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
15315 constexpr
int kCachedPowersMinDecExp = -300;
15316 constexpr
int kCachedPowersDecStep = 8;
15318 static constexpr std::array<cached_power, 79> kCachedPowers =
15321 { 0xAB70FE17C79AC6CA, -1060, -300 },
15322 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
15323 { 0xBE5691EF416BD60C, -1007, -284 },
15324 { 0x8DD01FAD907FFC3C, -980, -276 },
15325 { 0xD3515C2831559A83, -954, -268 },
15326 { 0x9D71AC8FADA6C9B5, -927, -260 },
15327 { 0xEA9C227723EE8BCB, -901, -252 },
15328 { 0xAECC49914078536D, -874, -244 },
15329 { 0x823C12795DB6CE57, -847, -236 },
15330 { 0xC21094364DFB5637, -821, -228 },
15331 { 0x9096EA6F3848984F, -794, -220 },
15332 { 0xD77485CB25823AC7, -768, -212 },
15333 { 0xA086CFCD97BF97F4, -741, -204 },
15334 { 0xEF340A98172AACE5, -715, -196 },
15335 { 0xB23867FB2A35B28E, -688, -188 },
15336 { 0x84C8D4DFD2C63F3B, -661, -180 },
15337 { 0xC5DD44271AD3CDBA, -635, -172 },
15338 { 0x936B9FCEBB25C996, -608, -164 },
15339 { 0xDBAC6C247D62A584, -582, -156 },
15340 { 0xA3AB66580D5FDAF6, -555, -148 },
15341 { 0xF3E2F893DEC3F126, -529, -140 },
15342 { 0xB5B5ADA8AAFF80B8, -502, -132 },
15343 { 0x87625F056C7C4A8B, -475, -124 },
15344 { 0xC9BCFF6034C13053, -449, -116 },
15345 { 0x964E858C91BA2655, -422, -108 },
15346 { 0xDFF9772470297EBD, -396, -100 },
15347 { 0xA6DFBD9FB8E5B88F, -369, -92 },
15348 { 0xF8A95FCF88747D94, -343, -84 },
15349 { 0xB94470938FA89BCF, -316, -76 },
15350 { 0x8A08F0F8BF0F156B, -289, -68 },
15351 { 0xCDB02555653131B6, -263, -60 },
15352 { 0x993FE2C6D07B7FAC, -236, -52 },
15353 { 0xE45C10C42A2B3B06, -210, -44 },
15354 { 0xAA242499697392D3, -183, -36 },
15355 { 0xFD87B5F28300CA0E, -157, -28 },
15356 { 0xBCE5086492111AEB, -130, -20 },
15357 { 0x8CBCCC096F5088CC, -103, -12 },
15358 { 0xD1B71758E219652C, -77, -4 },
15359 { 0x9C40000000000000, -50, 4 },
15360 { 0xE8D4A51000000000, -24, 12 },
15361 { 0xAD78EBC5AC620000, 3, 20 },
15362 { 0x813F3978F8940984, 30, 28 },
15363 { 0xC097CE7BC90715B3, 56, 36 },
15364 { 0x8F7E32CE7BEA5C70, 83, 44 },
15365 { 0xD5D238A4ABE98068, 109, 52 },
15366 { 0x9F4F2726179A2245, 136, 60 },
15367 { 0xED63A231D4C4FB27, 162, 68 },
15368 { 0xB0DE65388CC8ADA8, 189, 76 },
15369 { 0x83C7088E1AAB65DB, 216, 84 },
15370 { 0xC45D1DF942711D9A, 242, 92 },
15371 { 0x924D692CA61BE758, 269, 100 },
15372 { 0xDA01EE641A708DEA, 295, 108 },
15373 { 0xA26DA3999AEF774A, 322, 116 },
15374 { 0xF209787BB47D6B85, 348, 124 },
15375 { 0xB454E4A179DD1877, 375, 132 },
15376 { 0x865B86925B9BC5C2, 402, 140 },
15377 { 0xC83553C5C8965D3D, 428, 148 },
15378 { 0x952AB45CFA97A0B3, 455, 156 },
15379 { 0xDE469FBD99A05FE3, 481, 164 },
15380 { 0xA59BC234DB398C25, 508, 172 },
15381 { 0xF6C69A72A3989F5C, 534, 180 },
15382 { 0xB7DCBF5354E9BECE, 561, 188 },
15383 { 0x88FCF317F22241E2, 588, 196 },
15384 { 0xCC20CE9BD35C78A5, 614, 204 },
15385 { 0x98165AF37B2153DF, 641, 212 },
15386 { 0xE2A0B5DC971F303A, 667, 220 },
15387 { 0xA8D9D1535CE3B396, 694, 228 },
15388 { 0xFB9B7CD9A4A7443C, 720, 236 },
15389 { 0xBB764C4CA7A44410, 747, 244 },
15390 { 0x8BAB8EEFB6409C1A, 774, 252 },
15391 { 0xD01FEF10A657842C, 800, 260 },
15392 { 0x9B10A4E5E9913129, 827, 268 },
15393 { 0xE7109BFBA19C0C9D, 853, 276 },
15394 { 0xAC2820D9623BF429, 880, 284 },
15395 { 0x80444B5E7AA7CF85, 907, 292 },
15396 { 0xBF21E44003ACDD2D, 933, 300 },
15397 { 0x8E679C2F5E44FF8F, 960, 308 },
15398 { 0xD433179D9C8CB841, 986, 316 },
15399 { 0x9E19DB92B4E31BA9, 1013, 324 },
15409 const int f = kAlpha - e - 1;
15410 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
15412 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
15414 JSON_ASSERT(static_cast<std::size_t>(index) < kCachedPowers.size());
15430 if (n >= 1000000000)
15432 pow10 = 1000000000;
15436 if (n >= 100000000)
15481 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
15482 std::uint64_t rest, std::uint64_t ten_k)
15509 && delta - rest >= ten_k
15510 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
15525 static_assert(kAlpha >= -60,
"internal error");
15526 static_assert(kGamma <= -32,
"internal error");
15543 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
15544 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
15553 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
15555 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
15556 std::uint64_t p2 = M_plus.
f & (one.f - 1);
15564 std::uint32_t pow10{};
15592 const std::uint32_t
d = p1 / pow10;
15593 const std::uint32_t r = p1 % pow10;
15599 buffer[length++] =
static_cast<char>(
'0' + d);
15618 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
15623 decimal_exponent += n;
15634 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
15635 grisu2_round(buffer, length, dist, delta, rest, ten_n);
15696 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
15698 const std::uint64_t
d = p2 >> -one.e;
15699 const std::uint64_t r = p2 & (one.f - 1);
15706 buffer[length++] =
static_cast<char>(
'0' + d);
15731 decimal_exponent -= m;
15739 const std::uint64_t ten_m = one.f;
15763 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
15780 const diyfp c_minus_k(cached.
f, cached.
e);
15783 const diyfp w = diyfp::mul(v, c_minus_k);
15784 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
15785 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
15808 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
15809 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
15811 decimal_exponent = -cached.
k;
15821 template<
typename FloatType>
15825 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
15826 "internal error: not enough precision");
15878 auto k =
static_cast<std::uint32_t
>(e);
15884 *buf++ =
static_cast<char>(
'0' + k);
15888 *buf++ =
static_cast<char>(
'0' + k / 10);
15890 *buf++ =
static_cast<char>(
'0' + k);
15894 *buf++ =
static_cast<char>(
'0' + k / 100);
15896 *buf++ =
static_cast<char>(
'0' + k / 10);
15898 *buf++ =
static_cast<char>(
'0' + k);
15916 int min_exp,
int max_exp)
15922 const int n = len + decimal_exponent;
15928 if (k <= n && n <= max_exp)
15933 std::memset(buf + k,
'0', static_cast<size_t>(n) - static_cast<size_t>(k));
15937 return buf + (
static_cast<size_t>(n) + 2);
15940 if (0 < n && n <= max_exp)
15947 std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
15949 return buf + (
static_cast<size_t>(k) + 1U);
15952 if (min_exp < n && n <= 0)
15957 std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k));
15960 std::memset(buf + 2,
'0', static_cast<size_t>(-n));
15961 return buf + (2U +
static_cast<size_t>(-n) + static_cast<size_t>(k));
15976 std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1);
15978 buf += 1 +
static_cast<size_t>(k);
15997 template<
typename FloatType>
16002 static_cast<void>(last);
16006 if (std::signbit(value))
16013 #pragma GCC diagnostic push 16014 #pragma GCC diagnostic ignored "-Wfloat-equal" 16025 #pragma GCC diagnostic pop 16028 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
16035 int decimal_exponent = 0;
16038 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
16041 constexpr
int kMinExp = -4;
16046 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
16047 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
16084 template<
typename BasicJsonType>
16092 static constexpr std::uint8_t UTF8_ACCEPT = 0;
16093 static constexpr std::uint8_t UTF8_REJECT = 1;
16104 , loc(
std::localeconv())
16107 , indent_char(ichar)
16108 , indent_string(512, indent_char)
16142 const bool pretty_print,
16143 const bool ensure_ascii,
16144 const unsigned int indent_step,
16145 const unsigned int current_indent = 0)
16147 switch (val.m_type)
16151 if (val.m_value.object->empty())
16153 o->write_characters(
"{}", 2);
16159 o->write_characters(
"{\n", 2);
16162 const auto new_indent = current_indent + indent_step;
16165 indent_string.resize(indent_string.size() * 2,
' ');
16169 auto i = val.m_value.object->cbegin();
16170 for (
std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16172 o->write_characters(indent_string.c_str(), new_indent);
16173 o->write_character(
'\"');
16174 dump_escaped(i->first, ensure_ascii);
16175 o->write_characters(
"\": ", 3);
16176 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
16177 o->write_characters(
",\n", 2);
16182 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16183 o->write_characters(indent_string.c_str(), new_indent);
16184 o->write_character(
'\"');
16185 dump_escaped(i->first, ensure_ascii);
16186 o->write_characters(
"\": ", 3);
16187 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
16189 o->write_character(
'\n');
16190 o->write_characters(indent_string.c_str(), current_indent);
16191 o->write_character(
'}');
16195 o->write_character(
'{');
16198 auto i = val.m_value.object->cbegin();
16199 for (
std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16201 o->write_character(
'\"');
16202 dump_escaped(i->first, ensure_ascii);
16203 o->write_characters(
"\":", 2);
16204 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
16205 o->write_character(
',');
16210 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16211 o->write_character(
'\"');
16212 dump_escaped(i->first, ensure_ascii);
16213 o->write_characters(
"\":", 2);
16214 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
16216 o->write_character(
'}');
16224 if (val.m_value.array->empty())
16226 o->write_characters(
"[]", 2);
16232 o->write_characters(
"[\n", 2);
16235 const auto new_indent = current_indent + indent_step;
16238 indent_string.resize(indent_string.size() * 2,
' ');
16242 for (
auto i = val.m_value.array->cbegin();
16243 i != val.m_value.array->cend() - 1; ++i)
16245 o->write_characters(indent_string.c_str(), new_indent);
16246 dump(*i,
true, ensure_ascii, indent_step, new_indent);
16247 o->write_characters(
",\n", 2);
16252 o->write_characters(indent_string.c_str(), new_indent);
16253 dump(val.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
16255 o->write_character(
'\n');
16256 o->write_characters(indent_string.c_str(), current_indent);
16257 o->write_character(
']');
16261 o->write_character(
'[');
16264 for (
auto i = val.m_value.array->cbegin();
16265 i != val.m_value.array->cend() - 1; ++i)
16267 dump(*i,
false, ensure_ascii, indent_step, current_indent);
16268 o->write_character(
',');
16273 dump(val.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
16275 o->write_character(
']');
16283 o->write_character(
'\"');
16284 dump_escaped(*val.m_value.string, ensure_ascii);
16285 o->write_character(
'\"');
16293 o->write_characters(
"{\n", 2);
16296 const auto new_indent = current_indent + indent_step;
16299 indent_string.resize(indent_string.size() * 2,
' ');
16302 o->write_characters(indent_string.c_str(), new_indent);
16304 o->write_characters(
"\"bytes\": [", 10);
16306 if (!val.m_value.binary->empty())
16308 for (
auto i = val.m_value.binary->cbegin();
16309 i != val.m_value.binary->cend() - 1; ++i)
16312 o->write_characters(
", ", 2);
16314 dump_integer(val.m_value.binary->back());
16317 o->write_characters(
"],\n", 3);
16318 o->write_characters(indent_string.c_str(), new_indent);
16320 o->write_characters(
"\"subtype\": ", 11);
16321 if (val.m_value.binary->has_subtype())
16323 dump_integer(val.m_value.binary->subtype());
16327 o->write_characters(
"null", 4);
16329 o->write_character(
'\n');
16330 o->write_characters(indent_string.c_str(), current_indent);
16331 o->write_character(
'}');
16335 o->write_characters(
"{\"bytes\":[", 10);
16337 if (!val.m_value.binary->empty())
16339 for (
auto i = val.m_value.binary->cbegin();
16340 i != val.m_value.binary->cend() - 1; ++i)
16343 o->write_character(
',');
16345 dump_integer(val.m_value.binary->back());
16348 o->write_characters(
"],\"subtype\":", 12);
16349 if (val.m_value.binary->has_subtype())
16351 dump_integer(val.m_value.binary->subtype());
16352 o->write_character(
'}');
16356 o->write_characters(
"null}", 5);
16364 if (val.m_value.boolean)
16366 o->write_characters(
"true", 4);
16370 o->write_characters(
"false", 5);
16377 dump_integer(val.m_value.number_integer);
16383 dump_integer(val.m_value.number_unsigned);
16389 dump_float(val.m_value.number_float);
16395 o->write_characters(
"<discarded>", 11);
16401 o->write_characters(
"null", 4);
16425 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
16428 std::uint8_t state = UTF8_ACCEPT;
16437 const auto byte =
static_cast<std::uint8_t
>(s[i]);
16439 switch (decode(state,
codepoint, byte))
16447 string_buffer[bytes++] =
'\\';
16448 string_buffer[bytes++] =
'b';
16454 string_buffer[bytes++] =
'\\';
16455 string_buffer[bytes++] =
't';
16461 string_buffer[bytes++] =
'\\';
16462 string_buffer[bytes++] =
'n';
16468 string_buffer[bytes++] =
'\\';
16469 string_buffer[bytes++] =
'f';
16475 string_buffer[bytes++] =
'\\';
16476 string_buffer[bytes++] =
'r';
16482 string_buffer[bytes++] =
'\\';
16483 string_buffer[bytes++] =
'\"';
16489 string_buffer[bytes++] =
'\\';
16490 string_buffer[bytes++] =
'\\';
16500 if (codepoint <= 0xFFFF)
16503 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
16504 static_cast<std::uint16_t
>(
codepoint)));
16510 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
16511 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
16512 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
16520 string_buffer[bytes++] = s[i];
16529 if (string_buffer.size() - bytes < 13)
16531 o->write_characters(string_buffer.data(), bytes);
16536 bytes_after_last_accept = bytes;
16537 undumped_chars = 0;
16547 std::stringstream ss;
16548 ss << std::uppercase << std::setfill(
'0') << std::setw(2) << std::hex << (byte | 0);
16559 if (undumped_chars > 0)
16566 bytes = bytes_after_last_accept;
16573 string_buffer[bytes++] =
'\\';
16574 string_buffer[bytes++] =
'u';
16575 string_buffer[bytes++] =
'f';
16576 string_buffer[bytes++] =
'f';
16577 string_buffer[bytes++] =
'f';
16578 string_buffer[bytes++] =
'd';
16590 if (string_buffer.size() - bytes < 13)
16592 o->write_characters(string_buffer.data(), bytes);
16596 bytes_after_last_accept = bytes;
16599 undumped_chars = 0;
16602 state = UTF8_ACCEPT;
16617 string_buffer[bytes++] = s[i];
16631 o->write_characters(string_buffer.data(), bytes);
16641 std::stringstream ss;
16642 ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast<std::uint8_t>(s.back()) | 0);
16649 o->write_characters(string_buffer.data(), bytes_after_last_accept);
16656 o->write_characters(string_buffer.data(), bytes_after_last_accept);
16660 o->write_characters(
"\\ufffd", 6);
16664 o->write_characters(
"\xEF\xBF\xBD", 3);
16686 unsigned int n_digits = 1;
16695 return n_digits + 1;
16699 return n_digits + 2;
16703 return n_digits + 3;
16711 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
16712 bool is_negative_number(NumberType x)
16717 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
16718 bool is_negative_number(NumberType )
16733 std::is_integral<NumberType>::value ||
16734 std::is_same<NumberType, number_unsigned_t>::value ||
16735 std::is_same<NumberType, number_integer_t>::value ||
16736 std::is_same<NumberType, binary_char_t>::value,
16738 void dump_integer(NumberType x)
16740 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
16743 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
16744 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
16745 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
16746 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
16747 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
16748 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
16749 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
16750 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
16751 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
16752 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
16759 o->write_character(
'0');
16764 auto buffer_ptr = number_buffer.begin();
16768 unsigned int n_chars{};
16770 if (is_negative_number(x))
16773 abs_value = remove_sign(static_cast<number_integer_t>(x));
16789 buffer_ptr += n_chars;
16793 while (abs_value >= 100)
16795 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
16797 *(--buffer_ptr) = digits_to_99[digits_index][1];
16798 *(--buffer_ptr) = digits_to_99[digits_index][0];
16801 if (abs_value >= 10)
16803 const auto digits_index =
static_cast<unsigned>(abs_value);
16804 *(--buffer_ptr) = digits_to_99[digits_index][1];
16805 *(--buffer_ptr) = digits_to_99[digits_index][0];
16809 *(--buffer_ptr) = static_cast<char>(
'0' + abs_value);
16812 o->write_characters(number_buffer.data(), n_chars);
16828 o->write_characters(
"null", 4);
16837 static constexpr
bool is_ieee_single_or_double
16838 = (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) ||
16839 (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);
16841 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
16846 auto* begin = number_buffer.data();
16849 o->write_characters(begin, static_cast<size_t>(end - begin));
16855 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
16859 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d,
x);
16864 JSON_ASSERT(static_cast<std::size_t>(len) < number_buffer.size());
16871 std::fill(end, number_buffer.end(),
'\0');
16872 JSON_ASSERT((end - number_buffer.begin()) <= len);
16873 len = (end - number_buffer.begin());
16881 if (dec_pos != number_buffer.end())
16887 o->write_characters(number_buffer.data(),
static_cast<std::size_t>(len));
16890 const bool value_is_int_like =
16891 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
16894 return c ==
'.' || c ==
'e';
16897 if (value_is_int_like)
16899 o->write_characters(
".0", 2);
16924 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t byte) noexcept
16926 static const std::array<std::uint8_t, 400> utf8d =
16929 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,
16930 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,
16931 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,
16932 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,
16933 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,
16934 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,
16935 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,
16936 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
16937 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
16938 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
16939 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,
16940 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,
16941 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,
16942 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
16947 const std::uint8_t
type = utf8d[byte];
16949 codep = (state != UTF8_ACCEPT)
16950 ? (byte & 0x3fu) | (codep << 6u)
16951 : (0xFFu >> type) & (byte);
16953 std::size_t index = 256u +
static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
16955 state = utf8d[index];
16981 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
16990 std::array<char, 64> number_buffer{{}};
16993 const std::lconv* loc =
nullptr;
17000 std::array<char, 512> string_buffer{{}};
17020 #include <functional> 17021 #include <initializer_list> 17022 #include <iterator> 17024 #include <stdexcept> 17025 #include <type_traits> 17037 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
17038 class Allocator = std::allocator<std::pair<const Key, T>>>
17039 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
17043 using Container = std::vector<std::pair<const Key, T>, Allocator>;
17052 template <
class It>
17055 ordered_map(std::initializer_list<T> init,
const Allocator& alloc = Allocator() )
17060 for (
auto it = this->begin(); it != this->end(); ++it)
17062 if (it->first == key)
17064 return {it,
false};
17067 Container::emplace_back(key, t);
17068 return {--this->end(),
true};
17073 return emplace(key, T{}).first->second;
17083 for (
auto it = this->begin(); it != this->end(); ++it)
17085 if (it->first == key)
17091 JSON_THROW(std::out_of_range(
"key not found"));
17096 for (
auto it = this->begin(); it != this->end(); ++it)
17098 if (it->first == key)
17104 JSON_THROW(std::out_of_range(
"key not found"));
17109 for (
auto it = this->begin(); it != this->end(); ++it)
17111 if (it->first == key)
17114 for (
auto next = it; ++
next != this->end(); ++it)
17119 Container::pop_back();
17128 return erase(pos, std::next(pos));
17133 const auto elements_affected = std::distance(first, last);
17134 const auto offset = std::distance(Container::begin(), first);
17156 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
17167 Container::resize(this->
size() - static_cast<size_type>(elements_affected));
17176 return Container::begin() + offset;
17181 for (
auto it = this->begin(); it != this->end(); ++it)
17183 if (it->first == key)
17193 for (
auto it = this->begin(); it != this->end(); ++it)
17195 if (it->first == key)
17200 return Container::end();
17205 for (
auto it = this->begin(); it != this->end(); ++it)
17207 if (it->first == key)
17212 return Container::end();
17222 for (
auto it = this->begin(); it != this->end(); ++it)
17224 if (it->first == value.first)
17226 return {it,
false};
17229 Container::push_back(value);
17230 return {--this->end(),
true};
17233 template<
typename InputIt>
17234 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
17237 template<
typename InputIt,
typename = require_input_iter<InputIt>>
17240 for (
auto it = first; it != last; ++it)
17250 #if defined(JSON_HAS_CPP_17) 17251 #include <string_view> 17285 friend ::nlohmann::json_pointer<basic_json>;
17287 template<
typename BasicJsonType,
typename InputType>
17289 friend ::nlohmann::detail::serializer<basic_json>;
17290 template<
typename BasicJsonType>
17291 friend class ::nlohmann::detail::iter_impl;
17292 template<
typename BasicJsonType,
typename CharType>
17293 friend class ::nlohmann::detail::binary_writer;
17294 template<
typename BasicJsonType,
typename InputType,
typename SAX>
17295 friend class ::nlohmann::detail::binary_reader;
17296 template<
typename BasicJsonType>
17297 friend class ::nlohmann::detail::json_sax_dom_parser;
17298 template<
typename BasicJsonType>
17299 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
17300 friend class ::nlohmann::detail::exception;
17309 template<
typename InputAdapterType>
17310 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
17311 InputAdapterType adapter,
17313 const bool allow_exceptions =
true,
17314 const bool ignore_comments =
false 17317 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(
std::move(adapter),
17318 std::move(cb), allow_exceptions, ignore_comments);
17323 template<
typename BasicJsonType>
17325 template<
typename BasicJsonType>
17327 template<
typename Iterator>
17331 template<
typename CharType>
17334 template<
typename InputType>
17345 template<
typename T,
typename SFINAE>
17402 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
17404 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
17432 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
17433 result[
"name"] =
"JSON for Modern C++";
17434 result[
"url"] =
"https://github.com/nlohmann/json";
17435 result[
"version"][
"string"] =
17444 result[
"platform"] =
"win32";
17445 #elif defined __linux__ 17446 result[
"platform"] =
"linux";
17447 #elif defined __APPLE__ 17448 result[
"platform"] =
"apple";
17449 #elif defined __unix__ 17450 result[
"platform"] =
"unix";
17452 result[
"platform"] =
"unknown";
17455 #if defined(__ICC) || defined(__INTEL_COMPILER) 17456 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
17457 #elif defined(__clang__) 17458 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
17459 #elif defined(__GNUC__) || defined(__GNUG__) 17460 result[
"compiler"] = {{
"family",
"gcc"}, {
"version", std::to_string(__GNUC__) +
"." + std::to_string(__GNUC_MINOR__) +
"." + std::to_string(__GNUC_PATCHLEVEL__)}};
17461 #elif defined(__HP_cc) || defined(__HP_aCC) 17462 result[
"compiler"] =
"hp" 17463 #elif defined(__IBMCPP__) 17464 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
17465 #elif defined(_MSC_VER) 17466 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
17467 #elif defined(__PGI) 17468 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
17469 #elif defined(__SUNPRO_CC) 17470 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
17472 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
17476 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
17478 result[
"compiler"][
"c++"] =
"unknown";
17495 #if defined(JSON_HAS_CPP_14) 17505 using object_t = ObjectType<StringType,
17508 AllocatorType<std::pair<
const StringType,
17513 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
17544 template<
typename T,
typename... Args>
17548 AllocatorType<T> alloc;
17549 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
17551 auto deleter = [&](T * obj)
17553 AllocatorTraits::deallocate(alloc, obj, 1);
17555 std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
17558 return obj.release();
17611 json_value() =
default;
17627 object = create<object_t>();
17633 array = create<array_t>();
17639 string = create<string_t>(
"");
17645 binary = create<binary_t>();
17651 boolean =
static_cast<boolean_t>(
false);
17727 std::vector<basic_json> stack;
17732 stack.reserve(array->size());
17733 std::move(array->begin(), array->end(), std::back_inserter(stack));
17737 stack.reserve(object->size());
17738 for (
auto&& it : *
object)
17744 while (!stack.empty())
17747 basic_json current_item(
std::move(stack.back()));
17754 std::move(current_item.
m_value.array->begin(), current_item.
m_value.array->end(), std::back_inserter(stack));
17756 current_item.
m_value.array->clear();
17760 for (
auto&& it : *current_item.
m_value.object)
17765 current_item.
m_value.object->clear();
17777 AllocatorType<object_t> alloc;
17778 std::allocator_traits<decltype(alloc)>::destroy(alloc,
object);
17779 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
17785 AllocatorType<array_t> alloc;
17786 std::allocator_traits<decltype(alloc)>::destroy(alloc,
array);
17787 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
array, 1);
17793 AllocatorType<string_t> alloc;
17794 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
17795 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
17801 AllocatorType<binary_t> alloc;
17802 std::allocator_traits<decltype(alloc)>::destroy(alloc,
binary);
17803 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
binary, 1);
17847 #if JSON_DIAGNOSTICS 17851 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
17853 return j.m_parent ==
this;
17858 static_cast<void>(check_parents);
17863 #if JSON_DIAGNOSTICS 17868 for (
auto& element : *m_value.array)
17870 element.m_parent =
this;
17877 for (
auto& element : *m_value.object)
17879 element.second.m_parent =
this;
17900 #if JSON_DIAGNOSTICS 17903 (it + i)->m_parent =
this;
17906 static_cast<void>(count_set_parents);
17913 #if JSON_DIAGNOSTICS 17914 if (old_capacity != static_cast<std::size_t>(-1))
17928 #ifdef JSON_HEDLEY_MSVC_VERSION 17929 #pragma warning(push ) 17930 #pragma warning(disable : 4127) // ignore warning to replace if with if constexpr 17937 #ifdef JSON_HEDLEY_MSVC_VERSION 17938 #pragma warning( pop ) 17943 static_cast<void>(j);
17944 static_cast<void>(old_capacity);
17974 : m_type(v), m_value(v)
17976 assert_invariant();
17984 assert_invariant();
17989 template <
typename CompatibleType,
17995 std::forward<CompatibleType>(val))))
17999 assert_invariant();
18004 template <
typename BasicJsonType,
18009 using other_boolean_t =
typename BasicJsonType::boolean_t;
18010 using other_number_float_t =
typename BasicJsonType::number_float_t;
18011 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
18012 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18013 using other_string_t =
typename BasicJsonType::string_t;
18014 using other_object_t =
typename BasicJsonType::object_t;
18015 using other_array_t =
typename BasicJsonType::array_t;
18016 using other_binary_t =
typename BasicJsonType::binary_t;
18018 switch (val.type())
18054 assert_invariant();
18060 bool type_deduction =
true,
18065 bool is_an_object = std::all_of(init.begin(), init.end(),
18068 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
18072 if (!type_deduction)
18077 is_an_object =
false;
18093 for (
auto& element_ref : init)
18095 auto element = element_ref.moved_or_copied();
18096 m_value.object->emplace(
18097 std::move(*((*element.m_value.array)[0].m_value.string)),
18098 std::move((*element.m_value.array)[1]));
18105 m_value.array = create<array_t>(init.begin(), init.end());
18109 assert_invariant();
18117 auto res = basic_json();
18119 res.m_value = init;
18128 auto res = basic_json();
18130 res.m_value =
binary_t(init, subtype);
18139 auto res = basic_json();
18150 auto res = basic_json();
18177 m_value.array = create<array_t>(cnt, val);
18179 assert_invariant();
18184 template <
class InputIT,
typename std::enable_if <
18185 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
18186 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
18199 m_type = first.m_object->m_type;
18211 || !last.m_it.primitive_iterator.is_end()))
18231 m_value.number_integer = first.m_object->m_value.number_integer;
18237 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
18243 m_value.number_float = first.m_object->m_value.number_float;
18249 m_value.boolean = first.m_object->m_value.boolean;
18255 m_value = *first.m_object->m_value.string;
18261 m_value.object = create<object_t>(first.m_it.object_iterator,
18262 last.m_it.object_iterator);
18268 m_value.array = create<array_t>(first.m_it.array_iterator,
18269 last.m_it.array_iterator);
18275 m_value = *first.m_object->m_value.binary;
18286 assert_invariant();
18294 template<
typename JsonRef,
18296 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
18297 basic_json(
const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
18302 : m_type(other.m_type)
18311 m_value = *other.
m_value.object;
18317 m_value = *other.
m_value.array;
18323 m_value = *other.
m_value.string;
18329 m_value = other.
m_value.boolean;
18335 m_value = other.
m_value.number_integer;
18341 m_value = other.
m_value.number_unsigned;
18347 m_value = other.
m_value.number_float;
18353 m_value = *other.
m_value.binary;
18364 assert_invariant();
18374 other.assert_invariant(
false);
18378 other.m_value = {};
18381 assert_invariant();
18387 std::is_nothrow_move_constructible<value_t>::value&&
18388 std::is_nothrow_move_assignable<value_t>::value&&
18389 std::is_nothrow_move_constructible<json_value>::value&&
18390 std::is_nothrow_move_assignable<json_value>::value
18397 swap(m_type, other.m_type);
18398 swap(m_value, other.m_value);
18401 assert_invariant();
18409 assert_invariant(
false);
18410 m_value.destroy(m_type);
18427 const char indent_char =
' ',
18428 const bool ensure_ascii =
false,
18436 s.dump(*
this,
true, ensure_ascii, static_cast<unsigned int>(indent));
18440 s.dump(*
this,
false, ensure_ascii, 0);
18457 return is_null() ||
is_string() || is_boolean() || is_number() || is_binary();
18464 return is_array() || is_object();
18485 return is_number_integer() || is_number_float();
18563 return m_value.boolean;
18572 return is_object() ? m_value.object :
nullptr;
18578 return is_object() ? m_value.object :
nullptr;
18584 return is_array() ? m_value.array :
nullptr;
18590 return is_array() ? m_value.array :
nullptr;
18596 return is_string() ? m_value.string :
nullptr;
18602 return is_string() ? m_value.string :
nullptr;
18608 return is_boolean() ? &m_value.boolean :
nullptr;
18614 return is_boolean() ? &m_value.boolean :
nullptr;
18620 return is_number_integer() ? &m_value.number_integer :
nullptr;
18626 return is_number_integer() ? &m_value.number_integer :
nullptr;
18632 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
18638 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
18644 return is_number_float() ? &m_value.number_float :
nullptr;
18650 return is_number_float() ? &m_value.number_float :
nullptr;
18656 return is_binary() ? m_value.binary :
nullptr;
18662 return is_binary() ? m_value.binary :
nullptr;
18676 template<
typename ReferenceType,
typename ThisType>
18697 template<
typename PointerType,
typename std::enable_if<
18698 std::is_pointer<PointerType>::value,
int>::type = 0>
18702 return get_impl_ptr(static_cast<PointerType>(
nullptr));
18707 template <
typename PointerType,
typename std::enable_if <
18708 std::is_pointer<PointerType>::value&&
18713 return get_impl_ptr(static_cast<PointerType>(
nullptr));
18823 template <
typename BasicJsonType,
18846 template<
typename BasicJsonType,
18848 std::is_same<BasicJsonType, basic_json_t>::value,
18859 template<
typename PointerType,
18861 std::is_pointer<PointerType>::value,
18864 -> decltype(std::declval<const basic_json_t&>().
template get_ptr<PointerType>())
18867 return get_ptr<PointerType>();
18894 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
18895 #if defined(JSON_HAS_CPP_14) 18898 auto get()
const noexcept(
18905 static_assert(!std::is_reference<ValueTypeCV>::value,
18906 "get() cannot be used with reference types, you might want to use get_ref()");
18937 template<
typename PointerType,
typename std::enable_if<
18938 std::is_pointer<PointerType>::value,
int>::type = 0>
18939 auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
18942 return get_ptr<PointerType>();
18950 detail::has_from_json<basic_json_t, ValueType>::value,
18952 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
18973 typename Array = T (&)[N],
18978 std::declval<const basic_json_t&>(), v)))
18986 template<
typename ReferenceType,
typename std::enable_if<
18987 std::is_reference<ReferenceType>::value,
int>::type = 0>
18991 return get_ref_impl<ReferenceType>(*this);
18996 template <
typename ReferenceType,
typename std::enable_if <
18997 std::is_reference<ReferenceType>::value&&
19002 return get_ref_impl<ReferenceType>(*this);
19034 template <
typename ValueType,
typename std::enable_if <
19042 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) 19050 return get<ValueType>();
19062 return *get_ptr<binary_t*>();
19074 return *get_ptr<const binary_t*>();
19097 return set_parent(m_value.array->at(idx));
19120 return m_value.array->at(idx);
19143 return set_parent(m_value.object->at(key));
19166 return m_value.object->at(key);
19188 m_value.array = create<array_t>();
19189 assert_invariant();
19196 if (idx >= m_value.array->size())
19198 #if JSON_DIAGNOSTICS 19200 const auto old_size = m_value.array->size();
19201 const auto old_capacity = m_value.array->capacity();
19203 m_value.array->resize(idx + 1);
19205 #if JSON_DIAGNOSTICS 19214 set_parents(begin() + static_cast<typename iterator::difference_type>(old_size), static_cast<typename iterator::difference_type>(idx + 1 - old_size));
19217 assert_invariant();
19220 return m_value.array->operator[](idx);
19233 return m_value.
array->operator[](idx);
19247 m_value.object = create<object_t>();
19248 assert_invariant();
19254 return set_parent(m_value.object->operator[](key));
19267 JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
19268 return m_value.object->find(key)->second;
19276 template<
typename T>
19285 assert_invariant();
19291 return set_parent(m_value.object->operator[](key));
19299 template<
typename T>
19306 JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
19307 return m_value.object->find(key)->second;
19316 template <
class ValueType,
typename std::enable_if <
19318 && !std::is_same<value_t, ValueType>::value,
int >::type = 0 >
19319 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const 19325 const auto it =
find(key);
19328 return it->template get<ValueType>();
19331 return default_value;
19347 template<
class ValueType,
typename std::enable_if<
19357 return ptr.
get_checked(
this).template get<ValueType>();
19361 return default_value;
19411 template <
class IteratorType,
typename std::enable_if <
19412 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
19413 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >::type
19423 IteratorType
result = end();
19441 AllocatorType<string_t> alloc;
19442 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
19443 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
19444 m_value.string =
nullptr;
19446 else if (is_binary())
19448 AllocatorType<binary_t> alloc;
19449 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
19450 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
19451 m_value.binary =
nullptr;
19455 assert_invariant();
19461 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
19467 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
19482 template <
class IteratorType,
typename std::enable_if <
19483 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
19484 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >::type
19494 IteratorType
result = end();
19506 || !last.m_it.primitive_iterator.is_end()))
19513 AllocatorType<string_t> alloc;
19514 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
19515 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
19516 m_value.string =
nullptr;
19518 else if (is_binary())
19520 AllocatorType<binary_t> alloc;
19521 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
19522 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
19523 m_value.binary =
nullptr;
19527 assert_invariant();
19533 result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
19534 last.m_it.object_iterator);
19540 result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
19541 last.m_it.array_iterator);
19561 return m_value.object->erase(key);
19579 m_value.array->erase(m_value.array->begin() +
static_cast<difference_type>(idx));
19599 template<
typename KeyT>
19606 result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(
key));
19614 template<
typename KeyT>
19621 result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(
key));
19629 template<
typename KeyT>
19633 return is_object() ? m_value.object->count(std::forward<KeyT>(
key)) : 0;
19638 template <
typename KeyT,
typename std::enable_if <
19642 return is_object() && m_value.object->find(std::forward<KeyT>(
key)) != m_value.object->end();
19667 result.set_begin();
19683 result.set_begin();
19763 return ref.items();
19774 return ref.items();
19816 return m_value.array->empty();
19822 return m_value.object->empty();
19855 return m_value.array->size();
19861 return m_value.object->size();
19888 return m_value.array->max_size();
19894 return m_value.object->max_size();
19931 m_value.number_integer = 0;
19937 m_value.number_unsigned = 0;
19943 m_value.number_float = 0.0;
19949 m_value.boolean =
false;
19955 m_value.string->clear();
19961 m_value.binary->clear();
19967 m_value.array->clear();
19973 m_value.object->clear();
19999 assert_invariant();
20003 const auto old_capacity = m_value.array->capacity();
20004 m_value.array->push_back(
std::move(val));
20005 set_parent(m_value.array->back(), old_capacity);
20032 assert_invariant();
20036 const auto old_capacity = m_value.array->capacity();
20037 m_value.array->push_back(val);
20038 set_parent(m_value.array->back(), old_capacity);
20064 assert_invariant();
20068 auto res = m_value.object->insert(val);
20069 set_parent(res.first->second);
20084 if (is_object() && init.size() == 2 && (*init.begin())->
is_string())
20086 basic_json&&
key = init.begin()->moved_or_copied();
20092 push_back(basic_json(init));
20106 template<
class... Args>
20120 assert_invariant();
20124 const auto old_capacity = m_value.array->capacity();
20125 m_value.array->emplace_back(std::forward<Args>(
args)...);
20126 return set_parent(m_value.array->back(), old_capacity);
20131 template<
class... Args>
20145 assert_invariant();
20149 auto res = m_value.object->emplace(std::forward<Args>(
args)...);
20150 set_parent(res.first->second);
20154 it.m_it.object_iterator = res.first;
20157 return {it, res.second};
20163 template<
typename... Args>
20195 return insert_iterator(pos, val);
20205 return insert(pos, val);
20222 return insert_iterator(pos, cnt, val);
20276 return insert_iterator(pos, ilist.begin(), ilist.end());
20319 m_value.object = create<object_t>();
20320 assert_invariant();
20340 for (
auto it = first; it != last; ++it)
20342 if (merge_objects && it.value().is_object())
20344 auto it2 = m_value.object->find(it.key());
20345 if (it2 != m_value.object->end())
20347 it2->second.update(it.value(),
true);
20351 m_value.object->operator[](it.key()) = it.value();
20352 #if JSON_DIAGNOSTICS 20353 m_value.object->operator[](it.key()).m_parent =
this;
20361 std::is_nothrow_move_constructible<value_t>::value&&
20362 std::is_nothrow_move_assignable<value_t>::value&&
20363 std::is_nothrow_move_constructible<json_value>::value&&
20364 std::is_nothrow_move_assignable<json_value>::value
20371 other.set_parents();
20372 assert_invariant();
20378 std::is_nothrow_move_constructible<value_t>::value&&
20379 std::is_nothrow_move_assignable<value_t>::value&&
20380 std::is_nothrow_move_constructible<json_value>::value&&
20381 std::is_nothrow_move_assignable<json_value>::value
20477 #pragma GCC diagnostic push 20478 #pragma GCC diagnostic ignored "-Wfloat-equal" 20480 const auto lhs_type = lhs.type();
20481 const auto rhs_type = rhs.type();
20483 if (lhs_type == rhs_type)
20488 return *lhs.m_value.array == *rhs.m_value.array;
20491 return *lhs.m_value.object == *rhs.m_value.object;
20497 return *lhs.m_value.string == *rhs.m_value.string;
20500 return lhs.m_value.boolean == rhs.m_value.boolean;
20503 return lhs.m_value.number_integer == rhs.m_value.number_integer;
20506 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
20509 return lhs.m_value.number_float == rhs.m_value.number_float;
20512 return *lhs.m_value.binary == *rhs.m_value.binary;
20521 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
20525 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
20529 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
20533 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
20537 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
20541 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
20546 #pragma GCC diagnostic pop 20552 template<
typename ScalarType,
typename std::enable_if<
20553 std::is_scalar<ScalarType>::value,
int>::type = 0>
20556 return lhs == basic_json(rhs);
20561 template<
typename ScalarType,
typename std::enable_if<
20562 std::is_scalar<ScalarType>::value,
int>::type = 0>
20565 return basic_json(lhs) == rhs;
20572 return !(lhs == rhs);
20577 template<
typename ScalarType,
typename std::enable_if<
20578 std::is_scalar<ScalarType>::value,
int>::type = 0>
20581 return lhs != basic_json(rhs);
20586 template<
typename ScalarType,
typename std::enable_if<
20587 std::is_scalar<ScalarType>::value,
int>::type = 0>
20590 return basic_json(lhs) != rhs;
20597 const auto lhs_type = lhs.type();
20598 const auto rhs_type = rhs.type();
20600 if (lhs_type == rhs_type)
20607 return (*lhs.m_value.array) < (*rhs.m_value.array);
20610 return (*lhs.m_value.object) < (*rhs.m_value.object);
20616 return (*lhs.m_value.string) < (*rhs.m_value.string);
20619 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
20622 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
20625 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
20628 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
20631 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
20640 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
20644 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
20648 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
20652 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
20656 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
20660 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
20671 template<
typename ScalarType,
typename std::enable_if<
20672 std::is_scalar<ScalarType>::value,
int>::type = 0>
20675 return lhs < basic_json(rhs);
20680 template<
typename ScalarType,
typename std::enable_if<
20681 std::is_scalar<ScalarType>::value,
int>::type = 0>
20684 return basic_json(lhs) < rhs;
20691 return !(rhs < lhs);
20696 template<
typename ScalarType,
typename std::enable_if<
20697 std::is_scalar<ScalarType>::value,
int>::type = 0>
20700 return lhs <= basic_json(rhs);
20705 template<
typename ScalarType,
typename std::enable_if<
20706 std::is_scalar<ScalarType>::value,
int>::type = 0>
20709 return basic_json(lhs) <= rhs;
20716 return !(lhs <= rhs);
20721 template<
typename ScalarType,
typename std::enable_if<
20722 std::is_scalar<ScalarType>::value,
int>::type = 0>
20725 return lhs > basic_json(rhs);
20730 template<
typename ScalarType,
typename std::enable_if<
20731 std::is_scalar<ScalarType>::value,
int>::type = 0>
20734 return basic_json(lhs) > rhs;
20741 return !(lhs < rhs);
20746 template<
typename ScalarType,
typename std::enable_if<
20747 std::is_scalar<ScalarType>::value,
int>::type = 0>
20750 return lhs >= basic_json(rhs);
20755 template<
typename ScalarType,
typename std::enable_if<
20756 std::is_scalar<ScalarType>::value,
int>::type = 0>
20759 return basic_json(lhs) >= rhs;
20771 friend std::ostream&
operator<<(std::ostream& o,
const basic_json& j)
20776 const bool pretty_print = o.width() > 0;
20777 const auto indentation = pretty_print ? o.width() : 0;
20784 s.dump(j, pretty_print,
false, static_cast<unsigned int>(indentation));
20795 friend
std::ostream& operator>>(const basic_json& j,
std::ostream& o)
20799 #endif // JSON_NO_IO 20812 template<
typename InputType>
20816 const bool allow_exceptions =
true,
20817 const bool ignore_comments =
false)
20826 template<
typename IteratorType>
20831 const bool allow_exceptions =
true,
20832 const bool ignore_comments =
false)
20841 static basic_json parse(
detail::span_input_adapter&& i,
20843 const
bool allow_exceptions = true,
20844 const
bool ignore_comments = false)
20847 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
20853 template<
typename InputType>
20855 const bool ignore_comments =
false)
20862 template<
typename IteratorType>
20864 const bool ignore_comments =
false)
20871 static
bool accept(
detail::span_input_adapter&& i,
20872 const
bool ignore_comments = false)
20874 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
20879 template <
typename InputType,
typename SAX>
20881 static
bool sax_parse(InputType&& i, SAX* sax,
20883 const
bool strict = true,
20884 const
bool ignore_comments = false)
20894 template<
class IteratorType,
class SAX>
20896 static
bool sax_parse(IteratorType
first, IteratorType last, SAX* sax,
20898 const
bool strict = true,
20899 const
bool ignore_comments = false)
20912 template <
typename SAX>
20915 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
20917 const
bool strict = true,
20918 const
bool ignore_comments = false)
20935 friend
std::istream& operator<<(basic_json& j,
std::istream& i)
20937 return operator>>(i, j);
20947 #endif // JSON_NO_IO 20974 return "discarded";
20993 json_value m_value = {};
20995 #if JSON_DIAGNOSTICS 20996 basic_json* m_parent =
nullptr;
21010 static std::vector<std::uint8_t>
to_cbor(
const basic_json& j)
21012 std::vector<std::uint8_t>
result;
21013 to_cbor(j, result);
21035 std::vector<std::uint8_t>
result;
21036 to_msgpack(j, result);
21057 const bool use_size =
false,
21058 const bool use_type =
false)
21060 std::vector<std::uint8_t>
result;
21061 to_ubjson(j, result, use_size, use_type);
21068 const bool use_size =
false,
const bool use_type =
false)
21076 const bool use_size =
false,
const bool use_type =
false)
21083 static std::vector<std::uint8_t>
to_bson(
const basic_json& j)
21085 std::vector<std::uint8_t>
result;
21086 to_bson(j, result);
21106 template<
typename InputType>
21109 const bool strict =
true,
21110 const bool allow_exceptions =
true,
21122 template<
typename IteratorType>
21125 const bool strict =
true,
21126 const bool allow_exceptions =
true,
21136 template<
typename T>
21139 static basic_json from_cbor(const T*
ptr,
std::
size_t len,
21140 const
bool strict = true,
21141 const
bool allow_exceptions = true,
21144 return from_cbor(ptr, ptr + len,
strict, allow_exceptions, tag_handler);
21150 static basic_json from_cbor(
detail::span_input_adapter&& i,
21151 const
bool strict = true,
21152 const
bool allow_exceptions = true,
21165 template<
typename InputType>
21168 const bool strict =
true,
21169 const bool allow_exceptions =
true)
21180 template<
typename IteratorType>
21183 const bool strict =
true,
21184 const bool allow_exceptions =
true)
21193 template<
typename T>
21196 static basic_json from_msgpack(const T*
ptr,
std::
size_t len,
21197 const
bool strict = true,
21198 const
bool allow_exceptions = true)
21200 return from_msgpack(ptr, ptr + len,
strict, allow_exceptions);
21205 static basic_json from_msgpack(
detail::span_input_adapter&& i,
21206 const
bool strict = true,
21207 const
bool allow_exceptions = true)
21219 template<
typename InputType>
21222 const bool strict =
true,
21223 const bool allow_exceptions =
true)
21234 template<
typename IteratorType>
21237 const bool strict =
true,
21238 const bool allow_exceptions =
true)
21247 template<
typename T>
21250 static basic_json from_ubjson(const T*
ptr,
std::
size_t len,
21251 const
bool strict = true,
21252 const
bool allow_exceptions = true)
21254 return from_ubjson(ptr, ptr + len,
strict, allow_exceptions);
21259 static basic_json from_ubjson(
detail::span_input_adapter&& i,
21260 const
bool strict = true,
21261 const
bool allow_exceptions = true)
21273 template<
typename InputType>
21276 const bool strict =
true,
21277 const bool allow_exceptions =
true)
21288 template<
typename IteratorType>
21291 const bool strict =
true,
21292 const bool allow_exceptions =
true)
21301 template<
typename T>
21304 static basic_json from_bson(const T*
ptr,
std::
size_t len,
21305 const
bool strict = true,
21306 const
bool allow_exceptions = true)
21308 return from_bson(ptr, ptr + len,
strict, allow_exceptions);
21313 static basic_json from_bson(
detail::span_input_adapter&& i,
21314 const
bool strict = true,
21315 const
bool allow_exceptions = true)
21388 basic_json
patch(
const basic_json& json_patch)
const 21391 basic_json
result = *
this;
21394 enum class patch_operations {add,
remove,
replace,
move,
copy, test, invalid};
21400 return patch_operations::add;
21402 if (
op ==
"remove")
21406 if (
op ==
"replace")
21420 return patch_operations::test;
21423 return patch_operations::invalid;
21438 if (top_pointer != ptr)
21440 result.
at(top_pointer);
21444 const auto last_path = ptr.
back();
21446 basic_json& parent = result[
ptr];
21448 switch (parent.m_type)
21454 parent[last_path] = val;
21460 if (last_path ==
"-")
21497 const auto last_path = ptr.
back();
21499 basic_json& parent = result.
at(ptr);
21505 auto it = parent.
find(last_path);
21529 for (
const auto& val : json_patch)
21537 auto it = val.m_value.object->find(member);
21540 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
21567 const auto op =
get_value(
"op",
"op",
true).template get<std::string>();
21568 const auto path =
get_value(op,
"path",
true).template get<std::string>();
21571 switch (get_op(op))
21573 case patch_operations::add:
21575 operation_add(ptr,
get_value(
"add",
"value",
false));
21581 operation_remove(ptr);
21588 result.
at(ptr) =
get_value(
"replace",
"value",
false);
21594 const auto from_path =
get_value(
"move",
"from",
true).template get<std::string>();
21598 basic_json v = result.
at(from_ptr);
21604 operation_remove(from_ptr);
21605 operation_add(ptr, v);
21611 const auto from_path =
get_value(
"copy",
"from",
true).template get<std::string>();
21615 basic_json v = result.
at(from_ptr);
21620 operation_add(ptr, v);
21624 case patch_operations::test:
21626 bool success =
false;
21631 success = (result.
at(ptr) ==
get_value(
"test",
"value",
false));
21647 case patch_operations::invalid:
21663 static basic_json
diff(
const basic_json&
source,
const basic_json& target,
21670 if (source == target)
21675 if (source.
type() != target.
type())
21680 {
"op",
"replace"}, {
"path", path}, {
"value", target}
21685 switch (source.
type())
21691 while (i < source.
size() && i < target.
size())
21694 auto temp_diff = diff(source[i], target[i], path +
"/" + std::to_string(i));
21695 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
21704 while (i < source.
size())
21711 {
"path", path +
"/" + std::to_string(i)}
21717 while (i < target.
size())
21722 {
"path", path +
"/-"},
21723 {
"value", target[i]}
21734 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
21739 if (target.
find(it.key()) != target.
end())
21742 auto temp_diff = diff(it.value(), target[it.key()], path_key);
21743 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
21750 {
"op",
"remove"}, {
"path", path_key}
21756 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
21758 if (source.
find(it.key()) == source.
end())
21764 {
"op",
"add"}, {
"path", path_key},
21765 {
"value", it.value()}
21786 {
"op",
"replace"}, {
"path", path}, {
"value", target}
21814 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
21816 if (it.value().is_null())
21822 operator[](it.key()).merge_patch(it.value());
21828 *
this = apply_patch;
21879 #ifndef JSON_HAS_CPP_20 21885 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
21886 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
21915 #if defined(__clang__) 21916 #pragma clang diagnostic pop 21921 #undef JSON_INTERNAL_CATCH 21925 #undef JSON_PRIVATE_UNLESS_TESTED 21926 #undef JSON_HAS_CPP_11 21927 #undef JSON_HAS_CPP_14 21928 #undef JSON_HAS_CPP_17 21929 #undef JSON_HAS_CPP_20 21930 #undef JSON_HAS_FILESYSTEM 21931 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM 21932 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION 21933 #undef NLOHMANN_BASIC_JSON_TPL 21934 #undef JSON_EXPLICIT 21935 #undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL 21940 #undef JSON_HEDLEY_ALWAYS_INLINE 21941 #undef JSON_HEDLEY_ARM_VERSION 21942 #undef JSON_HEDLEY_ARM_VERSION_CHECK 21943 #undef JSON_HEDLEY_ARRAY_PARAM 21944 #undef JSON_HEDLEY_ASSUME 21945 #undef JSON_HEDLEY_BEGIN_C_DECLS 21946 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE 21947 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN 21948 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE 21949 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE 21950 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION 21951 #undef JSON_HEDLEY_CLANG_HAS_FEATURE 21952 #undef JSON_HEDLEY_CLANG_HAS_WARNING 21953 #undef JSON_HEDLEY_COMPCERT_VERSION 21954 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK 21955 #undef JSON_HEDLEY_CONCAT 21956 #undef JSON_HEDLEY_CONCAT3 21957 #undef JSON_HEDLEY_CONCAT3_EX 21958 #undef JSON_HEDLEY_CONCAT_EX 21959 #undef JSON_HEDLEY_CONST 21960 #undef JSON_HEDLEY_CONSTEXPR 21961 #undef JSON_HEDLEY_CONST_CAST 21962 #undef JSON_HEDLEY_CPP_CAST 21963 #undef JSON_HEDLEY_CRAY_VERSION 21964 #undef JSON_HEDLEY_CRAY_VERSION_CHECK 21965 #undef JSON_HEDLEY_C_DECL 21966 #undef JSON_HEDLEY_DEPRECATED 21967 #undef JSON_HEDLEY_DEPRECATED_FOR 21968 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 21969 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ 21970 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 21971 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 21972 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 21973 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 21974 #undef JSON_HEDLEY_DIAGNOSTIC_POP 21975 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH 21976 #undef JSON_HEDLEY_DMC_VERSION 21977 #undef JSON_HEDLEY_DMC_VERSION_CHECK 21978 #undef JSON_HEDLEY_EMPTY_BASES 21979 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION 21980 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK 21981 #undef JSON_HEDLEY_END_C_DECLS 21982 #undef JSON_HEDLEY_FLAGS 21983 #undef JSON_HEDLEY_FLAGS_CAST 21984 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE 21985 #undef JSON_HEDLEY_GCC_HAS_BUILTIN 21986 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE 21987 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE 21988 #undef JSON_HEDLEY_GCC_HAS_EXTENSION 21989 #undef JSON_HEDLEY_GCC_HAS_FEATURE 21990 #undef JSON_HEDLEY_GCC_HAS_WARNING 21991 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK 21992 #undef JSON_HEDLEY_GCC_VERSION 21993 #undef JSON_HEDLEY_GCC_VERSION_CHECK 21994 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE 21995 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN 21996 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE 21997 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE 21998 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION 21999 #undef JSON_HEDLEY_GNUC_HAS_FEATURE 22000 #undef JSON_HEDLEY_GNUC_HAS_WARNING 22001 #undef JSON_HEDLEY_GNUC_VERSION 22002 #undef JSON_HEDLEY_GNUC_VERSION_CHECK 22003 #undef JSON_HEDLEY_HAS_ATTRIBUTE 22004 #undef JSON_HEDLEY_HAS_BUILTIN 22005 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE 22006 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS 22007 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE 22008 #undef JSON_HEDLEY_HAS_EXTENSION 22009 #undef JSON_HEDLEY_HAS_FEATURE 22010 #undef JSON_HEDLEY_HAS_WARNING 22011 #undef JSON_HEDLEY_IAR_VERSION 22012 #undef JSON_HEDLEY_IAR_VERSION_CHECK 22013 #undef JSON_HEDLEY_IBM_VERSION 22014 #undef JSON_HEDLEY_IBM_VERSION_CHECK 22015 #undef JSON_HEDLEY_IMPORT 22016 #undef JSON_HEDLEY_INLINE 22017 #undef JSON_HEDLEY_INTEL_CL_VERSION 22018 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK 22019 #undef JSON_HEDLEY_INTEL_VERSION 22020 #undef JSON_HEDLEY_INTEL_VERSION_CHECK 22021 #undef JSON_HEDLEY_IS_CONSTANT 22022 #undef JSON_HEDLEY_IS_CONSTEXPR_ 22023 #undef JSON_HEDLEY_LIKELY 22024 #undef JSON_HEDLEY_MALLOC 22025 #undef JSON_HEDLEY_MCST_LCC_VERSION 22026 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK 22027 #undef JSON_HEDLEY_MESSAGE 22028 #undef JSON_HEDLEY_MSVC_VERSION 22029 #undef JSON_HEDLEY_MSVC_VERSION_CHECK 22030 #undef JSON_HEDLEY_NEVER_INLINE 22031 #undef JSON_HEDLEY_NON_NULL 22032 #undef JSON_HEDLEY_NO_ESCAPE 22033 #undef JSON_HEDLEY_NO_RETURN 22034 #undef JSON_HEDLEY_NO_THROW 22035 #undef JSON_HEDLEY_NULL 22036 #undef JSON_HEDLEY_PELLES_VERSION 22037 #undef JSON_HEDLEY_PELLES_VERSION_CHECK 22038 #undef JSON_HEDLEY_PGI_VERSION 22039 #undef JSON_HEDLEY_PGI_VERSION_CHECK 22040 #undef JSON_HEDLEY_PREDICT 22041 #undef JSON_HEDLEY_PRINTF_FORMAT 22042 #undef JSON_HEDLEY_PRIVATE 22043 #undef JSON_HEDLEY_PUBLIC 22044 #undef JSON_HEDLEY_PURE 22045 #undef JSON_HEDLEY_REINTERPRET_CAST 22046 #undef JSON_HEDLEY_REQUIRE 22047 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR 22048 #undef JSON_HEDLEY_REQUIRE_MSG 22049 #undef JSON_HEDLEY_RESTRICT 22050 #undef JSON_HEDLEY_RETURNS_NON_NULL 22051 #undef JSON_HEDLEY_SENTINEL 22052 #undef JSON_HEDLEY_STATIC_ASSERT 22053 #undef JSON_HEDLEY_STATIC_CAST 22054 #undef JSON_HEDLEY_STRINGIFY 22055 #undef JSON_HEDLEY_STRINGIFY_EX 22056 #undef JSON_HEDLEY_SUNPRO_VERSION 22057 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK 22058 #undef JSON_HEDLEY_TINYC_VERSION 22059 #undef JSON_HEDLEY_TINYC_VERSION_CHECK 22060 #undef JSON_HEDLEY_TI_ARMCL_VERSION 22061 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK 22062 #undef JSON_HEDLEY_TI_CL2000_VERSION 22063 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK 22064 #undef JSON_HEDLEY_TI_CL430_VERSION 22065 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK 22066 #undef JSON_HEDLEY_TI_CL6X_VERSION 22067 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK 22068 #undef JSON_HEDLEY_TI_CL7X_VERSION 22069 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK 22070 #undef JSON_HEDLEY_TI_CLPRU_VERSION 22071 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK 22072 #undef JSON_HEDLEY_TI_VERSION 22073 #undef JSON_HEDLEY_TI_VERSION_CHECK 22074 #undef JSON_HEDLEY_UNAVAILABLE 22075 #undef JSON_HEDLEY_UNLIKELY 22076 #undef JSON_HEDLEY_UNPREDICTABLE 22077 #undef JSON_HEDLEY_UNREACHABLE 22078 #undef JSON_HEDLEY_UNREACHABLE_RETURN 22079 #undef JSON_HEDLEY_VERSION 22080 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR 22081 #undef JSON_HEDLEY_VERSION_DECODE_MINOR 22082 #undef JSON_HEDLEY_VERSION_DECODE_REVISION 22083 #undef JSON_HEDLEY_VERSION_ENCODE 22084 #undef JSON_HEDLEY_WARNING 22085 #undef JSON_HEDLEY_WARN_UNUSED_RESULT 22086 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG 22087 #undef JSON_HEDLEY_FALL_THROUGH 22091 #endif // INCLUDE_NLOHMANN_JSON_HPP_ value_type moved_or_copied() const
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix)
static constexpr CharType get_ubjson_float_prefix(float)
constexpr bool operator<=(const optional< T > &lhs, const optional< U > &rhs)
relop
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
json_pointer & operator/=(std::string token)
append an unescaped reference token at the end of this JSON pointer
size_type count(KeyT &&key) const
returns the number of occurrences of a key in a JSON object
friend other_iter_impl
allow basic_json to access private members
bool contains(const BasicJsonType *ptr) const
bool parse_error(std::size_t, const std::string &, const detail::exception &)
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
std::random_access_iterator_tag iterator_category
typename utility_internal::Gen< T, N >::type make_integer_sequence
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
const string_type & key() const
return key of the iterator
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
number_unsigned_t number_unsigned
number (unsigned integer)
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
typename BasicJsonType::number_float_t number_float_t
typename T::pointer pointer_t
decltype(auto) get_value(std::false_type, T &&t)
const int id
the id of the exception
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
comparison: equal
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
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
iter_impl operator+(difference_type i) const
add to iterator
parse_error(int id_, std::size_t byte_, const char *what_arg)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
static constexpr CharType get_cbor_float_prefix(float)
tie_t< std::remove_reference_t< Tn >... > tie(Tn &&... argn)
iterator begin() noexcept
returns an iterator to the first element
IteratorType::reference value() const
return value of the iterator
array_t * array
array (stored with pointer to save storage)
typename BasicJsonType::binary_t binary_t
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
detected_t< result_of_end, t_ref > sentinel
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
error_handler_t
how to treat decoding errors
typename std::char_traits< char_type >::int_type char_int_type
iteration_proxy_value(IteratorType it) noexcept
typename BasicJsonType::number_float_t number_float_t
static std::size_t calc_bson_string_size(const string_t &value)
#define JSON_CATCH(exception)
size_type size() const noexcept
returns the number of elements
void insert(InputIt first, InputIt last)
void unget()
unget current character (read it again on next get)
reference operator[](difference_type n) const
access to successor
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
stack_iterator< proxy_t, is_const > operator+(typename stack_iterator< proxy_t, is_const >::difference_type n, const stack_iterator< proxy_t, is_const > &r)
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
typename BasicJsonType::string_t string_t
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
#define JSON_HEDLEY_DIAGNOSTIC_POP
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
iter_impl & operator+=(difference_type i)
add to iterator
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
bool operator>(const iter_impl &other) const
comparison: greater than
value_t
the JSON type enumeration
binary_reader(InputAdapterType &&adapter) noexcept
create a binary reader
primitive_iterator_t & operator+=(difference_type n) noexcept
iter_impl operator-(difference_type i) const
subtract from iterator
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
basic_object< reference > object
json_reverse_iterator const operator--(int)
post-decrement (it–)
void push_back(basic_json &&val)
add an object to an array
void remove(lua_State *L_, int rawindex, int count)
static BasicJsonType::size_type array_index(const std::string &s)
bool get_msgpack_object(const std::size_t len)
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
void write_bson_object(const typename BasicJsonType::object_t &value)
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
reference value() const
return the value of an iterator
iterator end() noexcept
returns an iterator to one past the last element
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t &>(), v)))
bool contains(KeyT &&key) const
check the existence of an element in a JSON object
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
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
void push_back(const typename object_t::value_type &val)
add an object to an object
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
bool start_array(std::size_t len)
static void unescape(std::string &s)
string unescaping as described in RFC 6901 (Sect. 4)
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
typename InputAdapterType::char_type char_type
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
typename BasicJsonType::string_t string_t
json_value(const string_t &value)
constructor for strings
size_type count(const Key &key) const
primitive_iterator_t & operator++() noexcept
void push_back(const basic_json &val)
add an object to an array
const char * what() const noexcept override
returns the explanatory string
throw a parse_error exception in case of a tag
bool number_integer(number_integer_t val)
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
array (ordered collection of values)
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
span_CONFIG_SIZE_TYPE size_t
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
json_pointer(const std::string &s="")
create JSON pointer
InputAdapterType ia
input adapter
primitive_iterator_t operator+(difference_type n) noexcept
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
typename std::add_lvalue_reference< T >::type t_ref
std::less< StringType > object_comparator_t
object key comparator type
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
bool parse_msgpack_internal()
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t &>().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
iter_impl & operator++()
pre-increment (++it)
reference emplace_back(Args &&... args)
add an object to an array
output_adapter(std::vector< CharType, AllocatorType > &vec)
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
static constexpr CharType to_char_type(InputCharType x) noexcept
reference back()
access the last element
a template for a reverse iterator class
const char indent_char
the indentation character
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
std::runtime_error m
an exception object as storage for error messages
a class to store JSON values
void init(const M_string &remappings)
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
static constexpr std::size_t size() noexcept
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
void to_json(BasicJsonType &j, const T &b)
typename BasicJsonType::binary_t binary_t
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
std::string to_string() const
return a string representation of the JSON pointer
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
bool string(string_t &val)
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
std::vector< std::pair< const Key, T >, Allocator > Container
typename BasicJsonType::string_t string_t
default JSONSerializer template argument
iter_impl const operator--(int)
post-decrement (it–)
std::ptrdiff_t difference_type
json_value(const array_t &value)
constructor for arrays
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
void write_compact_float(const number_float_t n, detail::input_format_t format)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
json_value(string_t &&value)
constructor for rvalue strings
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.
const_iterator cend() const noexcept
returns an iterator to one past the last element
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
check if the input is valid JSON
void swap(binary_t &other)
exchanges the values
bool operator<(const iter_impl &other) const
comparison: smaller
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())
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
std::string get_token_string() const
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
bool start_array(std::size_t len)
static std::string position_string(const position_t &pos)
bool start_object(std::size_t=static_cast< std::size_t >(-1))
#define JSON_HEDLEY_WARN_UNUSED_RESULT
number value (signed integer)
bool string(string_t &val)
const object_t::key_type & key() const
return the key of an object iterator
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)
#define JSON_INTERNAL_CATCH(exception)
void reset() noexcept
reset token_buffer; current character is beginning of token
Target reinterpret_bits(const Source source)
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
NumberIntegerType number_integer_t
a type for a number (integer)
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
typename BasicJsonType::number_unsigned_t number_unsigned_t
output_adapter(StringType &s)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
json_reverse_iterator & operator+=(difference_type i)
add to iterator
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
static constexpr CharType get_ubjson_float_prefix(double)
json_ref(Args &&... args)
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
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
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
iter_impl & operator-=(difference_type i)
subtract from iterator
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t &>().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
void push_back(std::string &&token)
append an unescaped token at the end of the reference pointer
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
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
void set_end() noexcept
set the iterator past the last value
bool start_object(std::size_t len)
the parser read ] and finished processing a JSON array
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
typename InputAdapterType::char_type char_type
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
std::size_t hash(const BasicJsonType &j)
hash a JSON value
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
std::size_t chars_read_current_line
the number of characters read in the current line
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
std::bidirectional_iterator_tag iterator_category
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
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
output_adapter(std::basic_ostream< CharType > &s)
const_iterator begin() const noexcept
returns an iterator to the first element
void write_character(CharType c) override
cached_power get_cached_power_for_binary_exponent(int e)
typename Container::const_iterator const_iterator
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::binary_t::value_type binary_char_t
static std::vector< std::string > split(const std::string &reference_string)
split the string input to reference tokens
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
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)))
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
void write_bson(const BasicJsonType &j)
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
json_value(const binary_t &value)
constructor for binary arrays (internal type)
void set_end() noexcept
set iterator to a defined past the end
static out_of_range create(int id_, const std::string &what_arg, const BasicJsonType &context)
typename BasicJsonType::number_integer_t number_integer_t
friend bool operator==(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for equality
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
serialization to CBOR and MessagePack values
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
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
output adapter for byte vectors
pointer operator->() const
dereference the iterator
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)
std::string get_token_string() const
const std::size_t byte
byte index of the parse error
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool get_ubjson_value(const char_int_type prefix)
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
void to_json(BasicJsonType &j, T b) noexcept
ptrdiff_t difference_type
integer_sequence< size_t, Ints... > index_sequence
byte_container_with_subtype() noexcept(noexcept(container_type()))
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
const_iterator find(const Key &key) const
constexpr bool is_boolean() const noexcept
return whether value is a boolean
throw a type_error exception in case of invalid UTF-8
bool accept(const bool strict=true)
public accept interface
bool skip_bom()
skip the UTF-8 byte order mark
const_reference front() const
access the first element
bool number_float(number_float_t val, const string_t &)
exception indicating access out of the defined range
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
typename BasicJsonType::number_unsigned_t number_unsigned_t
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
primitive_iterator_t & operator--() noexcept
binary array (ordered collection of bytes)
void set_begin() noexcept
set iterator to a defined beginning
decltype(std::declval< T >().template get< U >()) get_template_function
void write_msgpack(const BasicJsonType &j)
typename std::iterator_traits< T >::value_type value_type
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
IteratorType erase(IteratorType pos)
remove element given an iterator
void swap(typename binary_t::container_type &other)
exchanges the values
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
typename BasicJsonType::object_t object_t
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
typename BasicJsonType::exception exception_t
primitive_iterator_t const operator++(int) noexcept
void type_error(lua_State *L, int expected, int actual) noexcept(false)
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
ReferenceType get_ref() const
get a reference value (implicit)
typename T::difference_type difference_type_t
typename BasicJsonType::parser_callback_t parser_callback_t
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
iter_impl const operator++(int)
post-increment (it++)
void write_character(CharType c) override
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
typename BasicJsonType::number_float_t number_float_t
decltype(std::declval< T & >().end_object()) end_object_function_t
basic_json(const basic_json &other)
copy constructor
static void reverse(lua_State *L, StkId from, StkId to)
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
typename It::value_type value_type
SAX implementation to create a JSON value from SAX events.
typename detector< nonesuch, void, Op, Args... >::type detected_t
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
token_type scan_number()
scan a number literal
token_type
token types for the parser
string_t value(const typename object_t::key_type &key, const char *default_value) const
access specified object element with default value
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
constexpr bool is_binary() const noexcept
return whether value is a binary array
NumberFloatType number_float_t
a type for a number (floating-point)
auto base_iterator(std::back_insert_iterator< Container > &it, checked_ptr< typename Container::value_type >) -> std::back_insert_iterator< Container >
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename Container::iterator iterator
void erase(const size_type idx)
remove element from a JSON array given an index
bool get_cbor_string(string_t &result)
reads a CBOR string
exception indicating a parse error
#define JSON_THROW(exception)
difference_type operator-(const iter_impl &other) const
return difference
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
json_reverse_iterator const operator++(int)
post-increment (it++)
bool number_unsigned(number_unsigned_t val)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
decltype(std::declval< T & >().end_array()) end_array_function_t
json_value(boolean_t v) noexcept
constructor for booleans
integral_constant< bool, false > false_type
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
const_iterator cbegin() const noexcept
returns a const iterator to the first element
store tags as binary type
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
std::ptrdiff_t difference_type
typename Base::reference reference
the reference type for the pointed-to element
#define JSON_HEDLEY_RETURNS_NON_NULL
primitive_iterator_t primitive_iterator
generic iterator for all other types
abstract output adapter interface
const_reference back() const
access the last element
general exception of the basic_json class
IteratorType::reference container
the container to iterate
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
std::ostream & operator<<(std::ostream &out, const Interval< Scalar, Value > &i)
OutputIterator copy(const RangeT &range, OutputIterator out)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
bool operator!=(const byte_container_with_subtype &rhs) const
BinaryType container_type
boundaries compute_boundaries(FloatType value)
constexpr bool is_object() const noexcept
return whether value is an object
json_value(value_t t)
constructor for empty values of a given type
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
typename lexer_t::token_type token_type
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
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 ...
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_null(const string_t &name)
Writes a BSON element with key name and null value.
void clear() noexcept
clears the contents
bool get_msgpack_array(const std::size_t len)
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
const error_handler_t error_handler
error_handler how to react on decoding errors
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
std::string exception_message(const token_type expected, const std::string &context)
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)
bool number_integer(number_integer_t val)
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
an internal type for a backed binary type
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
typename BasicJsonType::number_float_t number_float_t
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
void push_back(const std::string &token)
append an unescaped token at the end of the reference pointer
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 std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
constexpr subtype_type subtype() const noexcept
return the binary subtype
exception indicating errors with iterators
void swap(array_t &other)
exchanges the values
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
size_type max_size() const noexcept
returns the maximum possible number of elements
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
the parser read [ and started to process a JSON array
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
reference operator+=(basic_json &&val)
add an object to an array
typename It::pointer pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
namespace for Niels Lohmann
std::vector< CharType, AllocatorType > & v
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
bool number_integer(number_integer_t)
bool number_float(number_float_t val, const string_t &)
token_type scan_string()
scan a string literal
static type_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
#define JSON_HEDLEY_CONST
json_ref(std::initializer_list< json_ref > init)
integral_constant< bool, true > true_type
bool parse_error(std::size_t, const std::string &, const Exception &ex)
typename BasicJsonType::string_t string_t
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
constexpr difference_type get_value() const noexcept
json_reverse_iterator operator+(difference_type i) const
add to iterator
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_integer_t number_integer_t
bool start_object(std::size_t len)
detected_t< result_of_begin, t_ref > iterator
object (unordered set of name/value pairs)
void write_number(const NumberType n)
constexpr bool is_errored() const
token_type get_token()
get next token from lexer
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
static std::string diagnostics(const BasicJsonType &leaf_element)
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::number_float_t number_float_t
reference operator*() const
return a reference to the value pointed to by the iterator
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
iterator find(KeyT &&key)
find an element in a JSON object
number_float_t number_float
number (floating-point)
typename std::enable_if< B, T >::type enable_if_t
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
ordered_map(const Allocator &alloc=Allocator())
ValueType & get_to(ValueType &v) const
const_reference at(size_type idx) const
access specified array element with bounds checking
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)
basic_json(const value_t v)
create an empty value with a given type
#define NLOHMANN_BASIC_JSON_TPL
const T & operator[](const Key &key) const
std::string type_name(lua_State *L, type t)
friend bool operator!=(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for inequality
exception indicating executing a member function with a wrong type
std::size_t combine(std::size_t seed, std::size_t h) noexcept
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
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
#define NLOHMANN_JSON_VERSION_PATCH
const_reference operator[](size_type idx) const
access specified array element
static void flatten(const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
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.
typename BasicJsonType::number_integer_t number_integer_t
static constexpr CharType get_cbor_float_prefix(double)
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
the parser read } and finished processing a JSON object
constexpr bool is_primitive() const noexcept
return whether type is primitive
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
bool binary(binary_t &val)
typename BasicJsonType::number_float_t number_float_t
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
typename BasicJsonType::parse_event_t parse_event_t
basic_reference< false > reference
size_type erase(const Key &key)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
value_type_t< iterator_traits< iterator_t< T > >> range_value_t
typename BasicJsonType::template json_serializer< T, void > serializer
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
cbor_tag_handler_t
how to treat CBOR tags
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t &>(), v)))
get a value (explicit)
T conditional_static_cast(U value)
typename BasicJsonType::number_unsigned_t number_unsigned_t
make_integer_sequence< size_t, N > make_index_sequence
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
#define JSON_HEDLEY_NON_NULL(...)
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
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
typename T::value_type value_type_t
constexpr bool is_errored() const
ring_iterator< RS, C > operator-(ring_iterator< RS, C > it, int i) nsrs_noexcept
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)
char_int_type get_ignore_noop()
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
typename BasicJsonType::binary_t binary_t
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)
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
bool operator==(const byte_container_with_subtype &rhs) const
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
decltype(std::declval< T & >().null()) null_function_t
std::ptrdiff_t difference_type
bool empty() const noexcept
return whether pointer points to the root document
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
comparison: equal
typename BasicJsonType::number_float_t number_float_t
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
reference set_parent(reference j, std::size_t old_capacity=static_cast< std::size_t >(-1))
IteratorType anchor
the iterator
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
basic_json flatten() const
return flattened JSON value
void parse(const bool strict, BasicJsonType &result)
public parser interface
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
bool get_number(const input_format_t format, NumberType &result)
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
bool empty() const noexcept
checks whether the container is empty.
typename BasicJsonType::exception exception_t
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
BasicJsonType & root
the parsed JSON value
typename BasicJsonType::binary_t binary_t
iteration_proxy_value< IteratorType > begin() noexcept
return iterator begin (needed for range-based for)
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.
typename It::difference_type difference_type
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
reference at(size_type idx)
access specified array element with bounds checking
void add(char_int_type c)
add a character to token_buffer
reference front()
access the first element
typename T::key_type key_type_t
output adapter for basic_string
typename std::char_traits< char_type >::int_type char_int_type
iterator insert_iterator(const_iterator pos, Args &&... args)
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
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
static int codepoint(lua_State *L)
const T & move(const T &v)
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
#define JSON_HEDLEY_LIKELY(expr)
iterator erase(iterator pos)
StringType string_t
a type for a string
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
typename BasicJsonType::number_float_t number_float_t
bool number_unsigned(number_unsigned_t)
#define JSON_PRIVATE_UNLESS_TESTED
std::pair< iterator, bool > insert(const value_type &value)
iteration_proxy_value & operator*()
dereference operator (needed for range-based for)
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
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static BasicJsonType unflatten(const BasicJsonType &value)
typename BasicJsonType::string_t string_t
output adapter for output streams
nlohmann::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
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.
string_t * string
string (stored with pointer to save storage)
int get_codepoint()
get codepoint from 4 hex characters following \u
#define NLOHMANN_JSON_VERSION_MINOR
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
typename BasicJsonType::object_t object_t
std::pair< iterator, bool > insert(value_type &&value)
BooleanType boolean_t
a type for a boolean
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
typename It::iterator_category iterator_category
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
iterator find(const Key &key)
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
value_type const & operator*() const
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
comparison: less than
const T & first(const T &value, const Tail &...)
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, const BasicJsonType &context)
json_ref(value_type &&value)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
exception indicating other library errors
bool operator==(QwtEventPattern::MousePattern b1, QwtEventPattern::MousePattern b2)
Compare operator.
typename BasicJsonType::number_integer_t number_integer_t
bool get_ubjson_size_value(std::size_t &result)
std::input_iterator_tag iterator_category
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
typename BasicJsonType::number_float_t number_float_t
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
static std::string name(const std::string &ename, int id_)
constexpr bool is_end() const noexcept
return whether the iterator is at end
typename BasicJsonType::string_t string_t
remove_cvref_t< decltype(*detail::range_begin(std::declval< Range >()))> value_type
reference operator+=(const basic_json &val)
add an object to an array
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
static invalid_iterator create(int id_, const std::string &what_arg, const BasicJsonType &context)
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
deserialization of CBOR, MessagePack, and UBJSON values
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
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
AllocatorType< basic_json > allocator_type
the allocator type
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
bool parse_error(std::size_t, const std::string &, const Exception &ex)
bool scan_comment()
scan a comment
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)>>, index_sequence< Idx... >)
std::size_t lines_read
the number of lines read
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
std::string escape(std::string s)
string escaping as described in RFC 6901 (Sect. 4)
static bool little_endianness(int num=1) noexcept
determine system byte order
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
typename BasicJsonType::number_float_t number_float_t
static std::size_t calc_bson_integer_size(const std::int64_t value)
std::uint64_t subtype_type
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)
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
std::basic_ostream< CharType > & stream
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
InputAdapterType ia
input adapter
typename BasicJsonType::binary_t binary_t
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
reference operator+=(initializer_list_t init)
add an object to an object
static constexpr CharType get_msgpack_float_prefix(float)
bool get_ubjson_high_precision_number()
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
constexpr bool is_number() const noexcept
return whether value is a number
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
void write_character(CharType c) override
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
decltype(T::from_json(std::declval< Args >()...)) from_json_function
static CharType to_char_type(std::uint8_t x) noexcept
bool operator<=(const iter_impl &other) const
comparison: less than or equal
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
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 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.
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
typename BasicJsonType::object_t object_t
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
iter_impl & operator--()
pre-decrement (–it)
replace invalid UTF-8 sequences with U+FFFD
typename make_void< Ts... >::type void_t
const T & at(const Key &key) const
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than or equal
constexpr bool is_array() const noexcept
return whether value is an array
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
static constexpr CharType to_char_type(std::uint8_t x) noexcept
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename Container::size_type size_type
typename BasicJsonType::string_t string_t
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
the parser finished reading a JSON value
typename BasicJsonType::template json_serializer< T, void > serializer
ordered_map(It first, It last, const Allocator &alloc=Allocator())
input_format_t
the supported input formats
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
typename BasicJsonType::number_integer_t number_integer_t
iteration_proxy_value< IteratorType > end() noexcept
return iterator end (needed for range-based for)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
constexpr bool is_null() const noexcept
return whether value is null
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
constexpr number_integer_t get_number_integer() const noexcept
return integer value
basic_json(const JsonRef &ref)
typename BasicJsonType::number_integer_t number_integer_t
bool get_msgpack_string(string_t &result)
reads a MessagePack string
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool start_array(std::size_t=static_cast< std::size_t >(-1))
typename BasicJsonType::string_t string_t
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
int construct(lua_State *L)
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 >>, priority_tag< 0 >)
primitive_iterator_t const operator--(int) noexcept
typename detected_or< Default, Op, Args... >::type detected_or_t
basic_json unflatten() const
unflatten a previously flattened JSON value
void swap(string_t &other)
exchanges the values
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
T & operator[](const Key &key)
BasicJsonType & root
the parsed JSON value
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
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true)
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
constexpr position_t get_position() const noexcept
return position of last read token
typename std::enable_if< B, T >::type enable_if_t
JSON Pointer defines a string syntax for identifying a specific value within a JSON document...
void swap(object_t &other)
exchanges the values
typename Container::value_type value_type
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
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)
reference operator[](difference_type n) const
access to successor
ordered_map(std::initializer_list< T > init, const Allocator &alloc=Allocator())
struct to capture the start position of the current token
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename It::reference reference
~basic_json() noexcept
destructor
std::ptrdiff_t difference_type
a type to represent differences between iterators
bool parse_ubjson_internal(const bool get_char=true)
number value (unsigned integer)
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
comparison: less than
number_integer_t number_integer
number (integer)
static bool accept(InputType &&i, const bool ignore_comments=false)
check if the input is valid JSON
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
span_constexpr std::size_t size(span< T, Extent > const &spn)
reference operator+=(const typename object_t::value_type &val)
add an object to an object
BasicJsonType & get_checked(BasicJsonType *ptr) const
static other_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
typename BasicJsonType::array_t array_t
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
CharType ubjson_prefix(const BasicJsonType &j) const noexcept
determine the type prefix of container values
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
const binary_t & get_binary() const
get a binary value
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
constexpr bool is_structured() const noexcept
return whether type is structured
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
typename T::iterator_category iterator_category_t
the parser read a key of a value in an object
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
typename BasicJsonType::number_integer_t number_integer_t
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
ReferenceType get_ref()
get a reference value (implicit)
detail namespace with internal helper functions
json_value m_value
the value of the current element
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
const std::string & back() const
return last reference token
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 allocator_type get_allocator()
returns the allocator associated with the container
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
decltype(T::to_json(std::declval< Args >()...)) to_json_function
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
comparison: not equal
typename BasicJsonType::number_integer_t number_integer_t
JSONSerializer< T, SFINAE > json_serializer
make_index_sequence< sizeof...(Ts)> index_sequence_for
void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value)
a minimal map-like container that preserves insertion order
json_value(array_t &&value)
constructor for rvalue arrays
typename T::reference reference_t
void push_back(initializer_list_t init)
add an object to an object
reference value() const
return the value of an iterator
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
friend json_pointer operator/(const json_pointer &lhs, std::string token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer ...
proxy class for the items() function
json_reverse_iterator & operator--()
pre-decrement (–it)
typename BasicJsonType::binary_t binary_t
const_iterator find(KeyT &&key) const
find an element in a JSON object
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 ...
bool number_unsigned(number_unsigned_t val)
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
comparison: less than or equal
binary_t & get_binary()
get a binary 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
typename BasicJsonType::number_float_t number_float_t
json_value(const object_t &value)
constructor for objects
string_t indent_string
the indentation string
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin)
std::size_t size_type
a type to represent container sizes
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a pair of character iterators
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
reference operator[](size_type idx)
access specified array element
iterator erase(iterator first, iterator last)
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
bool binary(binary_t &val)
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
number value (floating-point)
typename BasicJsonType::number_unsigned_t number_unsigned_t
constexpr diyfp(std::uint64_t f_, int e_) noexcept
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
typename BasicJsonType::number_integer_t number_integer_t
std::vector< std::string > reference_tokens
the reference tokens
basic_json(basic_json &&other) noexcept
move constructor
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
constexpr bool is_discarded() const noexcept
return whether value is discarded
typename BasicJsonType::number_integer_t number_integer_t
void write_cbor(const BasicJsonType &j)
ObjectType< StringType, basic_json, object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
typename BasicJsonType::string_t string_t
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
reference operator[](const typename object_t::key_type &key)
access specified object element
the parser read { and started to process a JSON object
std::size_t chars_read_total
the total number of characters read
typename lexer_base< BasicJsonType >::token_type token_type
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
#define JSON_HEDLEY_UNLIKELY(expr)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
std::numeric_limits< RealIntegerType > RealLimits
const_iterator end() const noexcept
returns an iterator to one past the last element
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
void replace_substring(std::string &s, const std::string &f, const std::string &t)
replace all occurrences of a substring by another string
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
binary_t * binary
binary (stored with pointer to save storage)
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
json_ref(const value_type &value)
json_value(object_t &&value)
constructor for rvalue objects
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.
json_reverse_iterator & operator++()
pre-increment (++it)
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than
value_type const * operator->() const
void int_to_string(string_type &target, std::size_t value)
output_string_adapter(StringType &s) noexcept
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result)
determine the type and size for a container
primitive_iterator_t & operator-=(difference_type n) noexcept
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
static constexpr CharType get_msgpack_float_prefix(double)
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
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).
void clear_subtype() noexcept
clears the binary subtype
typename BasicJsonType::string_t string_t
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
json_pointer parent_pointer() const
returns the parent of this JSON pointer
discarded by the parser callback function
void pop_back()
remove last reference token
#define NLOHMANN_JSON_VERSION_MAJOR
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
difference_type operator-(const json_reverse_iterator &other) const
return difference
constexpr bool is_string() const noexcept
return whether value is a string
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
typename T::mapped_type mapped_type_t
bool number_float(number_float_t, const string_t &)
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
typename BasicJsonType::binary_t binary_t
constexpr bool has_subtype() const noexcept
return whether the value has a subtype