1 #ifndef RAPIDJSON_RAPIDJSON_H_
2 #define RAPIDJSON_RAPIDJSON_H_
15 #ifndef RAPIDJSON_NO_INT64DEFINE
17 typedef __int64 int64_t;
18 typedef unsigned __int64 uint64_t;
22 #endif // RAPIDJSON_NO_INT64TYPEDEF
26 #define RAPIDJSON_LITTLEENDIAN 0
27 #define RAPIDJSON_BIGENDIAN 1
34 #ifndef RAPIDJSON_ENDIAN
36 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
37 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
39 #define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
40 #endif // __BYTE_ORDER__
42 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN // Assumes little endian otherwise.
44 #endif // RAPIDJSON_ENDIAN
55 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42)
56 #define RAPIDJSON_SIMD
62 #ifndef RAPIDJSON_NO_SIZETYPEDEFINE
78 #ifndef RAPIDJSON_ASSERT
80 #define RAPIDJSON_ASSERT(x) assert(x)
81 #endif // RAPIDJSON_ASSERT
86 #define RAPIDJSON_MULTILINEMACRO_BEGIN do {
87 #define RAPIDJSON_MULTILINEMACRO_END \
136 void*
Realloc(
void* originalPtr,
size_t originalSize,
size_t newSize) { (
void)originalSize;
return realloc(originalPtr, newSize); }
137 static void Free(
void *ptr) { free(ptr); }
159 template <
typename BaseAllocator = CrtAllocator>
220 capacity +=
c->capacity;
236 size = (size + 3) & ~3;
250 if (originalPtr == 0)
254 if (originalSize >= newSize)
260 increment = (increment + 3) & ~3;
269 void* newBuffer =
Malloc(newSize);
271 return memcpy(newBuffer, originalPtr, originalSize);
334 template<
typename CharType =
char>
339 if (codepoint <= 0x7F)
340 *buffer++ = codepoint & 0xFF;
341 else if (codepoint <= 0x7FF) {
342 *buffer++ = 0xC0 | ((codepoint >> 6) & 0xFF);
343 *buffer++ = 0x80 | ((codepoint & 0x3F));
345 else if (codepoint <= 0xFFFF) {
346 *buffer++ = 0xE0 | ((codepoint >> 12) & 0xFF);
347 *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
348 *buffer++ = 0x80 | (codepoint & 0x3F);
352 *buffer++ = 0xF0 | ((codepoint >> 18) & 0xFF);
353 *buffer++ = 0x80 | ((codepoint >> 12) & 0x3F);
354 *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
355 *buffer++ = 0x80 | (codepoint & 0x3F);
369 template<
typename CharType =
wchar_t>
374 if (codepoint <= 0xFFFF) {
376 *buffer++ =
static_cast<Ch>(codepoint);
380 unsigned v = codepoint - 0x10000;
381 *buffer++ =
static_cast<Ch>((v >> 10) + 0xD800);
382 *buffer++ = (v & 0x3FF) + 0xDC00;
396 template<
typename CharType =
unsigned>
402 *buffer++ = codepoint;
447 template<
typename Stream,
typename Ch>
449 for (
size_t i = 0; i <
n; i++)
459 template <
typename Encoding>
461 typedef typename Encoding::Ch
Ch;
486 template <
typename Encoding>
488 typedef typename Encoding::Ch
Ch;
525 #endif // RAPIDJSON_RAPIDJSON_H_