1 #ifndef RAPIDJSON_RAPIDJSON_H_
2 #define RAPIDJSON_RAPIDJSON_H_
15 #ifndef RAPIDJSON_NO_INT64DEFINE
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
42 #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
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)
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;
249 void*
Realloc(
void* originalPtr,
size_t originalSize,
size_t newSize) {
250 if (originalPtr == 0)
254 if (originalSize >= newSize)
259 size_t increment = newSize - originalSize;
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;
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
C-runtime library allocator.
Definition: rapidjson.h:132
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
Definition: rapidjson.h:136
static const bool kNeedFree
Definition: rapidjson.h:134
void * Malloc(size_t size)
Definition: rapidjson.h:135
static void Free(void *ptr)
Definition: rapidjson.h:137
Default memory allocator used by the parser and DOM.
Definition: rapidjson.h:160
void * Malloc(size_t size)
Allocates a memory block. (concept Allocator)
Definition: rapidjson.h:235
static const bool kNeedFree
Tell users that no need to call Free() with this allocator. (concept Allocator)
Definition: rapidjson.h:162
char * userBuffer_
User supplied buffer.
Definition: rapidjson.h:302
MemoryPoolAllocator(size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
Constructor with chunkSize.
Definition: rapidjson.h:168
size_t chunk_capacity_
The minimum capacity of chunk when they are allocated.
Definition: rapidjson.h:301
MemoryPoolAllocator(char *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
Constructor with user-supplied buffer.
Definition: rapidjson.h:186
ChunkHeader * chunkHead_
Head of the chunk linked-list. Only the head chunk serves allocation.
Definition: rapidjson.h:300
size_t Capacity()
Computes the total capacity of allocated memory chunks.
Definition: rapidjson.h:217
size_t Size()
Computes the memory blocks allocated.
Definition: rapidjson.h:227
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
Resizes a memory block (concept Allocator)
Definition: rapidjson.h:249
void AddChunk(size_t capacity)
Creates a new chunk.
Definition: rapidjson.h:281
void Clear()
Deallocates all memory chunks, excluding the user-supplied buffer.
Definition: rapidjson.h:206
~MemoryPoolAllocator()
Destructor.
Definition: rapidjson.h:200
static void Free(void *)
Frees a memory block (concept Allocator)
Definition: rapidjson.h:275
BaseAllocator * baseAllocator_
base allocator for allocating memory chunks.
Definition: rapidjson.h:303
static const int kDefaultChunkCapacity
Default chunk capacity.
Definition: rapidjson.h:289
BaseAllocator * ownBaseAllocator_
base allocator created by this object.
Definition: rapidjson.h:304
Concept for reading and writing characters.
std::int64_t int64_t
Definition: Meta.h:43
std::uint64_t uint64_t
Definition: Meta.h:42
int c
Definition: calibrate.py:100
Definition: document.h:13
unsigned SizeType
Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.
Definition: rapidjson.h:67
GenericInsituStringStream< UTF8<> > InsituStringStream
Definition: rapidjson.h:507
void PutN(GenericWriteStream &stream, char c, size_t n)
Definition: genericstream.h:88
GenericStringStream< UTF8<> > StringStream
Definition: rapidjson.h:477
Type
Type of JSON value.
Definition: rapidjson.h:513
@ kArrayType
array
Definition: rapidjson.h:518
@ kNull_Type
null
Definition: rapidjson.h:514
@ kTrueType
true
Definition: rapidjson.h:516
@ kFalseType
false
Definition: rapidjson.h:515
@ kNumberType
number
Definition: rapidjson.h:520
@ kObjectType
object
Definition: rapidjson.h:517
@ kStringType
string
Definition: rapidjson.h:519
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:80
A read-write string stream.
Definition: rapidjson.h:487
Ch Peek()
Definition: rapidjson.h:493
Ch * PutBegin()
Definition: rapidjson.h:498
size_t Tell()
Definition: rapidjson.h:495
Encoding::Ch Ch
Definition: rapidjson.h:488
GenericInsituStringStream(Ch *src)
Definition: rapidjson.h:490
Ch * head_
Definition: rapidjson.h:504
size_t PutEnd(Ch *begin)
Definition: rapidjson.h:500
Ch Take()
Definition: rapidjson.h:494
void Put(Ch c)
Definition: rapidjson.h:499
Ch * dst_
Definition: rapidjson.h:503
Ch * src_
Definition: rapidjson.h:502
Read-only string stream.
Definition: rapidjson.h:460
size_t PutEnd(Ch *)
Definition: rapidjson.h:471
const Ch * head_
Original head of the string.
Definition: rapidjson.h:474
Ch Take()
Definition: rapidjson.h:466
Encoding::Ch Ch
Definition: rapidjson.h:461
size_t Tell() const
Definition: rapidjson.h:467
const Ch * src_
Current read position.
Definition: rapidjson.h:473
void Put(Ch)
Definition: rapidjson.h:470
Ch Peek() const
Definition: rapidjson.h:465
GenericStringStream(const Ch *src)
Definition: rapidjson.h:463
Ch * PutBegin()
Definition: rapidjson.h:469
UTF-16 encoding.
Definition: rapidjson.h:370
static Ch * Encode(Ch *buffer, unsigned codepoint)
Definition: rapidjson.h:373
CharType Ch
Definition: rapidjson.h:371
UTF-32 encoding.
Definition: rapidjson.h:397
static Ch * Encode(Ch *buffer, unsigned codepoint)
Definition: rapidjson.h:400
CharType Ch
Definition: rapidjson.h:398
UTF-8 encoding.
Definition: rapidjson.h:335
CharType Ch
Definition: rapidjson.h:336
static Ch * Encode(Ch *buffer, unsigned codepoint)
Definition: rapidjson.h:338