26 #ifndef RAPIDJSON_RAPIDJSON_H_
27 #define RAPIDJSON_RAPIDJSON_H_
40 #ifndef RAPIDJSON_NO_INT64DEFINE
42 typedef __int64 int64_t;
43 typedef unsigned __int64 uint64_t;
51 #define RAPIDJSON_LITTLEENDIAN 0
52 #define RAPIDJSON_BIGENDIAN 1
59 #ifndef RAPIDJSON_ENDIAN
61 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
62 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
64 #define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
67 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
80 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42)
81 #define RAPIDJSON_SIMD
87 #ifndef RAPIDJSON_NO_SIZETYPEDEFINE
103 #ifndef RAPIDJSON_ASSERT
105 #define RAPIDJSON_ASSERT(x) assert(x)
111 #define RAPIDJSON_MULTILINEMACRO_BEGIN do {
112 #define RAPIDJSON_MULTILINEMACRO_END \
160 void*
Malloc(
size_t size) {
return malloc(size); }
161 void*
Realloc(
void* originalPtr,
size_t originalSize,
size_t newSize) { (void)originalSize;
return realloc(originalPtr, newSize); }
162 static void Free(
void *ptr) { free(ptr); }
184 template <
typename BaseAllocator = CrtAllocator>
245 capacity += c->capacity;
261 size = (size + 3) & ~3;
274 void*
Realloc(
void* originalPtr,
size_t originalSize,
size_t newSize) {
275 if (originalPtr == 0)
279 if (originalSize >= newSize)
284 size_t increment = newSize - originalSize;
285 increment = (increment + 3) & ~3;
294 void* newBuffer =
Malloc(newSize);
296 return memcpy(newBuffer, originalPtr, originalSize);
359 template<
typename CharType =
char>
364 if (codepoint <= 0x7F)
365 *buffer++ = codepoint & 0xFF;
366 else if (codepoint <= 0x7FF) {
367 *buffer++ = 0xC0 | ((codepoint >> 6) & 0xFF);
368 *buffer++ = 0x80 | ((codepoint & 0x3F));
370 else if (codepoint <= 0xFFFF) {
371 *buffer++ = 0xE0 | ((codepoint >> 12) & 0xFF);
372 *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
373 *buffer++ = 0x80 | (codepoint & 0x3F);
377 *buffer++ = 0xF0 | ((codepoint >> 18) & 0xFF);
378 *buffer++ = 0x80 | ((codepoint >> 12) & 0x3F);
379 *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
380 *buffer++ = 0x80 | (codepoint & 0x3F);
394 template<
typename CharType =
wchar_t>
399 if (codepoint <= 0xFFFF) {
401 *buffer++ =
static_cast<Ch>(codepoint);
405 unsigned v = codepoint - 0x10000;
406 *buffer++ =
static_cast<Ch>((v >> 10) + 0xD800);
407 *buffer++ = (v & 0x3FF) + 0xDC00;
421 template<
typename CharType =
unsigned>
427 *buffer++ = codepoint;
472 template<
typename Stream,
typename Ch>
474 for (
size_t i = 0;
i <
n;
i++)
484 template <
typename Encoding>
486 typedef typename Encoding::Ch
Ch;
511 template <
typename Encoding>
513 typedef typename Encoding::Ch
Ch;
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
C-runtime library allocator.
Definition: rapidjson.h:157
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
Definition: rapidjson.h:161
static const bool kNeedFree
Definition: rapidjson.h:159
void * Malloc(size_t size)
Definition: rapidjson.h:160
static void Free(void *ptr)
Definition: rapidjson.h:162
Default memory allocator used by the parser and DOM.
Definition: rapidjson.h:185
void * Malloc(size_t size)
Allocates a memory block. (concept Allocator)
Definition: rapidjson.h:260
static const bool kNeedFree
Tell users that no need to call Free() with this allocator. (concept Allocator)
Definition: rapidjson.h:187
char * userBuffer_
User supplied buffer.
Definition: rapidjson.h:327
MemoryPoolAllocator(size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
Constructor with chunkSize.
Definition: rapidjson.h:193
size_t chunk_capacity_
The minimum capacity of chunk when they are allocated.
Definition: rapidjson.h:326
MemoryPoolAllocator(char *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
Constructor with user-supplied buffer.
Definition: rapidjson.h:211
ChunkHeader * chunkHead_
Head of the chunk linked-list. Only the head chunk serves allocation.
Definition: rapidjson.h:325
size_t Capacity()
Computes the total capacity of allocated memory chunks.
Definition: rapidjson.h:242
size_t Size()
Computes the memory blocks allocated.
Definition: rapidjson.h:252
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
Resizes a memory block (concept Allocator)
Definition: rapidjson.h:274
void AddChunk(size_t capacity)
Creates a new chunk.
Definition: rapidjson.h:306
void Clear()
Deallocates all memory chunks, excluding the user-supplied buffer.
Definition: rapidjson.h:231
~MemoryPoolAllocator()
Destructor.
Definition: rapidjson.h:225
static void Free(void *)
Frees a memory block (concept Allocator)
Definition: rapidjson.h:300
BaseAllocator * baseAllocator_
base allocator for allocating memory chunks.
Definition: rapidjson.h:328
static const int kDefaultChunkCapacity
Default chunk capacity.
Definition: rapidjson.h:314
BaseAllocator * ownBaseAllocator_
base allocator created by this object.
Definition: rapidjson.h:329
Concept for reading and writing characters.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Definition: document.h:38
unsigned SizeType
Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.
Definition: rapidjson.h:92
GenericInsituStringStream< UTF8<> > InsituStringStream
Definition: rapidjson.h:532
void PutN(GenericWriteStream &stream, char c, size_t n)
Definition: genericstream.h:113
GenericStringStream< UTF8<> > StringStream
Definition: rapidjson.h:502
Type
Type of JSON value.
Definition: rapidjson.h:538
@ kArrayType
array
Definition: rapidjson.h:543
@ kNull_Type
null
Definition: rapidjson.h:539
@ kTrueType
true
Definition: rapidjson.h:541
@ kFalseType
false
Definition: rapidjson.h:540
@ kNumberType
number
Definition: rapidjson.h:545
@ kObjectType
object
Definition: rapidjson.h:542
@ kStringType
string
Definition: rapidjson.h:544
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:105
A read-write string stream.
Definition: rapidjson.h:512
Ch Peek()
Definition: rapidjson.h:518
Ch * PutBegin()
Definition: rapidjson.h:523
size_t Tell()
Definition: rapidjson.h:520
Encoding::Ch Ch
Definition: rapidjson.h:513
GenericInsituStringStream(Ch *src)
Definition: rapidjson.h:515
Ch * head_
Definition: rapidjson.h:529
size_t PutEnd(Ch *begin)
Definition: rapidjson.h:525
Ch Take()
Definition: rapidjson.h:519
void Put(Ch c)
Definition: rapidjson.h:524
Ch * dst_
Definition: rapidjson.h:528
Ch * src_
Definition: rapidjson.h:527
Read-only string stream.
Definition: rapidjson.h:485
size_t PutEnd(Ch *)
Definition: rapidjson.h:496
const Ch * head_
Original head of the string.
Definition: rapidjson.h:499
Ch Take()
Definition: rapidjson.h:491
Encoding::Ch Ch
Definition: rapidjson.h:486
size_t Tell() const
Definition: rapidjson.h:492
const Ch * src_
Current read position.
Definition: rapidjson.h:498
void Put(Ch)
Definition: rapidjson.h:495
Ch Peek() const
Definition: rapidjson.h:490
GenericStringStream(const Ch *src)
Definition: rapidjson.h:488
Ch * PutBegin()
Definition: rapidjson.h:494
UTF-16 encoding.
Definition: rapidjson.h:395
static Ch * Encode(Ch *buffer, unsigned codepoint)
Definition: rapidjson.h:398
CharType Ch
Definition: rapidjson.h:396
UTF-32 encoding.
Definition: rapidjson.h:422
static Ch * Encode(Ch *buffer, unsigned codepoint)
Definition: rapidjson.h:425
CharType Ch
Definition: rapidjson.h:423
UTF-8 encoding.
Definition: rapidjson.h:360
CharType Ch
Definition: rapidjson.h:361
static Ch * Encode(Ch *buffer, unsigned codepoint)
Definition: rapidjson.h:363