15 #ifndef RAPIDJSON_RAPIDJSON_H_
16 #define RAPIDJSON_RAPIDJSON_H_
50 #define RAPIDJSON_STRINGIFY(x) RAPIDJSON_DO_STRINGIFY(x)
51 #define RAPIDJSON_DO_STRINGIFY(x) #x
70 #define RAPIDJSON_MAJOR_VERSION 1
71 #define RAPIDJSON_MINOR_VERSION 0
72 #define RAPIDJSON_PATCH_VERSION 2
73 #define RAPIDJSON_VERSION_STRING \
74 RAPIDJSON_STRINGIFY(RAPIDJSON_MAJOR_VERSION.RAPIDJSON_MINOR_VERSION.RAPIDJSON_PATCH_VERSION)
112 #ifndef RAPIDJSON_NAMESPACE
113 #define RAPIDJSON_NAMESPACE rapidjson
115 #ifndef RAPIDJSON_NAMESPACE_BEGIN
116 #define RAPIDJSON_NAMESPACE_BEGIN namespace RAPIDJSON_NAMESPACE {
118 #ifndef RAPIDJSON_NAMESPACE_END
119 #define RAPIDJSON_NAMESPACE_END }
135 #ifndef RAPIDJSON_NO_INT64DEFINE
143 #include <inttypes.h>
145 #ifdef RAPIDJSON_DOXYGEN_RUNNING
147 #define RAPIDJSON_NO_INT64DEFINE
149 #endif // RAPIDJSON_NO_INT64TYPEDEF
154 #ifndef RAPIDJSON_FORCEINLINE
155 #if defined(_MSC_VER) && !defined(NDEBUG)
157 #define RAPIDJSON_FORCEINLINE __forceinline
158 #elif defined(__GNUC__) && __GNUC__ >= 4 && !defined(NDEBUG)
159 #define RAPIDJSON_FORCEINLINE __attribute__((always_inline))
161 #define RAPIDJSON_FORCEINLINE
163 #endif // RAPIDJSON_FORCEINLINE
168 #define RAPIDJSON_LITTLEENDIAN 0
169 #define RAPIDJSON_BIGENDIAN 1
184 #ifndef RAPIDJSON_ENDIAN
186 # ifdef __BYTE_ORDER__
187 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
188 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
189 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
190 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
192 # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.
193 # endif // __BYTE_ORDER__
195 # elif defined(__GLIBC__)
197 # if (__BYTE_ORDER == __LITTLE_ENDIAN)
198 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
199 # elif (__BYTE_ORDER == __BIG_ENDIAN)
200 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
202 # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.
205 # elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
206 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
207 # elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
208 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
210 # elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || defined(__s390__)
211 # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
212 # 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__)
213 # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
214 # elif defined(RAPIDJSON_DOXYGEN_RUNNING)
215 # define RAPIDJSON_ENDIAN
217 # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.
219 #endif // RAPIDJSON_ENDIAN
225 #ifndef RAPIDJSON_64BIT
226 #if defined(__LP64__) || defined(_WIN64)
227 #define RAPIDJSON_64BIT 1
229 #define RAPIDJSON_64BIT 0
231 #endif // RAPIDJSON_64BIT
243 #ifndef RAPIDJSON_ALIGN
244 #if RAPIDJSON_64BIT == 1
245 #define RAPIDJSON_ALIGN(x) ((x + 7u) & ~7u)
247 #define RAPIDJSON_ALIGN(x) ((x + 3u) & ~3u)
260 #ifndef RAPIDJSON_UINT64_C2
261 #define RAPIDJSON_UINT64_C2(high32, low32) ((static_cast<uint64_t>(high32) << 32) | static_cast<uint64_t>(low32))
289 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) \
290 || defined(RAPIDJSON_DOXYGEN_RUNNING)
291 #define RAPIDJSON_SIMD
297 #ifndef RAPIDJSON_NO_SIZETYPEDEFINE
313 #ifdef RAPIDJSON_DOXYGEN_RUNNING
314 #define RAPIDJSON_NO_SIZETYPEDEFINE
342 #ifndef RAPIDJSON_ASSERT
344 #define RAPIDJSON_ASSERT(x) assert(x)
345 #endif // RAPIDJSON_ASSERT
351 #ifndef RAPIDJSON_STATIC_ASSERT
354 template <
bool x>
struct STATIC_ASSERTION_FAILURE;
355 template <>
struct STATIC_ASSERTION_FAILURE<
true> {
enum {
value = 1 }; };
356 template<
int x>
struct StaticAssertTest {};
359 #define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y)
360 #define RAPIDJSON_DO_JOIN(X, Y) RAPIDJSON_DO_JOIN2(X, Y)
361 #define RAPIDJSON_DO_JOIN2(X, Y) X##Y
363 #if defined(__GNUC__)
364 #define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused))
366 #define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE
375 #define RAPIDJSON_STATIC_ASSERT(x) \
376 typedef ::RAPIDJSON_NAMESPACE::StaticAssertTest< \
377 sizeof(::RAPIDJSON_NAMESPACE::STATIC_ASSERTION_FAILURE<bool(x) >)> \
378 RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE
386 #define RAPIDJSON_MULTILINEMACRO_BEGIN do {
387 #define RAPIDJSON_MULTILINEMACRO_END \
391 #define RAPIDJSON_VERSION_CODE(x,y,z) \
392 (((x)*100000) + ((y)*100) + (z))
397 #if defined(__GNUC__)
398 #define RAPIDJSON_GNUC \
399 RAPIDJSON_VERSION_CODE(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__)
402 #if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,2,0))
404 #define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x))
405 #define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(GCC diagnostic x)
406 #define RAPIDJSON_DIAG_OFF(x) \
407 RAPIDJSON_DIAG_PRAGMA(ignored RAPIDJSON_STRINGIFY(RAPIDJSON_JOIN(-W,x)))
410 #if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0))
411 #define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push)
412 #define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop)
413 #else // GCC >= 4.2, < 4.6
414 #define RAPIDJSON_DIAG_PUSH
415 #define RAPIDJSON_DIAG_POP
418 #elif defined(_MSC_VER)
421 #define RAPIDJSON_PRAGMA(x) __pragma(x)
422 #define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(warning(x))
424 #define RAPIDJSON_DIAG_OFF(x) RAPIDJSON_DIAG_PRAGMA(disable: x)
425 #define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push)
426 #define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop)
430 #define RAPIDJSON_DIAG_OFF(x)
431 #define RAPIDJSON_DIAG_PUSH
432 #define RAPIDJSON_DIAG_POP
434 #endif // RAPIDJSON_DIAG_*
439 #ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS
440 #if defined(__clang__)
441 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS __has_feature(cxx_rvalue_references) && \
442 (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306)
443 #elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \
444 (defined(_MSC_VER) && _MSC_VER >= 1600)
446 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1
448 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0
450 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
452 #ifndef RAPIDJSON_HAS_CXX11_NOEXCEPT
453 #if defined(__clang__)
454 #define RAPIDJSON_HAS_CXX11_NOEXCEPT __has_feature(cxx_noexcept)
455 #elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__))
457 #define RAPIDJSON_HAS_CXX11_NOEXCEPT 1
459 #define RAPIDJSON_HAS_CXX11_NOEXCEPT 0
462 #if RAPIDJSON_HAS_CXX11_NOEXCEPT
463 #define RAPIDJSON_NOEXCEPT noexcept
465 #define RAPIDJSON_NOEXCEPT
466 #endif // RAPIDJSON_HAS_CXX11_NOEXCEPT
469 #ifndef RAPIDJSON_HAS_CXX11_TYPETRAITS
470 #define RAPIDJSON_HAS_CXX11_TYPETRAITS 0
478 #ifndef RAPIDJSON_NEW
479 #define RAPIDJSON_NEW(x) new x
482 #ifndef RAPIDJSON_DELETE
483 #define RAPIDJSON_DELETE(x) delete x
547 template<
typename Stream>
558 template<
typename Stream,
typename Ch>
559 inline void PutN(Stream& stream, Ch c,
size_t n) {
560 for (
size_t i = 0; i < n; i++)
570 template <
typename Encoding>
572 typedef typename Encoding::Ch
Ch;
589 template <
typename Encoding>
604 template <
typename Encoding>
606 typedef typename Encoding::Ch
Ch;
619 size_t PutEnd(Ch* begin) {
return static_cast<size_t>(
dst_ - begin); }
622 Ch*
Push(
size_t count) { Ch* begin =
dst_;
dst_ += count;
return begin; }
630 template <
typename Encoding>
654 #endif // RAPIDJSON_RAPIDJSON_H_
Ch * PutBegin()
Definition: rapidjson.h:580
Ch Take()
Definition: rapidjson.h:612
Ch Take()
Definition: rapidjson.h:577
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:322
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
Ch Peek()
Definition: rapidjson.h:611
object
Definition: rapidjson.h:646
Read-only string stream.
Definition: rapidjson.h:571
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
array
Definition: rapidjson.h:647
GenericInsituStringStream< UTF8<> > InsituStringStream
Insitu string stream with UTF8 encoding.
Definition: rapidjson.h:636
GenericStringStream< UTF8<> > StringStream
String stream with UTF8 encoding.
Definition: rapidjson.h:595
GenericInsituStringStream(Ch *src)
Definition: rapidjson.h:608
const Ch * src_
Current read position.
Definition: rapidjson.h:585
false
Definition: rapidjson.h:644
Ch Peek() const
Definition: rapidjson.h:576
void Pop(size_t count)
Definition: rapidjson.h:623
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
Ch * dst_
Definition: rapidjson.h:626
A read-write string stream.
Definition: rapidjson.h:605
#define true
Definition: CascPort.h:17
GenericStringStream(const Ch *src)
Definition: rapidjson.h:574
Ch * src_
Definition: rapidjson.h:625
void Flush()
Definition: rapidjson.h:582
string
Definition: rapidjson.h:648
size_t Tell()
Definition: rapidjson.h:613
number
Definition: rapidjson.h:649
Provides additional information for stream.
Definition: rapidjson.h:548
size_t PutEnd(Ch *)
Definition: rapidjson.h:583
Ch * head_
Definition: rapidjson.h:627
Definition: rapidjson.h:554
void Flush()
Definition: rapidjson.h:620
true
Definition: rapidjson.h:645
const FieldDescriptor value
Definition: descriptor.h:1522
size_t PutEnd(Ch *begin)
Definition: rapidjson.h:619
Encoding::Ch Ch
Definition: rapidjson.h:572
void Put(Ch)
Definition: rapidjson.h:581
void Put(Ch c)
Definition: rapidjson.h:616
Type
Type of JSON value.
Definition: rapidjson.h:642
size_t Tell() const
Definition: rapidjson.h:578
Ch * Push(size_t count)
Definition: rapidjson.h:622
Ch * PutBegin()
Definition: rapidjson.h:618
Encoding::Ch Ch
Definition: rapidjson.h:606
null
Definition: rapidjson.h:643
void PutN(Stream &stream, Ch c, size_t n)
Put N copies of a character to a stream.
Definition: rapidjson.h:559
const Ch * head_
Original head of the string.
Definition: rapidjson.h:586