19 #ifndef RAPIDJSON_RAPIDJSON_H_ 20 #define RAPIDJSON_RAPIDJSON_H_ 56 #define RAPIDJSON_STRINGIFY(x) RAPIDJSON_DO_STRINGIFY(x) 57 #define RAPIDJSON_DO_STRINGIFY(x) #x 60 #define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y) 61 #define RAPIDJSON_DO_JOIN(X, Y) RAPIDJSON_DO_JOIN2(X, Y) 62 #define RAPIDJSON_DO_JOIN2(X, Y) X##Y 81 #define RAPIDJSON_MAJOR_VERSION 1 82 #define RAPIDJSON_MINOR_VERSION 1 83 #define RAPIDJSON_PATCH_VERSION 0 84 #define RAPIDJSON_VERSION_STRING \ 85 RAPIDJSON_STRINGIFY( \ 86 RAPIDJSON_MAJOR_VERSION.RAPIDJSON_MINOR_VERSION.RAPIDJSON_PATCH_VERSION) 124 #ifndef RAPIDJSON_NAMESPACE 125 #define RAPIDJSON_NAMESPACE rapidjson 127 #ifndef RAPIDJSON_NAMESPACE_BEGIN 128 #define RAPIDJSON_NAMESPACE_BEGIN namespace RAPIDJSON_NAMESPACE { 130 #ifndef RAPIDJSON_NAMESPACE_END 131 #define RAPIDJSON_NAMESPACE_END } 137 #ifndef RAPIDJSON_HAS_STDSTRING 138 #ifdef RAPIDJSON_DOXYGEN_RUNNING 139 #define RAPIDJSON_HAS_STDSTRING 1 // force generation of documentation 141 #define RAPIDJSON_HAS_STDSTRING 0 // no std::string support by default 153 #endif // !defined(RAPIDJSON_HAS_STDSTRING) 155 #if RAPIDJSON_HAS_STDSTRING 157 #endif // RAPIDJSON_HAS_STDSTRING 172 #ifndef RAPIDJSON_NO_INT64DEFINE 173 #if defined(_MSC_VER) && (_MSC_VER < 1800) // Visual Studio 2013 182 #ifdef RAPIDJSON_DOXYGEN_RUNNING 184 #define RAPIDJSON_NO_INT64DEFINE 186 #endif // RAPIDJSON_NO_INT64TYPEDEF 191 #ifndef RAPIDJSON_FORCEINLINE 192 #if defined(_MSC_VER) && defined(NDEBUG) 194 #define RAPIDJSON_FORCEINLINE __forceinline 195 #elif defined(__GNUC__) && __GNUC__ >= 4 && defined(NDEBUG) 196 #define RAPIDJSON_FORCEINLINE __attribute__((always_inline)) 198 #define RAPIDJSON_FORCEINLINE 200 #endif // RAPIDJSON_FORCEINLINE 205 #define RAPIDJSON_LITTLEENDIAN 0 206 #define RAPIDJSON_BIGENDIAN 1 222 #ifndef RAPIDJSON_ENDIAN 224 #ifdef __BYTE_ORDER__ 225 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 226 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 227 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 228 #define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 230 # error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN. 231 #endif // __BYTE_ORDER__ 233 #elif defined(__GLIBC__) 235 #if (__BYTE_ORDER == __LITTLE_ENDIAN) 236 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 237 #elif (__BYTE_ORDER == __BIG_ENDIAN) 238 #define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 240 # error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN. 243 #elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) 244 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 245 #elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) 246 #define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 248 #elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || \ 249 defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || \ 250 defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || \ 252 #define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 253 #elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || \ 254 defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || \ 255 defined(_M_ALPHA) || defined(__amd64) || defined(__amd64__) || \ 256 defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || \ 257 defined(_M_X64) || defined(__bfin__) 258 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 259 #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) 260 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 261 #elif defined(RAPIDJSON_DOXYGEN_RUNNING) 262 #define RAPIDJSON_ENDIAN 264 # error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN. 266 #endif // RAPIDJSON_ENDIAN 272 #ifndef RAPIDJSON_64BIT 273 #if defined(__LP64__) || (defined(__x86_64__) && defined(__ILP32__)) || \ 274 defined(_WIN64) || defined(__EMSCRIPTEN__) 275 #define RAPIDJSON_64BIT 1 277 #define RAPIDJSON_64BIT 0 279 #endif // RAPIDJSON_64BIT 291 #ifndef RAPIDJSON_ALIGN 292 #define RAPIDJSON_ALIGN(x) \ 293 (((x) + static_cast<size_t>(7u)) & ~static_cast<size_t>(7u)) 305 #ifndef RAPIDJSON_UINT64_C2 306 #define RAPIDJSON_UINT64_C2(high32, low32) \ 307 ((static_cast<uint64_t>(high32) << 32) | static_cast<uint64_t>(low32)) 322 #ifndef RAPIDJSON_48BITPOINTER_OPTIMIZATION 323 #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \ 324 defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) 325 #define RAPIDJSON_48BITPOINTER_OPTIMIZATION 1 327 #define RAPIDJSON_48BITPOINTER_OPTIMIZATION 0 329 #endif // RAPIDJSON_48BITPOINTER_OPTIMIZATION 331 #if RAPIDJSON_48BITPOINTER_OPTIMIZATION == 1 332 #if RAPIDJSON_64BIT != 1 333 #error RAPIDJSON_48BITPOINTER_OPTIMIZATION can only be set to 1 when RAPIDJSON_64BIT=1 335 #define RAPIDJSON_SETPOINTER(type, p, x) \ 336 (p = reinterpret_cast<type *>( \ 337 (reinterpret_cast<uintptr_t>(p) & \ 338 static_cast<uintptr_t>(RAPIDJSON_UINT64_C2(0xFFFF0000, 0x00000000))) | \ 339 reinterpret_cast<uintptr_t>(reinterpret_cast<const void *>(x)))) 340 #define RAPIDJSON_GETPOINTER(type, p) \ 341 (reinterpret_cast<type *>( \ 342 reinterpret_cast<uintptr_t>(p) & \ 343 static_cast<uintptr_t>(RAPIDJSON_UINT64_C2(0x0000FFFF, 0xFFFFFFFF)))) 345 #define RAPIDJSON_SETPOINTER(type, p, x) (p = (x)) 346 #define RAPIDJSON_GETPOINTER(type, p) (p) 378 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) || \ 379 defined(RAPIDJSON_NEON) || defined(RAPIDJSON_DOXYGEN_RUNNING) 380 #define RAPIDJSON_SIMD 386 #ifndef RAPIDJSON_NO_SIZETYPEDEFINE 402 #ifdef RAPIDJSON_DOXYGEN_RUNNING 403 #define RAPIDJSON_NO_SIZETYPEDEFINE 431 #ifndef RAPIDJSON_ASSERT 433 #define RAPIDJSON_ASSERT(x) assert(x) 434 #endif // RAPIDJSON_ASSERT 440 #ifndef RAPIDJSON_STATIC_ASSERT 441 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) 442 #define RAPIDJSON_STATIC_ASSERT(x) static_assert(x, RAPIDJSON_STRINGIFY(x)) 444 #endif // RAPIDJSON_STATIC_ASSERT 447 #ifndef RAPIDJSON_STATIC_ASSERT 453 struct STATIC_ASSERTION_FAILURE;
455 struct STATIC_ASSERTION_FAILURE<true> {
459 struct StaticAssertTest {};
462 #if defined(__GNUC__) || defined(__clang__) 463 #define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) 465 #define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE 476 #define RAPIDJSON_STATIC_ASSERT(x) \ 477 typedef ::RAPIDJSON_NAMESPACE::StaticAssertTest<sizeof( \ 478 ::RAPIDJSON_NAMESPACE::STATIC_ASSERTION_FAILURE<bool(x)>)> \ 479 RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) \ 480 RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE 481 #endif // RAPIDJSON_STATIC_ASSERT 491 #ifndef RAPIDJSON_LIKELY 492 #if defined(__GNUC__) || defined(__clang__) 493 #define RAPIDJSON_LIKELY(x) __builtin_expect(!!(x), 1) 495 #define RAPIDJSON_LIKELY(x) (x) 504 #ifndef RAPIDJSON_UNLIKELY 505 #if defined(__GNUC__) || defined(__clang__) 506 #define RAPIDJSON_UNLIKELY(x) __builtin_expect(!!(x), 0) 508 #define RAPIDJSON_UNLIKELY(x) (x) 517 #define RAPIDJSON_MULTILINEMACRO_BEGIN do { 518 #define RAPIDJSON_MULTILINEMACRO_END \ 523 #define RAPIDJSON_VERSION_CODE(x, y, z) (((x)*100000) + ((y)*100) + (z)) 525 #if defined(__has_builtin) 526 #define RAPIDJSON_HAS_BUILTIN(x) __has_builtin(x) 528 #define RAPIDJSON_HAS_BUILTIN(x) 0 534 #if defined(__GNUC__) 535 #define RAPIDJSON_GNUC \ 536 RAPIDJSON_VERSION_CODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) 539 #if defined(__clang__) || (defined(RAPIDJSON_GNUC) && \ 540 RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4, 2, 0)) 542 #define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x)) 543 #define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(GCC diagnostic x) 544 #define RAPIDJSON_DIAG_OFF(x) \ 545 RAPIDJSON_DIAG_PRAGMA(ignored RAPIDJSON_STRINGIFY(RAPIDJSON_JOIN(-W, x))) 548 #if defined(__clang__) || (defined(RAPIDJSON_GNUC) && \ 549 RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4, 6, 0)) 550 #define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) 551 #define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) 552 #else // GCC >= 4.2, < 4.6 553 #define RAPIDJSON_DIAG_PUSH 554 #define RAPIDJSON_DIAG_POP 557 #elif defined(_MSC_VER) 560 #define RAPIDJSON_PRAGMA(x) __pragma(x) 561 #define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(warning(x)) 563 #define RAPIDJSON_DIAG_OFF(x) RAPIDJSON_DIAG_PRAGMA(disable : x) 564 #define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) 565 #define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) 569 #define RAPIDJSON_DIAG_OFF(x) 570 #define RAPIDJSON_DIAG_PUSH 571 #define RAPIDJSON_DIAG_POP 573 #endif // RAPIDJSON_DIAG_* 578 #ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS 579 #if defined(__clang__) 580 #if __has_feature(cxx_rvalue_references) && \ 581 (defined(_MSC_VER) || defined(_LIBCPP_VERSION) || \ 582 defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306) 583 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 585 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0 587 #elif (defined(RAPIDJSON_GNUC) && \ 588 (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4, 3, 0)) && \ 589 defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ 590 (defined(_MSC_VER) && _MSC_VER >= 1600) || \ 591 (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5140 && \ 592 defined(__GXX_EXPERIMENTAL_CXX0X__)) 594 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 596 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0 598 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 600 #ifndef RAPIDJSON_HAS_CXX11_NOEXCEPT 601 #if defined(__clang__) 602 #define RAPIDJSON_HAS_CXX11_NOEXCEPT __has_feature(cxx_noexcept) 603 #elif (defined(RAPIDJSON_GNUC) && \ 604 (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4, 6, 0)) && \ 605 defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ 606 (defined(_MSC_VER) && _MSC_VER >= 1900) || \ 607 (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5140 && \ 608 defined(__GXX_EXPERIMENTAL_CXX0X__)) 609 #define RAPIDJSON_HAS_CXX11_NOEXCEPT 1 611 #define RAPIDJSON_HAS_CXX11_NOEXCEPT 0 614 #if RAPIDJSON_HAS_CXX11_NOEXCEPT 615 #define RAPIDJSON_NOEXCEPT noexcept 617 #define RAPIDJSON_NOEXCEPT 618 #endif // RAPIDJSON_HAS_CXX11_NOEXCEPT 621 #ifndef RAPIDJSON_HAS_CXX11_TYPETRAITS 622 #if (defined(_MSC_VER) && _MSC_VER >= 1700) 623 #define RAPIDJSON_HAS_CXX11_TYPETRAITS 1 625 #define RAPIDJSON_HAS_CXX11_TYPETRAITS 0 629 #ifndef RAPIDJSON_HAS_CXX11_RANGE_FOR 630 #if defined(__clang__) 631 #define RAPIDJSON_HAS_CXX11_RANGE_FOR __has_feature(cxx_range_for) 632 #elif (defined(RAPIDJSON_GNUC) && \ 633 (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4, 6, 0)) && \ 634 defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ 635 (defined(_MSC_VER) && _MSC_VER >= 1700) || \ 636 (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5140 && \ 637 defined(__GXX_EXPERIMENTAL_CXX0X__)) 638 #define RAPIDJSON_HAS_CXX11_RANGE_FOR 1 640 #define RAPIDJSON_HAS_CXX11_RANGE_FOR 0 642 #endif // RAPIDJSON_HAS_CXX11_RANGE_FOR 647 #if defined(__has_cpp_attribute) 648 #if __has_cpp_attribute(fallthrough) 649 #define RAPIDJSON_DELIBERATE_FALLTHROUGH [[fallthrough]] 651 #define RAPIDJSON_DELIBERATE_FALLTHROUGH 654 #define RAPIDJSON_DELIBERATE_FALLTHROUGH 673 #ifndef RAPIDJSON_NOEXCEPT_ASSERT 674 #ifdef RAPIDJSON_ASSERT_THROWS 675 #if RAPIDJSON_HAS_CXX11_NOEXCEPT 676 #define RAPIDJSON_NOEXCEPT_ASSERT(x) 678 #define RAPIDJSON_NOEXCEPT_ASSERT(x) RAPIDJSON_ASSERT(x) 679 #endif // RAPIDJSON_HAS_CXX11_NOEXCEPT 681 #define RAPIDJSON_NOEXCEPT_ASSERT(x) RAPIDJSON_ASSERT(x) 682 #endif // RAPIDJSON_ASSERT_THROWS 683 #endif // RAPIDJSON_NOEXCEPT_ASSERT 688 #ifndef RAPIDJSON_NEW 689 #define RAPIDJSON_NEW(TypeName) new TypeName 692 #ifndef RAPIDJSON_DELETE 693 #define RAPIDJSON_DELETE(x) delete x 719 #endif // RAPIDJSON_RAPIDJSON_H_ RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
const GenericPointer< typename T::ValueType > T2 value