21 #ifndef RAPIDJSON_RAPIDJSON_H_ 22 #define RAPIDJSON_RAPIDJSON_H_ 64 #ifndef RAPIDJSON_NO_INT64DEFINE 67 #include "msinttypes/stdint.h" 68 #include "msinttypes/inttypes.h" 75 #ifdef RAPIDJSON_DOXYGEN_RUNNING 76 #define RAPIDJSON_NO_INT64DEFINE 78 #endif // RAPIDJSON_NO_INT64TYPEDEF 83 #ifndef RAPIDJSON_FORCEINLINE 86 #define RAPIDJSON_FORCEINLINE __forceinline 87 #elif defined(__GNUC__) && __GNUC__ >= 4 88 #define RAPIDJSON_FORCEINLINE __attribute__((always_inline)) 90 #define RAPIDJSON_FORCEINLINE 93 #endif // RAPIDJSON_FORCEINLINE 97 #define RAPIDJSON_LITTLEENDIAN 0 98 #define RAPIDJSON_BIGENDIAN 1
113 #ifndef RAPIDJSON_ENDIAN 115 # ifdef __BYTE_ORDER__ 116 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 117 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 118 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 119 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 121 # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN. 122 # endif // __BYTE_ORDER__ 124 # elif defined(__GLIBC__) 126 # if (__BYTE_ORDER == __LITTLE_ENDIAN) 127 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 128 # elif (__BYTE_ORDER == __BIG_ENDIAN) 129 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 131 # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN. 134 # elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) 135 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 136 # elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) 137 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 139 # elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || defined(__s390__) 140 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN 141 # elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_ALPHA) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__bfin__) 142 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN 143 # elif defined(RAPIDJSON_DOXYGEN_RUNNING) 144 # define RAPIDJSON_ENDIAN 146 # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN. 148 #endif // RAPIDJSON_ENDIAN 154 #ifndef RAPIDJSON_64BIT 155 #if defined(__LP64__) || defined(_WIN64) 156 #define RAPIDJSON_64BIT 1 158 #define RAPIDJSON_64BIT 0 160 #endif // RAPIDJSON_64BIT 172 #ifndef RAPIDJSON_ALIGN 173 #define RAPIDJSON_ALIGN(x) ((x + 3u) & ~3u) 185 #ifndef RAPIDJSON_UINT64_C2 186 #define RAPIDJSON_UINT64_C2(high32, low32) ((static_cast<uint64_t>(high32) << 32) | static_cast<uint64_t>(low32)) 214 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) \ 215 || defined(RAPIDJSON_DOXYGEN_RUNNING) 216 #define RAPIDJSON_SIMD 222 #ifndef RAPIDJSON_NO_SIZETYPEDEFINE 238 #ifdef RAPIDJSON_DOXYGEN_RUNNING 239 #define RAPIDJSON_NO_SIZETYPEDEFINE 267 #ifndef RAPIDJSON_ASSERT 269 #define RAPIDJSON_ASSERT(x) assert(x) 270 #endif // RAPIDJSON_ASSERT 276 #ifndef RAPIDJSON_STATIC_ASSERT 280 template <
bool x>
struct STATIC_ASSERTION_FAILURE;
281 template <>
struct STATIC_ASSERTION_FAILURE<true> {
enum { value = 1 }; };
282 template<
int x>
struct StaticAssertTest {};
285 #define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y) 286 #define RAPIDJSON_DO_JOIN(X, Y) RAPIDJSON_DO_JOIN2(X, Y) 287 #define RAPIDJSON_DO_JOIN2(X, Y) X##Y 289 #if defined(__GNUC__) 290 #define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) 292 #define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE 301 #define RAPIDJSON_STATIC_ASSERT(x) typedef ::rapidjson::StaticAssertTest<\ 302 sizeof(::rapidjson::STATIC_ASSERTION_FAILURE<bool(x) >)>\ 303 RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE 311 #define RAPIDJSON_MULTILINEMACRO_BEGIN do { 312 #define RAPIDJSON_MULTILINEMACRO_END \ 316 #define RAPIDJSON_VERSION_CODE(x,y,z) \ 317 (((x)*100000) + ((y)*100) + (z)) 320 #define RAPIDJSON_STRINGIFY(x) RAPIDJSON_DO_STRINGIFY(x) 321 #define RAPIDJSON_DO_STRINGIFY(x) #x 326 #if defined(__GNUC__) 327 #define RAPIDJSON_GNUC \ 328 RAPIDJSON_VERSION_CODE(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) 331 #if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,2,0)) 333 #define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x)) 334 #define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(GCC diagnostic x) 335 #define RAPIDJSON_DIAG_OFF(x) \ 336 RAPIDJSON_DIAG_PRAGMA(ignored RAPIDJSON_STRINGIFY(RAPIDJSON_JOIN(-W,x))) 339 #if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0)) 340 #define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) 341 #define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) 342 #else // GCC >= 4.2, < 4.6 343 #define RAPIDJSON_DIAG_PUSH 344 #define RAPIDJSON_DIAG_POP 347 #elif defined(_MSC_VER) 350 #define RAPIDJSON_PRAGMA(x) __pragma(x) 351 #define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(warning(x)) 353 #define RAPIDJSON_DIAG_OFF(x) RAPIDJSON_DIAG_PRAGMA(disable: x) 354 #define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) 355 #define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) 359 #define RAPIDJSON_DIAG_OFF(x) 360 #define RAPIDJSON_DIAG_PUSH 361 #define RAPIDJSON_DIAG_POP 363 #endif // RAPIDJSON_DIAG_* 368 #ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS 369 #if defined(__clang__) 370 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS __has_feature(cxx_rvalue_references) 371 #elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ 372 (defined(_MSC_VER) && _MSC_VER >= 1600) 374 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 376 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0 378 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 380 #ifndef RAPIDJSON_HAS_CXX11_NOEXCEPT 381 #if defined(__clang__) 382 #define RAPIDJSON_HAS_CXX11_NOEXCEPT __has_feature(cxx_noexcept) 383 #elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) 385 #define RAPIDJSON_HAS_CXX11_NOEXCEPT 1 387 #define RAPIDJSON_HAS_CXX11_NOEXCEPT 0 390 #if RAPIDJSON_HAS_CXX11_NOEXCEPT 391 #define RAPIDJSON_NOEXCEPT noexcept 393 #define RAPIDJSON_NOEXCEPT 394 #endif // RAPIDJSON_HAS_CXX11_NOEXCEPT 397 #ifndef RAPIDJSON_HAS_CXX11_TYPETRAITS 398 #define RAPIDJSON_HAS_CXX11_TYPETRAITS 0 406 #ifndef RAPIDJSON_NEW 408 #define RAPIDJSON_NEW(x) new x 410 #ifndef RAPIDJSON_DELETE 412 #define RAPIDJSON_DELETE(x) delete x 418 #include "allocators.h" 419 #include "encodings.h" 461 size_t PutEnd(Ch* begin);
472 template<
typename Stream>
479 enum { copyOptimization = 0 };
483 template<
typename Stream,
typename Ch>
485 for (
size_t i = 0; i < n; i++)
495 template <
typename Encoding>
497 typedef typename Encoding::Ch Ch;
501 Ch Peek()
const {
return *src_; }
502 Ch Take() {
return *src_++; }
503 size_t Tell()
const {
return static_cast<size_t>(src_ - head_); }
514 template <
typename Encoding>
516 enum { copyOptimization = 1 };
529 template <
typename Encoding>
531 typedef typename Encoding::Ch Ch;
536 Ch Peek() {
return *src_; }
537 Ch Take() {
return *src_++; }
538 size_t Tell() {
return static_cast<size_t>(src_ - head_); }
543 Ch* PutBegin() {
return dst_ = src_; }
544 size_t PutEnd(Ch* begin) {
return static_cast<size_t>(dst_ - begin); }
547 Ch* Push(
size_t count) { Ch* begin = dst_; dst_ += count;
return begin; }
548 void Pop(
size_t count) { dst_ -= count; }
555 template <
typename Encoding>
557 enum { copyOptimization = 1 };
579 #endif // RAPIDJSON_RAPIDJSON_H_ true
Definition: rapidjson.h:570
Read-only string stream.
Definition: rapidjson.h:496
unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:247
false
Definition: rapidjson.h:569
const Ch * head_
Original head of the string.
Definition: rapidjson.h:511
const Ch * src_
Current read position.
Definition: rapidjson.h:510
GenericInsituStringStream< UTF8<> > InsituStringStream
Insitu string stream with UTF8 encoding.
Definition: rapidjson.h:561
Concept for encoding of Unicode characters.
Type
Type of JSON value.
Definition: rapidjson.h:567
object
Definition: rapidjson.h:571
GenericStringStream< UTF8<> > StringStream
String stream with UTF8 encoding.
Definition: rapidjson.h:520
array
Definition: rapidjson.h:572
main RapidJSON namespace
Definition: rapidjson.h:241
null
Definition: rapidjson.h:568
Concept for reading and writing characters.
string
Definition: rapidjson.h:573
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:269
number
Definition: rapidjson.h:574
Provides additional information for stream.
Definition: rapidjson.h:473
A read-write string stream.
Definition: rapidjson.h:530
void PutN(Stream &stream, Ch c, size_t n)
Put N copies of a character to a stream.
Definition: rapidjson.h:484