30 #ifndef INCLUDE_NLOHMANN_JSON_HPP_ 31 #define INCLUDE_NLOHMANN_JSON_HPP_ 33 #define NLOHMANN_JSON_VERSION_MAJOR 3 34 #define NLOHMANN_JSON_VERSION_MINOR 9 35 #define NLOHMANN_JSON_VERSION_PATCH 1 40 #include <initializer_list> 52 #include <type_traits> 60 #include <forward_list> 65 #include <type_traits> 66 #include <unordered_map> 147 static constexpr std::array<std::uint8_t, 9> order = {{
154 const auto l_index =
static_cast<std::size_t
>(lhs);
155 const auto r_index =
static_cast<std::size_t
>(rhs);
156 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
184 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) 185 #if defined(JSON_HEDLEY_VERSION) 186 #undef JSON_HEDLEY_VERSION 188 #define JSON_HEDLEY_VERSION 15 190 #if defined(JSON_HEDLEY_STRINGIFY_EX) 191 #undef JSON_HEDLEY_STRINGIFY_EX 193 #define JSON_HEDLEY_STRINGIFY_EX(x) #x 195 #if defined(JSON_HEDLEY_STRINGIFY) 196 #undef JSON_HEDLEY_STRINGIFY 198 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) 200 #if defined(JSON_HEDLEY_CONCAT_EX) 201 #undef JSON_HEDLEY_CONCAT_EX 203 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b 205 #if defined(JSON_HEDLEY_CONCAT) 206 #undef JSON_HEDLEY_CONCAT 208 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) 210 #if defined(JSON_HEDLEY_CONCAT3_EX) 211 #undef JSON_HEDLEY_CONCAT3_EX 213 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c 215 #if defined(JSON_HEDLEY_CONCAT3) 216 #undef JSON_HEDLEY_CONCAT3 218 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) 220 #if defined(JSON_HEDLEY_VERSION_ENCODE) 221 #undef JSON_HEDLEY_VERSION_ENCODE 223 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) 225 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) 226 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR 228 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) 230 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) 231 #undef JSON_HEDLEY_VERSION_DECODE_MINOR 233 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) 235 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) 236 #undef JSON_HEDLEY_VERSION_DECODE_REVISION 238 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) 240 #if defined(JSON_HEDLEY_GNUC_VERSION) 241 #undef JSON_HEDLEY_GNUC_VERSION 243 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) 244 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) 245 #elif defined(__GNUC__) 246 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) 249 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) 250 #undef JSON_HEDLEY_GNUC_VERSION_CHECK 252 #if defined(JSON_HEDLEY_GNUC_VERSION) 253 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 255 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) 258 #if defined(JSON_HEDLEY_MSVC_VERSION) 259 #undef JSON_HEDLEY_MSVC_VERSION 261 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) 262 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) 263 #elif defined(_MSC_FULL_VER) && !defined(__ICL) 264 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) 265 #elif defined(_MSC_VER) && !defined(__ICL) 266 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) 269 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) 270 #undef JSON_HEDLEY_MSVC_VERSION_CHECK 272 #if !defined(JSON_HEDLEY_MSVC_VERSION) 273 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) 274 #elif defined(_MSC_VER) && (_MSC_VER >= 1400) 275 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) 276 #elif defined(_MSC_VER) && (_MSC_VER >= 1200) 277 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) 279 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) 282 #if defined(JSON_HEDLEY_INTEL_VERSION) 283 #undef JSON_HEDLEY_INTEL_VERSION 285 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) 286 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) 287 #elif defined(__INTEL_COMPILER) && !defined(__ICL) 288 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) 291 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) 292 #undef JSON_HEDLEY_INTEL_VERSION_CHECK 294 #if defined(JSON_HEDLEY_INTEL_VERSION) 295 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 297 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) 300 #if defined(JSON_HEDLEY_INTEL_CL_VERSION) 301 #undef JSON_HEDLEY_INTEL_CL_VERSION 303 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) 304 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) 307 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) 308 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK 310 #if defined(JSON_HEDLEY_INTEL_CL_VERSION) 311 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 313 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) 316 #if defined(JSON_HEDLEY_PGI_VERSION) 317 #undef JSON_HEDLEY_PGI_VERSION 319 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) 320 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) 323 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK) 324 #undef JSON_HEDLEY_PGI_VERSION_CHECK 326 #if defined(JSON_HEDLEY_PGI_VERSION) 327 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 329 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) 332 #if defined(JSON_HEDLEY_SUNPRO_VERSION) 333 #undef JSON_HEDLEY_SUNPRO_VERSION 335 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) 336 #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) 337 #elif defined(__SUNPRO_C) 338 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) 339 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) 340 #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) 341 #elif defined(__SUNPRO_CC) 342 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) 345 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) 346 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK 348 #if defined(JSON_HEDLEY_SUNPRO_VERSION) 349 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 351 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) 354 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) 355 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION 357 #if defined(__EMSCRIPTEN__) 358 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) 361 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) 362 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK 364 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) 365 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 367 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) 370 #if defined(JSON_HEDLEY_ARM_VERSION) 371 #undef JSON_HEDLEY_ARM_VERSION 373 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) 374 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) 375 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) 376 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) 379 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK) 380 #undef JSON_HEDLEY_ARM_VERSION_CHECK 382 #if defined(JSON_HEDLEY_ARM_VERSION) 383 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 385 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) 388 #if defined(JSON_HEDLEY_IBM_VERSION) 389 #undef JSON_HEDLEY_IBM_VERSION 391 #if defined(__ibmxl__) 392 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) 393 #elif defined(__xlC__) && defined(__xlC_ver__) 394 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) 395 #elif defined(__xlC__) 396 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) 399 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK) 400 #undef JSON_HEDLEY_IBM_VERSION_CHECK 402 #if defined(JSON_HEDLEY_IBM_VERSION) 403 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 405 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) 408 #if defined(JSON_HEDLEY_TI_VERSION) 409 #undef JSON_HEDLEY_TI_VERSION 412 defined(__TI_COMPILER_VERSION__) && \ 414 defined(__TMS470__) || defined(__TI_ARM__) || \ 415 defined(__MSP430__) || \ 416 defined(__TMS320C2000__) \ 418 #if (__TI_COMPILER_VERSION__ >= 16000000) 419 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 423 #if defined(JSON_HEDLEY_TI_VERSION_CHECK) 424 #undef JSON_HEDLEY_TI_VERSION_CHECK 426 #if defined(JSON_HEDLEY_TI_VERSION) 427 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 429 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) 432 #if defined(JSON_HEDLEY_TI_CL2000_VERSION) 433 #undef JSON_HEDLEY_TI_CL2000_VERSION 435 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) 436 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 439 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) 440 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK 442 #if defined(JSON_HEDLEY_TI_CL2000_VERSION) 443 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 445 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) 448 #if defined(JSON_HEDLEY_TI_CL430_VERSION) 449 #undef JSON_HEDLEY_TI_CL430_VERSION 451 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) 452 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 455 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) 456 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK 458 #if defined(JSON_HEDLEY_TI_CL430_VERSION) 459 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 461 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) 464 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) 465 #undef JSON_HEDLEY_TI_ARMCL_VERSION 467 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) 468 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 471 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) 472 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK 474 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) 475 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 477 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) 480 #if defined(JSON_HEDLEY_TI_CL6X_VERSION) 481 #undef JSON_HEDLEY_TI_CL6X_VERSION 483 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) 484 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 487 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) 488 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK 490 #if defined(JSON_HEDLEY_TI_CL6X_VERSION) 491 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 493 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) 496 #if defined(JSON_HEDLEY_TI_CL7X_VERSION) 497 #undef JSON_HEDLEY_TI_CL7X_VERSION 499 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) 500 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 503 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) 504 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK 506 #if defined(JSON_HEDLEY_TI_CL7X_VERSION) 507 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 509 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) 512 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) 513 #undef JSON_HEDLEY_TI_CLPRU_VERSION 515 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) 516 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) 519 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) 520 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK 522 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) 523 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 525 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) 528 #if defined(JSON_HEDLEY_CRAY_VERSION) 529 #undef JSON_HEDLEY_CRAY_VERSION 532 #if defined(_RELEASE_PATCHLEVEL) 533 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) 535 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) 539 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) 540 #undef JSON_HEDLEY_CRAY_VERSION_CHECK 542 #if defined(JSON_HEDLEY_CRAY_VERSION) 543 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 545 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) 548 #if defined(JSON_HEDLEY_IAR_VERSION) 549 #undef JSON_HEDLEY_IAR_VERSION 551 #if defined(__IAR_SYSTEMS_ICC__) 553 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) 555 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) 559 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK) 560 #undef JSON_HEDLEY_IAR_VERSION_CHECK 562 #if defined(JSON_HEDLEY_IAR_VERSION) 563 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 565 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) 568 #if defined(JSON_HEDLEY_TINYC_VERSION) 569 #undef JSON_HEDLEY_TINYC_VERSION 571 #if defined(__TINYC__) 572 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) 575 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) 576 #undef JSON_HEDLEY_TINYC_VERSION_CHECK 578 #if defined(JSON_HEDLEY_TINYC_VERSION) 579 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 581 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) 584 #if defined(JSON_HEDLEY_DMC_VERSION) 585 #undef JSON_HEDLEY_DMC_VERSION 588 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) 591 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK) 592 #undef JSON_HEDLEY_DMC_VERSION_CHECK 594 #if defined(JSON_HEDLEY_DMC_VERSION) 595 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 597 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) 600 #if defined(JSON_HEDLEY_COMPCERT_VERSION) 601 #undef JSON_HEDLEY_COMPCERT_VERSION 603 #if defined(__COMPCERT_VERSION__) 604 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) 607 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) 608 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK 610 #if defined(JSON_HEDLEY_COMPCERT_VERSION) 611 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 613 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) 616 #if defined(JSON_HEDLEY_PELLES_VERSION) 617 #undef JSON_HEDLEY_PELLES_VERSION 619 #if defined(__POCC__) 620 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) 623 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) 624 #undef JSON_HEDLEY_PELLES_VERSION_CHECK 626 #if defined(JSON_HEDLEY_PELLES_VERSION) 627 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 629 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) 632 #if defined(JSON_HEDLEY_MCST_LCC_VERSION) 633 #undef JSON_HEDLEY_MCST_LCC_VERSION 635 #if defined(__LCC__) && defined(__LCC_MINOR__) 636 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) 639 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) 640 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK 642 #if defined(JSON_HEDLEY_MCST_LCC_VERSION) 643 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 645 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) 648 #if defined(JSON_HEDLEY_GCC_VERSION) 649 #undef JSON_HEDLEY_GCC_VERSION 652 defined(JSON_HEDLEY_GNUC_VERSION) && \ 653 !defined(__clang__) && \ 654 !defined(JSON_HEDLEY_INTEL_VERSION) && \ 655 !defined(JSON_HEDLEY_PGI_VERSION) && \ 656 !defined(JSON_HEDLEY_ARM_VERSION) && \ 657 !defined(JSON_HEDLEY_CRAY_VERSION) && \ 658 !defined(JSON_HEDLEY_TI_VERSION) && \ 659 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ 660 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ 661 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ 662 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ 663 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ 664 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ 665 !defined(__COMPCERT__) && \ 666 !defined(JSON_HEDLEY_MCST_LCC_VERSION) 667 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION 670 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK) 671 #undef JSON_HEDLEY_GCC_VERSION_CHECK 673 #if defined(JSON_HEDLEY_GCC_VERSION) 674 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) 676 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) 679 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) 680 #undef JSON_HEDLEY_HAS_ATTRIBUTE 683 defined(__has_attribute) && \ 685 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ 687 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) 689 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) 692 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) 693 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE 695 #if defined(__has_attribute) 696 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 698 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 701 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) 702 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE 704 #if defined(__has_attribute) 705 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 707 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 710 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) 711 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE 714 defined(__has_cpp_attribute) && \ 715 defined(__cplusplus) && \ 716 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) 717 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) 719 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) 722 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) 723 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS 725 #if !defined(__cplusplus) || !defined(__has_cpp_attribute) 726 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) 728 !defined(JSON_HEDLEY_PGI_VERSION) && \ 729 !defined(JSON_HEDLEY_IAR_VERSION) && \ 730 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ 731 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) 732 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) 734 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) 737 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) 738 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE 740 #if defined(__has_cpp_attribute) && defined(__cplusplus) 741 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) 743 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 746 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) 747 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE 749 #if defined(__has_cpp_attribute) && defined(__cplusplus) 750 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) 752 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 755 #if defined(JSON_HEDLEY_HAS_BUILTIN) 756 #undef JSON_HEDLEY_HAS_BUILTIN 758 #if defined(__has_builtin) 759 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) 761 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) 764 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) 765 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN 767 #if defined(__has_builtin) 768 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) 770 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 773 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) 774 #undef JSON_HEDLEY_GCC_HAS_BUILTIN 776 #if defined(__has_builtin) 777 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) 779 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 782 #if defined(JSON_HEDLEY_HAS_FEATURE) 783 #undef JSON_HEDLEY_HAS_FEATURE 785 #if defined(__has_feature) 786 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) 788 #define JSON_HEDLEY_HAS_FEATURE(feature) (0) 791 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) 792 #undef JSON_HEDLEY_GNUC_HAS_FEATURE 794 #if defined(__has_feature) 795 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) 797 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 800 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE) 801 #undef JSON_HEDLEY_GCC_HAS_FEATURE 803 #if defined(__has_feature) 804 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) 806 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 809 #if defined(JSON_HEDLEY_HAS_EXTENSION) 810 #undef JSON_HEDLEY_HAS_EXTENSION 812 #if defined(__has_extension) 813 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) 815 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) 818 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) 819 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION 821 #if defined(__has_extension) 822 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) 824 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 827 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) 828 #undef JSON_HEDLEY_GCC_HAS_EXTENSION 830 #if defined(__has_extension) 831 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) 833 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 836 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) 837 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE 839 #if defined(__has_declspec_attribute) 840 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) 842 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) 845 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) 846 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE 848 #if defined(__has_declspec_attribute) 849 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) 851 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 854 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) 855 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE 857 #if defined(__has_declspec_attribute) 858 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) 860 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 863 #if defined(JSON_HEDLEY_HAS_WARNING) 864 #undef JSON_HEDLEY_HAS_WARNING 866 #if defined(__has_warning) 867 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) 869 #define JSON_HEDLEY_HAS_WARNING(warning) (0) 872 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING) 873 #undef JSON_HEDLEY_GNUC_HAS_WARNING 875 #if defined(__has_warning) 876 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) 878 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) 881 #if defined(JSON_HEDLEY_GCC_HAS_WARNING) 882 #undef JSON_HEDLEY_GCC_HAS_WARNING 884 #if defined(__has_warning) 885 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) 887 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 891 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ 892 defined(__clang__) || \ 893 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ 894 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 895 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ 896 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ 897 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 898 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 899 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ 900 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ 901 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ 902 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ 903 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 904 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 905 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ 906 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ 907 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ 908 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) 909 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) 910 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 911 #define JSON_HEDLEY_PRAGMA(value) __pragma(value) 913 #define JSON_HEDLEY_PRAGMA(value) 916 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) 917 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH 919 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP) 920 #undef JSON_HEDLEY_DIAGNOSTIC_POP 922 #if defined(__clang__) 923 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 924 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 925 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 926 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") 927 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") 928 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) 929 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 930 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 932 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ 933 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 934 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) 935 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) 936 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) 937 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") 938 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") 940 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 941 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 942 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ 943 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ 944 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 945 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) 946 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") 947 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") 948 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) 949 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") 950 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") 952 #define JSON_HEDLEY_DIAGNOSTIC_PUSH 953 #define JSON_HEDLEY_DIAGNOSTIC_POP 958 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) 959 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ 961 #if defined(__cplusplus) 962 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") 963 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") 964 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") 965 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 966 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 967 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 968 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ 969 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ 971 JSON_HEDLEY_DIAGNOSTIC_POP 973 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 974 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 975 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 976 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ 978 JSON_HEDLEY_DIAGNOSTIC_POP 981 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ 982 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 983 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ 985 JSON_HEDLEY_DIAGNOSTIC_POP 989 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) 990 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x 993 #if defined(JSON_HEDLEY_CONST_CAST) 994 #undef JSON_HEDLEY_CONST_CAST 996 #if defined(__cplusplus) 997 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr)) 999 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ 1000 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ 1001 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1002 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ 1003 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1004 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ 1006 JSON_HEDLEY_DIAGNOSTIC_POP \ 1009 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) 1012 #if defined(JSON_HEDLEY_REINTERPRET_CAST) 1013 #undef JSON_HEDLEY_REINTERPRET_CAST 1015 #if defined(__cplusplus) 1016 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr)) 1018 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) 1021 #if defined(JSON_HEDLEY_STATIC_CAST) 1022 #undef JSON_HEDLEY_STATIC_CAST 1024 #if defined(__cplusplus) 1025 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr)) 1027 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) 1030 #if defined(JSON_HEDLEY_CPP_CAST) 1031 #undef JSON_HEDLEY_CPP_CAST 1033 #if defined(__cplusplus) 1034 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") 1035 # define JSON_HEDLEY_CPP_CAST(T, expr) \ 1036 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1037 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ 1039 JSON_HEDLEY_DIAGNOSTIC_POP 1040 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) 1041 # define JSON_HEDLEY_CPP_CAST(T, expr) \ 1042 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 1043 _Pragma("diag_suppress=Pe137") \ 1044 JSON_HEDLEY_DIAGNOSTIC_POP 1046 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) 1049 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr) 1052 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) 1053 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 1055 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") 1056 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") 1057 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1058 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") 1059 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1060 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) 1061 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) 1062 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") 1063 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1064 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") 1065 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) 1066 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 1067 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 1068 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) 1069 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1070 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") 1072 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1073 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1074 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1075 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1076 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1077 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1078 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1079 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1080 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1081 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1082 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) 1083 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") 1084 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) 1085 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") 1086 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) 1087 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") 1088 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1089 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") 1090 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) 1091 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") 1093 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 1096 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) 1097 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 1099 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 1100 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") 1101 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") 1103 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) 1105 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1106 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") 1107 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) 1108 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") 1109 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) 1110 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) 1112 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ 1113 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ 1114 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1115 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) 1116 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") 1117 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) 1118 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") 1119 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1120 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") 1121 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1122 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") 1124 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 1127 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) 1128 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 1130 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") 1131 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") 1132 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) 1133 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 1134 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) 1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") 1136 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1137 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) 1138 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) 1139 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) 1140 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) 1141 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") 1142 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) 1143 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") 1144 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) 1145 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") 1147 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ 1148 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ 1149 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) 1150 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") 1151 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") 1153 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") 1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 1159 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) 1160 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 1162 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") 1163 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") 1164 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 1165 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") 1166 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) 1167 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") 1169 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 1172 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) 1173 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 1175 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function") 1176 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") 1177 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) 1178 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") 1179 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) 1180 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) 1181 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1182 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") 1184 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 1187 #if defined(JSON_HEDLEY_DEPRECATED) 1188 #undef JSON_HEDLEY_DEPRECATED 1190 #if defined(JSON_HEDLEY_DEPRECATED_FOR) 1191 #undef JSON_HEDLEY_DEPRECATED_FOR 1194 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1195 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1196 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) 1197 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) 1199 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ 1200 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ 1201 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1202 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ 1203 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ 1204 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1205 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ 1206 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ 1207 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ 1208 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1209 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ 1210 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1211 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) 1212 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) 1213 #elif defined(__cplusplus) && (__cplusplus >= 201402L) 1214 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) 1215 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) 1217 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ 1218 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1219 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1220 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1221 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1222 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1223 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1224 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1225 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1226 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1227 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1228 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1229 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1230 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1231 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1232 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1233 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) 1234 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) 1236 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1237 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ 1238 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1239 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) 1240 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) 1241 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1242 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") 1243 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") 1245 #define JSON_HEDLEY_DEPRECATED(since) 1246 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) 1249 #if defined(JSON_HEDLEY_UNAVAILABLE) 1250 #undef JSON_HEDLEY_UNAVAILABLE 1253 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ 1254 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ 1255 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1256 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1257 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) 1259 #define JSON_HEDLEY_UNAVAILABLE(available_since) 1262 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) 1263 #undef JSON_HEDLEY_WARN_UNUSED_RESULT 1265 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) 1266 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG 1269 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ 1270 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 1271 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1272 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1273 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1274 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1275 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1276 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1277 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1278 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1279 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1280 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1281 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1282 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1283 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ 1284 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1285 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1286 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 1287 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) 1288 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) 1289 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1290 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) 1291 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) 1292 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1293 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) 1294 #elif defined(_Check_return_) 1295 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ 1296 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ 1298 #define JSON_HEDLEY_WARN_UNUSED_RESULT 1299 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) 1302 #if defined(JSON_HEDLEY_SENTINEL) 1303 #undef JSON_HEDLEY_SENTINEL 1306 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ 1307 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1308 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1309 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ 1310 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1311 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) 1313 #define JSON_HEDLEY_SENTINEL(position) 1316 #if defined(JSON_HEDLEY_NO_RETURN) 1317 #undef JSON_HEDLEY_NO_RETURN 1319 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1320 #define JSON_HEDLEY_NO_RETURN __noreturn 1322 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1323 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1324 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) 1325 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 1326 #define JSON_HEDLEY_NO_RETURN _Noreturn 1327 #elif defined(__cplusplus) && (__cplusplus >= 201103L) 1328 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) 1330 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ 1331 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ 1332 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1333 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1334 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1335 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1336 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1337 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1338 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1339 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1340 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1341 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1342 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1343 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1344 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1345 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1346 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1347 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) 1348 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1349 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") 1351 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1352 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1353 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) 1354 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) 1355 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") 1356 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) 1357 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) 1358 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) 1359 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) 1361 #define JSON_HEDLEY_NO_RETURN 1364 #if defined(JSON_HEDLEY_NO_ESCAPE) 1365 #undef JSON_HEDLEY_NO_ESCAPE 1367 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) 1368 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) 1370 #define JSON_HEDLEY_NO_ESCAPE 1373 #if defined(JSON_HEDLEY_UNREACHABLE) 1374 #undef JSON_HEDLEY_UNREACHABLE 1376 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN) 1377 #undef JSON_HEDLEY_UNREACHABLE_RETURN 1379 #if defined(JSON_HEDLEY_ASSUME) 1380 #undef JSON_HEDLEY_ASSUME 1383 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1384 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1385 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1386 #define JSON_HEDLEY_ASSUME(expr) __assume(expr) 1387 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) 1388 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) 1390 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1391 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) 1392 #if defined(__cplusplus) 1393 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) 1395 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) 1399 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ 1400 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ 1401 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ 1402 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1403 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ 1404 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ 1405 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1406 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() 1407 #elif defined(JSON_HEDLEY_ASSUME) 1408 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) 1410 #if !defined(JSON_HEDLEY_ASSUME) 1411 #if defined(JSON_HEDLEY_UNREACHABLE) 1412 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) 1414 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) 1417 #if defined(JSON_HEDLEY_UNREACHABLE) 1419 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1420 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) 1421 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) 1423 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() 1426 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) 1428 #if !defined(JSON_HEDLEY_UNREACHABLE) 1429 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) 1433 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic") 1434 #pragma clang diagnostic ignored "-Wpedantic" 1436 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) 1437 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" 1439 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) 1440 #if defined(__clang__) 1441 #pragma clang diagnostic ignored "-Wvariadic-macros" 1442 #elif defined(JSON_HEDLEY_GCC_VERSION) 1443 #pragma GCC diagnostic ignored "-Wvariadic-macros" 1446 #if defined(JSON_HEDLEY_NON_NULL) 1447 #undef JSON_HEDLEY_NON_NULL 1450 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ 1451 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1452 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1453 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) 1454 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) 1456 #define JSON_HEDLEY_NON_NULL(...) 1460 #if defined(JSON_HEDLEY_PRINTF_FORMAT) 1461 #undef JSON_HEDLEY_PRINTF_FORMAT 1463 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) 1464 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) 1465 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) 1466 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) 1468 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ 1469 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1470 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1471 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ 1472 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1473 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1474 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1475 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1476 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1477 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1478 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1479 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1480 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1481 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1482 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1483 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1484 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1485 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) 1486 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) 1487 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) 1489 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) 1492 #if defined(JSON_HEDLEY_CONSTEXPR) 1493 #undef JSON_HEDLEY_CONSTEXPR 1495 #if defined(__cplusplus) 1496 #if __cplusplus >= 201103L 1497 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) 1500 #if !defined(JSON_HEDLEY_CONSTEXPR) 1501 #define JSON_HEDLEY_CONSTEXPR 1504 #if defined(JSON_HEDLEY_PREDICT) 1505 #undef JSON_HEDLEY_PREDICT 1507 #if defined(JSON_HEDLEY_LIKELY) 1508 #undef JSON_HEDLEY_LIKELY 1510 #if defined(JSON_HEDLEY_UNLIKELY) 1511 #undef JSON_HEDLEY_UNLIKELY 1513 #if defined(JSON_HEDLEY_UNPREDICTABLE) 1514 #undef JSON_HEDLEY_UNPREDICTABLE 1516 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) 1517 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) 1520 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ 1521 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ 1522 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1523 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) 1524 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) 1525 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) 1526 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) 1527 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) 1529 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ 1530 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ 1531 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1532 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ 1533 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1534 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1535 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1536 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ 1537 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ 1538 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ 1539 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1540 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1541 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1542 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ 1543 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 1544 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1545 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \ 1546 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) 1547 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ 1549 double hedley_probability_ = (probability); \ 1550 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ 1552 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ 1554 double hedley_probability_ = (probability); \ 1555 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ 1557 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) 1558 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) 1560 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) 1561 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) 1562 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) 1563 # define JSON_HEDLEY_LIKELY(expr) (!!(expr)) 1564 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) 1566 #if !defined(JSON_HEDLEY_UNPREDICTABLE) 1567 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) 1570 #if defined(JSON_HEDLEY_MALLOC) 1571 #undef JSON_HEDLEY_MALLOC 1574 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ 1575 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1576 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1577 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1578 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1579 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ 1580 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1581 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1582 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1583 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1584 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1585 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1586 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1587 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1588 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1589 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1590 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1591 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1592 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) 1593 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1594 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") 1596 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1597 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1598 #define JSON_HEDLEY_MALLOC __declspec(restrict) 1600 #define JSON_HEDLEY_MALLOC 1603 #if defined(JSON_HEDLEY_PURE) 1604 #undef JSON_HEDLEY_PURE 1607 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ 1608 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ 1609 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1610 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1611 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1612 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1613 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1614 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1615 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1616 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1617 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1618 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1619 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1620 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1621 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1622 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1623 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1624 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1625 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1626 # define JSON_HEDLEY_PURE __attribute__((__pure__)) 1627 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1628 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") 1629 #elif defined(__cplusplus) && \ 1631 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ 1632 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ 1633 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ 1635 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") 1637 # define JSON_HEDLEY_PURE 1640 #if defined(JSON_HEDLEY_CONST) 1641 #undef JSON_HEDLEY_CONST 1644 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ 1645 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ 1646 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1647 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1648 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1649 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1650 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1651 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1652 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1653 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1654 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1655 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1656 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1657 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1658 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1659 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1660 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1661 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1662 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1663 #define JSON_HEDLEY_CONST __attribute__((__const__)) 1665 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) 1666 #define JSON_HEDLEY_CONST _Pragma("no_side_effect") 1668 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE 1671 #if defined(JSON_HEDLEY_RESTRICT) 1672 #undef JSON_HEDLEY_RESTRICT 1674 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) 1675 #define JSON_HEDLEY_RESTRICT restrict 1677 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ 1678 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ 1679 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1680 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1681 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1682 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1683 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ 1684 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1685 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ 1686 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ 1687 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1688 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ 1689 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ 1690 defined(__clang__) || \ 1691 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1692 #define JSON_HEDLEY_RESTRICT __restrict 1693 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) 1694 #define JSON_HEDLEY_RESTRICT _Restrict 1696 #define JSON_HEDLEY_RESTRICT 1699 #if defined(JSON_HEDLEY_INLINE) 1700 #undef JSON_HEDLEY_INLINE 1703 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ 1704 (defined(__cplusplus) && (__cplusplus >= 199711L)) 1705 #define JSON_HEDLEY_INLINE inline 1707 defined(JSON_HEDLEY_GCC_VERSION) || \ 1708 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) 1709 #define JSON_HEDLEY_INLINE __inline__ 1711 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ 1712 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1713 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1714 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ 1715 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ 1716 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ 1717 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ 1718 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1719 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1720 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1721 #define JSON_HEDLEY_INLINE __inline 1723 #define JSON_HEDLEY_INLINE 1726 #if defined(JSON_HEDLEY_ALWAYS_INLINE) 1727 #undef JSON_HEDLEY_ALWAYS_INLINE 1730 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ 1731 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1732 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1733 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1734 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1735 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1736 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1737 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1738 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1739 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1740 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1741 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1742 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1743 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1744 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1745 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1746 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1747 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1748 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1749 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE 1751 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ 1752 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1753 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline 1754 #elif defined(__cplusplus) && \ 1756 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1757 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1758 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1759 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1760 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1761 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ 1763 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") 1764 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1765 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") 1767 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE 1770 #if defined(JSON_HEDLEY_NEVER_INLINE) 1771 #undef JSON_HEDLEY_NEVER_INLINE 1774 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ 1775 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ 1776 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1777 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1778 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1779 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ 1780 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ 1781 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1782 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ 1783 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1784 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ 1785 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1786 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ 1787 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1788 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ 1789 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ 1790 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ 1791 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ 1792 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) 1793 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) 1795 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ 1796 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 1797 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) 1798 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) 1799 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") 1800 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) 1801 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") 1802 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 1803 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") 1804 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) 1805 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) 1806 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) 1807 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) 1809 #define JSON_HEDLEY_NEVER_INLINE 1812 #if defined(JSON_HEDLEY_PRIVATE) 1813 #undef JSON_HEDLEY_PRIVATE 1815 #if defined(JSON_HEDLEY_PUBLIC) 1816 #undef JSON_HEDLEY_PUBLIC 1818 #if defined(JSON_HEDLEY_IMPORT) 1819 #undef JSON_HEDLEY_IMPORT 1821 #if defined(_WIN32) || defined(__CYGWIN__) 1822 # define JSON_HEDLEY_PRIVATE 1823 # define JSON_HEDLEY_PUBLIC __declspec(dllexport) 1824 # define JSON_HEDLEY_IMPORT __declspec(dllimport) 1827 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ 1828 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1829 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ 1830 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1831 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1832 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 1834 defined(__TI_EABI__) && \ 1836 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ 1837 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ 1840 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1841 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) 1842 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) 1844 # define JSON_HEDLEY_PRIVATE 1845 # define JSON_HEDLEY_PUBLIC 1847 # define JSON_HEDLEY_IMPORT extern 1850 #if defined(JSON_HEDLEY_NO_THROW) 1851 #undef JSON_HEDLEY_NO_THROW 1854 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ 1855 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ 1856 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1857 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1858 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) 1860 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ 1861 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ 1862 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) 1863 #define JSON_HEDLEY_NO_THROW __declspec(nothrow) 1865 #define JSON_HEDLEY_NO_THROW 1868 #if defined(JSON_HEDLEY_FALL_THROUGH) 1869 #undef JSON_HEDLEY_FALL_THROUGH 1872 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ 1873 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ 1874 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1875 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) 1876 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) 1877 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) 1878 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) 1879 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) 1880 #elif defined(__fallthrough) 1881 #define JSON_HEDLEY_FALL_THROUGH __fallthrough 1883 #define JSON_HEDLEY_FALL_THROUGH 1886 #if defined(JSON_HEDLEY_RETURNS_NON_NULL) 1887 #undef JSON_HEDLEY_RETURNS_NON_NULL 1890 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ 1891 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ 1892 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1893 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) 1894 #elif defined(_Ret_notnull_) 1895 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ 1897 #define JSON_HEDLEY_RETURNS_NON_NULL 1900 #if defined(JSON_HEDLEY_ARRAY_PARAM) 1901 #undef JSON_HEDLEY_ARRAY_PARAM 1904 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ 1905 !defined(__STDC_NO_VLA__) && \ 1906 !defined(__cplusplus) && \ 1907 !defined(JSON_HEDLEY_PGI_VERSION) && \ 1908 !defined(JSON_HEDLEY_TINYC_VERSION) 1909 #define JSON_HEDLEY_ARRAY_PARAM(name) (name) 1911 #define JSON_HEDLEY_ARRAY_PARAM(name) 1914 #if defined(JSON_HEDLEY_IS_CONSTANT) 1915 #undef JSON_HEDLEY_IS_CONSTANT 1917 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) 1918 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR 1922 #if defined(JSON_HEDLEY_IS_CONSTEXPR_) 1923 #undef JSON_HEDLEY_IS_CONSTEXPR_ 1926 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ 1927 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 1928 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1929 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ 1930 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ 1931 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 1932 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ 1933 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ 1934 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 1935 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) 1936 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) 1938 #if !defined(__cplusplus) 1940 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ 1941 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ 1942 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 1943 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ 1944 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ 1945 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ 1946 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) 1947 #if defined(__INTPTR_TYPE__) 1948 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) 1951 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) 1955 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ 1956 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ 1957 !defined(JSON_HEDLEY_PGI_VERSION) && \ 1958 !defined(JSON_HEDLEY_IAR_VERSION)) || \ 1959 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ 1960 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ 1961 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ 1962 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ 1963 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) 1964 #if defined(__INTPTR_TYPE__) 1965 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) 1968 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) 1971 defined(JSON_HEDLEY_GCC_VERSION) || \ 1972 defined(JSON_HEDLEY_INTEL_VERSION) || \ 1973 defined(JSON_HEDLEY_TINYC_VERSION) || \ 1974 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ 1975 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ 1976 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ 1977 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ 1978 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ 1979 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ 1981 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ 1985 ((void*) ((expr) * 0L) ) : \ 1986 ((struct { char v[sizeof(void) * 2]; } *) 1) \ 1992 #if defined(JSON_HEDLEY_IS_CONSTEXPR_) 1993 #if !defined(JSON_HEDLEY_IS_CONSTANT) 1994 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) 1996 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) 1998 #if !defined(JSON_HEDLEY_IS_CONSTANT) 1999 #define JSON_HEDLEY_IS_CONSTANT(expr) (0) 2001 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) 2004 #if defined(JSON_HEDLEY_BEGIN_C_DECLS) 2005 #undef JSON_HEDLEY_BEGIN_C_DECLS 2007 #if defined(JSON_HEDLEY_END_C_DECLS) 2008 #undef JSON_HEDLEY_END_C_DECLS 2010 #if defined(JSON_HEDLEY_C_DECL) 2011 #undef JSON_HEDLEY_C_DECL 2013 #if defined(__cplusplus) 2014 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { 2015 #define JSON_HEDLEY_END_C_DECLS } 2016 #define JSON_HEDLEY_C_DECL extern "C" 2018 #define JSON_HEDLEY_BEGIN_C_DECLS 2019 #define JSON_HEDLEY_END_C_DECLS 2020 #define JSON_HEDLEY_C_DECL 2023 #if defined(JSON_HEDLEY_STATIC_ASSERT) 2024 #undef JSON_HEDLEY_STATIC_ASSERT 2027 !defined(__cplusplus) && ( \ 2028 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ 2029 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ 2030 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ 2031 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ 2032 defined(_Static_assert) \ 2034 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) 2036 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ 2037 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ 2038 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2039 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) 2041 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) 2044 #if defined(JSON_HEDLEY_NULL) 2045 #undef JSON_HEDLEY_NULL 2047 #if defined(__cplusplus) 2048 #if __cplusplus >= 201103L 2049 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) 2051 #define JSON_HEDLEY_NULL NULL 2053 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) 2056 #define JSON_HEDLEY_NULL NULL 2058 #define JSON_HEDLEY_NULL ((void*) 0) 2061 #if defined(JSON_HEDLEY_MESSAGE) 2062 #undef JSON_HEDLEY_MESSAGE 2064 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 2065 # define JSON_HEDLEY_MESSAGE(msg) \ 2066 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2067 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ 2068 JSON_HEDLEY_PRAGMA(message msg) \ 2069 JSON_HEDLEY_DIAGNOSTIC_POP 2071 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ 2072 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 2073 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) 2074 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) 2075 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) 2076 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) 2077 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2078 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) 2079 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2081 # define JSON_HEDLEY_MESSAGE(msg) 2084 #if defined(JSON_HEDLEY_WARNING) 2085 #undef JSON_HEDLEY_WARNING 2087 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") 2088 # define JSON_HEDLEY_WARNING(msg) \ 2089 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2090 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ 2091 JSON_HEDLEY_PRAGMA(clang warning msg) \ 2092 JSON_HEDLEY_DIAGNOSTIC_POP 2094 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ 2095 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ 2096 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) 2097 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) 2099 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ 2100 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2101 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) 2103 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) 2106 #if defined(JSON_HEDLEY_REQUIRE) 2107 #undef JSON_HEDLEY_REQUIRE 2109 #if defined(JSON_HEDLEY_REQUIRE_MSG) 2110 #undef JSON_HEDLEY_REQUIRE_MSG 2112 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) 2113 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") 2114 # define JSON_HEDLEY_REQUIRE(expr) \ 2115 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2116 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ 2117 __attribute__((diagnose_if(!(expr), #expr, "error"))) \ 2118 JSON_HEDLEY_DIAGNOSTIC_POP 2119 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ 2120 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2121 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ 2122 __attribute__((diagnose_if(!(expr), msg, "error"))) \ 2123 JSON_HEDLEY_DIAGNOSTIC_POP 2125 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) 2126 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) 2129 # define JSON_HEDLEY_REQUIRE(expr) 2130 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) 2133 #if defined(JSON_HEDLEY_FLAGS) 2134 #undef JSON_HEDLEY_FLAGS 2136 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) 2137 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) 2139 #define JSON_HEDLEY_FLAGS 2142 #if defined(JSON_HEDLEY_FLAGS_CAST) 2143 #undef JSON_HEDLEY_FLAGS_CAST 2145 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) 2146 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ 2147 JSON_HEDLEY_DIAGNOSTIC_PUSH \ 2148 _Pragma("warning(disable:188)") \ 2150 JSON_HEDLEY_DIAGNOSTIC_POP \ 2153 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) 2156 #if defined(JSON_HEDLEY_EMPTY_BASES) 2157 #undef JSON_HEDLEY_EMPTY_BASES 2160 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ 2161 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) 2162 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) 2164 #define JSON_HEDLEY_EMPTY_BASES 2169 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) 2170 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK 2172 #if defined(__clang__) 2173 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) 2175 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) 2178 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) 2179 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE 2181 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) 2183 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) 2184 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE 2186 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) 2188 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) 2189 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN 2191 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) 2193 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) 2194 #undef JSON_HEDLEY_CLANG_HAS_FEATURE 2196 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) 2198 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) 2199 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION 2201 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) 2203 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) 2204 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE 2206 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) 2208 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING) 2209 #undef JSON_HEDLEY_CLANG_HAS_WARNING 2211 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) 2220 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) 2221 #if defined(__clang__) 2222 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 2223 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" 2225 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) 2226 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 2227 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" 2234 #if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) 2235 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) 2236 #define JSON_HAS_CPP_20 2237 #define JSON_HAS_CPP_17 2238 #define JSON_HAS_CPP_14 2239 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 2240 #define JSON_HAS_CPP_17 2241 #define JSON_HAS_CPP_14 2242 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) 2243 #define JSON_HAS_CPP_14 2246 #define JSON_HAS_CPP_11 2250 #if defined(__clang__) 2251 #pragma GCC diagnostic push 2252 #pragma GCC diagnostic ignored "-Wdocumentation" 2256 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) 2257 #define JSON_THROW(exception) throw exception 2258 #define JSON_TRY try 2259 #define JSON_CATCH(exception) catch(exception) 2260 #define JSON_INTERNAL_CATCH(exception) catch(exception) 2263 #define JSON_THROW(exception) std::abort() 2264 #define JSON_TRY if(true) 2265 #define JSON_CATCH(exception) if(false) 2266 #define JSON_INTERNAL_CATCH(exception) if(false) 2270 #if defined(JSON_THROW_USER) 2272 #define JSON_THROW JSON_THROW_USER 2274 #if defined(JSON_TRY_USER) 2276 #define JSON_TRY JSON_TRY_USER 2278 #if defined(JSON_CATCH_USER) 2280 #define JSON_CATCH JSON_CATCH_USER 2281 #undef JSON_INTERNAL_CATCH 2282 #define JSON_INTERNAL_CATCH JSON_CATCH_USER 2284 #if defined(JSON_INTERNAL_CATCH_USER) 2285 #undef JSON_INTERNAL_CATCH 2286 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER 2290 #if !defined(JSON_ASSERT) 2292 #define JSON_ASSERT(x) assert(x) 2296 #if defined(JSON_TESTS_PRIVATE) 2297 #define JSON_PRIVATE_UNLESS_TESTED public 2299 #define JSON_PRIVATE_UNLESS_TESTED private 2307 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ 2308 template<typename BasicJsonType> \ 2309 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ 2311 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ 2312 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ 2313 auto it = std::find_if(std::begin(m), std::end(m), \ 2314 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ 2316 return ej_pair.first == e; \ 2318 j = ((it != std::end(m)) ? it : std::begin(m))->second; \ 2320 template<typename BasicJsonType> \ 2321 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ 2323 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ 2324 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ 2325 auto it = std::find_if(std::begin(m), std::end(m), \ 2326 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ 2328 return ej_pair.second == j; \ 2330 e = ((it != std::end(m)) ? it : std::begin(m))->first; \ 2336 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ 2337 template<template<typename, typename, typename...> class ObjectType, \ 2338 template<typename, typename...> class ArrayType, \ 2339 class StringType, class BooleanType, class NumberIntegerType, \ 2340 class NumberUnsignedType, class NumberFloatType, \ 2341 template<typename> class AllocatorType, \ 2342 template<typename, typename = void> class JSONSerializer, \ 2345 #define NLOHMANN_BASIC_JSON_TPL \ 2346 basic_json<ObjectType, ArrayType, StringType, BooleanType, \ 2347 NumberIntegerType, NumberUnsignedType, NumberFloatType, \ 2348 AllocatorType, JSONSerializer, BinaryType> 2352 #define NLOHMANN_JSON_EXPAND( x ) x 2353 #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 2354 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ 2355 NLOHMANN_JSON_PASTE64, \ 2356 NLOHMANN_JSON_PASTE63, \ 2357 NLOHMANN_JSON_PASTE62, \ 2358 NLOHMANN_JSON_PASTE61, \ 2359 NLOHMANN_JSON_PASTE60, \ 2360 NLOHMANN_JSON_PASTE59, \ 2361 NLOHMANN_JSON_PASTE58, \ 2362 NLOHMANN_JSON_PASTE57, \ 2363 NLOHMANN_JSON_PASTE56, \ 2364 NLOHMANN_JSON_PASTE55, \ 2365 NLOHMANN_JSON_PASTE54, \ 2366 NLOHMANN_JSON_PASTE53, \ 2367 NLOHMANN_JSON_PASTE52, \ 2368 NLOHMANN_JSON_PASTE51, \ 2369 NLOHMANN_JSON_PASTE50, \ 2370 NLOHMANN_JSON_PASTE49, \ 2371 NLOHMANN_JSON_PASTE48, \ 2372 NLOHMANN_JSON_PASTE47, \ 2373 NLOHMANN_JSON_PASTE46, \ 2374 NLOHMANN_JSON_PASTE45, \ 2375 NLOHMANN_JSON_PASTE44, \ 2376 NLOHMANN_JSON_PASTE43, \ 2377 NLOHMANN_JSON_PASTE42, \ 2378 NLOHMANN_JSON_PASTE41, \ 2379 NLOHMANN_JSON_PASTE40, \ 2380 NLOHMANN_JSON_PASTE39, \ 2381 NLOHMANN_JSON_PASTE38, \ 2382 NLOHMANN_JSON_PASTE37, \ 2383 NLOHMANN_JSON_PASTE36, \ 2384 NLOHMANN_JSON_PASTE35, \ 2385 NLOHMANN_JSON_PASTE34, \ 2386 NLOHMANN_JSON_PASTE33, \ 2387 NLOHMANN_JSON_PASTE32, \ 2388 NLOHMANN_JSON_PASTE31, \ 2389 NLOHMANN_JSON_PASTE30, \ 2390 NLOHMANN_JSON_PASTE29, \ 2391 NLOHMANN_JSON_PASTE28, \ 2392 NLOHMANN_JSON_PASTE27, \ 2393 NLOHMANN_JSON_PASTE26, \ 2394 NLOHMANN_JSON_PASTE25, \ 2395 NLOHMANN_JSON_PASTE24, \ 2396 NLOHMANN_JSON_PASTE23, \ 2397 NLOHMANN_JSON_PASTE22, \ 2398 NLOHMANN_JSON_PASTE21, \ 2399 NLOHMANN_JSON_PASTE20, \ 2400 NLOHMANN_JSON_PASTE19, \ 2401 NLOHMANN_JSON_PASTE18, \ 2402 NLOHMANN_JSON_PASTE17, \ 2403 NLOHMANN_JSON_PASTE16, \ 2404 NLOHMANN_JSON_PASTE15, \ 2405 NLOHMANN_JSON_PASTE14, \ 2406 NLOHMANN_JSON_PASTE13, \ 2407 NLOHMANN_JSON_PASTE12, \ 2408 NLOHMANN_JSON_PASTE11, \ 2409 NLOHMANN_JSON_PASTE10, \ 2410 NLOHMANN_JSON_PASTE9, \ 2411 NLOHMANN_JSON_PASTE8, \ 2412 NLOHMANN_JSON_PASTE7, \ 2413 NLOHMANN_JSON_PASTE6, \ 2414 NLOHMANN_JSON_PASTE5, \ 2415 NLOHMANN_JSON_PASTE4, \ 2416 NLOHMANN_JSON_PASTE3, \ 2417 NLOHMANN_JSON_PASTE2, \ 2418 NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) 2419 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1) 2420 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) 2421 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) 2422 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) 2423 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) 2424 #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) 2425 #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) 2426 #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) 2427 #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) 2428 #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) 2429 #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) 2430 #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) 2431 #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) 2432 #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) 2433 #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) 2434 #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) 2435 #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) 2436 #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) 2437 #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) 2438 #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) 2439 #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) 2440 #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) 2441 #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) 2442 #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) 2443 #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) 2444 #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) 2445 #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) 2446 #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) 2447 #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) 2448 #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) 2449 #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) 2450 #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) 2451 #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) 2452 #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) 2453 #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) 2454 #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) 2455 #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) 2456 #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) 2457 #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) 2458 #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) 2459 #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) 2460 #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) 2461 #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) 2462 #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) 2463 #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) 2464 #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) 2465 #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) 2466 #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) 2467 #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) 2468 #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) 2469 #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) 2470 #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) 2471 #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) 2472 #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) 2473 #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) 2474 #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) 2475 #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) 2476 #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) 2477 #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) 2478 #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) 2479 #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) 2480 #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) 2481 #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) 2483 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; 2484 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); 2491 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ 2492 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__)) } \ 2493 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__)) } 2500 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ 2501 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__)) } \ 2502 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__)) } 2504 #ifndef JSON_USE_IMPLICIT_CONVERSIONS 2505 #define JSON_USE_IMPLICIT_CONVERSIONS 1 2508 #if JSON_USE_IMPLICIT_CONVERSIONS 2509 #define JSON_EXPLICIT 2511 #define JSON_EXPLICIT explicit 2537 for (
auto pos = s.find(f);
2538 pos != std::string::npos;
2539 s.replace(pos, f.size(), t),
2540 pos = s.find(f, pos + t.size()))
2587 std::size_t chars_read_total = 0;
2589 std::size_t chars_read_current_line = 0;
2591 std::size_t lines_read = 0;
2594 constexpr
operator size_t()
const 2596 return chars_read_total;
2646 const char*
what() const noexcept
override 2656 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
2660 return "[json.exception." + ename +
"." +
std::to_string(id_) +
"] ";
2663 template<
typename BasicJsonType>
2666 #if JSON_DIAGNOSTICS 2667 std::vector<std::string> tokens;
2668 for (
const auto* current = &leaf_element; current->m_parent !=
nullptr; current = current->m_parent)
2670 switch (current->m_parent->type())
2674 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2676 if (¤t->m_parent->m_value.array->operator[](i) == current)
2687 for (
const auto& element : *current->m_parent->m_value.object)
2689 if (&element.second == current)
2691 tokens.emplace_back(element.first.c_str());
2708 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(),
std::string{},
2714 static_cast<void>(leaf_element);
2721 std::runtime_error
m;
2781 template<
typename BasicJsonType>
2789 template<
typename BasicJsonType>
2811 :
exception(id_, what_arg), byte(byte_) {}
2860 template<
typename BasicJsonType>
2915 template<
typename BasicJsonType>
2963 template<
typename BasicJsonType>
3002 template<
typename BasicJsonType>
3022 #include <type_traits> 3033 template<
typename T>
3036 #ifdef JSON_HAS_CPP_14 3047 template<
bool B,
typename T =
void>
3074 template <
typename T, T... Ints>
3078 static constexpr std::size_t
size() noexcept
3080 return sizeof...(Ints);
3089 template <
size_t... Ints>
3092 namespace utility_internal
3095 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3099 template <
typename T, T... Ints,
size_t SeqSize>
3105 template <
typename T, T... Ints,
size_t SeqSize>
3113 template <
typename T,
size_t N>
3117 typename Extend <
typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
3120 template <
typename T>
3135 template <
typename T, T N>
3151 template <
typename... Ts>
3163 template<
typename T>
3169 template<
typename T>
3191 #include <type_traits> 3222 template<
typename It,
typename =
void>
3225 template<
typename It>
3229 typename It::reference, typename It::iterator_category >>
3240 template<
typename T,
typename =
void>
3245 template<
typename T>
3251 template<
typename T>
3270 #include <type_traits> 3286 void operator=(
nonesuch const&) =
delete;
3287 void operator=(
nonesuch&&) =
delete;
3290 template<
class Default,
3292 template<
class...>
class Op,
3300 template<
class Default,
template<
class...>
class Op,
class... Args>
3307 template<
template<
class...>
class Op,
class... Args>
3310 template<
template<
class...>
class Op,
class... Args>
3313 template<
class Default,
template<
class...>
class Op,
class... Args>
3316 template<
class Default,
template<
class...>
class Op,
class... Args>
3319 template<
class Expected,
template<
class...>
class Op,
class... Args>
3322 template<
class To,
template<
class...>
class Op,
class... Args>
3329 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3330 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3352 template<
typename T =
void,
typename SFINAE =
void>
3355 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3357 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3358 class StringType =
std::string,
class BooleanType = bool,
3359 class NumberIntegerType = std::int64_t,
3360 class NumberUnsignedType = std::uint64_t,
3361 class NumberFloatType = double,
3362 template<
typename U>
class AllocatorType = std::allocator,
3363 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3365 class BinaryType = std::vector<std::uint8_t>>
3379 template<
typename BasicJsonType>
3392 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3406 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ 3449 template<
typename T>
3456 template<
typename T>
3459 template<
typename T>
3462 template<
typename T>
3465 template<
typename T>
3468 template<
typename T>
3471 template<
typename T>
3474 template<
typename T>
3477 template<
typename T>
3480 template<
typename T,
typename... Args>
3483 template<
typename T,
typename... Args>
3486 template<
typename T,
typename U>
3490 template<
typename BasicJsonType,
typename T,
typename =
void>
3497 template <
typename BasicJsonType,
typename T>
3503 template<
typename BasicJsonType,
typename T>
3506 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3510 const BasicJsonType&, T&>
::value;
3515 template<
typename BasicJsonType,
typename T,
typename =
void>
3518 template<
typename BasicJsonType,
typename T>
3521 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3530 template<
typename BasicJsonType,
typename T,
typename =
void>
3533 template<
typename BasicJsonType,
typename T>
3536 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3551 template<
class B1,
class... Bn>
3553 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>
::type {};
3558 template <
typename T>
3561 template <
typename T1,
typename T2>
3563 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3565 template <
typename T1,
typename T2>
3567 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3569 template <
typename... Ts>
3571 :
conjunction<is_default_constructible<Ts>...> {};
3573 template <
typename... Ts>
3575 :
conjunction<is_default_constructible<Ts>...> {};
3578 template <
typename T,
typename... Args>
3581 template <
typename T1,
typename T2>
3584 template <
typename T1,
typename T2>
3587 template <
typename... Ts>
3590 template <
typename... Ts>
3594 template<
typename T,
typename =
void>
3597 template<
typename T>
3616 template<
typename T,
typename =
void>
3619 template<
typename T>
3622 template<
typename BasicJsonType,
typename CompatibleObjectType,
3626 template<
typename BasicJsonType,
typename CompatibleObjectType>
3628 BasicJsonType, CompatibleObjectType,
3637 typename CompatibleObjectType::key_type>
::value &&
3639 typename CompatibleObjectType::mapped_type>
::value;
3642 template<
typename BasicJsonType,
typename CompatibleObjectType>
3646 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3650 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3652 BasicJsonType, ConstructibleObjectType,
3660 (std::is_move_assignable<ConstructibleObjectType>::value ||
3661 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3663 typename object_t::key_type>::value &&
3665 typename object_t::mapped_type,
3666 typename ConstructibleObjectType::mapped_type >::value)) ||
3668 typename ConstructibleObjectType::mapped_type>::value ||
3671 typename ConstructibleObjectType::mapped_type >::value);
3674 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3677 ConstructibleObjectType> {};
3679 template<
typename BasicJsonType,
typename CompatibleStringType,
3683 template<
typename BasicJsonType,
typename CompatibleStringType>
3685 BasicJsonType, CompatibleStringType,
3689 static constexpr
auto value =
3693 template<
typename BasicJsonType,
typename ConstructibleStringType>
3697 template<
typename BasicJsonType,
typename ConstructibleStringType,
3701 template<
typename BasicJsonType,
typename ConstructibleStringType>
3703 BasicJsonType, ConstructibleStringType,
3707 static constexpr
auto value =
3709 typename BasicJsonType::string_t>
::value;
3712 template<
typename BasicJsonType,
typename ConstructibleStringType>
3716 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3719 template<
typename BasicJsonType,
typename CompatibleArrayType>
3721 BasicJsonType, CompatibleArrayType,
3728 iterator_traits<CompatibleArrayType >>
::value >>
3730 static constexpr
bool value =
3732 typename CompatibleArrayType::value_type>
::value;
3735 template<
typename BasicJsonType,
typename CompatibleArrayType>
3739 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3742 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3744 BasicJsonType, ConstructibleArrayType,
3746 typename BasicJsonType::value_type>
::value >>
3747 : std::true_type {};
3749 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3751 BasicJsonType, ConstructibleArrayType,
3752 enable_if_t < !std::is_same<ConstructibleArrayType,
3753 typename BasicJsonType::value_type>
::value&&
3755 (std::is_move_assignable<ConstructibleArrayType>::value ||
3756 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3760 detected_t<value_type_t, ConstructibleArrayType >>
::value >>
3762 static constexpr
bool value =
3770 (std::is_same<
typename ConstructibleArrayType::value_type,
3771 typename BasicJsonType::array_t::value_type>
::value ||
3773 typename ConstructibleArrayType::value_type>
::value ||
3775 BasicJsonType,
typename ConstructibleArrayType::value_type >
::value);
3778 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3782 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3786 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3788 RealIntegerType, CompatibleNumberIntegerType,
3789 enable_if_t < std::is_integral<RealIntegerType>::value&&
3790 std::is_integral<CompatibleNumberIntegerType>::value&&
3791 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3797 static constexpr
auto value =
3799 CompatibleNumberIntegerType>::value &&
3800 CompatibleLimits::is_integer &&
3801 RealLimits::is_signed == CompatibleLimits::is_signed;
3804 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3807 CompatibleNumberIntegerType> {};
3809 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3812 template<
typename BasicJsonType,
typename CompatibleType>
3814 BasicJsonType, CompatibleType,
3817 static constexpr
bool value =
3821 template<
typename BasicJsonType,
typename CompatibleType>
3825 template<
typename T1,
typename T2>
3828 template<
typename T1,
typename... Args>
3840 template<
typename BasicJsonType>
3841 void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
3851 template <
typename BasicJsonType,
typename ArithmeticType,
3853 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3857 switch (static_cast<value_t>(j))
3861 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3866 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3871 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,
3939 typename std::underlying_type<EnumType>::type val;
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())
3982 for (std::size_t i = 0; i < N; ++i)
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())
3999 for (std::size_t i = 0; i < N; ++i)
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>();
4026 arr = std::move(ret);
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>();
4047 arr = std::move(ret);
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*>();
4112 using value_type =
typename ConstructibleObjectType::value_type;
4114 inner_object->begin(), inner_object->end(),
4115 std::inserter(ret, ret.begin()),
4116 [](
typename BasicJsonType::object_t::value_type
const & p)
4118 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4120 obj = std::move(ret);
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*>());
4165 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4168 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4171 template <
typename BasicJsonType,
class A1,
class A2 >
4174 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4175 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4178 template<
typename BasicJsonType,
typename A1,
typename A2>
4184 template<
typename BasicJsonType,
typename... Args>
4190 template<
typename BasicJsonType,
typename... Args>
4196 template<
typename BasicJsonType,
typename TupleRelated>
4208 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4210 typename BasicJsonType::string_t, Key >::value >>
4211 void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4218 for (
const auto& p : j)
4224 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4228 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4230 typename BasicJsonType::string_t, Key >::value >>
4231 void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4238 for (
const auto& p : j)
4244 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4250 template<
typename BasicJsonType,
typename T>
4252 noexcept(noexcept(
from_json(j, std::forward<T>(val))))
4253 -> decltype(
from_json(j, std::forward<T>(val)))
4255 return from_json(j, std::forward<T>(val));
4272 #include <algorithm> 4276 #include <type_traits> 4299 template<
typename string_type>
4314 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::
type >::
type;
4320 std::size_t array_index = 0;
4322 mutable std::size_t array_index_last = 0;
4330 : anchor(std::move(it))
4351 return anchor == o.
anchor;
4357 return anchor != o.
anchor;
4365 switch (anchor.m_object->type())
4370 if (array_index != array_index_last)
4373 array_index_last = array_index;
4375 return array_index_str;
4380 return anchor.key();
4389 typename IteratorType::reference
value()
const 4391 return anchor.value();
4405 : container(cont) {}
4422 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4430 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4444 #if defined(__clang__) 4446 #pragma clang diagnostic push 4447 #pragma clang diagnostic ignored "-Wmismatched-tags" 4449 template<
typename IteratorType>
4451 :
public std::integral_constant<std::size_t, 2> {};
4453 template<std::
size_t N,
typename IteratorType>
4457 using type = decltype(
4458 get<N>(std::declval <
4461 #if defined(__clang__) 4462 #pragma clang diagnostic pop 4486 template<
typename BasicJsonType>
4487 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b) noexcept
4491 j.assert_invariant();
4498 template<
typename BasicJsonType>
4499 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4503 j.assert_invariant();
4506 template<
typename BasicJsonType>
4507 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4510 j.m_value = std::move(s);
4511 j.assert_invariant();
4514 template <
typename BasicJsonType,
typename CompatibleStringType,
4517 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4520 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4521 j.assert_invariant();
4528 template<
typename BasicJsonType>
4529 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4532 j.m_value =
typename BasicJsonType::binary_t(b);
4533 j.assert_invariant();
4536 template<
typename BasicJsonType>
4537 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4540 j.m_value =
typename BasicJsonType::binary_t(std::move(b));;
4541 j.assert_invariant();
4548 template<
typename BasicJsonType>
4549 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val) noexcept
4553 j.assert_invariant();
4560 template<
typename BasicJsonType>
4561 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val) noexcept
4565 j.assert_invariant();
4572 template<
typename BasicJsonType>
4573 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val) noexcept
4577 j.assert_invariant();
4584 template<
typename BasicJsonType>
4585 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4590 j.assert_invariant();
4593 template<
typename BasicJsonType>
4594 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4597 j.m_value = std::move(arr);
4599 j.assert_invariant();
4602 template <
typename BasicJsonType,
typename CompatibleArrayType,
4605 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4610 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4612 j.assert_invariant();
4615 template<
typename BasicJsonType>
4616 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4620 j.m_value.array->reserve(arr.size());
4621 for (
const bool x : arr)
4623 j.m_value.array->push_back(x);
4624 j.set_parent(j.m_value.array->back());
4626 j.assert_invariant();
4629 template<
typename BasicJsonType,
typename T,
4631 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4635 j.m_value.array->resize(arr.size());
4638 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4641 j.assert_invariant();
4648 template<
typename BasicJsonType>
4649 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
4654 j.assert_invariant();
4657 template<
typename BasicJsonType>
4658 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4661 j.m_value = std::move(obj);
4663 j.assert_invariant();
4666 template <
typename BasicJsonType,
typename CompatibleObjectType,
4668 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
4674 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4676 j.assert_invariant();
4684 template<
typename BasicJsonType,
typename T,
4691 template<
typename BasicJsonType,
typename CompatibleString,
4693 void to_json(BasicJsonType& j,
const CompatibleString& s)
4698 template<
typename BasicJsonType>
4699 void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4704 template<
typename BasicJsonType,
typename FloatType,
4706 void to_json(BasicJsonType& j, FloatType val) noexcept
4711 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
4713 void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
4718 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
4720 void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
4725 template<
typename BasicJsonType,
typename EnumType,
4726 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4727 void to_json(BasicJsonType& j, EnumType e) noexcept
4729 using underlying_type =
typename std::underlying_type<EnumType>::type;
4733 template<
typename BasicJsonType>
4734 void to_json(BasicJsonType& j,
const std::vector<bool>& e)
4739 template <
typename BasicJsonType,
typename CompatibleArrayType,
4741 CompatibleArrayType>::value&&
4744 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4747 void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
4752 template<
typename BasicJsonType>
4753 void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
4758 template<
typename BasicJsonType,
typename T,
4760 void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
4765 template<
typename BasicJsonType>
4766 void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4771 template <
typename BasicJsonType,
typename CompatibleObjectType,
4773 void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
4778 template<
typename BasicJsonType>
4779 void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4785 typename BasicJsonType,
typename T, std::size_t N,
4786 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
4794 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
4795 void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
4797 j = { p.first, p.second };
4801 template<
typename BasicJsonType,
typename T,
4805 j = { {b.key(), b.value()} };
4808 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
4811 j = { std::get<Idx>(t)... };
4815 void to_json(BasicJsonType& j,
const T& t)
4822 template<
typename BasicJsonType,
typename T>
4823 auto operator()(BasicJsonType& j, T&& val)
const noexcept(noexcept(
to_json(j, std::forward<T>(val))))
4824 -> decltype(
to_json(j, std::forward<T>(val)),
void())
4826 return to_json(j, std::forward<T>(val));
4848 template<
typename ValueType,
typename>
4862 template<
typename BasicJsonType,
typename TargetType = ValueType>
4863 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
4882 template<
typename BasicJsonType,
typename TargetType = ValueType>
4899 template<
typename BasicJsonType,
typename TargetType = ValueType>
4900 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
4932 template<
typename BinaryType>
4953 , m_subtype(subtype_)
4954 , m_has_subtype(true)
4959 , m_subtype(subtype_)
4960 , m_has_subtype(true)
4965 return std::tie(static_cast<const BinaryType&>(*
this), m_subtype, m_has_subtype) ==
4971 return !(rhs == *
this);
4994 m_subtype = subtype_;
4995 m_has_subtype =
true;
5042 return m_has_subtype;
5067 m_has_subtype =
false;
5071 std::uint8_t m_subtype = 0;
5072 bool m_has_subtype =
false;
5088 #include <functional> 5099 inline std::size_t
combine(std::size_t seed, std::size_t h) noexcept
5101 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5116 template<
typename BasicJsonType>
5117 std::size_t
hash(
const BasicJsonType& j)
5119 using string_t =
typename BasicJsonType::string_t;
5120 using number_integer_t =
typename BasicJsonType::number_integer_t;
5121 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5122 using number_float_t =
typename BasicJsonType::number_float_t;
5124 const auto type =
static_cast<std::size_t
>(j.type());
5127 case BasicJsonType::value_t::null:
5128 case BasicJsonType::value_t::discarded:
5133 case BasicJsonType::value_t::object:
5136 for (
const auto& element : j.items())
5138 const auto h = std::hash<string_t> {}(element.key());
5145 case BasicJsonType::value_t::array:
5148 for (
const auto& element : j)
5155 case BasicJsonType::value_t::string:
5157 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5161 case BasicJsonType::value_t::boolean:
5163 const auto h = std::hash<bool> {}(j.template get<bool>());
5167 case BasicJsonType::value_t::number_integer:
5169 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5173 case BasicJsonType::value_t::number_unsigned:
5175 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5179 case BasicJsonType::value_t::number_float:
5181 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5185 case BasicJsonType::value_t::binary:
5188 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5190 seed =
combine(seed, j.get_binary().subtype());
5191 for (
const auto byte : j.get_binary())
5193 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
5210 #include <algorithm> 5237 #include <type_traits> 5279 return std::fgetc(m_file);
5308 is->clear(is->rdstate() & std::ios::eofbit);
5313 : is(&i), sb(i.rdbuf())
5322 : is(rhs.is), sb(rhs.sb)
5333 auto res = sb->sbumpc();
5337 is->clear(is->rdstate() | std::ios::eofbit);
5344 std::istream* is =
nullptr;
5345 std::streambuf* sb =
nullptr;
5350 template<
typename IteratorType>
5354 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5357 : current(
std::move(first)), end(
std::move(last))
5364 auto result = std::char_traits<char_type>::to_int_type(*current);
5365 std::advance(current, 1);
5369 return std::char_traits<char_type>::eof();
5376 template<
typename BaseInputAdapter,
size_t T>
5381 return current == end;
5386 template<
typename BaseInputAdapter,
size_t T>
5389 template<
typename BaseInputAdapter>
5394 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5395 size_t& utf8_bytes_index,
5396 size_t& utf8_bytes_filled)
5398 utf8_bytes_index = 0;
5402 utf8_bytes[0] = std::char_traits<char>::eof();
5403 utf8_bytes_filled = 1;
5408 const auto wc = input.get_character();
5413 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5414 utf8_bytes_filled = 1;
5416 else if (wc <= 0x7FF)
5418 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5419 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5420 utf8_bytes_filled = 2;
5422 else if (wc <= 0xFFFF)
5424 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5425 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5426 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5427 utf8_bytes_filled = 3;
5429 else if (wc <= 0x10FFFF)
5431 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5432 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5433 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5434 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5435 utf8_bytes_filled = 4;
5440 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5441 utf8_bytes_filled = 1;
5447 template<
typename BaseInputAdapter>
5452 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5453 size_t& utf8_bytes_index,
5454 size_t& utf8_bytes_filled)
5456 utf8_bytes_index = 0;
5460 utf8_bytes[0] = std::char_traits<char>::eof();
5461 utf8_bytes_filled = 1;
5466 const auto wc = input.get_character();
5471 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5472 utf8_bytes_filled = 1;
5474 else if (wc <= 0x7FF)
5476 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5477 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5478 utf8_bytes_filled = 2;
5480 else if (0xD800 > wc || wc >= 0xE000)
5482 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5483 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5484 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5485 utf8_bytes_filled = 3;
5491 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5492 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5493 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5494 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5495 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5496 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5497 utf8_bytes_filled = 4;
5501 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5502 utf8_bytes_filled = 1;
5510 template<
typename BaseInputAdapter,
typename W
ideCharType>
5517 : base_adapter(base) {}
5522 if (utf8_bytes_index == utf8_bytes_filled)
5524 fill_buffer<sizeof(WideCharType)>();
5532 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
5533 return utf8_bytes[utf8_bytes_index++];
5546 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
5549 std::size_t utf8_bytes_index = 0;
5551 std::size_t utf8_bytes_filled = 0;
5555 template<
typename IteratorType,
typename Enable =
void>
5559 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5564 return adapter_type(std::move(first), std::move(last));
5568 template<
typename T>
5578 template<
typename IteratorType>
5582 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5593 template<
typename IteratorType>
5597 return factory_type::create(first, last);
5604 namespace container_input_adapter_factory_impl
5610 template<
typename ContainerType,
typename Enable =
void>
5613 template<
typename ContainerType>
5615 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5627 template<
typename ContainerType>
5652 template <
typename CharT,
5653 typename std::enable_if <
5654 std::is_pointer<CharT>::value&&
5655 !std::is_array<CharT>::value&&
5656 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5657 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5661 auto length = std::strlen(reinterpret_cast<const char*>(b));
5662 const auto* ptr =
reinterpret_cast<const char*
>(b);
5666 template<
typename T, std::
size_t N>
5678 template <
typename CharT,
5679 typename std::enable_if <
5680 std::is_pointer<CharT>::value&&
5681 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5682 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5685 : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
5687 template<
class IteratorType,
5688 typename std::enable_if<
5689 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
5696 return std::move(ia);
5729 template<
typename BasicJsonType>
5742 virtual bool null() = 0;
5749 virtual bool boolean(
bool val) = 0;
5795 virtual bool start_object(std::size_t elements) = 0;
5809 virtual bool end_object() = 0;
5817 virtual bool start_array(std::size_t elements) = 0;
5823 virtual bool end_array() = 0;
5832 virtual bool parse_error(std::size_t position,
5860 template<
typename BasicJsonType>
5876 : root(r), allow_exceptions(allow_exceptions_)
5888 handle_value(
nullptr);
5924 handle_value(std::move(val));
5930 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
5943 object_element = &(ref_stack.back()->m_value.object->operator[](val));
5949 ref_stack.back()->set_parents();
5950 ref_stack.pop_back();
5956 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
5968 ref_stack.back()->set_parents();
5969 ref_stack.pop_back();
5973 template<
class Exception>
5975 const Exception& ex)
5978 static_cast<void>(ex);
5979 if (allow_exceptions)
5998 template<
typename Value>
6002 if (ref_stack.empty())
6004 root = BasicJsonType(std::forward<Value>(v));
6008 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6010 if (ref_stack.back()->is_array())
6012 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6013 return &(ref_stack.back()->m_value.array->back());
6018 *object_element = BasicJsonType(std::forward<Value>(v));
6019 return object_element;
6025 std::vector<BasicJsonType*> ref_stack {};
6027 BasicJsonType* object_element =
nullptr;
6029 bool errored =
false;
6031 const bool allow_exceptions =
true;
6034 template<
typename BasicJsonType>
6048 const bool allow_exceptions_ =
true)
6049 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6051 keep_stack.push_back(
true);
6063 handle_value(
nullptr);
6099 handle_value(std::move(val));
6107 keep_stack.push_back(keep);
6109 auto val = handle_value(BasicJsonType::value_t::object,
true);
6110 ref_stack.push_back(val.second);
6113 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6123 BasicJsonType k = BasicJsonType(val);
6126 const bool keep = callback(static_cast<int>(ref_stack.size()),
parse_event_t::key, k);
6127 key_keep_stack.push_back(keep);
6130 if (keep && ref_stack.back())
6132 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6140 if (ref_stack.back())
6149 ref_stack.back()->set_parents();
6155 ref_stack.pop_back();
6156 keep_stack.pop_back();
6158 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6161 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6163 if (it->is_discarded())
6165 ref_stack.back()->erase(it);
6177 keep_stack.push_back(keep);
6179 auto val = handle_value(BasicJsonType::value_t::array,
true);
6180 ref_stack.push_back(val.second);
6183 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6195 if (ref_stack.back())
6200 ref_stack.back()->set_parents();
6211 ref_stack.pop_back();
6212 keep_stack.pop_back();
6215 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6217 ref_stack.back()->m_value.array->pop_back();
6223 template<
class Exception>
6225 const Exception& ex)
6228 static_cast<void>(ex);
6229 if (allow_exceptions)
6257 template<
typename Value>
6258 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
6264 if (!keep_stack.back())
6266 return {
false,
nullptr};
6270 auto value = BasicJsonType(std::forward<Value>(v));
6278 return {
false,
nullptr};
6281 if (ref_stack.empty())
6283 root = std::move(
value);
6284 return {
true, &root};
6289 if (!ref_stack.back())
6291 return {
false,
nullptr};
6295 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6298 if (ref_stack.back()->is_array())
6300 ref_stack.back()->m_value.array->emplace_back(std::move(
value));
6301 return {
true, &(ref_stack.back()->m_value.array->back())};
6308 const bool store_element = key_keep_stack.back();
6309 key_keep_stack.pop_back();
6313 return {
false,
nullptr};
6317 *object_element = std::move(
value);
6318 return {
true, object_element};
6324 std::vector<BasicJsonType*> ref_stack {};
6326 std::vector<bool> keep_stack {};
6328 std::vector<bool> key_keep_stack {};
6330 BasicJsonType* object_element =
nullptr;
6332 bool errored =
false;
6336 const bool allow_exceptions =
true;
6338 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6341 template<
typename BasicJsonType>
6428 #include <initializer_list> 6448 template<
typename BasicJsonType>
6481 case token_type::uninitialized:
6482 return "<uninitialized>";
6483 case token_type::literal_true:
6484 return "true literal";
6485 case token_type::literal_false:
6486 return "false literal";
6487 case token_type::literal_null:
6488 return "null literal";
6489 case token_type::value_string:
6490 return "string literal";
6491 case token_type::value_unsigned:
6492 case token_type::value_integer:
6493 case token_type::value_float:
6494 return "number literal";
6495 case token_type::begin_array:
6497 case token_type::begin_object:
6499 case token_type::end_array:
6501 case token_type::end_object:
6503 case token_type::name_separator:
6505 case token_type::value_separator:
6507 case token_type::parse_error:
6508 return "<parse error>";
6509 case token_type::end_of_input:
6510 return "end of input";
6511 case token_type::literal_or_value:
6512 return "'[', '{', or a literal";
6515 return "unknown token";
6525 template<
typename BasicJsonType,
typename InputAdapterType>
6538 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6539 : ia(
std::move(adapter))
6540 , ignore_comments(ignore_comments_)
6541 , decimal_point_char(static_cast<
char_int_type>(get_decimal_point()))
6560 const auto* loc = localeconv();
6562 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6590 const auto factors = { 12u, 8u, 4u, 0u };
6591 for (
const auto factor : factors)
6595 if (current >=
'0' && current <=
'9')
6597 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
6599 else if (current >=
'A' && current <=
'F')
6601 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
6603 else if (current >=
'a' && current <=
'f')
6605 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
6613 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6634 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6637 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6646 error_message =
"invalid string: ill-formed UTF-8 byte";
6683 case std::char_traits<char_type>::eof():
6685 error_message =
"invalid string: missing closing quote";
6686 return token_type::parse_error;
6692 return token_type::value_string;
6736 const int codepoint1 = get_codepoint();
6737 int codepoint = codepoint1;
6741 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6742 return token_type::parse_error;
6746 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6751 const int codepoint2 = get_codepoint();
6755 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6756 return token_type::parse_error;
6763 codepoint =
static_cast<int>(
6765 (
static_cast<unsigned int>(codepoint1) << 10u)
6767 +
static_cast<unsigned int>(codepoint2)
6775 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6776 return token_type::parse_error;
6781 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6782 return token_type::parse_error;
6789 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6790 return token_type::parse_error;
6795 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
6798 if (codepoint < 0x80)
6801 add(static_cast<char_int_type>(codepoint));
6803 else if (codepoint <= 0x7FF)
6806 add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
6807 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6809 else if (codepoint <= 0xFFFF)
6812 add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
6813 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6814 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6819 add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
6820 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
6821 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6822 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
6830 error_message =
"invalid string: forbidden character after backslash";
6831 return token_type::parse_error;
6840 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6841 return token_type::parse_error;
6846 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6847 return token_type::parse_error;
6852 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6853 return token_type::parse_error;
6858 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6859 return token_type::parse_error;
6864 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6865 return token_type::parse_error;
6870 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6871 return token_type::parse_error;
6876 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6877 return token_type::parse_error;
6882 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6883 return token_type::parse_error;
6888 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6889 return token_type::parse_error;
6894 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6895 return token_type::parse_error;
6900 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6901 return token_type::parse_error;
6906 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
6907 return token_type::parse_error;
6912 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
6913 return token_type::parse_error;
6918 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
6919 return token_type::parse_error;
6924 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
6925 return token_type::parse_error;
6930 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
6931 return token_type::parse_error;
6936 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
6937 return token_type::parse_error;
6942 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
6943 return token_type::parse_error;
6948 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
6949 return token_type::parse_error;
6954 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
6955 return token_type::parse_error;
6960 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
6961 return token_type::parse_error;
6966 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
6967 return token_type::parse_error;
6972 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
6973 return token_type::parse_error;
6978 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
6979 return token_type::parse_error;
6984 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
6985 return token_type::parse_error;
6990 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
6991 return token_type::parse_error;
6996 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
6997 return token_type::parse_error;
7002 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7003 return token_type::parse_error;
7008 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7009 return token_type::parse_error;
7014 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7015 return token_type::parse_error;
7020 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7021 return token_type::parse_error;
7026 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7027 return token_type::parse_error;
7164 return token_type::parse_error;
7174 return token_type::parse_error;
7198 return token_type::parse_error;
7208 return token_type::parse_error;
7218 return token_type::parse_error;
7230 return token_type::parse_error;
7240 return token_type::parse_error;
7248 error_message =
"invalid string: ill-formed UTF-8 byte";
7249 return token_type::parse_error;
7272 case std::char_traits<char_type>::eof():
7289 case std::char_traits<char_type>::eof():
7292 error_message =
"invalid comment; missing closing '*/'";
7320 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7327 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7329 f = std::strtof(str, endptr);
7333 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7335 f = std::strtod(str, endptr);
7339 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7341 f = std::strtold(str, endptr);
7391 token_type number_type = token_type::value_unsigned;
7399 goto scan_number_minus;
7405 goto scan_number_zero;
7419 goto scan_number_any1;
7429 number_type = token_type::value_integer;
7435 goto scan_number_zero;
7449 goto scan_number_any1;
7454 error_message =
"invalid number; expected digit after '-'";
7455 return token_type::parse_error;
7465 add(decimal_point_char);
7466 goto scan_number_decimal1;
7473 goto scan_number_exponent;
7477 goto scan_number_done;
7496 goto scan_number_any1;
7501 add(decimal_point_char);
7502 goto scan_number_decimal1;
7509 goto scan_number_exponent;
7513 goto scan_number_done;
7516 scan_number_decimal1:
7518 number_type = token_type::value_float;
7533 goto scan_number_decimal2;
7538 error_message =
"invalid number; expected digit after '.'";
7539 return token_type::parse_error;
7543 scan_number_decimal2:
7559 goto scan_number_decimal2;
7566 goto scan_number_exponent;
7570 goto scan_number_done;
7573 scan_number_exponent:
7575 number_type = token_type::value_float;
7582 goto scan_number_sign;
7597 goto scan_number_any2;
7603 "invalid number; expected '+', '-', or digit after exponent";
7604 return token_type::parse_error;
7624 goto scan_number_any2;
7629 error_message =
"invalid number; expected digit after exponent sign";
7630 return token_type::parse_error;
7650 goto scan_number_any2;
7654 goto scan_number_done;
7662 char* endptr =
nullptr;
7666 if (number_type == token_type::value_unsigned)
7668 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
7671 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7676 if (value_unsigned == x)
7678 return token_type::value_unsigned;
7682 else if (number_type == token_type::value_integer)
7684 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
7687 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7692 if (value_integer == x)
7694 return token_type::value_integer;
7701 strtof(value_float, token_buffer.data(), &endptr);
7704 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7706 return token_type::value_float;
7718 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
7719 for (std::size_t i = 1; i < length; ++i)
7723 error_message =
"invalid literal";
7724 return token_type::parse_error;
7737 token_buffer.clear();
7738 token_string.clear();
7739 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7754 ++position.chars_read_total;
7755 ++position.chars_read_current_line;
7764 current = ia.get_character();
7769 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7772 if (current ==
'\n')
7774 ++position.lines_read;
7775 position.chars_read_current_line = 0;
7793 --position.chars_read_total;
7796 if (position.chars_read_current_line == 0)
7798 if (position.lines_read > 0)
7800 --position.lines_read;
7805 --position.chars_read_current_line;
7811 token_string.pop_back();
7818 token_buffer.push_back(static_cast<typename string_t::value_type>(c));
7829 return value_integer;
7835 return value_unsigned;
7847 return token_buffer;
7867 for (
const auto c : token_string)
7869 if (static_cast<unsigned char>(c) <=
'\x1F')
7872 std::array<char, 9> cs{{}};
7873 (std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c));
7874 result += cs.data();
7879 result.push_back(static_cast<std::string::value_type>(c));
7890 return error_message;
7906 return get() == 0xBB &&
get() == 0xBF;
7921 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
7927 if (position.chars_read_total == 0 && !skip_bom())
7929 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
7930 return token_type::parse_error;
7937 while (ignore_comments && current ==
'/')
7939 if (!scan_comment())
7941 return token_type::parse_error;
7952 return token_type::begin_array;
7954 return token_type::end_array;
7956 return token_type::begin_object;
7958 return token_type::end_object;
7960 return token_type::name_separator;
7962 return token_type::value_separator;
7968 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
7973 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
7978 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
7983 return scan_string();
7997 return scan_number();
8002 case std::char_traits<char_type>::eof():
8003 return token_type::end_of_input;
8007 error_message =
"invalid literal";
8008 return token_type::parse_error;
8017 const bool ignore_comments =
false;
8023 bool next_unget =
false;
8029 std::vector<char_type> token_string {};
8035 const char* error_message =
"";
8066 template<
typename T>
8069 template<
typename T>
8071 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
8073 template<
typename T,
typename Integer>
8077 template<
typename T,
typename Un
signed>
8081 template<
typename T,
typename Float,
typename String>
8083 std::declval<Float>(), std::declval<const String&>()));
8085 template<
typename T,
typename String>
8087 decltype(std::declval<T&>().
string(std::declval<String&>()));
8089 template<
typename T,
typename Binary>
8091 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
8093 template<
typename T>
8095 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8097 template<
typename T,
typename String>
8099 decltype(std::declval<T&>().
key(std::declval<String&>()));
8101 template<
typename T>
8104 template<
typename T>
8106 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8108 template<
typename T>
8111 template<
typename T,
typename Exception>
8113 std::declval<std::size_t>(), std::declval<const std::string&>(),
8114 std::declval<const Exception&>()));
8116 template<
typename SAX,
typename BasicJsonType>
8121 "BasicJsonType must be of type basic_json<...>");
8147 template<
typename SAX,
typename BasicJsonType>
8152 "BasicJsonType must be of type basic_json<...>");
8163 "Missing/invalid function: bool null()");
8165 "Missing/invalid function: bool boolean(bool)");
8167 "Missing/invalid function: bool boolean(bool)");
8171 "Missing/invalid function: bool number_integer(number_integer_t)");
8175 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8178 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8181 "Missing/invalid function: bool string(string_t&)");
8184 "Missing/invalid function: bool binary(binary_t&)");
8186 "Missing/invalid function: bool start_object(std::size_t)");
8188 "Missing/invalid function: bool key(string_t&)");
8190 "Missing/invalid function: bool end_object()");
8192 "Missing/invalid function: bool start_array(std::size_t)");
8194 "Missing/invalid function: bool end_array()");
8197 "Missing/invalid function: bool parse_error(std::size_t, const " 8198 "std::string&, const exception&)");
8227 return *
reinterpret_cast<char*
>(&num) == 1;
8238 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8256 explicit binary_reader(InputAdapterType&& adapter) noexcept : ia(std::move(adapter))
8279 const
bool strict = true,
8283 bool result =
false;
8288 result = parse_bson_internal();
8292 result = parse_cbor_internal(
true, tag_handler);
8296 result = parse_msgpack_internal();
8300 result = parse_ubjson_internal();
8321 return sax->parse_error(chars_read, get_token_string(),
8322 parse_error::create(110, chars_read, exception_message(format,
"expected end of input; last byte: 0x" + get_token_string(),
"value"), BasicJsonType()));
8340 std::int32_t document_size{};
8353 return sax->end_object();
8365 auto out = std::back_inserter(result);
8373 if (current == 0x00)
8377 *out++ =
static_cast<typename string_t::value_type
>(current);
8392 template<
typename NumberType>
8397 auto last_token = get_token_string();
8401 return get_string(
input_format_t::bson, len - static_cast<NumberType>(1), result) &&
get() != std::char_traits<char_type>::eof();
8413 template<
typename NumberType>
8418 auto last_token = get_token_string();
8423 std::uint8_t subtype{};
8425 result.set_subtype(subtype);
8427 return get_binary(input_format_t::bson, len, result);
8441 const std::size_t element_type_parse_position)
8443 switch (element_type)
8448 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number),
"");
8455 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
8460 return parse_bson_internal();
8465 return parse_bson_array();
8472 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
8477 return sax->boolean(
get() != 0);
8487 std::int32_t
value{};
8493 std::int64_t
value{};
8499 std::array<char, 3> cr{{}};
8500 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type));
8501 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()));
8522 while (
auto element_type =
get())
8529 const std::size_t element_type_parse_position = chars_read;
8535 if (!is_array && !sax->key(key))
8540 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
8558 std::int32_t document_size{};
8571 return sax->end_array();
8589 switch (get_char ?
get() : current)
8592 case std::char_traits<char_type>::eof():
8620 return sax->number_unsigned(static_cast<number_unsigned_t>(current));
8624 std::uint8_t number{};
8630 std::uint16_t number{};
8636 std::uint32_t number{};
8642 std::uint64_t number{};
8671 return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
8675 std::uint8_t number{};
8676 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8681 std::uint16_t number{};
8682 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8687 std::uint32_t number{};
8688 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
8693 std::uint64_t number{};
8694 return get_number(
input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1)
8695 - static_cast<number_integer_t>(number));
8730 return get_cbor_binary(b) && sax->binary(b);
8765 return get_cbor_string(s) && sax->string(s);
8793 return get_cbor_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8798 return get_number(
input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8803 std::uint16_t len{};
8804 return get_number(
input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8809 std::uint32_t len{};
8810 return get_number(
input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8815 std::uint64_t len{};
8816 return get_number(
input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
8820 return get_cbor_array(std::size_t(-1), tag_handler);
8847 return get_cbor_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8852 return get_number(
input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8857 std::uint16_t len{};
8858 return get_number(
input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8863 std::uint32_t len{};
8864 return get_number(
input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8869 std::uint64_t len{};
8870 return get_number(
input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
8874 return get_cbor_object(std::size_t(-1), tag_handler);
8896 switch (tag_handler)
8900 auto last_token = get_token_string();
8916 std::uint16_t len{};
8922 std::uint32_t len{};
8928 std::uint64_t len{};
8935 return parse_cbor_internal(
true, tag_handler);
8945 return sax->boolean(
false);
8948 return sax->boolean(
true);
8955 const auto byte1_raw =
get();
8960 const auto byte2_raw =
get();
8966 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
8967 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
8977 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
8978 const double val = [&half]
8980 const int exp = (half >> 10u) & 0x1Fu;
8981 const unsigned int mant = half & 0x3FFu;
8987 return std::ldexp(mant, -24);
8990 ? std::numeric_limits<double>::infinity()
8991 : std::numeric_limits<double>::quiet_NaN();
8993 return std::ldexp(mant + 1024, exp - 25);
8996 return sax->number_float((half & 0x8000u) != 0
8997 ? static_cast<number_float_t>(-val)
8998 : static_cast<number_float_t>(val),
"");
9004 return get_number(
input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9010 return get_number(
input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9015 auto last_token = get_token_string();
9078 std::uint16_t len{};
9084 std::uint32_t len{};
9090 std::uint64_t len{};
9096 while (
get() != 0xFF)
9099 if (!get_cbor_string(chunk))
9103 result.append(chunk);
9110 auto last_token = get_token_string();
9111 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()));
9174 std::uint16_t len{};
9181 std::uint32_t len{};
9188 std::uint64_t len{};
9195 while (
get() != 0xFF)
9198 if (!get_cbor_binary(chunk))
9202 result.insert(result.end(), chunk.begin(), chunk.end());
9209 auto last_token = get_token_string();
9210 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()));
9229 if (len != std::size_t(-1))
9231 for (std::size_t i = 0; i < len; ++i)
9241 while (
get() != 0xFF)
9250 return sax->end_array();
9268 if (len != std::size_t(-1))
9270 for (std::size_t i = 0; i < len; ++i)
9287 while (
get() != 0xFF)
9302 return sax->end_object();
9317 case std::char_traits<char_type>::eof():
9449 return sax->number_unsigned(static_cast<number_unsigned_t>(current));
9468 return get_msgpack_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
9487 return get_msgpack_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
9527 return get_msgpack_string(s) && sax->string(s);
9534 return sax->boolean(
false);
9537 return sax->boolean(
true);
9552 return get_msgpack_binary(b) && sax->binary(b);
9558 return get_number(
input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9564 return get_number(
input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number),
"");
9569 std::uint8_t number{};
9575 std::uint16_t number{};
9581 std::uint32_t number{};
9587 std::uint64_t number{};
9593 std::int8_t number{};
9599 std::int16_t number{};
9605 std::int32_t number{};
9611 std::int64_t number{};
9617 std::uint16_t len{};
9623 std::uint32_t len{};
9629 std::uint16_t len{};
9635 std::uint32_t len{};
9672 return sax->number_integer(static_cast<std::int8_t>(current));
9676 auto last_token = get_token_string();
9746 std::uint16_t len{};
9752 std::uint32_t len{};
9758 auto last_token = get_token_string();
9759 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()));
9777 auto assign_and_return_true = [&result](std::int8_t subtype)
9779 result.set_subtype(static_cast<std::uint8_t>(subtype));
9794 std::uint16_t len{};
9801 std::uint32_t len{};
9809 std::int8_t subtype{};
9813 assign_and_return_true(subtype);
9818 std::uint16_t len{};
9819 std::int8_t subtype{};
9823 assign_and_return_true(subtype);
9828 std::uint32_t len{};
9829 std::int8_t subtype{};
9833 assign_and_return_true(subtype);
9838 std::int8_t subtype{};
9841 assign_and_return_true(subtype);
9846 std::int8_t subtype{};
9849 assign_and_return_true(subtype);
9854 std::int8_t subtype{};
9857 assign_and_return_true(subtype);
9862 std::int8_t subtype{};
9865 assign_and_return_true(subtype);
9870 std::int8_t subtype{};
9873 assign_and_return_true(subtype);
9892 for (std::size_t i = 0; i < len; ++i)
9900 return sax->end_array();
9915 for (std::size_t i = 0; i < len; ++i)
9930 return sax->end_object();
9946 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10003 std::int64_t len{};
10008 auto last_token = get_token_string();
10009 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()));
10019 switch (get_ignore_noop())
10023 std::uint8_t number{};
10028 result =
static_cast<std::size_t
>(number);
10034 std::int8_t number{};
10039 result =
static_cast<std::size_t
>(number);
10045 std::int16_t number{};
10050 result =
static_cast<std::size_t
>(number);
10056 std::int32_t number{};
10061 result =
static_cast<std::size_t
>(number);
10067 std::int64_t number{};
10072 result =
static_cast<std::size_t
>(number);
10078 auto last_token = get_token_string();
10079 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()));
10096 result.first = string_t::npos;
10101 if (current ==
'$')
10103 result.second =
get();
10116 auto last_token = get_token_string();
10117 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()));
10120 return get_ubjson_size_value(result.first);
10123 if (current ==
'#')
10125 return get_ubjson_size_value(result.first);
10139 case std::char_traits<char_type>::eof():
10143 return sax->boolean(
true);
10145 return sax->boolean(
false);
10148 return sax->null();
10152 std::uint8_t number{};
10158 std::int8_t number{};
10164 std::int16_t number{};
10170 std::int32_t number{};
10176 std::int64_t number{};
10183 return get_number(
input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number),
"");
10189 return get_number(
input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number),
"");
10194 return get_ubjson_high_precision_number();
10206 auto last_token = get_token_string();
10207 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()));
10209 string_t s(1, static_cast<typename string_t::value_type>(current));
10210 return sax->string(s);
10216 return get_ubjson_string(s) && sax->string(s);
10220 return get_ubjson_array();
10223 return get_ubjson_object();
10227 auto last_token = get_token_string();
10238 std::pair<std::size_t, char_int_type> size_and_type;
10244 if (size_and_type.first != string_t::npos)
10251 if (size_and_type.second != 0)
10253 if (size_and_type.second !=
'N')
10255 for (std::size_t i = 0; i < size_and_type.first; ++i)
10266 for (std::size_t i = 0; i < size_and_type.first; ++i)
10282 while (current !=
']')
10292 return sax->end_array();
10300 std::pair<std::size_t, char_int_type> size_and_type;
10307 if (size_and_type.first != string_t::npos)
10314 if (size_and_type.second != 0)
10316 for (std::size_t i = 0; i < size_and_type.first; ++i)
10331 for (std::size_t i = 0; i < size_and_type.first; ++i)
10352 while (current !=
'}')
10367 return sax->end_object();
10376 std::size_t size{};
10377 auto res = get_ubjson_size_value(size);
10384 std::vector<char> number_vector;
10385 for (std::size_t i = 0; i < size; ++i)
10392 number_vector.push_back(static_cast<char>(current));
10398 const auto result_number = number_lexer.
scan();
10399 const auto number_string = number_lexer.get_token_string();
10400 const auto result_remainder = number_lexer.scan();
10406 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()));
10409 switch (result_number)
10411 case token_type::value_integer:
10412 return sax->number_integer(number_lexer.get_number_integer());
10413 case token_type::value_unsigned:
10414 return sax->number_unsigned(number_lexer.get_number_unsigned());
10415 case token_type::value_float:
10416 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
10418 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()));
10438 return current = ia.get_character();
10450 while (current ==
'N');
10468 template<
typename NumberType,
bool InputIsLittleEndian = false>
10472 std::array<std::uint8_t, sizeof(NumberType)> vec{};
10473 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
10482 if (is_little_endian != InputIsLittleEndian)
10484 vec[
sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
10488 vec[i] =
static_cast<std::uint8_t
>(current);
10493 std::memcpy(&result, vec.data(),
sizeof(NumberType));
10511 template<
typename NumberType>
10513 const NumberType len,
10516 bool success =
true;
10517 for (NumberType i = 0; i < len; i++)
10525 result.push_back(static_cast<typename string_t::value_type>(current));
10544 template<
typename NumberType>
10546 const NumberType len,
10549 bool success =
true;
10550 for (NumberType i = 0; i < len; i++)
10558 result.push_back(static_cast<std::uint8_t>(current));
10573 return sax->parse_error(chars_read,
"<end of file>",
10574 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context), BasicJsonType()));
10584 std::array<char, 3> cr{{}};
10585 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current));
10599 std::string error_msg =
"syntax error while parsing ";
10604 error_msg +=
"CBOR";
10608 error_msg +=
"MessagePack";
10612 error_msg +=
"UBJSON";
10616 error_msg +=
"BSON";
10623 return error_msg +
" " + context +
": " + detail;
10634 std::size_t chars_read = 0;
10654 #include <functional> 10698 template<
typename BasicJsonType>
10707 template<
typename BasicJsonType,
typename InputAdapterType>
10721 const bool allow_exceptions_ =
true,
10722 const bool skip_comments =
false)
10724 , m_lexer(
std::move(adapter), skip_comments)
10725 , allow_exceptions(allow_exceptions_)
10746 sax_parse_internal(&sdp);
10749 if (strict && (get_token() != token_type::end_of_input))
10752 m_lexer.get_token_string(),
10754 exception_message(token_type::end_of_input,
"value"), BasicJsonType()));
10766 if (result.is_discarded())
10774 sax_parse_internal(&sdp);
10777 if (strict && (get_token() != token_type::end_of_input))
10780 m_lexer.get_token_string(),
10781 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"), BasicJsonType()));
10792 result.assert_invariant();
10804 return sax_parse(&sax_acceptor,
strict);
10807 template<
typename SAX>
10809 bool sax_parse(SAX* sax, const
bool strict = true)
10812 const bool result = sax_parse_internal(sax);
10815 if (result &&
strict && (get_token() != token_type::end_of_input))
10817 return sax->parse_error(m_lexer.get_position(),
10818 m_lexer.get_token_string(),
10819 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"), BasicJsonType()));
10826 template<
typename SAX>
10828 bool sax_parse_internal(SAX* sax)
10832 std::vector<bool> states;
10834 bool skip_to_state_evaluation =
false;
10838 if (!skip_to_state_evaluation)
10841 switch (last_token)
10843 case token_type::begin_object:
10851 if (get_token() == token_type::end_object)
10863 return sax->parse_error(m_lexer.get_position(),
10864 m_lexer.get_token_string(),
10865 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"), BasicJsonType()));
10875 return sax->parse_error(m_lexer.get_position(),
10876 m_lexer.get_token_string(),
10877 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"), BasicJsonType()));
10881 states.push_back(
false);
10888 case token_type::begin_array:
10896 if (get_token() == token_type::end_array)
10906 states.push_back(
true);
10912 case token_type::value_float:
10914 const auto res = m_lexer.get_number_float();
10918 return sax->parse_error(m_lexer.get_position(),
10919 m_lexer.get_token_string(),
10920 out_of_range::create(406,
"number overflow parsing '" + m_lexer.get_token_string() +
"'", BasicJsonType()));
10931 case token_type::literal_false:
10940 case token_type::literal_null:
10949 case token_type::literal_true:
10958 case token_type::value_integer:
10967 case token_type::value_string:
10976 case token_type::value_unsigned:
10985 case token_type::parse_error:
10988 return sax->parse_error(m_lexer.get_position(),
10989 m_lexer.get_token_string(),
10990 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"), BasicJsonType()));
10995 return sax->parse_error(m_lexer.get_position(),
10996 m_lexer.get_token_string(),
10997 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"), BasicJsonType()));
11003 skip_to_state_evaluation =
false;
11007 if (states.empty())
11016 if (get_token() == token_type::value_separator)
11037 skip_to_state_evaluation =
true;
11041 return sax->parse_error(m_lexer.get_position(),
11042 m_lexer.get_token_string(),
11043 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"), BasicJsonType()));
11049 if (get_token() == token_type::value_separator)
11054 return sax->parse_error(m_lexer.get_position(),
11055 m_lexer.get_token_string(),
11056 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"), BasicJsonType()));
11067 return sax->parse_error(m_lexer.get_position(),
11068 m_lexer.get_token_string(),
11069 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"), BasicJsonType()));
11091 skip_to_state_evaluation =
true;
11095 return sax->parse_error(m_lexer.get_position(),
11096 m_lexer.get_token_string(),
11097 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"), BasicJsonType()));
11104 return last_token = m_lexer.scan();
11111 if (!context.empty())
11113 error_msg +=
"while parsing " + context +
" ";
11118 if (last_token == token_type::parse_error)
11120 error_msg +=
std::string(m_lexer.get_error_message()) +
"; last read: '" +
11121 m_lexer.get_token_string() +
"'";
11125 error_msg +=
"unexpected " +
std::string(lexer_t::token_type_name(last_token));
11128 if (expected != token_type::uninitialized)
11130 error_msg +=
"; expected " +
std::string(lexer_t::token_type_name(expected));
11144 const bool allow_exceptions =
true;
11195 m_it = begin_value;
11207 return m_it == begin_value;
11213 return m_it == end_value;
11218 return lhs.m_it == rhs.m_it;
11223 return lhs.m_it < rhs.m_it;
11228 auto result = *
this;
11235 return lhs.m_it - rhs.m_it;
11246 auto result = *
this;
11259 auto result = *
this;
11293 typename BasicJsonType::object_t::iterator object_iterator {};
11295 typename BasicJsonType::array_t::iterator array_iterator {};
11305 #include <iterator> 11306 #include <type_traits> 11347 template<
typename BasicJsonType>
11361 static_assert(
is_basic_json<
typename std::remove_const<BasicJsonType>::type>::
value,
11362 "iter_impl only accepts (const) basic_json");
11378 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
11379 typename BasicJsonType::const_pointer,
11380 typename BasicJsonType::pointer>::type;
11383 typename std::conditional<std::is_const<BasicJsonType>::value,
11384 typename BasicJsonType::const_reference,
11385 typename BasicJsonType::reference>::type;
11402 switch (m_object->m_type)
11406 m_it.object_iterator =
typename object_t::iterator();
11412 m_it.array_iterator =
typename array_t::iterator();
11441 : m_object(other.m_object), m_it(other.m_it)
11452 if (&other !=
this)
11454 m_object = other.m_object;
11466 : m_object(other.m_object), m_it(other.m_it)
11477 m_object = other.m_object;
11487 void set_begin() noexcept
11491 switch (m_object->m_type)
11495 m_it.object_iterator = m_object->m_value.object->begin();
11501 m_it.array_iterator = m_object->m_value.array->begin();
11508 m_it.primitive_iterator.set_end();
11514 m_it.primitive_iterator.set_begin();
11528 switch (m_object->m_type)
11532 m_it.object_iterator = m_object->m_value.object->end();
11538 m_it.array_iterator = m_object->m_value.array->end();
11544 m_it.primitive_iterator.set_end();
11559 switch (m_object->m_type)
11563 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
11564 return m_it.object_iterator->second;
11569 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
11570 return *m_it.array_iterator;
11596 switch (m_object->m_type)
11600 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
11601 return &(m_it.object_iterator->second);
11606 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
11607 return &*m_it.array_iterator;
11628 auto result = *
this;
11641 switch (m_object->m_type)
11645 std::advance(m_it.object_iterator, 1);
11651 std::advance(m_it.array_iterator, 1);
11657 ++m_it.primitive_iterator;
11671 auto result = *
this;
11684 switch (m_object->m_type)
11688 std::advance(m_it.object_iterator, -1);
11694 std::advance(m_it.array_iterator, -1);
11700 --m_it.primitive_iterator;
11712 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 >
11713 bool operator==(
const IterImpl& other)
const 11723 switch (m_object->m_type)
11726 return (m_it.object_iterator == other.m_it.object_iterator);
11729 return (m_it.array_iterator == other.m_it.array_iterator);
11732 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
11740 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 >
11741 bool operator!=(
const IterImpl& other)
const 11743 return !operator==(other);
11760 switch (m_object->m_type)
11779 return !other.operator < (*this);
11788 return !operator<=(other);
11808 switch (m_object->m_type)
11815 std::advance(m_it.array_iterator, i);
11821 m_it.primitive_iterator += i;
11835 return operator+=(-i);
11844 auto result = *
this;
11866 auto result = *
this;
11879 switch (m_object->m_type)
11900 switch (m_object->m_type)
11906 return *std::next(m_it.array_iterator, n);
11927 const typename object_t::key_type&
key()
const 11933 return m_it.object_iterator->first;
11945 return operator*();
11963 #include <iterator> 11992 template<
typename Base>
12060 return *(this->operator+(n));
12066 auto it = --this->base();
12073 auto it = --this->base();
12074 return it.operator * ();
12085 #include <algorithm> 12104 template<
typename BasicJsonType>
12134 : reference_tokens(split(s))
12153 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
12185 reference_tokens.insert(reference_tokens.end(),
12209 push_back(std::move(token));
12340 reference_tokens.pop_back();
12364 return reference_tokens.back();
12381 reference_tokens.push_back(token);
12387 reference_tokens.push_back(std::move(token));
12406 return reference_tokens.empty();
12422 using size_type =
typename BasicJsonType::size_type;
12436 std::size_t processed_chars = 0;
12437 unsigned long long res = 0;
12440 res = std::stoull(s, &processed_chars);
12455 if (res >= static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
12460 return static_cast<size_type
>(res);
12491 for (
const auto& reference_token : reference_tokens)
12493 switch (result->type())
12497 if (reference_token ==
"0")
12500 result = &result->operator[](0);
12505 result = &result->operator[](reference_token);
12513 result = &result->operator[](reference_token);
12520 result = &result->operator[](array_index(reference_token));
12559 for (
const auto& reference_token : reference_tokens)
12562 if (ptr->is_null())
12566 std::all_of(reference_token.begin(), reference_token.end(),
12567 [](
const unsigned char x)
12569 return std::isdigit(x);
12573 *ptr = (nums || reference_token ==
"-")
12578 switch (ptr->type())
12583 ptr = &ptr->operator[](reference_token);
12589 if (reference_token ==
"-")
12592 ptr = &ptr->operator[](ptr->m_value.array->size());
12597 ptr = &ptr->operator[](array_index(reference_token));
12618 for (
const auto& reference_token : reference_tokens)
12620 switch (ptr->type())
12625 ptr = &ptr->at(reference_token);
12635 "array index '-' (" +
std::to_string(ptr->m_value.array->size()) +
12636 ") is out of range", *ptr));
12640 ptr = &ptr->at(array_index(reference_token));
12667 for (
const auto& reference_token : reference_tokens)
12669 switch (ptr->type())
12674 ptr = &ptr->operator[](reference_token);
12687 ptr = &ptr->operator[](array_index(reference_token));
12707 for (
const auto& reference_token : reference_tokens)
12709 switch (ptr->type())
12714 ptr = &ptr->at(reference_token);
12724 "array index '-' (" +
std::to_string(ptr->m_value.array->size()) +
12725 ") is out of range", *ptr));
12729 ptr = &ptr->at(array_index(reference_token));
12747 for (
const auto& reference_token : reference_tokens)
12749 switch (ptr->type())
12753 if (!ptr->contains(reference_token))
12759 ptr = &ptr->operator[](reference_token);
12770 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
12782 for (std::size_t i = 1; i < reference_token.size(); i++)
12792 const auto idx = array_index(reference_token);
12793 if (idx >= ptr->size())
12799 ptr = &ptr->operator[](idx);
12827 std::vector<std::string> result;
12830 if (reference_string.empty())
12846 std::size_t slash = reference_string.find_first_of(
'/', 1),
12853 start = (slash == std::string::npos) ? 0 : slash + 1,
12855 slash = reference_string.find_first_of(
'/', start))
12859 auto reference_token = reference_string.substr(start, slash - start);
12862 for (std::size_t pos = reference_token.find_first_of(
'~');
12863 pos != std::string::npos;
12864 pos = reference_token.find_first_of(
'~', pos + 1))
12870 (reference_token[pos + 1] !=
'0' &&
12871 reference_token[pos + 1] !=
'1')))
12879 result.push_back(reference_token);
12894 const BasicJsonType&
value,
12895 BasicJsonType& result)
12897 switch (value.type())
12901 if (value.m_value.array->empty())
12904 result[reference_string] =
nullptr;
12909 for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
12912 value.m_value.array->operator[](i), result);
12920 if (value.m_value.object->empty())
12923 result[reference_string] =
nullptr;
12928 for (
const auto& element : *value.m_value.object)
12930 flatten(reference_string +
"/" +
detail::escape(element.first), element.second, result);
12939 result[reference_string] =
value;
12955 static BasicJsonType
12963 BasicJsonType result;
12966 for (
const auto& element : *value.m_value.object)
12997 return lhs.reference_tokens == rhs.reference_tokens;
13014 return !(lhs == rhs);
13025 #include <initializer_list> 13035 template<
typename BasicJsonType>
13046 : value_ref(&value)
13050 : owned_value(init)
13057 : owned_value(
std::forward<Args>(args)...)
13069 if (value_ref ==
nullptr)
13071 return std::move(owned_value);
13078 return value_ref ? *value_ref : owned_value;
13087 mutable value_type owned_value =
nullptr;
13088 value_type
const* value_ref =
nullptr;
13104 #include <algorithm> 13120 #include <algorithm> 13123 #include <iterator> 13138 virtual void write_character(CharType c) = 0;
13139 virtual void write_characters(
const CharType* s, std::size_t length) = 0;
13150 template<
typename CharType>
13154 template<
typename CharType>
13168 void write_characters(const CharType* s,
std::
size_t length)
override 13170 std::copy(s, s + length, std::back_inserter(v));
13174 std::vector<CharType>&
v;
13178 template<
typename CharType>
13192 void write_characters(const CharType* s,
std::
size_t length)
override 13194 stream.write(s, static_cast<std::streamsize>(length));
13202 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13216 void write_characters(const CharType* s,
std::
size_t length)
override 13218 str.append(s, length);
13225 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13261 template<
typename BasicJsonType,
typename CharType>
13289 write_bson_object(*j.m_value.object);
13309 oa->write_character(to_char_type(0xF6));
13315 oa->write_character(j.m_value.boolean
13316 ? to_char_type(0xF5)
13317 : to_char_type(0xF4));
13323 if (j.m_value.number_integer >= 0)
13328 if (j.m_value.number_integer <= 0x17)
13330 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13332 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
13334 oa->write_character(to_char_type(0x18));
13335 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13337 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
13339 oa->write_character(to_char_type(0x19));
13340 write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13342 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
13344 oa->write_character(to_char_type(0x1A));
13345 write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13349 oa->write_character(to_char_type(0x1B));
13350 write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
13357 const auto positive_number = -1 - j.m_value.number_integer;
13358 if (j.m_value.number_integer >= -24)
13360 write_number(static_cast<std::uint8_t>(0x20 + positive_number));
13362 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
13364 oa->write_character(to_char_type(0x38));
13365 write_number(static_cast<std::uint8_t>(positive_number));
13367 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
13369 oa->write_character(to_char_type(0x39));
13370 write_number(static_cast<std::uint16_t>(positive_number));
13372 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
13374 oa->write_character(to_char_type(0x3A));
13375 write_number(static_cast<std::uint32_t>(positive_number));
13379 oa->write_character(to_char_type(0x3B));
13380 write_number(static_cast<std::uint64_t>(positive_number));
13388 if (j.m_value.number_unsigned <= 0x17)
13390 write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
13392 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13394 oa->write_character(to_char_type(0x18));
13395 write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
13397 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13399 oa->write_character(to_char_type(0x19));
13400 write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
13402 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13404 oa->write_character(to_char_type(0x1A));
13405 write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
13409 oa->write_character(to_char_type(0x1B));
13410 write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
13417 if (std::isnan(j.m_value.number_float))
13420 oa->write_character(to_char_type(0xF9));
13421 oa->write_character(to_char_type(0x7E));
13422 oa->write_character(to_char_type(0x00));
13424 else if (std::isinf(j.m_value.number_float))
13427 oa->write_character(to_char_type(0xf9));
13428 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
13429 oa->write_character(to_char_type(0x00));
13441 const auto N = j.m_value.string->size();
13444 write_number(static_cast<std::uint8_t>(0x60 + N));
13446 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13448 oa->write_character(to_char_type(0x78));
13449 write_number(static_cast<std::uint8_t>(N));
13451 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13453 oa->write_character(to_char_type(0x79));
13454 write_number(static_cast<std::uint16_t>(N));
13456 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13458 oa->write_character(to_char_type(0x7A));
13459 write_number(static_cast<std::uint32_t>(N));
13462 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13464 oa->write_character(to_char_type(0x7B));
13465 write_number(static_cast<std::uint64_t>(N));
13470 oa->write_characters(
13471 reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
13472 j.m_value.string->size());
13479 const auto N = j.m_value.array->size();
13482 write_number(static_cast<std::uint8_t>(0x80 + N));
13484 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13486 oa->write_character(to_char_type(0x98));
13487 write_number(static_cast<std::uint8_t>(N));
13489 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13491 oa->write_character(to_char_type(0x99));
13492 write_number(static_cast<std::uint16_t>(N));
13494 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13496 oa->write_character(to_char_type(0x9A));
13497 write_number(static_cast<std::uint32_t>(N));
13500 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13502 oa->write_character(to_char_type(0x9B));
13503 write_number(static_cast<std::uint64_t>(N));
13508 for (
const auto& el : *j.m_value.array)
13517 if (j.m_value.binary->has_subtype())
13519 write_number(static_cast<std::uint8_t>(0xd8));
13520 write_number(j.m_value.binary->subtype());
13524 const auto N = j.m_value.binary->size();
13527 write_number(static_cast<std::uint8_t>(0x40 + N));
13529 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13531 oa->write_character(to_char_type(0x58));
13532 write_number(static_cast<std::uint8_t>(N));
13534 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13536 oa->write_character(to_char_type(0x59));
13537 write_number(static_cast<std::uint16_t>(N));
13539 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13541 oa->write_character(to_char_type(0x5A));
13542 write_number(static_cast<std::uint32_t>(N));
13545 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13547 oa->write_character(to_char_type(0x5B));
13548 write_number(static_cast<std::uint64_t>(N));
13553 oa->write_characters(
13554 reinterpret_cast<const CharType*>(j.m_value.binary->data()),
13563 const auto N = j.m_value.object->size();
13566 write_number(static_cast<std::uint8_t>(0xA0 + N));
13568 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13570 oa->write_character(to_char_type(0xB8));
13571 write_number(static_cast<std::uint8_t>(N));
13573 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13575 oa->write_character(to_char_type(0xB9));
13576 write_number(static_cast<std::uint16_t>(N));
13578 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13580 oa->write_character(to_char_type(0xBA));
13581 write_number(static_cast<std::uint32_t>(N));
13584 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13586 oa->write_character(to_char_type(0xBB));
13587 write_number(static_cast<std::uint64_t>(N));
13592 for (
const auto& el : *j.m_value.object)
13594 write_cbor(el.first);
13595 write_cbor(el.second);
13614 oa->write_character(to_char_type(0xC0));
13620 oa->write_character(j.m_value.boolean
13621 ? to_char_type(0xC3)
13622 : to_char_type(0xC2));
13628 if (j.m_value.number_integer >= 0)
13633 if (j.m_value.number_unsigned < 128)
13636 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13638 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13641 oa->write_character(to_char_type(0xCC));
13642 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13644 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13647 oa->write_character(to_char_type(0xCD));
13648 write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13650 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13653 oa->write_character(to_char_type(0xCE));
13654 write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13656 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13659 oa->write_character(to_char_type(0xCF));
13660 write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
13665 if (j.m_value.number_integer >= -32)
13668 write_number(static_cast<std::int8_t>(j.m_value.number_integer));
13670 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
13671 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13674 oa->write_character(to_char_type(0xD0));
13675 write_number(static_cast<std::int8_t>(j.m_value.number_integer));
13677 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
13678 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13681 oa->write_character(to_char_type(0xD1));
13682 write_number(static_cast<std::int16_t>(j.m_value.number_integer));
13684 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
13685 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13688 oa->write_character(to_char_type(0xD2));
13689 write_number(static_cast<std::int32_t>(j.m_value.number_integer));
13691 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
13692 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13695 oa->write_character(to_char_type(0xD3));
13696 write_number(static_cast<std::int64_t>(j.m_value.number_integer));
13704 if (j.m_value.number_unsigned < 128)
13707 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13709 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13712 oa->write_character(to_char_type(0xCC));
13713 write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
13715 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13718 oa->write_character(to_char_type(0xCD));
13719 write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
13721 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13724 oa->write_character(to_char_type(0xCE));
13725 write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
13727 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13730 oa->write_character(to_char_type(0xCF));
13731 write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
13745 const auto N = j.m_value.string->size();
13749 write_number(static_cast<std::uint8_t>(0xA0 | N));
13751 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13754 oa->write_character(to_char_type(0xD9));
13755 write_number(static_cast<std::uint8_t>(N));
13757 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13760 oa->write_character(to_char_type(0xDA));
13761 write_number(static_cast<std::uint16_t>(N));
13763 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13766 oa->write_character(to_char_type(0xDB));
13767 write_number(static_cast<std::uint32_t>(N));
13771 oa->write_characters(
13772 reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
13773 j.m_value.string->size());
13780 const auto N = j.m_value.array->size();
13784 write_number(static_cast<std::uint8_t>(0x90 | N));
13786 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13789 oa->write_character(to_char_type(0xDC));
13790 write_number(static_cast<std::uint16_t>(N));
13792 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13795 oa->write_character(to_char_type(0xDD));
13796 write_number(static_cast<std::uint32_t>(N));
13800 for (
const auto& el : *j.m_value.array)
13811 const bool use_ext = j.m_value.binary->has_subtype();
13814 const auto N = j.m_value.binary->size();
13815 if (N <= (std::numeric_limits<std::uint8_t>::max)())
13817 std::uint8_t output_type{};
13824 output_type = 0xD4;
13827 output_type = 0xD5;
13830 output_type = 0xD6;
13833 output_type = 0xD7;
13836 output_type = 0xD8;
13839 output_type = 0xC7;
13847 output_type = 0xC4;
13851 oa->write_character(to_char_type(output_type));
13854 write_number(static_cast<std::uint8_t>(N));
13857 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13859 std::uint8_t output_type = use_ext
13863 oa->write_character(to_char_type(output_type));
13864 write_number(static_cast<std::uint16_t>(N));
13866 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13868 std::uint8_t output_type = use_ext
13872 oa->write_character(to_char_type(output_type));
13873 write_number(static_cast<std::uint32_t>(N));
13879 write_number(static_cast<std::int8_t>(j.m_value.binary->subtype()));
13883 oa->write_characters(
13884 reinterpret_cast<const CharType*>(j.m_value.binary->data()),
13893 const auto N = j.m_value.object->size();
13897 write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
13899 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13902 oa->write_character(to_char_type(0xDE));
13903 write_number(static_cast<std::uint16_t>(N));
13905 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13908 oa->write_character(to_char_type(0xDF));
13909 write_number(static_cast<std::uint32_t>(N));
13913 for (
const auto& el : *j.m_value.object)
13915 write_msgpack(el.first);
13916 write_msgpack(el.second);
13933 const bool use_type,
const bool add_prefix =
true)
13941 oa->write_character(to_char_type(
'Z'));
13950 oa->write_character(j.m_value.boolean
13951 ? to_char_type(
'T')
13952 : to_char_type(
'F'));
13959 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
13965 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
13971 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
13979 oa->write_character(to_char_type(
'S'));
13981 write_number_with_ubjson_prefix(j.m_value.string->size(),
true);
13982 oa->write_characters(
13983 reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
13984 j.m_value.string->size());
13992 oa->write_character(to_char_type(
'['));
13995 bool prefix_required =
true;
13996 if (use_type && !j.m_value.array->empty())
13999 const CharType first_prefix = ubjson_prefix(j.front());
14000 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14001 [
this, first_prefix](
const BasicJsonType & v)
14003 return ubjson_prefix(v) == first_prefix;
14008 prefix_required =
false;
14009 oa->write_character(to_char_type(
'$'));
14010 oa->write_character(first_prefix);
14016 oa->write_character(to_char_type(
'#'));
14017 write_number_with_ubjson_prefix(j.m_value.array->size(),
true);
14020 for (
const auto& el : *j.m_value.array)
14022 write_ubjson(el, use_count, use_type, prefix_required);
14027 oa->write_character(to_char_type(
']'));
14037 oa->write_character(to_char_type(
'['));
14040 if (use_type && !j.m_value.binary->empty())
14043 oa->write_character(to_char_type(
'$'));
14044 oa->write_character(
'U');
14049 oa->write_character(to_char_type(
'#'));
14050 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true);
14055 oa->write_characters(
14056 reinterpret_cast<const CharType*>(j.m_value.binary->data()),
14057 j.m_value.binary->size());
14061 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
14063 oa->write_character(to_char_type(
'U'));
14064 oa->write_character(j.m_value.binary->data()[i]);
14070 oa->write_character(to_char_type(
']'));
14080 oa->write_character(to_char_type(
'{'));
14083 bool prefix_required =
true;
14084 if (use_type && !j.m_value.object->empty())
14087 const CharType first_prefix = ubjson_prefix(j.front());
14088 const bool same_prefix = std::all_of(j.begin(), j.end(),
14089 [
this, first_prefix](
const BasicJsonType & v)
14091 return ubjson_prefix(v) == first_prefix;
14096 prefix_required =
false;
14097 oa->write_character(to_char_type(
'$'));
14098 oa->write_character(first_prefix);
14104 oa->write_character(to_char_type(
'#'));
14105 write_number_with_ubjson_prefix(j.m_value.object->size(),
true);
14108 for (
const auto& el : *j.m_value.object)
14110 write_number_with_ubjson_prefix(el.first.size(),
true);
14111 oa->write_characters(
14112 reinterpret_cast<const CharType*>(el.first.c_str()),
14114 write_ubjson(el.second, use_count, use_type, prefix_required);
14119 oa->write_character(to_char_type(
'}'));
14141 const auto it = name.find(static_cast<typename string_t::value_type>(0));
14147 return 1ul + name.size() + 1u;
14154 const std::uint8_t element_type)
14156 oa->write_character(to_char_type(element_type));
14157 oa->write_characters(
14158 reinterpret_cast<const CharType*>(name.c_str()),
14168 write_bson_entry_header(name, 0x08);
14169 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
14176 const double value)
14178 write_bson_entry_header(name, 0x01);
14179 write_number<double, true>(
value);
14187 return sizeof(std::int32_t) + value.size() + 1ul;
14196 write_bson_entry_header(name, 0x02);
14198 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(value.size() + 1ul));
14199 oa->write_characters(
14200 reinterpret_cast<const CharType*>(value.c_str()),
14209 write_bson_entry_header(name, 0x0A);
14217 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
14218 ?
sizeof(std::int32_t)
14219 :
sizeof(std::int64_t);
14226 const std::int64_t
value)
14228 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
14230 write_bson_entry_header(name, 0x10);
14231 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value));
14235 write_bson_entry_header(name, 0x12);
14236 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(
value));
14245 return (
value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14246 ?
sizeof(std::int32_t)
14247 :
sizeof(std::int64_t);
14254 const BasicJsonType& j)
14256 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14258 write_bson_entry_header(name, 0x10 );
14259 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(j.m_value.number_unsigned));
14261 else if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14263 write_bson_entry_header(name, 0x12 );
14264 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(j.m_value.number_unsigned));
14276 const typename BasicJsonType::object_t&
value)
14278 write_bson_entry_header(name, 0x03);
14279 write_bson_object(value);
14287 std::size_t array_index = 0ul;
14289 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
14291 return result + calc_bson_element_size(
std::to_string(array_index++), el);
14294 return sizeof(std::int32_t) + embedded_document_size + 1ul;
14302 return sizeof(std::int32_t) + value.size() + 1ul;
14309 const typename BasicJsonType::array_t&
value)
14311 write_bson_entry_header(name, 0x04);
14312 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_array_size(value)));
14314 std::size_t array_index = 0ul;
14316 for (
const auto& el : value)
14321 oa->write_character(to_char_type(0x00));
14330 write_bson_entry_header(name, 0x05);
14332 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(value.size()));
14333 write_number(value.has_subtype() ? value.subtype() : std::uint8_t(0x00));
14335 oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
14343 const BasicJsonType& j)
14345 const auto header_size = calc_bson_entry_header_size(name, j);
14349 return header_size + calc_bson_object_size(*j.m_value.object);
14352 return header_size + calc_bson_array_size(*j.m_value.array);
14355 return header_size + calc_bson_binary_size(*j.m_value.binary);
14358 return header_size + 1ul;
14361 return header_size + 8ul;
14364 return header_size + calc_bson_integer_size(j.m_value.number_integer);
14367 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
14370 return header_size + calc_bson_string_size(*j.m_value.string);
14373 return header_size + 0ul;
14390 const BasicJsonType& j)
14395 return write_bson_object_entry(name, *j.m_value.object);
14398 return write_bson_array(name, *j.m_value.array);
14401 return write_bson_binary(name, *j.m_value.binary);
14404 return write_bson_boolean(name, j.m_value.boolean);
14407 return write_bson_double(name, j.m_value.number_float);
14410 return write_bson_integer(name, j.m_value.number_integer);
14413 return write_bson_unsigned(name, j);
14416 return write_bson_string(name, *j.m_value.string);
14419 return write_bson_null(name);
14437 std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0),
14438 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
14440 return result += calc_bson_element_size(el.first, el.second);
14443 return sizeof(std::int32_t) + document_size + 1ul;
14452 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_object_size(value)));
14454 for (
const auto& el : value)
14456 write_bson_element(el.first, el.second);
14459 oa->write_character(to_char_type(0x00));
14468 return to_char_type(0xFA);
14473 return to_char_type(0xFB);
14482 return to_char_type(0xCA);
14487 return to_char_type(0xCB);
14495 template<
typename NumberType,
typename std::enable_if<
14496 std::is_floating_point<NumberType>::value,
int>
::type = 0>
14498 const bool add_prefix)
14502 oa->write_character(get_ubjson_float_prefix(n));
14508 template<
typename NumberType,
typename std::enable_if<
14509 std::is_unsigned<NumberType>::value,
int>::type = 0>
14511 const bool add_prefix)
14513 if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
14517 oa->write_character(to_char_type(
'i'));
14519 write_number(static_cast<std::uint8_t>(n));
14521 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14525 oa->write_character(to_char_type(
'U'));
14527 write_number(static_cast<std::uint8_t>(n));
14529 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
14533 oa->write_character(to_char_type(
'I'));
14535 write_number(static_cast<std::int16_t>(n));
14537 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14541 oa->write_character(to_char_type(
'l'));
14543 write_number(static_cast<std::int32_t>(n));
14545 else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14549 oa->write_character(to_char_type(
'L'));
14551 write_number(static_cast<std::int64_t>(n));
14557 oa->write_character(to_char_type(
'H'));
14560 const auto number = BasicJsonType(n).dump();
14561 write_number_with_ubjson_prefix(number.size(),
true);
14562 for (std::size_t i = 0; i < number.size(); ++i)
14564 oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
14570 template <
typename NumberType,
typename std::enable_if <
14571 std::is_signed<NumberType>::value&&
14572 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
14574 const bool add_prefix)
14576 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
14580 oa->write_character(to_char_type(
'i'));
14582 write_number(static_cast<std::int8_t>(n));
14584 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)()))
14588 oa->write_character(to_char_type(
'U'));
14590 write_number(static_cast<std::uint8_t>(n));
14592 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
14596 oa->write_character(to_char_type(
'I'));
14598 write_number(static_cast<std::int16_t>(n));
14600 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
14604 oa->write_character(to_char_type(
'l'));
14606 write_number(static_cast<std::int32_t>(n));
14608 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
14612 oa->write_character(to_char_type(
'L'));
14614 write_number(static_cast<std::int64_t>(n));
14621 oa->write_character(to_char_type(
'H'));
14624 const auto number = BasicJsonType(n).dump();
14625 write_number_with_ubjson_prefix(number.size(),
true);
14626 for (std::size_t i = 0; i < number.size(); ++i)
14628 oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
14645 return j.m_value.boolean ?
'T' :
'F';
14649 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)())
14653 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)())
14657 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)())
14661 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)())
14665 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)())
14675 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
14679 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
14683 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
14687 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
14691 if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
14700 return get_ubjson_float_prefix(j.m_value.number_float);
14742 template<
typename NumberType,
bool OutputIsLittleEndian = false>
14746 std::array<CharType, sizeof(NumberType)> vec{};
14747 std::memcpy(vec.data(), &n,
sizeof(NumberType));
14750 if (is_little_endian != OutputIsLittleEndian)
14753 std::reverse(vec.begin(), vec.end());
14756 oa->write_characters(vec.data(),
sizeof(NumberType));
14761 if (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
14762 static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
14763 static_cast<double>(static_cast<float>(n)) == static_cast<double>(n))
14766 ? get_cbor_float_prefix(static_cast<float>(n))
14767 : get_msgpack_float_prefix(static_cast<float>(n)));
14768 write_number(static_cast<float>(n));
14773 ? get_cbor_float_prefix(n)
14774 : get_msgpack_float_prefix(n));
14784 template <
typename C = CharType,
14788 return *
reinterpret_cast<char*
>(&x);
14791 template <
typename C = CharType,
14795 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
14796 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
14798 std::memcpy(&result, &x,
sizeof(x));
14802 template<
typename C = CharType,
14809 template <
typename InputCharType,
typename C = CharType,
14811 std::is_signed<C>::value &&
14812 std::is_signed<char>::value &&
14813 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
14835 #include <algorithm> 14844 #include <type_traits> 14855 #include <type_traits> 14884 namespace dtoa_impl
14887 template<
typename Target,
typename Source>
14890 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
14893 std::memcpy(&target, &source,
sizeof(Source));
14899 static constexpr
int kPrecision = 64;
14901 std::uint64_t f = 0;
14904 constexpr
diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
14915 return {x.f - y.f, x.e};
14924 static_assert(kPrecision == 64,
"internal error");
14949 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
14950 const std::uint64_t u_hi = x.f >> 32u;
14951 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
14952 const std::uint64_t v_hi = y.f >> 32u;
14954 const std::uint64_t p0 = u_lo * v_lo;
14955 const std::uint64_t p1 = u_lo * v_hi;
14956 const std::uint64_t p2 = u_hi * v_lo;
14957 const std::uint64_t p3 = u_hi * v_hi;
14959 const std::uint64_t p0_hi = p0 >> 32u;
14960 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
14961 const std::uint64_t p1_hi = p1 >> 32u;
14962 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
14963 const std::uint64_t p2_hi = p2 >> 32u;
14965 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
14976 Q += std::uint64_t{1} << (64u - 32u - 1u);
14978 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
14980 return {h, x.e + y.e + 64};
14991 while ((x.f >> 63u) == 0)
15006 const int delta = x.
e - target_exponent;
15011 return {x.f << delta, target_exponent};
15028 template<
typename FloatType>
15041 static_assert(std::numeric_limits<FloatType>::is_iec559,
15042 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
15044 constexpr
int kPrecision = std::numeric_limits<FloatType>::digits;
15045 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
15046 constexpr
int kMinExp = 1 - kBias;
15047 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
15049 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
15051 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
15052 const std::uint64_t E = bits >> (kPrecision - 1);
15053 const std::uint64_t F = bits & (kHiddenBit - 1);
15055 const bool is_denormal = E == 0;
15056 const diyfp v = is_denormal
15057 ?
diyfp(F, kMinExp)
15058 : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
15081 const bool lower_boundary_is_closer = F == 0 && E > 1;
15082 const diyfp m_plus = diyfp(2 * v.
f + 1, v.
e - 1);
15083 const diyfp m_minus = lower_boundary_is_closer
15084 ? diyfp(4 * v.
f - 1, v.
e - 2)
15085 : diyfp(2 * v.
f - 1, v.
e - 1);
15088 const diyfp w_plus = diyfp::normalize(m_plus);
15091 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
15093 return {diyfp::normalize(v), w_minus, w_plus};
15220 constexpr
int kCachedPowersMinDecExp = -300;
15221 constexpr
int kCachedPowersDecStep = 8;
15223 static constexpr std::array<cached_power, 79> kCachedPowers =
15226 { 0xAB70FE17C79AC6CA, -1060, -300 },
15227 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
15228 { 0xBE5691EF416BD60C, -1007, -284 },
15229 { 0x8DD01FAD907FFC3C, -980, -276 },
15230 { 0xD3515C2831559A83, -954, -268 },
15231 { 0x9D71AC8FADA6C9B5, -927, -260 },
15232 { 0xEA9C227723EE8BCB, -901, -252 },
15233 { 0xAECC49914078536D, -874, -244 },
15234 { 0x823C12795DB6CE57, -847, -236 },
15235 { 0xC21094364DFB5637, -821, -228 },
15236 { 0x9096EA6F3848984F, -794, -220 },
15237 { 0xD77485CB25823AC7, -768, -212 },
15238 { 0xA086CFCD97BF97F4, -741, -204 },
15239 { 0xEF340A98172AACE5, -715, -196 },
15240 { 0xB23867FB2A35B28E, -688, -188 },
15241 { 0x84C8D4DFD2C63F3B, -661, -180 },
15242 { 0xC5DD44271AD3CDBA, -635, -172 },
15243 { 0x936B9FCEBB25C996, -608, -164 },
15244 { 0xDBAC6C247D62A584, -582, -156 },
15245 { 0xA3AB66580D5FDAF6, -555, -148 },
15246 { 0xF3E2F893DEC3F126, -529, -140 },
15247 { 0xB5B5ADA8AAFF80B8, -502, -132 },
15248 { 0x87625F056C7C4A8B, -475, -124 },
15249 { 0xC9BCFF6034C13053, -449, -116 },
15250 { 0x964E858C91BA2655, -422, -108 },
15251 { 0xDFF9772470297EBD, -396, -100 },
15252 { 0xA6DFBD9FB8E5B88F, -369, -92 },
15253 { 0xF8A95FCF88747D94, -343, -84 },
15254 { 0xB94470938FA89BCF, -316, -76 },
15255 { 0x8A08F0F8BF0F156B, -289, -68 },
15256 { 0xCDB02555653131B6, -263, -60 },
15257 { 0x993FE2C6D07B7FAC, -236, -52 },
15258 { 0xE45C10C42A2B3B06, -210, -44 },
15259 { 0xAA242499697392D3, -183, -36 },
15260 { 0xFD87B5F28300CA0E, -157, -28 },
15261 { 0xBCE5086492111AEB, -130, -20 },
15262 { 0x8CBCCC096F5088CC, -103, -12 },
15263 { 0xD1B71758E219652C, -77, -4 },
15264 { 0x9C40000000000000, -50, 4 },
15265 { 0xE8D4A51000000000, -24, 12 },
15266 { 0xAD78EBC5AC620000, 3, 20 },
15267 { 0x813F3978F8940984, 30, 28 },
15268 { 0xC097CE7BC90715B3, 56, 36 },
15269 { 0x8F7E32CE7BEA5C70, 83, 44 },
15270 { 0xD5D238A4ABE98068, 109, 52 },
15271 { 0x9F4F2726179A2245, 136, 60 },
15272 { 0xED63A231D4C4FB27, 162, 68 },
15273 { 0xB0DE65388CC8ADA8, 189, 76 },
15274 { 0x83C7088E1AAB65DB, 216, 84 },
15275 { 0xC45D1DF942711D9A, 242, 92 },
15276 { 0x924D692CA61BE758, 269, 100 },
15277 { 0xDA01EE641A708DEA, 295, 108 },
15278 { 0xA26DA3999AEF774A, 322, 116 },
15279 { 0xF209787BB47D6B85, 348, 124 },
15280 { 0xB454E4A179DD1877, 375, 132 },
15281 { 0x865B86925B9BC5C2, 402, 140 },
15282 { 0xC83553C5C8965D3D, 428, 148 },
15283 { 0x952AB45CFA97A0B3, 455, 156 },
15284 { 0xDE469FBD99A05FE3, 481, 164 },
15285 { 0xA59BC234DB398C25, 508, 172 },
15286 { 0xF6C69A72A3989F5C, 534, 180 },
15287 { 0xB7DCBF5354E9BECE, 561, 188 },
15288 { 0x88FCF317F22241E2, 588, 196 },
15289 { 0xCC20CE9BD35C78A5, 614, 204 },
15290 { 0x98165AF37B2153DF, 641, 212 },
15291 { 0xE2A0B5DC971F303A, 667, 220 },
15292 { 0xA8D9D1535CE3B396, 694, 228 },
15293 { 0xFB9B7CD9A4A7443C, 720, 236 },
15294 { 0xBB764C4CA7A44410, 747, 244 },
15295 { 0x8BAB8EEFB6409C1A, 774, 252 },
15296 { 0xD01FEF10A657842C, 800, 260 },
15297 { 0x9B10A4E5E9913129, 827, 268 },
15298 { 0xE7109BFBA19C0C9D, 853, 276 },
15299 { 0xAC2820D9623BF429, 880, 284 },
15300 { 0x80444B5E7AA7CF85, 907, 292 },
15301 { 0xBF21E44003ACDD2D, 933, 300 },
15302 { 0x8E679C2F5E44FF8F, 960, 308 },
15303 { 0xD433179D9C8CB841, 986, 316 },
15304 { 0x9E19DB92B4E31BA9, 1013, 324 },
15314 const int f = kAlpha - e - 1;
15315 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
15317 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
15319 JSON_ASSERT(static_cast<std::size_t>(index) < kCachedPowers.size());
15321 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
15335 if (n >= 1000000000)
15337 pow10 = 1000000000;
15341 if (n >= 100000000)
15386 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
15387 std::uint64_t rest, std::uint64_t ten_k)
15414 && delta - rest >= ten_k
15415 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
15430 static_assert(kAlpha >= -60,
"internal error");
15431 static_assert(kGamma <= -32,
"internal error");
15448 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
15449 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
15458 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
15460 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
15461 std::uint64_t p2 = M_plus.
f & (one.f - 1);
15469 std::uint32_t pow10{};
15497 const std::uint32_t d = p1 / pow10;
15498 const std::uint32_t r = p1 % pow10;
15504 buffer[length++] =
static_cast<char>(
'0' + d);
15523 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
15528 decimal_exponent += n;
15539 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
15540 grisu2_round(buffer, length, dist, delta, rest, ten_n);
15601 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
15603 const std::uint64_t d = p2 >> -one.e;
15604 const std::uint64_t r = p2 & (one.f - 1);
15611 buffer[length++] =
static_cast<char>(
'0' + d);
15636 decimal_exponent -= m;
15644 const std::uint64_t ten_m = one.f;
15668 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
15685 const diyfp c_minus_k(cached.
f, cached.
e);
15688 const diyfp w = diyfp::mul(v, c_minus_k);
15689 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
15690 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
15713 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
15714 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
15716 decimal_exponent = -cached.
k;
15726 template<
typename FloatType>
15730 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
15731 "internal error: not enough precision");
15783 auto k =
static_cast<std::uint32_t
>(e);
15789 *buf++ =
static_cast<char>(
'0' + k);
15793 *buf++ =
static_cast<char>(
'0' + k / 10);
15795 *buf++ =
static_cast<char>(
'0' + k);
15799 *buf++ =
static_cast<char>(
'0' + k / 100);
15801 *buf++ =
static_cast<char>(
'0' + k / 10);
15803 *buf++ =
static_cast<char>(
'0' + k);
15821 int min_exp,
int max_exp)
15827 const int n = len + decimal_exponent;
15833 if (k <= n && n <= max_exp)
15838 std::memset(buf + k,
'0', static_cast<size_t>(n) - static_cast<size_t>(k));
15842 return buf + (
static_cast<size_t>(n) + 2);
15845 if (0 < n && n <= max_exp)
15852 std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
15854 return buf + (
static_cast<size_t>(k) + 1U);
15857 if (min_exp < n && n <= 0)
15862 std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k));
15865 std::memset(buf + 2,
'0', static_cast<size_t>(-n));
15866 return buf + (2U +
static_cast<size_t>(-n) + static_cast<size_t>(k));
15881 std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1);
15883 buf += 1 +
static_cast<size_t>(k);
15902 template<
typename FloatType>
15907 static_cast<void>(last);
15911 if (std::signbit(value))
15926 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
15933 int decimal_exponent = 0;
15936 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
15939 constexpr
int kMinExp = -4;
15941 constexpr
int kMaxExp = std::numeric_limits<FloatType>::digits10;
15944 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
15945 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
15982 template<
typename BasicJsonType>
15990 static constexpr std::uint8_t UTF8_ACCEPT = 0;
15991 static constexpr std::uint8_t UTF8_REJECT = 1;
16002 , loc(
std::localeconv())
16003 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
16004 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->decimal_point)))
16005 , indent_char(ichar)
16006 , indent_string(512, indent_char)
16007 , error_handler(error_handler_)
16040 const bool pretty_print,
16041 const bool ensure_ascii,
16042 const unsigned int indent_step,
16043 const unsigned int current_indent = 0)
16045 switch (val.m_type)
16049 if (val.m_value.object->empty())
16051 o->write_characters(
"{}", 2);
16057 o->write_characters(
"{\n", 2);
16060 const auto new_indent = current_indent + indent_step;
16063 indent_string.resize(indent_string.size() * 2,
' ');
16067 auto i = val.m_value.object->cbegin();
16068 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16070 o->write_characters(indent_string.c_str(), new_indent);
16071 o->write_character(
'\"');
16072 dump_escaped(i->first, ensure_ascii);
16073 o->write_characters(
"\": ", 3);
16074 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
16075 o->write_characters(
",\n", 2);
16080 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16081 o->write_characters(indent_string.c_str(), new_indent);
16082 o->write_character(
'\"');
16083 dump_escaped(i->first, ensure_ascii);
16084 o->write_characters(
"\": ", 3);
16085 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
16087 o->write_character(
'\n');
16088 o->write_characters(indent_string.c_str(), current_indent);
16089 o->write_character(
'}');
16093 o->write_character(
'{');
16096 auto i = val.m_value.object->cbegin();
16097 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16099 o->write_character(
'\"');
16100 dump_escaped(i->first, ensure_ascii);
16101 o->write_characters(
"\":", 2);
16102 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
16103 o->write_character(
',');
16108 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16109 o->write_character(
'\"');
16110 dump_escaped(i->first, ensure_ascii);
16111 o->write_characters(
"\":", 2);
16112 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
16114 o->write_character(
'}');
16122 if (val.m_value.array->empty())
16124 o->write_characters(
"[]", 2);
16130 o->write_characters(
"[\n", 2);
16133 const auto new_indent = current_indent + indent_step;
16136 indent_string.resize(indent_string.size() * 2,
' ');
16140 for (
auto i = val.m_value.array->cbegin();
16141 i != val.m_value.array->cend() - 1; ++i)
16143 o->write_characters(indent_string.c_str(), new_indent);
16144 dump(*i,
true, ensure_ascii, indent_step, new_indent);
16145 o->write_characters(
",\n", 2);
16150 o->write_characters(indent_string.c_str(), new_indent);
16151 dump(val.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
16153 o->write_character(
'\n');
16154 o->write_characters(indent_string.c_str(), current_indent);
16155 o->write_character(
']');
16159 o->write_character(
'[');
16162 for (
auto i = val.m_value.array->cbegin();
16163 i != val.m_value.array->cend() - 1; ++i)
16165 dump(*i,
false, ensure_ascii, indent_step, current_indent);
16166 o->write_character(
',');
16171 dump(val.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
16173 o->write_character(
']');
16181 o->write_character(
'\"');
16182 dump_escaped(*val.m_value.string, ensure_ascii);
16183 o->write_character(
'\"');
16191 o->write_characters(
"{\n", 2);
16194 const auto new_indent = current_indent + indent_step;
16197 indent_string.resize(indent_string.size() * 2,
' ');
16200 o->write_characters(indent_string.c_str(), new_indent);
16202 o->write_characters(
"\"bytes\": [", 10);
16204 if (!val.m_value.binary->empty())
16206 for (
auto i = val.m_value.binary->cbegin();
16207 i != val.m_value.binary->cend() - 1; ++i)
16210 o->write_characters(
", ", 2);
16212 dump_integer(val.m_value.binary->back());
16215 o->write_characters(
"],\n", 3);
16216 o->write_characters(indent_string.c_str(), new_indent);
16218 o->write_characters(
"\"subtype\": ", 11);
16219 if (val.m_value.binary->has_subtype())
16221 dump_integer(val.m_value.binary->subtype());
16225 o->write_characters(
"null", 4);
16227 o->write_character(
'\n');
16228 o->write_characters(indent_string.c_str(), current_indent);
16229 o->write_character(
'}');
16233 o->write_characters(
"{\"bytes\":[", 10);
16235 if (!val.m_value.binary->empty())
16237 for (
auto i = val.m_value.binary->cbegin();
16238 i != val.m_value.binary->cend() - 1; ++i)
16241 o->write_character(
',');
16243 dump_integer(val.m_value.binary->back());
16246 o->write_characters(
"],\"subtype\":", 12);
16247 if (val.m_value.binary->has_subtype())
16249 dump_integer(val.m_value.binary->subtype());
16250 o->write_character(
'}');
16254 o->write_characters(
"null}", 5);
16262 if (val.m_value.boolean)
16264 o->write_characters(
"true", 4);
16268 o->write_characters(
"false", 5);
16275 dump_integer(val.m_value.number_integer);
16281 dump_integer(val.m_value.number_unsigned);
16287 dump_float(val.m_value.number_float);
16293 o->write_characters(
"<discarded>", 11);
16299 o->write_characters(
"null", 4);
16323 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
16325 std::uint32_t codepoint{};
16326 std::uint8_t state = UTF8_ACCEPT;
16327 std::size_t bytes = 0;
16330 std::size_t bytes_after_last_accept = 0;
16331 std::size_t undumped_chars = 0;
16333 for (std::size_t i = 0; i < s.size(); ++i)
16335 const auto byte =
static_cast<uint8_t
>(s[i]);
16337 switch (decode(state, codepoint, byte))
16345 string_buffer[bytes++] =
'\\';
16346 string_buffer[bytes++] =
'b';
16352 string_buffer[bytes++] =
'\\';
16353 string_buffer[bytes++] =
't';
16359 string_buffer[bytes++] =
'\\';
16360 string_buffer[bytes++] =
'n';
16366 string_buffer[bytes++] =
'\\';
16367 string_buffer[bytes++] =
'f';
16373 string_buffer[bytes++] =
'\\';
16374 string_buffer[bytes++] =
'r';
16380 string_buffer[bytes++] =
'\\';
16381 string_buffer[bytes++] =
'\"';
16387 string_buffer[bytes++] =
'\\';
16388 string_buffer[bytes++] =
'\\';
16396 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
16398 if (codepoint <= 0xFFFF)
16401 (std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
16402 static_cast<std::uint16_t
>(codepoint));
16408 (std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
16409 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
16410 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu)));
16418 string_buffer[bytes++] = s[i];
16427 if (string_buffer.size() - bytes < 13)
16429 o->write_characters(string_buffer.data(), bytes);
16434 bytes_after_last_accept = bytes;
16435 undumped_chars = 0;
16441 switch (error_handler)
16447 (std::snprintf)(&sn[0], sn.size(),
"%.2X", byte);
16458 if (undumped_chars > 0)
16465 bytes = bytes_after_last_accept;
16472 string_buffer[bytes++] =
'\\';
16473 string_buffer[bytes++] =
'u';
16474 string_buffer[bytes++] =
'f';
16475 string_buffer[bytes++] =
'f';
16476 string_buffer[bytes++] =
'f';
16477 string_buffer[bytes++] =
'd';
16489 if (string_buffer.size() - bytes < 13)
16491 o->write_characters(string_buffer.data(), bytes);
16495 bytes_after_last_accept = bytes;
16498 undumped_chars = 0;
16501 state = UTF8_ACCEPT;
16516 string_buffer[bytes++] = s[i];
16530 o->write_characters(string_buffer.data(), bytes);
16536 switch (error_handler)
16542 (std::snprintf)(&sn[0], sn.size(),
"%.2X",
static_cast<std::uint8_t
>(s.back()));
16549 o->write_characters(string_buffer.data(), bytes_after_last_accept);
16556 o->write_characters(string_buffer.data(), bytes_after_last_accept);
16560 o->write_characters(
"\\ufffd", 6);
16564 o->write_characters(
"\xEF\xBF\xBD", 3);
16586 unsigned int n_digits = 1;
16595 return n_digits + 1;
16599 return n_digits + 2;
16603 return n_digits + 3;
16620 std::is_same<NumberType, number_unsigned_t>::value ||
16621 std::is_same<NumberType, number_integer_t>::value ||
16622 std::is_same<NumberType, binary_char_t>::value,
16624 void dump_integer(NumberType x)
16626 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
16629 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
16630 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
16631 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
16632 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
16633 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
16634 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
16635 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
16636 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
16637 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
16638 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
16645 o->write_character(
'0');
16650 auto buffer_ptr = number_buffer.begin();
16652 const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0);
16655 unsigned int n_chars{};
16660 abs_value = remove_sign(static_cast<number_integer_t>(x));
16663 n_chars = 1 + count_digits(abs_value);
16668 n_chars = count_digits(abs_value);
16676 buffer_ptr += n_chars;
16680 while (abs_value >= 100)
16682 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
16684 *(--buffer_ptr) = digits_to_99[digits_index][1];
16685 *(--buffer_ptr) = digits_to_99[digits_index][0];
16688 if (abs_value >= 10)
16690 const auto digits_index =
static_cast<unsigned>(abs_value);
16691 *(--buffer_ptr) = digits_to_99[digits_index][1];
16692 *(--buffer_ptr) = digits_to_99[digits_index][0];
16696 *(--buffer_ptr) = static_cast<char>(
'0' + abs_value);
16699 o->write_characters(number_buffer.data(), n_chars);
16713 if (!std::isfinite(x))
16715 o->write_characters(
"null", 4);
16724 static constexpr
bool is_ieee_single_or_double
16725 = (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) ||
16726 (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);
16728 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
16733 auto* begin = number_buffer.data();
16736 o->write_characters(begin, static_cast<size_t>(end - begin));
16742 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
16746 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
16751 JSON_ASSERT(static_cast<std::size_t>(len) < number_buffer.size());
16754 if (thousands_sep !=
'\0')
16756 auto*
const end = std::remove(number_buffer.begin(),
16757 number_buffer.begin() + len, thousands_sep);
16758 std::fill(end, number_buffer.end(),
'\0');
16759 JSON_ASSERT((end - number_buffer.begin()) <= len);
16760 len = (end - number_buffer.begin());
16764 if (decimal_point !=
'\0' && decimal_point !=
'.')
16766 auto*
const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
16767 if (dec_pos != number_buffer.end())
16773 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
16776 const bool value_is_int_like =
16777 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
16780 return c ==
'.' || c ==
'e';
16783 if (value_is_int_like)
16785 o->write_characters(
".0", 2);
16810 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t byte) noexcept
16812 static const std::array<std::uint8_t, 400> utf8d =
16815 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,
16816 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,
16817 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,
16818 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,
16819 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,
16820 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,
16821 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,
16822 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
16823 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
16824 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
16825 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,
16826 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,
16827 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,
16828 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
16833 const std::uint8_t
type = utf8d[byte];
16835 codep = (state != UTF8_ACCEPT)
16836 ? (byte & 0x3fu) | (codep << 6u)
16837 : (0xFFu >> type) & (byte);
16839 std::size_t index = 256u +
static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
16841 state = utf8d[index];
16867 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
16876 std::array<char, 64> number_buffer{{}};
16879 const std::lconv* loc =
nullptr;
16881 const char thousands_sep =
'\0';
16883 const char decimal_point =
'\0';
16886 std::array<char, 512> string_buffer{{}};
16906 #include <functional> 16907 #include <initializer_list> 16908 #include <iterator> 16910 #include <stdexcept> 16911 #include <type_traits> 16923 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
16924 class Allocator = std::allocator<std::pair<const Key, T>>>
16925 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
16929 using Container = std::vector<std::pair<const Key, T>, Allocator>;
16930 using typename Container::iterator;
16931 using typename Container::const_iterator;
16932 using typename Container::size_type;
16933 using typename Container::value_type;
16938 template <
class It>
16941 ordered_map(std::initializer_list<T> init,
const Allocator& alloc = Allocator() )
16946 for (
auto it = this->begin(); it != this->end(); ++it)
16948 if (it->first == key)
16950 return {it,
false};
16953 Container::emplace_back(key, t);
16954 return {--this->end(),
true};
16959 return emplace(key, T{}).first->second;
16969 for (
auto it = this->begin(); it != this->end(); ++it)
16971 if (it->first == key)
16977 JSON_THROW(std::out_of_range(
"key not found"));
16982 for (
auto it = this->begin(); it != this->end(); ++it)
16984 if (it->first == key)
16990 JSON_THROW(std::out_of_range(
"key not found"));
16995 for (
auto it = this->begin(); it != this->end(); ++it)
16997 if (it->first == key)
17000 for (
auto next = it; ++next != this->end(); ++it)
17003 new (&*it) value_type{std::move(*next)};
17005 Container::pop_back();
17017 for (
auto next = it; ++next != this->end(); ++it)
17020 new (&*it) value_type{std::move(*next)};
17022 Container::pop_back();
17028 for (
auto it = this->begin(); it != this->end(); ++it)
17030 if (it->first == key)
17040 for (
auto it = this->begin(); it != this->end(); ++it)
17042 if (it->first == key)
17047 return Container::end();
17052 for (
auto it = this->begin(); it != this->end(); ++it)
17054 if (it->first == key)
17059 return Container::end();
17064 return emplace(
value.first, std::move(
value.second));
17069 for (
auto it = this->begin(); it != this->end(); ++it)
17071 if (it->first == value.first)
17073 return {it,
false};
17076 Container::push_back(value);
17077 return {--this->end(),
true};
17080 template<
typename InputIt>
17081 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
17084 template<
typename InputIt,
typename = require_input_iter<InputIt>>
17087 for (
auto it = first; it != last; ++it)
17097 #if defined(JSON_HAS_CPP_17) 17098 #include <string_view> 17198 friend ::nlohmann::json_pointer<basic_json>;
17200 template<
typename BasicJsonType,
typename InputType>
17201 friend class ::nlohmann::detail::parser;
17202 friend ::nlohmann::detail::serializer<basic_json>;
17203 template<
typename BasicJsonType>
17204 friend class ::nlohmann::detail::iter_impl;
17205 template<
typename BasicJsonType,
typename CharType>
17206 friend class ::nlohmann::detail::binary_writer;
17207 template<
typename BasicJsonType,
typename InputType,
typename SAX>
17208 friend class ::nlohmann::detail::binary_reader;
17209 template<
typename BasicJsonType>
17210 friend class ::nlohmann::detail::json_sax_dom_parser;
17211 template<
typename BasicJsonType>
17212 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
17213 friend class ::nlohmann::detail::exception;
17222 template<
typename InputAdapterType>
17223 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
17224 InputAdapterType adapter,
17226 const bool allow_exceptions =
true,
17227 const bool ignore_comments =
false 17230 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
17231 std::move(cb), allow_exceptions, ignore_comments);
17236 template<
typename BasicJsonType>
17238 template<
typename BasicJsonType>
17240 template<
typename Iterator>
17244 template<
typename CharType>
17247 template<
typename InputType>
17258 template<
typename T,
typename SFINAE>
17321 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
17323 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
17376 result[
"copyright"] =
"(C) 2013-2021 Niels Lohmann";
17377 result[
"name"] =
"JSON for Modern C++";
17378 result[
"url"] =
"https://github.com/nlohmann/json";
17379 result[
"version"][
"string"] =
17388 result[
"platform"] =
"win32";
17389 #elif defined __linux__ 17390 result[
"platform"] =
"linux";
17391 #elif defined __APPLE__ 17392 result[
"platform"] =
"apple";
17393 #elif defined __unix__ 17394 result[
"platform"] =
"unix";
17396 result[
"platform"] =
"unknown";
17399 #if defined(__ICC) || defined(__INTEL_COMPILER) 17400 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
17401 #elif defined(__clang__) 17402 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
17403 #elif defined(__GNUC__) || defined(__GNUG__) 17405 #elif defined(__HP_cc) || defined(__HP_aCC) 17406 result[
"compiler"] =
"hp" 17407 #elif defined(__IBMCPP__) 17408 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
17409 #elif defined(_MSC_VER) 17410 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
17411 #elif defined(__PGI) 17412 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
17413 #elif defined(__SUNPRO_CC) 17414 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
17416 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
17422 result[
"compiler"][
"c++"] =
"unknown";
17437 #if defined(JSON_HAS_CPP_14) 17528 using object_t = ObjectType<StringType,
17531 AllocatorType<std::pair<
const StringType,
17578 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
17945 template<
typename T,
typename... Args>
17949 AllocatorType<T> alloc;
17950 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
17952 auto deleter = [&](T * obj)
17954 AllocatorTraits::deallocate(alloc, obj, 1);
17956 std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
17957 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
17959 return obj.release();
18012 json_value() =
default;
18028 object = create<object_t>();
18034 array = create<array_t>();
18040 string = create<string_t>(
"");
18046 binary = create<binary_t>();
18095 string = create<string_t>(
value);
18101 string = create<string_t>(std::move(
value));
18107 object = create<object_t>(
value);
18113 object = create<object_t>(std::move(
value));
18119 array = create<array_t>(
value);
18125 array = create<array_t>(std::move(
value));
18131 binary = create<binary_t>(
value);
18137 binary = create<binary_t>(std::move(
value));
18143 binary = create<binary_t>(
value);
18149 binary = create<binary_t>(std::move(
value));
18155 std::vector<basic_json> stack;
18160 stack.reserve(array->size());
18161 std::move(array->begin(), array->end(), std::back_inserter(stack));
18165 stack.reserve(object->size());
18166 for (
auto&& it : *
object)
18168 stack.push_back(std::move(it.second));
18172 while (!stack.empty())
18175 basic_json current_item(std::move(stack.back()));
18182 std::move(current_item.
m_value.array->begin(), current_item.
m_value.array->end(),
18183 std::back_inserter(stack));
18185 current_item.
m_value.array->clear();
18189 for (
auto&& it : *current_item.
m_value.object)
18191 stack.push_back(std::move(it.second));
18194 current_item.
m_value.object->clear();
18205 AllocatorType<object_t> alloc;
18206 std::allocator_traits<decltype(alloc)>::destroy(alloc,
object);
18207 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
18213 AllocatorType<array_t> alloc;
18214 std::allocator_traits<decltype(alloc)>::destroy(alloc,
array);
18215 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
array, 1);
18221 AllocatorType<string_t> alloc;
18222 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
18223 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
18229 AllocatorType<binary_t> alloc;
18230 std::allocator_traits<decltype(alloc)>::destroy(alloc,
binary);
18231 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
binary, 1);
18269 #if JSON_DIAGNOSTICS 18273 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
18275 return j.m_parent ==
this;
18280 static_cast<void>(check_parents);
18285 #if JSON_DIAGNOSTICS 18290 for (
auto& element : *m_value.array)
18292 element.m_parent =
this;
18299 for (
auto& element : *m_value.object)
18301 element.second.m_parent =
this;
18314 #if JSON_DIAGNOSTICS 18317 (it + i)->m_parent =
this;
18320 static_cast<void>(count);
18327 #if JSON_DIAGNOSTICS 18330 static_cast<void>(j);
18448 : m_type(v), m_value(v)
18450 assert_invariant();
18474 assert_invariant();
18539 template <
typename CompatibleType,
18545 std::forward<CompatibleType>(val))))
18549 assert_invariant();
18578 template <
typename BasicJsonType,
18583 using other_boolean_t =
typename BasicJsonType::boolean_t;
18584 using other_number_float_t =
typename BasicJsonType::number_float_t;
18585 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
18586 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18587 using other_string_t =
typename BasicJsonType::string_t;
18588 using other_object_t =
typename BasicJsonType::object_t;
18589 using other_array_t =
typename BasicJsonType::array_t;
18590 using other_binary_t =
typename BasicJsonType::binary_t;
18592 switch (val.type())
18628 assert_invariant();
18706 bool type_deduction =
true,
18711 bool is_an_object = std::all_of(init.begin(), init.end(),
18714 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
18718 if (!type_deduction)
18723 is_an_object =
false;
18739 for (
auto& element_ref : init)
18741 auto element = element_ref.moved_or_copied();
18742 m_value.object->emplace(
18743 std::move(*((*element.m_value.array)[0].m_value.string)),
18744 std::move((*element.m_value.array)[1]));
18751 m_value.array = create<array_t>(init.begin(), init.end());
18755 assert_invariant();
18788 auto res = basic_json();
18790 res.m_value = init;
18825 auto res = basic_json();
18827 res.m_value =
binary_t(init, subtype);
18835 auto res = basic_json();
18837 res.m_value = std::move(init);
18845 auto res = basic_json();
18847 res.m_value =
binary_t(std::move(init), subtype);
18963 m_value.array = create<array_t>(cnt, val);
18965 assert_invariant();
19023 template <
class InputIT,
typename std::enable_if <
19024 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
19025 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
19038 m_type = first.m_object->m_type;
19050 || !last.m_it.primitive_iterator.is_end()))
19065 m_value.number_integer = first.m_object->m_value.number_integer;
19071 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
19077 m_value.number_float = first.m_object->m_value.number_float;
19083 m_value.boolean = first.m_object->m_value.boolean;
19089 m_value = *first.m_object->m_value.string;
19095 m_value.object = create<object_t>(first.m_it.object_iterator,
19096 last.m_it.object_iterator);
19102 m_value.array = create<array_t>(first.m_it.array_iterator,
19103 last.m_it.array_iterator);
19109 m_value = *first.m_object->m_value.binary;
19118 assert_invariant();
19126 template<
typename JsonRef,
19128 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
19129 basic_json(
const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
19157 : m_type(other.m_type)
19166 m_value = *other.
m_value.object;
19172 m_value = *other.
m_value.array;
19178 m_value = *other.
m_value.string;
19184 m_value = other.
m_value.boolean;
19190 m_value = other.
m_value.number_integer;
19196 m_value = other.
m_value.number_unsigned;
19202 m_value = other.
m_value.number_float;
19208 m_value = *other.
m_value.binary;
19217 assert_invariant();
19247 : m_type(std::move(other.m_type)),
19248 m_value(std::move(other.m_value))
19251 other.assert_invariant(
false);
19255 other.m_value = {};
19258 assert_invariant();
19285 std::is_nothrow_move_constructible<value_t>::value&&
19286 std::is_nothrow_move_assignable<value_t>::value&&
19287 std::is_nothrow_move_constructible<json_value>::value&&
19288 std::is_nothrow_move_assignable<json_value>::value
19295 swap(m_type, other.m_type);
19296 swap(m_value, other.m_value);
19299 assert_invariant();
19320 assert_invariant(
false);
19321 m_value.destroy(m_type);
19383 const char indent_char =
' ',
19384 const bool ensure_ascii =
false,
19392 s.dump(*
this,
true, ensure_ascii, static_cast<unsigned int>(indent));
19396 s.dump(*
this,
false, ensure_ascii, 0);
19468 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
19495 return is_array() || is_object();
19569 return is_number_integer() || is_number_float();
19810 return m_value.boolean;
19819 return is_object() ? m_value.object :
nullptr;
19825 return is_object() ? m_value.object :
nullptr;
19831 return is_array() ? m_value.array :
nullptr;
19837 return is_array() ? m_value.array :
nullptr;
19843 return is_string() ? m_value.string :
nullptr;
19849 return is_string() ? m_value.string :
nullptr;
19855 return is_boolean() ? &m_value.boolean :
nullptr;
19861 return is_boolean() ? &m_value.boolean :
nullptr;
19867 return is_number_integer() ? &m_value.number_integer :
nullptr;
19873 return is_number_integer() ? &m_value.number_integer :
nullptr;
19879 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
19885 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
19891 return is_number_float() ? &m_value.number_float :
nullptr;
19897 return is_number_float() ? &m_value.number_float :
nullptr;
19903 return is_binary() ? m_value.binary :
nullptr;
19909 return is_binary() ? m_value.binary :
nullptr;
19923 template<
typename ReferenceType,
typename ThisType>
19927 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
19968 template<
typename PointerType,
typename std::enable_if<
19969 std::is_pointer<PointerType>::value,
int>::type = 0>
19973 return get_impl_ptr(static_cast<PointerType>(
nullptr));
19980 template <
typename PointerType,
typename std::enable_if <
19981 std::is_pointer<PointerType>::value&&
19982 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >::type = 0 >
19986 return get_impl_ptr(static_cast<PointerType>(
nullptr));
20028 template <
typename ValueType,
20071 template <
typename ValueType,
20096 template <
typename BasicJsonType,
20119 template<
typename BasicJsonType,
20121 std::is_same<BasicJsonType, basic_json_t>::value,
20132 template<
typename PointerType,
20134 std::is_pointer<PointerType>::value,
20137 -> decltype(std::declval<const basic_json_t&>().
template get_ptr<PointerType>())
20140 return get_ptr<PointerType>();
20167 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20168 #if defined(JSON_HAS_CPP_14) 20171 auto get()
const noexcept(
20178 static_assert(!std::is_reference<ValueTypeCV>::value,
20179 "get() cannot be used with reference types, you might want to use get_ref()");
20210 template<
typename PointerType,
typename std::enable_if<
20211 std::is_pointer<PointerType>::value,
int>::type = 0>
20212 auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
20215 return get_ptr<PointerType>();
20251 template <
typename ValueType,
20254 detail::has_from_json<basic_json_t, ValueType>::value,
20256 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
20265 template<
typename ValueType,
20276 typename T, std::size_t N,
20277 typename Array = T (&)[N],
20282 std::declval<const basic_json_t&>(), v)))
20314 template<
typename ReferenceType,
typename std::enable_if<
20315 std::is_reference<ReferenceType>::value,
int>::type = 0>
20319 return get_ref_impl<ReferenceType>(*this);
20326 template <
typename ReferenceType,
typename std::enable_if <
20327 std::is_reference<ReferenceType>::value&&
20328 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >::type = 0 >
20332 return get_ref_impl<ReferenceType>(*this);
20364 template <
typename ValueType,
typename std::enable_if <
20365 !std::is_pointer<ValueType>::value&&
20366 !std::is_same<ValueType, detail::json_ref<basic_json>>::value&&
20367 !std::is_same<ValueType, typename string_t::value_type>::value&&
20368 !detail::is_basic_json<ValueType>::value
20369 && !std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
20370 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) 20371 && !std::is_same<ValueType, typename std::string_view>::value
20374 ,
int >::type = 0 >
20378 return get<ValueType>();
20397 return *get_ptr<binary_t*>();
20408 return *get_ptr<const binary_t*>();
20455 return set_parent(m_value.array->at(idx));
20502 return m_value.array->at(idx);
20553 return set_parent(m_value.object->at(key));
20604 return m_value.object->at(key);
20649 m_value.array = create<array_t>();
20650 assert_invariant();
20657 if (idx >= m_value.array->size())
20659 #if JSON_DIAGNOSTICS 20661 const auto previous_size = m_value.array->size();
20663 m_value.array->resize(idx + 1);
20665 #if JSON_DIAGNOSTICS 20667 set_parents(begin() + static_cast<typename iterator::difference_type>(previous_size), static_cast<typename iterator::difference_type>(idx + 1 - previous_size));
20671 return m_value.array->operator[](idx);
20701 return m_value.
array->operator[](idx);
20740 m_value.object = create<object_t>();
20741 assert_invariant();
20747 return set_parent(m_value.object->operator[](key));
20788 JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
20789 return m_value.object->find(key)->second;
20822 template<
typename T>
20831 assert_invariant();
20837 return set_parent(m_value.object->operator[](key));
20873 template<
typename T>
20880 JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
20881 return m_value.object->find(key)->second;
20938 template <
class ValueType,
typename std::enable_if <
20940 && !std::is_same<value_t, ValueType>::value,
int >::type = 0 >
20941 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const 20947 const auto it = find(key);
20950 return it->template get<ValueType>();
20953 return default_value;
21011 template<
class ValueType,
typename std::enable_if<
21021 return ptr.
get_checked(
this).template get<ValueType>();
21025 return default_value;
21174 template <
class IteratorType,
typename std::enable_if <
21175 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21176 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >::type
21186 IteratorType result = end();
21204 AllocatorType<string_t> alloc;
21205 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
21206 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21207 m_value.string =
nullptr;
21209 else if (is_binary())
21211 AllocatorType<binary_t> alloc;
21212 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
21213 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21214 m_value.binary =
nullptr;
21218 assert_invariant();
21224 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
21230 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
21287 template <
class IteratorType,
typename std::enable_if <
21288 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21289 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >::type
21291 IteratorType
erase(IteratorType first, IteratorType last)
21299 IteratorType result = end();
21311 || !last.m_it.primitive_iterator.is_end()))
21318 AllocatorType<string_t> alloc;
21319 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
21320 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21321 m_value.string =
nullptr;
21323 else if (is_binary())
21325 AllocatorType<binary_t> alloc;
21326 std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
21327 std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21328 m_value.binary =
nullptr;
21332 assert_invariant();
21338 result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
21339 last.m_it.object_iterator);
21345 result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
21346 last.m_it.array_iterator);
21391 return m_value.object->erase(key);
21431 m_value.array->erase(m_value.array->begin() +
static_cast<difference_type>(idx));
21473 template<
typename KeyT>
21476 auto result = end();
21480 result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(
key));
21490 template<
typename KeyT>
21493 auto result = cend();
21497 result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(
key));
21524 template<
typename KeyT>
21528 return is_object() ? m_value.object->count(std::forward<KeyT>(
key)) : 0;
21556 template <
typename KeyT,
typename std::enable_if <
21560 return is_object() && m_value.object->find(std::forward<KeyT>(
key)) != m_value.object->end();
21631 result.set_begin();
21671 result.set_begin();
21938 return ref.items();
21947 return ref.items();
22096 return m_value.array->empty();
22102 return m_value.object->empty();
22169 return m_value.array->size();
22175 return m_value.object->size();
22234 return m_value.array->max_size();
22240 return m_value.object->max_size();
22304 m_value.number_integer = 0;
22310 m_value.number_unsigned = 0;
22316 m_value.number_float = 0.0;
22322 m_value.boolean =
false;
22328 m_value.string->clear();
22334 m_value.binary->clear();
22340 m_value.array->clear();
22346 m_value.object->clear();
22388 assert_invariant();
22392 m_value.array->push_back(std::move(val));
22393 set_parent(m_value.array->back());
22403 push_back(std::move(val));
22424 assert_invariant();
22428 m_value.array->push_back(val);
22429 set_parent(m_value.array->back());
22475 assert_invariant();
22479 auto res = m_value.object->insert(val);
22480 set_parent(res.first->second);
22520 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22522 basic_json&&
key = init.begin()->moved_or_copied();
22523 push_back(
typename object_t::value_type(
22524 std::move(key.
get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22528 push_back(basic_json(init));
22565 template<
class... Args>
22579 assert_invariant();
22583 #ifdef JSON_HAS_CPP_17 22584 return set_parent(m_value.array->emplace_back(std::forward<Args>(args)...));
22586 m_value.array->emplace_back(std::forward<Args>(args)...);
22587 return set_parent(m_value.array->back());
22618 template<
class... Args>
22632 assert_invariant();
22636 auto res = m_value.object->emplace(std::forward<Args>(args)...);
22637 set_parent(res.first->second);
22641 it.m_it.object_iterator = res.first;
22644 return {it, res.second};
22650 template<
typename... Args>
22701 return set_parents(insert_iterator(pos, val), static_cast<typename iterator::difference_type>(1));
22713 return insert(pos, val);
22752 return set_parents(insert_iterator(pos, cnt, val), static_cast<typename iterator::difference_type>(cnt));
22856 return set_parents(insert_iterator(pos, ilist.begin(), ilist.end()), static_cast<typename iterator::difference_type>(ilist.size()));
22930 m_value.object = create<object_t>();
22931 assert_invariant();
22943 for (
auto it = j.
cbegin(); it != j.
cend(); ++it)
22945 m_value.object->operator[](it.key()) = it.value();
22981 m_value.object = create<object_t>();
22982 assert_invariant();
22998 || !last.m_object->is_object()))
23003 for (
auto it = first; it != last; ++it)
23005 m_value.object->operator[](it.key()) = it.value();
23027 std::is_nothrow_move_constructible<value_t>::value&&
23028 std::is_nothrow_move_assignable<value_t>::value&&
23029 std::is_nothrow_move_constructible<json_value>::value&&
23030 std::is_nothrow_move_assignable<json_value>::value
23033 std::swap(m_type, other.m_type);
23034 std::swap(m_value, other.m_value);
23037 other.set_parents();
23038 assert_invariant();
23060 std::is_nothrow_move_constructible<value_t>::value&&
23061 std::is_nothrow_move_assignable<value_t>::value&&
23062 std::is_nothrow_move_constructible<json_value>::value&&
23063 std::is_nothrow_move_assignable<json_value>::value
23094 std::swap(*(m_value.array), other);
23127 std::swap(*(m_value.object), other);
23160 std::swap(*(m_value.string), other);
23193 std::swap(*(m_value.binary), other);
23207 std::swap(*(m_value.binary), other);
23282 const auto lhs_type = lhs.type();
23283 const auto rhs_type = rhs.type();
23285 if (lhs_type == rhs_type)
23290 return *lhs.m_value.array == *rhs.m_value.array;
23293 return *lhs.m_value.object == *rhs.m_value.object;
23299 return *lhs.m_value.string == *rhs.m_value.string;
23302 return lhs.m_value.boolean == rhs.m_value.boolean;
23305 return lhs.m_value.number_integer == rhs.m_value.number_integer;
23308 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
23311 return lhs.m_value.number_float == rhs.m_value.number_float;
23314 return *lhs.m_value.binary == *rhs.m_value.binary;
23322 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
23326 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
23330 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
23334 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
23338 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
23342 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
23352 template<
typename ScalarType,
typename std::enable_if<
23353 std::is_scalar<ScalarType>::value,
int>::type = 0>
23356 return lhs == basic_json(rhs);
23363 template<
typename ScalarType,
typename std::enable_if<
23364 std::is_scalar<ScalarType>::value,
int>::type = 0>
23367 return basic_json(lhs) == rhs;
23390 return !(lhs == rhs);
23397 template<
typename ScalarType,
typename std::enable_if<
23398 std::is_scalar<ScalarType>::value,
int>::type = 0>
23401 return lhs != basic_json(rhs);
23408 template<
typename ScalarType,
typename std::enable_if<
23409 std::is_scalar<ScalarType>::value,
int>::type = 0>
23412 return basic_json(lhs) != rhs;
23443 const auto lhs_type = lhs.type();
23444 const auto rhs_type = rhs.type();
23446 if (lhs_type == rhs_type)
23453 return (*lhs.m_value.array) < (*rhs.m_value.array);
23456 return (*lhs.m_value.object) < (*rhs.m_value.object);
23462 return (*lhs.m_value.string) < (*rhs.m_value.string);
23465 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
23468 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
23471 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
23474 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
23477 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
23485 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
23489 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
23493 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
23497 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
23501 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
23505 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
23518 template<
typename ScalarType,
typename std::enable_if<
23519 std::is_scalar<ScalarType>::value,
int>::type = 0>
23522 return lhs < basic_json(rhs);
23529 template<
typename ScalarType,
typename std::enable_if<
23530 std::is_scalar<ScalarType>::value,
int>::type = 0>
23533 return basic_json(lhs) < rhs;
23557 return !(rhs < lhs);
23564 template<
typename ScalarType,
typename std::enable_if<
23565 std::is_scalar<ScalarType>::value,
int>::type = 0>
23568 return lhs <= basic_json(rhs);
23575 template<
typename ScalarType,
typename std::enable_if<
23576 std::is_scalar<ScalarType>::value,
int>::type = 0>
23579 return basic_json(lhs) <= rhs;
23603 return !(lhs <= rhs);
23610 template<
typename ScalarType,
typename std::enable_if<
23611 std::is_scalar<ScalarType>::value,
int>::type = 0>
23614 return lhs > basic_json(rhs);
23621 template<
typename ScalarType,
typename std::enable_if<
23622 std::is_scalar<ScalarType>::value,
int>::type = 0>
23625 return basic_json(lhs) > rhs;
23649 return !(lhs < rhs);
23656 template<
typename ScalarType,
typename std::enable_if<
23657 std::is_scalar<ScalarType>::value,
int>::type = 0>
23660 return lhs >= basic_json(rhs);
23667 template<
typename ScalarType,
typename std::enable_if<
23668 std::is_scalar<ScalarType>::value,
int>::type = 0>
23671 return basic_json(lhs) >= rhs;
23714 friend std::ostream&
operator<<(std::ostream& o,
const basic_json& j)
23717 const bool pretty_print = o.width() > 0;
23718 const auto indentation = pretty_print ? o.width() : 0;
23725 s.dump(j, pretty_print,
false, static_cast<unsigned int>(indentation));
23738 friend
std::ostream& operator>>(const basic_json& j,
std::ostream& o)
23804 template<
typename InputType>
23808 const bool allow_exceptions =
true,
23809 const bool ignore_comments =
false)
23842 template<
typename IteratorType>
23847 const bool allow_exceptions =
true,
23848 const bool ignore_comments =
false)
23851 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).
parse(
true, result);
23857 static basic_json parse(detail::span_input_adapter&& i,
23859 const
bool allow_exceptions = true,
23860 const
bool ignore_comments = false)
23863 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23897 template<
typename InputType>
23899 const bool ignore_comments =
false)
23901 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
23904 template<
typename IteratorType>
23905 static bool accept(IteratorType first, IteratorType last,
23906 const bool ignore_comments =
false)
23908 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
23913 static
bool accept(detail::span_input_adapter&& i,
23914 const
bool ignore_comments = false)
23916 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23959 template <
typename InputType,
typename SAX>
23961 static
bool sax_parse(InputType&& i, SAX* sax,
23963 const
bool strict = true,
23964 const
bool ignore_comments = false)
23968 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax,
strict)
23972 template<
class IteratorType,
class SAX>
23974 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23976 const
bool strict = true,
23977 const
bool ignore_comments = false)
23981 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax,
strict)
23985 template <
typename SAX>
23988 static
bool sax_parse(detail::span_input_adapter&& i, SAX* sax,
23990 const
bool strict = true,
23991 const
bool ignore_comments = false)
23996 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax,
strict)
24010 friend
std::istream& operator<<(basic_json& j,
std::istream& i)
24012 return operator>>(i, j);
24102 return "discarded";
24119 json_value m_value = {};
24121 #if JSON_DIAGNOSTICS 24122 basic_json* m_parent =
nullptr;
24228 static std::vector<uint8_t>
to_cbor(
const basic_json& j)
24230 std::vector<uint8_t> result;
24231 to_cbor(j, result);
24325 std::vector<uint8_t> result;
24326 to_msgpack(j, result);
24427 const bool use_size =
false,
24428 const bool use_type =
false)
24430 std::vector<uint8_t> result;
24431 to_ubjson(j, result, use_size, use_type);
24436 const bool use_size =
false,
const bool use_type =
false)
24442 const bool use_size =
false,
const bool use_type =
false)
24504 static std::vector<uint8_t>
to_bson(
const basic_json& j)
24506 std::vector<uint8_t> result;
24507 to_bson(j, result);
24635 template<
typename InputType>
24638 const bool strict =
true,
24639 const bool allow_exceptions =
true,
24652 template<
typename IteratorType>
24654 static basic_json
from_cbor(IteratorType first, IteratorType last,
24655 const bool strict =
true,
24656 const bool allow_exceptions =
true,
24666 template<
typename T>
24669 static basic_json from_cbor(const T* ptr,
std::
size_t len,
24670 const
bool strict = true,
24671 const
bool allow_exceptions = true,
24674 return from_cbor(ptr, ptr + len,
strict, allow_exceptions, tag_handler);
24680 static basic_json from_cbor(detail::span_input_adapter&& i,
24681 const
bool strict = true,
24682 const
bool allow_exceptions = true,
24779 template<
typename InputType>
24782 const bool strict =
true,
24783 const bool allow_exceptions =
true)
24795 template<
typename IteratorType>
24798 const bool strict =
true,
24799 const bool allow_exceptions =
true)
24809 template<
typename T>
24812 static basic_json from_msgpack(const T* ptr,
std::
size_t len,
24813 const
bool strict = true,
24814 const
bool allow_exceptions = true)
24816 return from_msgpack(ptr, ptr + len,
strict, allow_exceptions);
24821 static basic_json from_msgpack(detail::span_input_adapter&& i,
24822 const
bool strict = true,
24823 const
bool allow_exceptions = true)
24896 template<
typename InputType>
24899 const bool strict =
true,
24900 const bool allow_exceptions =
true)
24912 template<
typename IteratorType>
24915 const bool strict =
true,
24916 const bool allow_exceptions =
true)
24925 template<
typename T>
24928 static basic_json from_ubjson(const T* ptr,
std::
size_t len,
24929 const
bool strict = true,
24930 const
bool allow_exceptions = true)
24932 return from_ubjson(ptr, ptr + len,
strict, allow_exceptions);
24937 static basic_json from_ubjson(detail::span_input_adapter&& i,
24938 const
bool strict = true,
24939 const
bool allow_exceptions = true)
25010 template<
typename InputType>
25013 const bool strict =
true,
25014 const bool allow_exceptions =
true)
25026 template<
typename IteratorType>
25028 static basic_json
from_bson(IteratorType first, IteratorType last,
25029 const bool strict =
true,
25030 const bool allow_exceptions =
true)
25039 template<
typename T>
25042 static basic_json from_bson(const T* ptr,
std::
size_t len,
25043 const
bool strict = true,
25044 const
bool allow_exceptions = true)
25046 return from_bson(ptr, ptr + len,
strict, allow_exceptions);
25051 static basic_json from_bson(detail::span_input_adapter&& i,
25052 const
bool strict = true,
25053 const
bool allow_exceptions = true)
25343 basic_json
patch(
const basic_json& json_patch)
const 25346 basic_json result = *
this;
25349 enum class patch_operations {add,
remove,
replace, move, copy, test, invalid};
25355 return patch_operations::add;
25357 if (op ==
"remove")
25359 return patch_operations::remove;
25361 if (op ==
"replace")
25367 return patch_operations::move;
25371 return patch_operations::copy;
25375 return patch_operations::test;
25378 return patch_operations::invalid;
25382 const auto operation_add = [&result](
json_pointer & ptr, basic_json val)
25393 if (top_pointer != ptr)
25395 result.
at(top_pointer);
25399 const auto last_path = ptr.
back();
25401 basic_json& parent = result[ptr];
25403 switch (parent.m_type)
25409 parent[last_path] = val;
25415 if (last_path ==
"-")
25442 const auto operation_remove = [
this, &result](
json_pointer & ptr)
25445 const auto last_path = ptr.
back();
25447 basic_json& parent = result.
at(ptr);
25453 auto it = parent.
find(last_path);
25477 for (
const auto& val : json_patch)
25480 const auto get_value = [&val](
const std::string & op,
25482 bool string_type) -> basic_json &
25485 auto it = val.m_value.object->find(member);
25488 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
25515 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
25516 const auto path = get_value(op,
"path",
true).template get<std::string>();
25519 switch (get_op(op))
25521 case patch_operations::add:
25523 operation_add(ptr, get_value(
"add",
"value",
false));
25527 case patch_operations::remove:
25529 operation_remove(ptr);
25536 result.
at(ptr) = get_value(
"replace",
"value",
false);
25540 case patch_operations::move:
25542 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
25546 basic_json v = result.
at(from_ptr);
25552 operation_remove(from_ptr);
25553 operation_add(ptr, v);
25557 case patch_operations::copy:
25559 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
25563 basic_json v = result.
at(from_ptr);
25568 operation_add(ptr, v);
25572 case patch_operations::test:
25574 bool success =
false;
25579 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25641 static basic_json
diff(
const basic_json& source,
const basic_json& target,
25648 if (source == target)
25653 if (source.
type() != target.
type())
25658 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25663 switch (source.
type())
25669 while (i < source.
size() && i < target.
size())
25672 auto temp_diff = diff(source[i], target[i], path +
"/" +
std::to_string(i));
25673 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25682 while (i < source.
size())
25695 while (i < target.
size())
25700 {
"path", path +
"/-"},
25701 {
"value", target[i]}
25712 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25717 if (target.
find(it.key()) != target.
end())
25720 auto temp_diff = diff(it.value(), target[it.key()], path_key);
25721 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25728 {
"op",
"remove"}, {
"path", path_key}
25734 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25736 if (source.
find(it.key()) == source.
end())
25742 {
"op",
"add"}, {
"path", path_key},
25743 {
"value", it.value()}
25756 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25824 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25826 if (it.value().is_null())
25832 operator[](it.key()).merge_patch(it.value());
25838 *
this = apply_patch;
25902 #ifndef JSON_HAS_CPP_20 25911 is_nothrow_move_constructible<nlohmann::json>::value&&
25912 is_nothrow_move_assignable<nlohmann::json>::value
25964 #if defined(__clang__) 25965 #pragma GCC diagnostic pop 25970 #undef JSON_INTERNAL_CATCH 25974 #undef JSON_PRIVATE_UNLESS_TESTED 25975 #undef JSON_HAS_CPP_14 25976 #undef JSON_HAS_CPP_17 25977 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION 25978 #undef NLOHMANN_BASIC_JSON_TPL 25979 #undef JSON_EXPLICIT 25984 #undef JSON_HEDLEY_ALWAYS_INLINE 25985 #undef JSON_HEDLEY_ARM_VERSION 25986 #undef JSON_HEDLEY_ARM_VERSION_CHECK 25987 #undef JSON_HEDLEY_ARRAY_PARAM 25988 #undef JSON_HEDLEY_ASSUME 25989 #undef JSON_HEDLEY_BEGIN_C_DECLS 25990 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE 25991 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN 25992 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE 25993 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE 25994 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION 25995 #undef JSON_HEDLEY_CLANG_HAS_FEATURE 25996 #undef JSON_HEDLEY_CLANG_HAS_WARNING 25997 #undef JSON_HEDLEY_COMPCERT_VERSION 25998 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK 25999 #undef JSON_HEDLEY_CONCAT 26000 #undef JSON_HEDLEY_CONCAT3 26001 #undef JSON_HEDLEY_CONCAT3_EX 26002 #undef JSON_HEDLEY_CONCAT_EX 26003 #undef JSON_HEDLEY_CONST 26004 #undef JSON_HEDLEY_CONSTEXPR 26005 #undef JSON_HEDLEY_CONST_CAST 26006 #undef JSON_HEDLEY_CPP_CAST 26007 #undef JSON_HEDLEY_CRAY_VERSION 26008 #undef JSON_HEDLEY_CRAY_VERSION_CHECK 26009 #undef JSON_HEDLEY_C_DECL 26010 #undef JSON_HEDLEY_DEPRECATED 26011 #undef JSON_HEDLEY_DEPRECATED_FOR 26012 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL 26013 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ 26014 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED 26015 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES 26016 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS 26017 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION 26018 #undef JSON_HEDLEY_DIAGNOSTIC_POP 26019 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH 26020 #undef JSON_HEDLEY_DMC_VERSION 26021 #undef JSON_HEDLEY_DMC_VERSION_CHECK 26022 #undef JSON_HEDLEY_EMPTY_BASES 26023 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION 26024 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK 26025 #undef JSON_HEDLEY_END_C_DECLS 26026 #undef JSON_HEDLEY_FLAGS 26027 #undef JSON_HEDLEY_FLAGS_CAST 26028 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE 26029 #undef JSON_HEDLEY_GCC_HAS_BUILTIN 26030 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE 26031 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE 26032 #undef JSON_HEDLEY_GCC_HAS_EXTENSION 26033 #undef JSON_HEDLEY_GCC_HAS_FEATURE 26034 #undef JSON_HEDLEY_GCC_HAS_WARNING 26035 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK 26036 #undef JSON_HEDLEY_GCC_VERSION 26037 #undef JSON_HEDLEY_GCC_VERSION_CHECK 26038 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE 26039 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN 26040 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE 26041 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE 26042 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION 26043 #undef JSON_HEDLEY_GNUC_HAS_FEATURE 26044 #undef JSON_HEDLEY_GNUC_HAS_WARNING 26045 #undef JSON_HEDLEY_GNUC_VERSION 26046 #undef JSON_HEDLEY_GNUC_VERSION_CHECK 26047 #undef JSON_HEDLEY_HAS_ATTRIBUTE 26048 #undef JSON_HEDLEY_HAS_BUILTIN 26049 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE 26050 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS 26051 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE 26052 #undef JSON_HEDLEY_HAS_EXTENSION 26053 #undef JSON_HEDLEY_HAS_FEATURE 26054 #undef JSON_HEDLEY_HAS_WARNING 26055 #undef JSON_HEDLEY_IAR_VERSION 26056 #undef JSON_HEDLEY_IAR_VERSION_CHECK 26057 #undef JSON_HEDLEY_IBM_VERSION 26058 #undef JSON_HEDLEY_IBM_VERSION_CHECK 26059 #undef JSON_HEDLEY_IMPORT 26060 #undef JSON_HEDLEY_INLINE 26061 #undef JSON_HEDLEY_INTEL_CL_VERSION 26062 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK 26063 #undef JSON_HEDLEY_INTEL_VERSION 26064 #undef JSON_HEDLEY_INTEL_VERSION_CHECK 26065 #undef JSON_HEDLEY_IS_CONSTANT 26066 #undef JSON_HEDLEY_IS_CONSTEXPR_ 26067 #undef JSON_HEDLEY_LIKELY 26068 #undef JSON_HEDLEY_MALLOC 26069 #undef JSON_HEDLEY_MCST_LCC_VERSION 26070 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK 26071 #undef JSON_HEDLEY_MESSAGE 26072 #undef JSON_HEDLEY_MSVC_VERSION 26073 #undef JSON_HEDLEY_MSVC_VERSION_CHECK 26074 #undef JSON_HEDLEY_NEVER_INLINE 26075 #undef JSON_HEDLEY_NON_NULL 26076 #undef JSON_HEDLEY_NO_ESCAPE 26077 #undef JSON_HEDLEY_NO_RETURN 26078 #undef JSON_HEDLEY_NO_THROW 26079 #undef JSON_HEDLEY_NULL 26080 #undef JSON_HEDLEY_PELLES_VERSION 26081 #undef JSON_HEDLEY_PELLES_VERSION_CHECK 26082 #undef JSON_HEDLEY_PGI_VERSION 26083 #undef JSON_HEDLEY_PGI_VERSION_CHECK 26084 #undef JSON_HEDLEY_PREDICT 26085 #undef JSON_HEDLEY_PRINTF_FORMAT 26086 #undef JSON_HEDLEY_PRIVATE 26087 #undef JSON_HEDLEY_PUBLIC 26088 #undef JSON_HEDLEY_PURE 26089 #undef JSON_HEDLEY_REINTERPRET_CAST 26090 #undef JSON_HEDLEY_REQUIRE 26091 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR 26092 #undef JSON_HEDLEY_REQUIRE_MSG 26093 #undef JSON_HEDLEY_RESTRICT 26094 #undef JSON_HEDLEY_RETURNS_NON_NULL 26095 #undef JSON_HEDLEY_SENTINEL 26096 #undef JSON_HEDLEY_STATIC_ASSERT 26097 #undef JSON_HEDLEY_STATIC_CAST 26098 #undef JSON_HEDLEY_STRINGIFY 26099 #undef JSON_HEDLEY_STRINGIFY_EX 26100 #undef JSON_HEDLEY_SUNPRO_VERSION 26101 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK 26102 #undef JSON_HEDLEY_TINYC_VERSION 26103 #undef JSON_HEDLEY_TINYC_VERSION_CHECK 26104 #undef JSON_HEDLEY_TI_ARMCL_VERSION 26105 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK 26106 #undef JSON_HEDLEY_TI_CL2000_VERSION 26107 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK 26108 #undef JSON_HEDLEY_TI_CL430_VERSION 26109 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK 26110 #undef JSON_HEDLEY_TI_CL6X_VERSION 26111 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK 26112 #undef JSON_HEDLEY_TI_CL7X_VERSION 26113 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK 26114 #undef JSON_HEDLEY_TI_CLPRU_VERSION 26115 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK 26116 #undef JSON_HEDLEY_TI_VERSION 26117 #undef JSON_HEDLEY_TI_VERSION_CHECK 26118 #undef JSON_HEDLEY_UNAVAILABLE 26119 #undef JSON_HEDLEY_UNLIKELY 26120 #undef JSON_HEDLEY_UNPREDICTABLE 26121 #undef JSON_HEDLEY_UNREACHABLE 26122 #undef JSON_HEDLEY_UNREACHABLE_RETURN 26123 #undef JSON_HEDLEY_VERSION 26124 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR 26125 #undef JSON_HEDLEY_VERSION_DECODE_MINOR 26126 #undef JSON_HEDLEY_VERSION_DECODE_REVISION 26127 #undef JSON_HEDLEY_VERSION_ENCODE 26128 #undef JSON_HEDLEY_WARNING 26129 #undef JSON_HEDLEY_WARN_UNUSED_RESULT 26130 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG 26131 #undef JSON_HEDLEY_FALL_THROUGH 26135 #endif // INCLUDE_NLOHMANN_JSON_HPP_ value_type moved_or_copied() const
const_reference operator[](const typename object_t::key_type &key) const
read-only 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)
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
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, std::uint8_t subtype)
explicitly create a binary array (with subtype)
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.
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
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
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
static bool little_endianess(int num=1) noexcept
determine system byte order
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)
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)
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
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
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
json_reverse_iterator const operator--(int)
post-decrement (it–)
void push_back(basic_json &&val)
add an object to an array
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
byte_container_with_subtype(container_type &&b, std::uint8_t subtype_) noexcept(noexcept(container_type(std::move(b))))
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
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 elements
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)
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 elements
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.
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
std::less< StringType > object_comparator_t
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
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
bool start_object(std::size_t=std::size_t(-1))
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
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)
typename T::iterator iterator_t
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
void destroy(value_t t) noexcept
void to_json(BasicJsonType &j, const T &b)
typename BasicJsonType::binary_t binary_t
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)
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)
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
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 a const iterator to one past the last element
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
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)
#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
the parser read [ and started to process a JSON array
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
static std::vector< uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
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)
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
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 a const iterator to the first element
void write_character(CharType c) override
cached_power get_cached_power_for_binary_exponent(int e)
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
constexpr std::uint8_t subtype() const noexcept
return the binary subtype
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
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)
the parser read ] and finished processing a JSON array
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
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++)
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
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
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
overload for a default value of type const char*
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
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)
the parser read a key of a value in an object
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
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
std::vector< CharType > & v
friend json_pointer operator/(const json_pointer &ptr, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer ...
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
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
void write_character(CharType c) override
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)
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
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
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)
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
output_adapter(std::vector< CharType > &vec)
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
the parser read } and finished processing a JSON object
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.
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
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
static std::vector< 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
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)
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)
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
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
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
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)
typename BasicJsonType::template json_serializer< T, void > serializer
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
friend json_pointer operator/(const json_pointer &ptr, std::string token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer ...
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)
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
output_vector_adapter(std::vector< CharType > &vec) 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 start_array(std::size_t=std::size_t(-1))
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)
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
std::size_t operator()(const nlohmann::json &j) const
return a hash value for a JSON object
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)
lexer< BasicJsonType, InputAdapterType > lexer_t
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
the parser read { and started to process a JSON object
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)
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
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
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
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
typename BasicJsonType::number_integer_t number_integer_t
bool get_ubjson_size_value(std::size_t &result)
std::input_iterator_tag iterator_category
void update(const_reference j)
updates a JSON object from another object, overwriting existing keys
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
reference set_parent(reference j)
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
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)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array (without subtype)
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... >)
the parser finished reading a JSON value
std::size_t lines_read
the number of lines read
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
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)
void set_subtype(std::uint8_t subtype_) noexcept
sets the binary subtype
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)
void insert(const_iterator first, const_iterator last)
inserts elements
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
std::basic_ostream< CharType > & stream
InputAdapterType ia
input adapter
typename BasicJsonType::binary_t binary_t
const_reverse_iterator rbegin() const noexcept
returns a const reverse iterator to the last element
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
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
static void to_msgpack(const basic_json &j, detail::output_adapter< uint8_t > o)
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_iterator first, const_iterator last)
updates a JSON object from another object, overwriting existing keys
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::string_t string_t
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
typename BasicJsonType::template json_serializer< T, void > serializer
static void to_cbor(const basic_json &j, detail::output_adapter< uint8_t > o)
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
typename BasicJsonType::string_t string_t
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
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
void swap(object_t &other)
exchanges the values
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
byte_container_with_subtype(const container_type &b, std::uint8_t subtype_) noexcept(noexcept(container_type(b)))
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)
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
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)
static void to_bson(const basic_json &j, detail::output_adapter< uint8_t > o)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
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
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
static std::vector< uint8_t > to_bson(const basic_json &j)
Serializes the given JSON object j to BSON and returns a vector containing the corresponding BSON-rep...
typename T::iterator_category iterator_category_t
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
iterator set_parents(iterator it, typename iterator::difference_type count)
ReferenceType get_ref()
get a reference value (implicit)
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 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)
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)
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
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
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
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
std::size_t chars_read_total
the total number of characters read
typename lexer_base< BasicJsonType >::token_type token_type
#define JSON_HEDLEY_UNLIKELY(expr)
static std::vector< uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
std::numeric_limits< RealIntegerType > RealLimits
const_iterator end() const noexcept
returns a const 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
static void to_ubjson(const basic_json &j, detail::output_adapter< uint8_t > o, const bool use_size=false, const bool use_type=false)
const_reverse_iterator rend() const noexcept
returns a const reverse iterator to one before the first
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
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
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, std::uint8_t subtype)
explicitly create a binary array (with subtype)
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