21 #ifndef RAPIDJSON_DOCUMENT_H_
22 #define RAPIDJSON_DOCUMENT_H_
25 #include "internal/strfunc.h"
30 RAPIDJSON_DIAG_OFF(4127)
31 #elif defined(__GNUC__)
33 RAPIDJSON_DIAG_OFF(effc++)
36 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS
37 #include "internal/meta.h"
44 template <
typename Encoding,
typename Allocator>
53 template <
typename Encoding,
typename Allocator>
59 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS
80 template <
bool Const,
typename Encoding,
typename Allocator>
82 :
public std::iterator<std::random_access_iterator_tag
83 , typename internal::MaybeAddConst<Const,GenericMember<Encoding,Allocator> >::Type> {
90 typedef std::iterator<std::random_access_iterator_tag,ValueType> BaseType;
133 Iterator& operator++(){ ++ptr_;
return *
this; }
134 Iterator& operator--(){ --ptr_;
return *
this; }
150 bool operator==(
Iterator that)
const {
return ptr_ == that.ptr_; }
151 bool operator!=(
Iterator that)
const {
return ptr_ != that.ptr_; }
152 bool operator<=(
Iterator that)
const {
return ptr_ <= that.ptr_; }
153 bool operator>=(
Iterator that)
const {
return ptr_ >= that.ptr_; }
154 bool operator< (
Iterator that)
const {
return ptr_ < that.ptr_; }
155 bool operator> (
Iterator that)
const {
return ptr_ > that.ptr_; }
160 Reference operator*()
const {
return *ptr_; }
161 Pointer operator->()
const {
return ptr_; }
175 #else // RAPIDJSON_NOMEMBERITERATORCLASS
179 template <
bool Const,
typename Encoding,
typename Allocator>
180 struct GenericMemberIterator;
183 template <
typename Encoding,
typename Allocator>
184 struct GenericMemberIterator<false,Encoding,Allocator> {
186 typedef GenericMember<Encoding,Allocator>*
Iterator;
189 template <
typename Encoding,
typename Allocator>
190 struct GenericMemberIterator<true,Encoding,Allocator> {
192 typedef const GenericMember<Encoding,Allocator>*
Iterator;
195 #endif // RAPIDJSON_NOMEMBERITERATORCLASS
227 template<
typename CharType>
278 :
s(str),
length(internal::StrLen(str)){}
291 operator const Ch *()
const {
return s; }
316 template<
typename CharType>
336 template<
typename CharType>
354 #pragma pack (push, 4)
355 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
362 typedef typename Encoding::Ch
Ch;
387 static const unsigned defaultFlags[7] = {
388 kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kConstStringFlag,
392 flags_ = defaultFlags[type];
402 template<
typename SourceAllocator >
411 #ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen
412 template <
typename T>
413 explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<T,bool>)))
417 : data_(), flags_(b ? kTrueFlag : kFalseFlag) {}
423 flags_ |= kUintFlag | kUint64Flag;
429 if (!(u & 0x80000000))
430 flags_ |= kIntFlag | kInt64Flag;
434 explicit GenericValue(int64_t i64) : data_(), flags_(kNumberInt64Flag) {
437 flags_ |= kNumberUint64Flag;
448 explicit GenericValue(uint64_t u64) : data_(), flags_(kNumberUint64Flag) {
451 flags_ |= kInt64Flag;
459 explicit GenericValue(
double d) : data_(), flags_(kNumberDoubleFlag) { data_.n.d = d; }
477 if (Allocator::kNeedFree) {
480 for (
GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
482 Allocator::Free(data_.a.elements);
489 Allocator::Free(data_.o.members);
492 case kCopyStringFlag:
493 Allocator::Free(const_cast<Ch*>(data_.s.str));
539 template <
typename T>
540 RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer<T>,
GenericValue&)
552 template <
typename SourceAllocator>
567 temp.RawAssign(*
this);
569 other.RawAssign(temp);
586 if (GetType() != rhs.GetType())
591 if (data_.o.size != rhs.data_.o.size)
595 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
601 if (data_.a.size != rhs.data_.a.size)
603 for (
SizeType i = 0; i < data_.a.size; i++)
604 if ((*
this)[i] != rhs[i])
609 return StringEqual(rhs);
612 if (IsDouble() || rhs.GetDouble())
613 return GetDouble() == rhs.GetDouble();
615 return data_.n.u64 == rhs.data_.n.u64;
641 template <
typename T>
friend bool operator!=(
const GenericValue& lhs,
const T& rhs) {
return !(lhs == rhs); }
643 template <
typename T>
friend bool operator!=(
const T& lhs,
const GenericValue& rhs) {
return !(lhs == rhs); }
649 Type GetType()
const {
return static_cast<Type>(flags_ & kTypeMask); }
650 bool IsNull()
const {
return flags_ == kNullFlag; }
651 bool IsFalse()
const {
return flags_ == kFalseFlag; }
652 bool IsTrue()
const {
return flags_ == kTrueFlag; }
653 bool IsBool()
const {
return (flags_ & kBoolFlag) != 0; }
654 bool IsObject()
const {
return flags_ == kObjectFlag; }
655 bool IsArray()
const {
return flags_ == kArrayFlag; }
656 bool IsNumber()
const {
return (flags_ & kNumberFlag) != 0; }
657 bool IsInt()
const {
return (flags_ & kIntFlag) != 0; }
658 bool IsUint()
const {
return (flags_ & kUintFlag) != 0; }
659 bool IsInt64()
const {
return (flags_ & kInt64Flag) != 0; }
660 bool IsUint64()
const {
return (flags_ & kUint64Flag) != 0; }
661 bool IsDouble()
const {
return (flags_ & kDoubleFlag) != 0; }
662 bool IsString()
const {
return (flags_ & kStringFlag) != 0; }
709 return member->value;
789 if (name.StringEqual(member->name))
810 if (o.size >= o.capacity) {
811 if (o.capacity == 0) {
812 o.capacity = kDefaultObjectCapacity;
813 o.members =
reinterpret_cast<Member*
>(allocator.Malloc(o.capacity *
sizeof(
Member)));
818 o.members =
reinterpret_cast<Member*
>(allocator.Realloc(o.members, oldCapacity *
sizeof(
Member), o.capacity *
sizeof(
Member)));
821 o.members[o.size].
name.RawAssign(name);
822 o.members[o.size].value.RawAssign(value);
873 template <
typename T>
874 RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer<T>,
GenericValue&)
916 if (data_.o.size > 1 && m != last) {
960 data_.o.size -= (last - first);
988 for (
SizeType i = 0; i < data_.a.size; ++i)
989 data_.a.elements[i].~GenericValue();
1006 return data_.a.elements[index];
1031 if (newCapacity > data_.a.capacity) {
1033 data_.a.capacity = newCapacity;
1050 if (data_.a.size >= data_.a.capacity)
1051 Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : data_.a.capacity * 2, allocator);
1052 data_.a.elements[data_.a.size++].RawAssign(value);
1066 return (*this).template PushBack<StringRefType>(value, allocator);
1086 template <
typename T>
1087 RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer<T>,
GenericValue&)
1100 data_.a.elements[--data_.a.size].~GenericValue();
1112 return Erase(pos, pos + 1);
1134 data_.a.size -= (last - first);
1143 int GetInt()
const {
RAPIDJSON_ASSERT(flags_ & kIntFlag);
return data_.n.i.i; }
1144 unsigned GetUint()
const {
RAPIDJSON_ASSERT(flags_ & kUintFlag);
return data_.n.u.u; }
1145 int64_t GetInt64()
const {
RAPIDJSON_ASSERT(flags_ & kInt64Flag);
return data_.n.i64; }
1146 uint64_t GetUint64()
const {
RAPIDJSON_ASSERT(flags_ & kUint64Flag);
return data_.n.u64; }
1148 double GetDouble()
const {
1150 if ((flags_ & kDoubleFlag) != 0)
return data_.n.d;
1151 if ((flags_ & kIntFlag) != 0)
return data_.n.i.i;
1152 if ((flags_ & kUintFlag) != 0)
return data_.n.u.u;
1153 if ((flags_ & kInt64Flag) != 0)
return (
double)data_.n.i64;
1219 template <
typename Handler>
1224 case kTrueType:
return handler.Bool(
true);
1227 if (!handler.StartObject())
1230 if (!handler.String(m->name.data_.s.str, m->name.data_.s.length, (m->name.flags_ & kCopyFlag) != 0))
1232 if (!m->value.Accept(handler))
1235 return handler.EndObject(data_.o.size);
1238 if (!handler.StartArray())
1240 for (
GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
1241 if (!v->Accept(handler))
1243 return handler.EndArray(data_.a.size);
1246 return handler.String(data_.s.str, data_.s.length, (flags_ & kCopyFlag) != 0);
1249 if (IsInt())
return handler.Int(data_.n.i.i);
1250 else if (IsUint())
return handler.Uint(data_.n.u.u);
1251 else if (IsInt64())
return handler.Int64(data_.n.i64);
1252 else if (IsUint64())
return handler.Uint64(data_.n.u64);
1253 else return handler.Double(data_.n.d);
1262 template <
typename,
typename>
1267 kNumberFlag = 0x200,
1270 kInt64Flag = 0x1000,
1271 kUint64Flag = 0x2000,
1272 kDoubleFlag = 0x4000,
1273 kStringFlag = 0x100000,
1274 kCopyFlag = 0x200000,
1280 kNumberIntFlag =
kNumberType | kNumberFlag | kIntFlag | kInt64Flag,
1281 kNumberUintFlag =
kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag,
1282 kNumberInt64Flag =
kNumberType | kNumberFlag | kInt64Flag,
1283 kNumberUint64Flag =
kNumberType | kNumberFlag | kUint64Flag,
1284 kNumberDoubleFlag =
kNumberType | kNumberFlag | kDoubleFlag,
1285 kNumberAnyFlag =
kNumberType | kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag,
1287 kCopyStringFlag =
kStringType | kStringFlag | kCopyFlag,
1294 static const SizeType kDefaultArrayCapacity = 16;
1295 static const SizeType kDefaultObjectCapacity = 16;
1305 #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN
1350 flags_ = kArrayFlag;
1352 memcpy(data_.a.elements, values, count *
sizeof(
GenericValue));
1353 data_.a.size = data_.a.capacity = count;
1357 void SetObjectRaw(
Member* members,
SizeType count, Allocator& allocator) {
1358 flags_ = kObjectFlag;
1359 data_.o.members = (
Member*)allocator.Malloc(count *
sizeof(
Member));
1360 memcpy(data_.o.members, members, count *
sizeof(
Member));
1361 data_.o.size = data_.o.capacity = count;
1366 flags_ = kConstStringFlag;
1368 data_.s.length = s.length;
1373 flags_ = kCopyStringFlag;
1374 data_.s.str = (
Ch *)allocator.Malloc((s.length + 1) *
sizeof(
Ch));
1375 data_.s.length = s.length;
1376 memcpy(const_cast<Ch*>(data_.s.str), s, s.length *
sizeof(
Ch));
1377 const_cast<Ch*
>(data_.s.str)[s.length] =
'\0';
1383 flags_ = rhs.flags_;
1384 rhs.flags_ = kNullFlag;
1390 return data_.s.length == rhs.data_.s.length &&
1391 (data_.s.str == rhs.data_.s.str
1392 || memcmp(data_.s.str, rhs.data_.s.str,
sizeof(
Ch) * data_.s.length) == 0);
1413 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
1416 typedef typename Encoding::Ch
Ch;
1424 GenericDocument(
Allocator* allocator = 0,
size_t stackCapacity = kDefaultStackCapacity) : stack_(allocator, stackCapacity), parseResult_() {}
1436 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
1438 ValueType::SetNull();
1440 ClearStackOnExit scope(*
this);
1441 parseResult_ = reader.template Parse<parseFlags>(is, *
this);
1444 this->RawAssign(*stack_.template Pop<ValueType>(1));
1455 template <
unsigned parseFlags,
typename InputStream>
1457 return ParseStream<parseFlags,Encoding,InputStream>(is);
1465 template <
typename InputStream>
1467 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
1480 template <
unsigned parseFlags,
typename SourceEncoding>
1483 return ParseStream<parseFlags | kParseInsituFlag, SourceEncoding>(s);
1491 template <
unsigned parseFlags>
1493 return ParseInsitu<parseFlags, Encoding>(str);
1501 return ParseInsitu<kParseDefaultFlags, Encoding>(str);
1513 template <
unsigned parseFlags,
typename SourceEncoding>
1517 return ParseStream<parseFlags, SourceEncoding>(s);
1524 template <
unsigned parseFlags>
1526 return Parse<parseFlags, Encoding>(str);
1533 return Parse<kParseDefaultFlags>(str);
1559 struct ClearStackOnExit {
1561 ~ClearStackOnExit() { d_.ClearStack(); }
1563 ClearStackOnExit(
const ClearStackOnExit&);
1564 ClearStackOnExit& operator=(
const ClearStackOnExit&);
1569 template <
typename,
typename,
typename>
friend class GenericReader;
1573 bool Null() {
new (stack_.template Push<ValueType>())
ValueType();
return true; }
1574 bool Bool(
bool b) {
new (stack_.template Push<ValueType>())
ValueType(b);
return true; }
1575 bool Int(
int i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
1576 bool Uint(
unsigned i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
1577 bool Int64(int64_t i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
1578 bool Uint64(uint64_t i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
1579 bool Double(
double d) {
new (stack_.template Push<ValueType>())
ValueType(d);
return true; }
1581 bool String(
const Ch* str,
SizeType length,
bool copy) {
1585 new (stack_.template Push<ValueType>())
ValueType(str, length);
1589 bool StartObject() {
new (stack_.template Push<ValueType>())
ValueType(
kObjectType);
return true; }
1591 bool EndObject(
SizeType memberCount) {
1592 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
1593 stack_.template Top<ValueType>()->SetObjectRaw(members, (
SizeType)memberCount,
GetAllocator());
1597 bool StartArray() {
new (stack_.template Push<ValueType>())
ValueType(
kArrayType);
return true; }
1599 bool EndArray(
SizeType elementCount) {
1600 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
1601 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount,
GetAllocator());
1610 if (Allocator::kNeedFree)
1611 while (stack_.GetSize() > 0)
1612 (stack_.template Pop<ValueType>(1))->~
ValueType();
1617 static const size_t kDefaultStackCapacity = 1024;
1618 internal::Stack<Allocator> stack_;
1619 ParseResult parseResult_;
1626 template <
typename Encoding,
typename Allocator>
1627 template <
typename SourceAllocator>
1633 RawAssign(*d.stack_.template Pop<GenericValue>(1));
1638 #if defined(_MSC_VER) || defined(__GNUC__)
1642 #endif // RAPIDJSON_DOCUMENT_H_
BaseType::difference_type DifferenceType
Signed integer type (e.g. ptrdiff_t)
Definition: document.h:105
true
Definition: rapidjson.h:423
ValueIterator Erase(ConstValueIterator first, ConstValueIterator last)
Remove elements in the range [first, last) of the array.
Definition: document.h:1123
bool operator==(const GenericValue &rhs) const
Equal-to operator.
Definition: document.h:585
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
Definition: document.h:1525
Definition: document.h:1306
Read-only string stream.
Definition: rapidjson.h:349
Concept for receiving events from GenericReader upon parsing. The functions return true if no error o...
GenericValue & operator=(StringRefType str)
Assignment of constant string reference (no copy)
Definition: document.h:522
ValueIterator Begin()
Element iterator.
Definition: document.h:1012
GenericValue & Move()
Prepare Value for move semantics.
Definition: document.h:575
friend bool operator==(const GenericValue &lhs, const Ch *rhs)
(Not-)Equal-to operator with const C-string pointer.
Definition: document.h:626
GenericMemberIterator< true, Encoding, Allocator > ConstType
Constant iterator type.
Definition: document.h:96
GenericValue(uint64_t u64)
Constructor for uint64_t value.
Definition: document.h:448
friend bool operator==(const GenericValue &lhs, Ch *rhs)
(Not-)Equal-to operator with non-const C-string pointer.
Definition: document.h:632
GenericValue(const Ch *s, SizeType length, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
Definition: document.h:468
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
Definition: document.h:1544
~GenericValue()
Destructor.
Definition: document.h:476
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:138
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition: reader.h:353
GenericValue(const Ch *s, SizeType length)
Constructor for constant string (i.e. do not make a copy of string)
Definition: document.h:462
GenericMemberIterator(const NonConstType &it)
Iterator conversions to more const.
Definition: document.h:129
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
Definition: document.h:1492
GenericValue & operator[](const Ch *name)
Get the value associated with the name.
Definition: document.h:698
GenericValue & SetObject()
Set this value as an empty object.
Definition: document.h:688
GenericStringRef< Ch > StringRefType
Reference to a constant string.
Definition: document.h:363
GenericMemberIterator Iterator
Iterator type itself.
Definition: document.h:94
ConstMemberIterator MemberBegin() const
Const member iterator.
Definition: document.h:720
ConstMemberIterator MemberEnd() const
Const past-the-end member iterator.
Definition: document.h:723
unsigned SizeType
Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.
Definition: rapidjson.h:162
false
Definition: rapidjson.h:422
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags)
Definition: document.h:1532
GenericValue(const Ch *s, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
Definition: document.h:471
size_t GetStackCapacity() const
Get the capacity of stack in bytes.
Definition: document.h:1555
bool RemoveMember(const Ch *name)
Remove a member in object by its name.
Definition: document.h:887
bool Accept(Handler &handler) const
Generate events of this value to a Handler.
Definition: document.h:1220
GenericValue(int64_t i64)
Constructor for int64_t value.
Definition: document.h:434
GenericValue(double d)
Constructor for double value.
Definition: document.h:459
GenericValue & PopBack()
Remove the last element in the array.
Definition: document.h:1097
GenericValue & Reserve(SizeType newCapacity, Allocator &allocator)
Request the array to have enough capacity to store elements.
Definition: document.h:1029
ValueIterator End()
Past-the-end element iterator
Definition: document.h:1015
GenericStringRef(const CharType(&str)[N])
Create string reference from const character array.
Definition: document.h:255
Allocator AllocatorType
Allocator type from template parameter.
Definition: document.h:1418
bool GetBool() const
Set boolean value.
Definition: document.h:676
MemberIterator RemoveMember(MemberIterator m)
Remove a member in object by iterator.
Definition: document.h:909
MemberIterator MemberBegin()
Member iterator.
Definition: document.h:726
bool operator!=(const GenericValue &rhs) const
Not-equal-to operator.
Definition: document.h:623
Allocator AllocatorType
Allocator type from template parameter.
Definition: document.h:361
bool HasMember(const GenericValue &name) const
Check whether a member exists in the object with GenericValue name.
Definition: document.h:750
GenericValue & AddMember(StringRefType name, StringRefType value, Allocator &allocator)
Add a constant string value as member (name-value pair) to the object.
Definition: document.h:851
friend bool operator==(const GenericValue &lhs, const T &rhs)
(Not-)Equal-to operator with primitive types.
Definition: document.h:640
GenericValue & SetString(const Ch *s, SizeType length, Allocator &allocator)
Set this value as a string by copying from source string.
Definition: document.h:1200
MemberIterator EraseMember(ConstMemberIterator pos)
Remove a member from an object by iterator.
Definition: document.h:936
GenericStringRef(const CharType *str, SizeType len)
Create constant string reference from pointer and length.
Definition: document.h:287
Name-value pair in a JSON object value.
Definition: document.h:54
GenericValue & SetString(const Ch *s, SizeType length)
Set this value as a string without copying source string.
Definition: document.h:1183
GenericValue(Type type)
Constructor with JSON value type.
Definition: document.h:386
SizeType Size() const
Get the number of elements in array.
Definition: document.h:974
GenericMemberIterator< false, Encoding, Allocator > NonConstType
Non-constant iterator type.
Definition: document.h:98
const SizeType length
length of the string (excluding the trailing NULL terminator)
Definition: document.h:294
BaseType::reference Reference
Reference to (const) GenericMember.
Definition: document.h:103
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
Definition: document.h:367
Concept for encoding of Unicode characters.
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1417
GenericValue & AddMember(GenericValue &name, GenericValue &value, Allocator &allocator)
Add a member (name-value pair) to the object.
Definition: document.h:805
MemberIterator FindMember(const Ch *name)
Find member by name.
Definition: document.h:764
ConstValueIterator Begin() const
Constant element iterator.
Definition: document.h:1018
void Clear()
Remove all elements in the array.
Definition: document.h:986
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:317
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:175
GenericValue & operator=(GenericValue &rhs)
Assignment with move semantics.
Definition: document.h:510
GenericValue()
Default constructor creates a null value.
Definition: document.h:373
Type
Type of JSON value.
Definition: rapidjson.h:420
GenericValue & operator[](SizeType index)
Get an element from array by index.
Definition: document.h:1003
BaseType::pointer Pointer
Pointer to (const) GenericMember.
Definition: document.h:101
object
Definition: rapidjson.h:424
GenericValue & PushBack(GenericValue &value, Allocator &allocator)
Append a GenericValue at the end of the array.
Definition: document.h:1048
bool HasParseError() const
Whether a parse error has occured in the last parsing.
Definition: document.h:1541
MemberIterator MemberEnd()
Past-the-end member iterator
Definition: document.h:729
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
Definition: document.h:1456
A document for parsing JSON text as DOM.
Definition: document.h:1414
array
Definition: rapidjson.h:425
GenericValue * ValueIterator
Value iterator for iterating in array.
Definition: document.h:366
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with Encoding conversion)
Definition: document.h:1481
bool IsError() const
Whether the result is an error.
Definition: error.h:112
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:1416
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:362
Definition: document.h:1310
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
Definition: document.h:364
GenericValue< Encoding, Allocator > value
value of member.
Definition: document.h:56
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
Definition: document.h:277
null
Definition: rapidjson.h:421
ParseErrorCode Code() const
Get the error code.
Definition: error.h:105
GenericValue< Encoding, Allocator > name
name of member (must be a string)
Definition: document.h:55
string
Definition: rapidjson.h:426
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:1552
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:359
CharType Ch
character type of the string
Definition: document.h:229
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
Definition: document.h:1547
Encoding EncodingType
Encoding type from template parameter.
Definition: document.h:360
DifferenceType operator-(Iterator that) const
Distance.
Definition: document.h:166
GenericValue & SetString(StringRefType s)
Set this value as a string without copying source string.
Definition: document.h:1190
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with kParseDefaultFlags)
Definition: document.h:1500
MemberIterator FindMember(const GenericValue &name)
Find member by name.
Definition: document.h:784
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags)
Definition: document.h:1466
GenericValue(unsigned u)
Constructor for unsigned value.
Definition: document.h:427
In-situ(destructive) parsing.
Definition: reader.h:87
bool HasMember(const Ch *name) const
Check whether a member exists in the object.
Definition: document.h:739
ParseErrorCode
Error code of parsing.
Definition: error.h:56
bool Empty() const
Check whether the array is empty.
Definition: document.h:980
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition: document.h:1514
GenericValue(int i)
Constructor for int value.
Definition: document.h:420
GenericValue(StringRefType s)
Constructor for constant string (i.e. do not make a copy of string)
Definition: document.h:465
Reference to a constant string (not taking a copy)
Definition: document.h:228
GenericValue & SetBool(bool b)
Definition: document.h:679
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity)
Constructor.
Definition: document.h:1424
Concept for allocating, resizing and freeing memory block.
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:45
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:1401
GenericValue & CopyFrom(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator)
Deep-copy assignment from Value.
Definition: document.h:553
GenericValue & SetArray()
Set this value as an empty array.
Definition: document.h:971
(Constant) member iterator for a JSON object value
Definition: document.h:81
GenericValue & SetString(const Ch *s, Allocator &allocator)
Set this value as a string by copying from source string.
Definition: document.h:1208
GenericValue(bool b)
Constructor for boolean value.
Definition: document.h:415
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition: error.h:107
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last)
Remove members in the range [first, last) from an object.
Definition: document.h:948
const Ch *const s
plain CharType pointer
Definition: document.h:293
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
Definition: document.h:365
ConstValueIterator End() const
Constant past-the-end element iterator.
Definition: document.h:1021
GenericMemberIterator()
Default constructor (singular value)
Definition: document.h:111
SizeType Capacity() const
Get the capacity of array.
Definition: document.h:977
GenericValue & PushBack(StringRefType value, Allocator &allocator)
Append a constant string reference at the end of the array.
Definition: document.h:1065
GenericValue & AddMember(StringRefType name, GenericValue &value, Allocator &allocator)
Add a member (name-value pair) to the object.
Definition: document.h:837
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
Definition: document.h:1437
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:1623
number
Definition: rapidjson.h:427
GenericValue & Swap(GenericValue &other)
Exchange the contents of this value with those of other.
Definition: document.h:565
ValueIterator Erase(ConstValueIterator pos)
Remove an element of array by iterator.
Definition: document.h:1111
SizeType GetStringLength() const
Get the length of string.
Definition: document.h:1173
A read-write string stream.
Definition: rapidjson.h:383