15 #ifndef RAPIDJSON_DOCUMENT_H_ 16 #define RAPIDJSON_DOCUMENT_H_ 30 RAPIDJSON_DIAG_OFF(4127)
31 RAPIDJSON_DIAG_OFF(4244)
32 #ifdef _MINWINDEF_ // see: http://stackoverflow.com/questions/22744262/cant-call-stdmax-because-minwindef-h-defines-max 34 #pragma push_macro("min") 35 #pragma push_macro("max") 43 RAPIDJSON_DIAG_OFF(padded)
44 RAPIDJSON_DIAG_OFF(switch-enum)
45 RAPIDJSON_DIAG_OFF(c++98-compat)
49 RAPIDJSON_DIAG_OFF(effc++)
51 RAPIDJSON_DIAG_OFF(terminate)
55 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 59 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 66 template <
typename Encoding,
typename Allocator>
69 template <
typename Encoding,
typename Allocator,
typename StackAllocator>
78 template <
typename Encoding,
typename Allocator>
87 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 108 template <
bool Const,
typename Encoding,
typename Allocator>
110 :
public std::iterator<std::random_access_iterator_tag
111 , typename internal::MaybeAddConst<Const,GenericMember<Encoding,Allocator> >::Type> {
118 typedef std::iterator<std::random_access_iterator_tag,ValueType>
BaseType;
204 #else // RAPIDJSON_NOMEMBERITERATORCLASS 208 template <
bool Const,
typename Encoding,
typename Allocator>
212 template <
typename Encoding,
typename Allocator>
218 template <
typename Encoding,
typename Allocator>
224 #endif // RAPIDJSON_NOMEMBERITERATORCLASS 256 template<
typename CharType>
261 #ifndef __clang__ // -Wdocumentation 287 :
s(str), length(N-1) {}
290 #ifndef __clang__ // -Wdocumentation 311 :
s(str), length(NotNullStrLen(str)) {}
314 #ifndef __clang__ // -Wdocumentation 328 operator const Ch *()
const {
return s; }
340 static const Ch emptyString[];
349 template<
typename CharType>
364 template<
typename CharType>
384 template<
typename CharType>
389 #if RAPIDJSON_HAS_STDSTRING 402 template<
typename CharType>
412 template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
417 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>
::Type {};
429 template <
typename ValueType,
typename T>
432 template<
typename ValueType>
434 static bool Is(
const ValueType& v) {
return v.IsBool(); }
435 static bool Get(
const ValueType& v) {
return v.GetBool(); }
436 static ValueType&
Set(ValueType& v,
bool data) {
return v.SetBool(data); }
437 static ValueType&
Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&) {
return v.SetBool(data); }
440 template<
typename ValueType>
442 static bool Is(
const ValueType& v) {
return v.IsInt(); }
443 static int Get(
const ValueType& v) {
return v.GetInt(); }
444 static ValueType&
Set(ValueType& v,
int data) {
return v.SetInt(data); }
445 static ValueType&
Set(ValueType& v,
int data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
448 template<
typename ValueType>
450 static bool Is(
const ValueType& v) {
return v.IsUint(); }
451 static unsigned Get(
const ValueType& v) {
return v.GetUint(); }
452 static ValueType&
Set(ValueType& v,
unsigned data) {
return v.SetUint(data); }
453 static ValueType&
Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
456 template<
typename ValueType>
458 static bool Is(
const ValueType& v) {
return v.IsInt64(); }
459 static int64_t Get(
const ValueType& v) {
return v.GetInt64(); }
460 static ValueType&
Set(ValueType& v,
int64_t data) {
return v.SetInt64(data); }
461 static ValueType&
Set(ValueType& v,
int64_t data,
typename ValueType::AllocatorType&) {
return v.SetInt64(data); }
464 template<
typename ValueType>
466 static bool Is(
const ValueType& v) {
return v.IsUint64(); }
468 static ValueType&
Set(ValueType& v,
uint64_t data) {
return v.SetUint64(data); }
469 static ValueType&
Set(ValueType& v,
uint64_t data,
typename ValueType::AllocatorType&) {
return v.SetUint64(data); }
472 template<
typename ValueType>
474 static bool Is(
const ValueType& v) {
return v.IsDouble(); }
475 static double Get(
const ValueType& v) {
return v.GetDouble(); }
476 static ValueType&
Set(ValueType& v,
double data) {
return v.SetDouble(data); }
477 static ValueType&
Set(ValueType& v,
double data,
typename ValueType::AllocatorType&) {
return v.SetDouble(data); }
480 template<
typename ValueType>
482 static bool Is(
const ValueType& v) {
return v.IsFloat(); }
483 static float Get(
const ValueType& v) {
return v.GetFloat(); }
484 static ValueType&
Set(ValueType& v,
float data) {
return v.SetFloat(data); }
485 static ValueType&
Set(ValueType& v,
float data,
typename ValueType::AllocatorType&) {
return v.SetFloat(data); }
488 template<
typename ValueType>
489 struct TypeHelper<ValueType, const typename ValueType::Ch*> {
491 static bool Is(
const ValueType& v) {
return v.IsString(); }
492 static StringType
Get(
const ValueType& v) {
return v.GetString(); }
493 static ValueType&
Set(ValueType& v,
const StringType data) {
return v.SetString(
typename ValueType::StringRefType(data)); }
494 static ValueType&
Set(ValueType& v,
const StringType data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data, a); }
497 #if RAPIDJSON_HAS_STDSTRING 498 template<
typename ValueType>
499 struct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch> > {
500 typedef std::basic_string<typename ValueType::Ch>
StringType;
501 static bool Is(
const ValueType& v) {
return v.IsString(); }
502 static StringType Get(
const ValueType& v) {
return StringType(v.GetString(), v.GetStringLength()); }
503 static ValueType& Set(ValueType& v,
const StringType& data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data, a); }
507 template<
typename ValueType>
510 static bool Is(
const ValueType& v) {
return v.IsArray(); }
511 static ArrayType
Get(ValueType& v) {
return v.GetArray(); }
512 static ValueType&
Set(ValueType& v, ArrayType data) {
return v = data; }
513 static ValueType&
Set(ValueType& v, ArrayType data,
typename ValueType::AllocatorType&) {
return v = data; }
516 template<
typename ValueType>
517 struct TypeHelper<ValueType, typename ValueType::ConstArray> {
519 static bool Is(
const ValueType& v) {
return v.IsArray(); }
520 static ArrayType
Get(
const ValueType& v) {
return v.GetArray(); }
523 template<
typename ValueType>
526 static bool Is(
const ValueType& v) {
return v.IsObject(); }
527 static ObjectType
Get(ValueType& v) {
return v.GetObject(); }
528 static ValueType&
Set(ValueType& v, ObjectType data) {
return v = data; }
529 static ValueType&
Set(ValueType& v, ObjectType data,
typename ValueType::AllocatorType&) {
return v = data; }
532 template<
typename ValueType>
533 struct TypeHelper<ValueType, typename ValueType::ConstObject> {
535 static bool Is(
const ValueType& v) {
return v.IsObject(); }
536 static ObjectType
Get(
const ValueType& v) {
return v.GetObject(); }
558 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
565 typedef typename Encoding::Ch
Ch;
581 GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; }
583 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 594 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 595 template <
typename StackAllocator>
600 template <
typename StackAllocator>
612 static const uint16_t defaultFlags[7] = {
613 kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kShortStringFlag,
617 data_.f.flags = defaultFlags[type];
621 data_.ss.SetLength(0);
632 template <
typename SourceAllocator>
634 switch (rhs.GetType()) {
637 Member* lm =
reinterpret_cast<Member*
>(allocator.Malloc(count *
sizeof(Member)));
639 for (
SizeType i = 0; i < count; i++) {
643 data_.f.flags = kObjectFlag;
644 data_.o.size = data_.o.capacity = count;
645 SetMembersPointer(lm);
652 for (
SizeType i = 0; i < count; i++)
653 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
654 data_.f.flags = kArrayFlag;
655 data_.a.size = data_.a.capacity = count;
656 SetElementsPointer(le);
660 if (rhs.
data_.f.flags == kConstStringFlag && !copyConstStrings) {
661 data_.f.flags = rhs.
data_.f.flags;
662 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
665 SetStringRaw(
StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
668 data_.f.flags = rhs.
data_.f.flags;
669 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
680 #ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen 681 template <
typename T>
682 explicit GenericValue(
T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT
689 data_.f.flags = b ? kTrueFlag : kFalseFlag;
695 data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;
701 data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
707 data_.f.flags = kNumberInt64Flag;
709 data_.f.flags |= kNumberUint64Flag;
711 data_.f.flags |= kUintFlag;
713 data_.f.flags |= kIntFlag;
716 data_.f.flags |= kIntFlag;
722 data_.f.flags = kNumberUint64Flag;
724 data_.f.flags |= kInt64Flag;
726 data_.f.flags |= kUintFlag;
728 data_.f.flags |= kIntFlag;
732 explicit GenericValue(
double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d =
d; data_.f.flags = kNumberDoubleFlag; }
735 explicit GenericValue(
float f) RAPIDJSON_NOEXCEPT : data_() { data_.n.d =
static_cast<double>(
f); data_.f.flags = kNumberDoubleFlag; }
741 explicit GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(s); }
749 #if RAPIDJSON_HAS_STDSTRING 753 GenericValue(
const std::basic_string<Ch>& s, Allocator& allocator) : data_() { SetStringRaw(
StringRef(s), allocator); }
763 a.value_.data_ = Data();
764 a.value_.data_.f.flags = kArrayFlag;
774 o.value_.data_ = Data();
775 o.value_.data_.f.flags = kObjectFlag;
782 if (Allocator::kNeedFree) {
783 switch(data_.f.flags) {
794 for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
796 Allocator::Free(GetMembersPointer());
799 case kCopyStringFlag:
800 Allocator::Free(const_cast<Ch*>(GetStringPointer()));
824 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 827 return *
this = rhs.Move();
853 template <
typename T>
867 template <
typename SourceAllocator>
869 RAPIDJSON_ASSERT(static_cast<void*>(
this) != static_cast<void const*>(&rhs));
871 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
904 GenericValue& Move() RAPIDJSON_NOEXCEPT {
return *
this; }
914 template <
typename SourceAllocator>
917 if (GetType() != rhs.GetType())
922 if (data_.o.size != rhs.
data_.o.size)
924 for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
925 typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
926 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
932 if (data_.a.size != rhs.
data_.a.size)
934 for (
SizeType i = 0; i < data_.a.size; i++)
935 if ((*
this)[i] != rhs[i])
940 return StringEqual(rhs);
943 if (IsDouble() || rhs.IsDouble()) {
944 double a = GetDouble();
945 double b = rhs.GetDouble();
946 return a >= b && a <= b;
949 return data_.n.u64 == rhs.
data_.n.u64;
959 #if RAPIDJSON_HAS_STDSTRING 963 bool operator==(
const std::basic_string<Ch>& rhs)
const {
return *
this ==
GenericValue(
StringRef(rhs)); }
974 template <
typename SourceAllocator>
978 bool operator!=(
const Ch* rhs)
const {
return !(*
this == rhs); }
999 Type GetType()
const {
return static_cast<Type>(data_.f.flags & kTypeMask); }
1000 bool IsNull()
const {
return data_.f.flags == kNullFlag; }
1001 bool IsFalse()
const {
return data_.f.flags == kFalseFlag; }
1002 bool IsTrue()
const {
return data_.f.flags == kTrueFlag; }
1003 bool IsBool()
const {
return (data_.f.flags & kBoolFlag) != 0; }
1004 bool IsObject()
const {
return data_.f.flags == kObjectFlag; }
1005 bool IsArray()
const {
return data_.f.flags == kArrayFlag; }
1006 bool IsNumber()
const {
return (data_.f.flags & kNumberFlag) != 0; }
1007 bool IsInt()
const {
return (data_.f.flags & kIntFlag) != 0; }
1008 bool IsUint()
const {
return (data_.f.flags & kUintFlag) != 0; }
1009 bool IsInt64()
const {
return (data_.f.flags & kInt64Flag) != 0; }
1010 bool IsUint64()
const {
return (data_.f.flags & kUint64Flag) != 0; }
1011 bool IsDouble()
const {
return (data_.f.flags & kDoubleFlag) != 0; }
1012 bool IsString()
const {
return (data_.f.flags & kStringFlag) != 0; }
1015 bool IsLosslessDouble()
const {
1016 if (!IsNumber())
return false;
1019 volatile double d =
static_cast<double>(u);
1021 && (d < static_cast<double>(std::numeric_limits<uint64_t>::max()))
1022 && (u ==
static_cast<uint64_t>(d));
1026 volatile double d =
static_cast<double>(i);
1027 return (d >= static_cast<double>(std::numeric_limits<int64_t>::min()))
1028 && (d < static_cast<double>(std::numeric_limits<int64_t>::max()))
1029 && (i == static_cast<int64_t>(d));
1035 bool IsFloat()
const {
1036 if ((data_.f.flags & kDoubleFlag) == 0)
1038 double d = GetDouble();
1039 return d >= -3.4028234e38 && d <= 3.4028234e38;
1042 bool IsLosslessFloat()
const {
1043 if (!IsNumber())
return false;
1044 double a = GetDouble();
1045 if (a < static_cast<double>(-std::numeric_limits<float>::max())
1046 || a > static_cast<double>(std::numeric_limits<float>::max()))
1048 double b =
static_cast<double>(
static_cast<float>(
a));
1049 return a >= b && a <= b;
1064 bool GetBool()
const {
RAPIDJSON_ASSERT(IsBool());
return data_.f.flags == kTrueFlag; }
1082 bool ObjectEmpty()
const {
RAPIDJSON_ASSERT(IsObject());
return data_.o.size == 0; }
1093 template <
typename T>
1098 template <
typename T>
1110 template <
typename SourceAllocator>
1112 MemberIterator member = FindMember(name);
1113 if (member != MemberEnd())
1114 return member->value;
1127 template <
typename SourceAllocator>
1130 #if RAPIDJSON_HAS_STDSTRING 1138 ConstMemberIterator MemberBegin()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstMemberIterator(GetMembersPointer()); }
1141 ConstMemberIterator MemberEnd()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstMemberIterator(GetMembersPointer() + data_.o.size); }
1144 MemberIterator MemberBegin() {
RAPIDJSON_ASSERT(IsObject());
return MemberIterator(GetMembersPointer()); }
1147 MemberIterator MemberEnd() {
RAPIDJSON_ASSERT(IsObject());
return MemberIterator(GetMembersPointer() + data_.o.size); }
1157 bool HasMember(
const Ch* name)
const {
return FindMember(name) != MemberEnd(); }
1159 #if RAPIDJSON_HAS_STDSTRING 1168 bool HasMember(
const std::basic_string<Ch>& name)
const {
return FindMember(name) != MemberEnd(); }
1180 template <
typename SourceAllocator>
1195 MemberIterator FindMember(
const Ch* name) {
1197 return FindMember(n);
1200 ConstMemberIterator FindMember(
const Ch* name)
const {
return const_cast<GenericValue&
>(*this).FindMember(name); }
1215 template <
typename SourceAllocator>
1219 MemberIterator member = MemberBegin();
1220 for ( ; member != MemberEnd(); ++member)
1227 #if RAPIDJSON_HAS_STDSTRING 1235 MemberIterator FindMember(
const std::basic_string<Ch>& name) {
return FindMember(
GenericValue(
StringRef(name))); }
1236 ConstMemberIterator FindMember(
const std::basic_string<Ch>& name)
const {
return FindMember(
GenericValue(
StringRef(name))); }
1253 ObjectData& o = data_.o;
1254 if (o.size >= o.capacity) {
1255 if (o.capacity == 0) {
1256 o.capacity = kDefaultObjectCapacity;
1257 SetMembersPointer(reinterpret_cast<Member*>(allocator.Malloc(o.capacity *
sizeof(Member))));
1261 o.capacity += (oldCapacity + 1) / 2;
1262 SetMembersPointer(reinterpret_cast<Member*>(allocator.Realloc(GetMembersPointer(), oldCapacity *
sizeof(Member), o.capacity *
sizeof(Member))));
1265 Member* members = GetMembersPointer();
1266 members[o.size].
name.RawAssign(name);
1267 members[o.size].
value.RawAssign(value);
1283 return AddMember(name, v, allocator);
1286 #if RAPIDJSON_HAS_STDSTRING 1298 return AddMember(name, v, allocator);
1319 template <
typename T>
1321 AddMember(
GenericValue& name,
T value, Allocator& allocator) {
1323 return AddMember(name, v, allocator);
1326 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1328 return AddMember(name, value, allocator);
1331 return AddMember(name, value, allocator);
1334 return AddMember(name, value, allocator);
1338 return AddMember(n, value, allocator);
1340 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1355 return AddMember(n, value, allocator);
1367 GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator) {
1369 return AddMember(name, v, allocator);
1389 template <
typename T>
1391 AddMember(StringRefType name,
T value, Allocator& allocator) {
1393 return AddMember(n, value, allocator);
1400 void RemoveAllMembers() {
1402 for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
1415 bool RemoveMember(
const Ch* name) {
1417 return RemoveMember(n);
1420 #if RAPIDJSON_HAS_STDSTRING 1421 bool RemoveMember(
const std::basic_string<Ch>& name) {
return RemoveMember(
GenericValue(
StringRef(name))); }
1424 template <
typename SourceAllocator>
1426 MemberIterator m = FindMember(name);
1427 if (m != MemberEnd()) {
1443 MemberIterator RemoveMember(MemberIterator m) {
1449 MemberIterator last(GetMembersPointer() + (data_.o.size - 1));
1450 if (data_.o.size > 1 && m != last)
1467 MemberIterator EraseMember(ConstMemberIterator pos) {
1468 return EraseMember(pos, pos +1);
1480 MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) {
1488 MemberIterator pos = MemberBegin() + (first - MemberBegin());
1489 for (MemberIterator itr = pos; itr != last; ++itr)
1491 std::memmove(&*pos, &*last, static_cast<size_t>(MemberEnd() - last) *
sizeof(Member));
1492 data_.o.size -=
static_cast<SizeType>(last - first);
1501 bool EraseMember(
const Ch* name) {
1503 return EraseMember(n);
1506 #if RAPIDJSON_HAS_STDSTRING 1507 bool EraseMember(
const std::basic_string<Ch>& name) {
return EraseMember(
GenericValue(
StringRef(name))); }
1510 template <
typename SourceAllocator>
1512 MemberIterator m = FindMember(name);
1513 if (m != MemberEnd()) {
1522 ConstObject GetObject()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstObject(*
this); }
1540 bool Empty()
const {
RAPIDJSON_ASSERT(IsArray());
return data_.a.size == 0; }
1562 return GetElementsPointer()[index];
1568 ValueIterator Begin() {
RAPIDJSON_ASSERT(IsArray());
return GetElementsPointer(); }
1571 ValueIterator End() {
RAPIDJSON_ASSERT(IsArray());
return GetElementsPointer() + data_.a.size; }
1574 ConstValueIterator Begin()
const {
return const_cast<GenericValue&
>(*this).Begin(); }
1577 ConstValueIterator End()
const {
return const_cast<GenericValue&
>(*this).End(); }
1587 if (newCapacity > data_.a.capacity) {
1588 SetElementsPointer(reinterpret_cast<GenericValue*>(allocator.Realloc(GetElementsPointer(), data_.a.capacity *
sizeof(
GenericValue), newCapacity *
sizeof(
GenericValue))));
1589 data_.a.capacity = newCapacity;
1606 if (data_.a.size >= data_.a.capacity)
1607 Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2), allocator);
1608 GetElementsPointer()[data_.a.size++].RawAssign(value);
1612 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1614 return PushBack(value, allocator);
1616 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1627 GenericValue& PushBack(StringRefType value, Allocator& allocator) {
1628 return (*this).template PushBack<StringRefType>(value, allocator);
1648 template <
typename T>
1650 PushBack(
T value, Allocator& allocator) {
1652 return PushBack(v, allocator);
1662 GetElementsPointer()[--data_.a.size].~GenericValue();
1673 ValueIterator Erase(ConstValueIterator pos) {
1674 return Erase(pos, pos + 1);
1685 ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) {
1692 ValueIterator pos = Begin() + (first - Begin());
1693 for (ValueIterator itr = pos; itr != last; ++itr)
1695 std::memmove(pos, last, static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
1696 data_.a.size -=
static_cast<SizeType>(last - first);
1701 ConstArray GetArray()
const {
RAPIDJSON_ASSERT(IsArray());
return ConstArray(*
this); }
1708 int GetInt()
const {
RAPIDJSON_ASSERT(data_.f.flags & kIntFlag);
return data_.n.i.i; }
1709 unsigned GetUint()
const {
RAPIDJSON_ASSERT(data_.f.flags & kUintFlag);
return data_.n.u.u; }
1716 double GetDouble()
const {
1718 if ((data_.f.flags & kDoubleFlag) != 0)
return data_.n.d;
1719 if ((data_.f.flags & kIntFlag) != 0)
return data_.n.i.i;
1720 if ((data_.f.flags & kUintFlag) != 0)
return data_.n.u.u;
1721 if ((data_.f.flags & kInt64Flag) != 0)
return static_cast<double>(data_.n.i64);
1722 RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0);
return static_cast<double>(data_.n.u64);
1728 float GetFloat()
const {
1729 return static_cast<float>(GetDouble());
1744 const Ch* GetString()
const {
RAPIDJSON_ASSERT(IsString());
return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer(); }
1749 SizeType GetStringLength()
const {
RAPIDJSON_ASSERT(IsString());
return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength()) : data_.s.length); }
1784 GenericValue& SetString(
const Ch* s, Allocator& allocator) {
return SetString(
StringRef(s), allocator); }
1792 GenericValue& SetString(StringRefType s, Allocator& allocator) { this->~
GenericValue(); SetStringRaw(s, allocator);
return *
this; }
1794 #if RAPIDJSON_HAS_STDSTRING 1802 GenericValue& SetString(
const std::basic_string<Ch>& s, Allocator& allocator) {
return SetString(
StringRef(s), allocator); }
1814 template <
typename T>
1817 template <
typename T>
1820 template <
typename T>
1823 template<
typename T>
1826 template<
typename T>
1838 template <
typename Handler>
1839 bool Accept(Handler& handler)
const {
1843 case kTrueType:
return handler.Bool(
true);
1848 for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m) {
1850 if (
RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0)))
1855 return handler.EndObject(data_.o.size);
1863 return handler.EndArray(data_.a.size);
1866 return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0);
1870 if (IsDouble())
return handler.Double(data_.n.d);
1871 else if (IsInt())
return handler.Int(data_.n.i.i);
1872 else if (IsUint())
return handler.Uint(data_.n.u.u);
1873 else if (IsInt64())
return handler.Int64(data_.n.i64);
1874 else return handler.Uint64(data_.n.u64);
1879 template <
typename,
typename>
friend class GenericValue;
1917 #if RAPIDJSON_48BITPOINTER_OPTIMIZATION 1918 char payload[
sizeof(
SizeType) * 2 + 6];
1919 #elif RAPIDJSON_64BIT 1920 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 6];
1922 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 2];
1942 enum { MaxChars =
sizeof(
static_cast<Flag*
>(0)->payload) /
sizeof(Ch), MaxSize = MaxChars - 1, LenPos = MaxSize };
1952 #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN 2006 data_.f.flags = kArrayFlag;
2009 SetElementsPointer(e);
2013 SetElementsPointer(0);
2014 data_.a.size = data_.a.capacity = count;
2019 data_.f.flags = kObjectFlag;
2021 Member* m =
static_cast<Member*
>(allocator.Malloc(count *
sizeof(Member)));
2022 SetMembersPointer(m);
2023 std::memcpy(m, members, count *
sizeof(Member));
2026 SetMembersPointer(0);
2027 data_.o.size = data_.o.capacity = count;
2032 data_.f.flags = kConstStringFlag;
2033 SetStringPointer(s);
2034 data_.s.length = s.length;
2040 if (ShortString::Usable(s.
length)) {
2041 data_.f.flags = kShortStringFlag;
2042 data_.ss.SetLength(s.
length);
2045 data_.f.flags = kCopyStringFlag;
2046 data_.s.length = s.
length;
2047 str =
static_cast<Ch *
>(allocator.Malloc((s.
length + 1) *
sizeof(Ch)));
2048 SetStringPointer(str);
2050 std::memcpy(str, s, s.
length *
sizeof(Ch));
2061 template <
typename SourceAllocator>
2066 const SizeType len1 = GetStringLength();
2067 const SizeType len2 = rhs.GetStringLength();
2068 if(len1 != len2) {
return false; }
2070 const Ch*
const str1 = GetString();
2071 const Ch*
const str2 = rhs.GetString();
2072 if(str1 == str2) {
return true; }
2074 return (std::memcmp(str1, str2,
sizeof(Ch) * len1) == 0);
2094 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>,
typename StackAllocator = CrtAllocator>
2097 typedef typename Encoding::Ch
Ch;
2108 explicit GenericDocument(
Type type, Allocator* allocator = 0,
size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2109 GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2121 GenericDocument(Allocator* allocator = 0,
size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2122 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2128 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2131 : ValueType(std::forward<ValueType>(rhs)),
2132 allocator_(rhs.allocator_),
2133 ownAllocator_(rhs.ownAllocator_),
2134 stack_(std::move(rhs.stack_)),
2135 parseResult_(rhs.parseResult_)
2138 rhs.ownAllocator_ = 0;
2147 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2153 ValueType::operator=(std::forward<ValueType>(rhs));
2158 allocator_ = rhs.allocator_;
2159 ownAllocator_ = rhs.ownAllocator_;
2160 stack_ = std::move(rhs.stack_);
2161 parseResult_ = rhs.parseResult_;
2164 rhs.ownAllocator_ = 0;
2179 stack_.Swap(rhs.stack_);
2209 template <
typename Generator>
2211 ClearStackOnExit scope(*
this);
2214 ValueType::operator=(*stack_.template Pop<ValueType>(1));
2229 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
2232 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2233 ClearStackOnExit scope(*
this);
2234 parseResult_ = reader.template Parse<parseFlags>(is, *
this);
2237 ValueType::operator=(*stack_.template Pop<ValueType>(1));
2248 template <
unsigned parseFlags,
typename InputStream>
2250 return ParseStream<parseFlags, Encoding, InputStream>(is);
2258 template <
typename InputStream>
2260 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2272 template <
unsigned parseFlags>
2275 return ParseStream<parseFlags | kParseInsituFlag>(s);
2283 return ParseInsitu<kParseDefaultFlags>(str);
2295 template <
unsigned parseFlags,
typename SourceEncoding>
2299 return ParseStream<parseFlags, SourceEncoding>(s);
2306 template <
unsigned parseFlags>
2308 return Parse<parseFlags, Encoding>(str);
2315 return Parse<kParseDefaultFlags>(str);
2318 template <
unsigned parseFlags,
typename SourceEncoding>
2321 MemoryStream ms(reinterpret_cast<const char*>(str), length *
sizeof(
typename SourceEncoding::Ch));
2323 ParseStream<parseFlags, SourceEncoding>(is);
2327 template <
unsigned parseFlags>
2329 return Parse<parseFlags, Encoding>(str, length);
2333 return Parse<kParseDefaultFlags>(str, length);
2336 #if RAPIDJSON_HAS_STDSTRING 2337 template <
unsigned parseFlags,
typename SourceEncoding>
2338 GenericDocument& Parse(
const std::basic_string<typename SourceEncoding::Ch>& str) {
2340 return Parse<parseFlags, SourceEncoding>(str.c_str());
2343 template <
unsigned parseFlags>
2345 return Parse<parseFlags, Encoding>(str.c_str());
2349 return Parse<kParseDefaultFlags>(str);
2351 #endif // RAPIDJSON_HAS_STDSTRING 2368 #ifndef __clang // -Wdocumentation 2408 bool Null() {
new (stack_.template Push<ValueType>())
ValueType();
return true; }
2409 bool Bool(
bool b) {
new (stack_.template Push<ValueType>())
ValueType(b);
return true; }
2410 bool Int(
int i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2411 bool Uint(
unsigned i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2414 bool Double(
double d) {
new (stack_.template Push<ValueType>())
ValueType(d);
return true; }
2418 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
2420 new (stack_.template Push<ValueType>())
ValueType(str, length);
2426 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
2428 new (stack_.template Push<ValueType>())
ValueType(str, length);
2437 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2438 stack_.template Top<ValueType>()->
SetObjectRaw(members, memberCount, GetAllocator());
2445 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2446 stack_.template Top<ValueType>()->
SetArrayRaw(elements, elementCount, GetAllocator());
2457 if (Allocator::kNeedFree)
2458 while (stack_.GetSize() > 0)
2459 (stack_.template Pop<ValueType>(1))->~
ValueType();
2462 stack_.ShrinkToFit();
2469 static const size_t kDefaultStackCapacity = 1024;
2484 template <
bool Const,
typename ValueT>
2496 template <
typename,
typename>
2505 bool Empty()
const {
return value_.Empty(); }
2508 ValueIterator
Begin()
const {
return value_.Begin(); }
2509 ValueIterator
End()
const {
return value_.End(); }
2512 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2514 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 2518 ValueIterator
Erase(ConstValueIterator pos)
const {
return value_.Erase(pos); }
2519 ValueIterator
Erase(ConstValueIterator first, ConstValueIterator last)
const {
return value_.Erase(first, last); }
2521 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 2522 ValueIterator begin()
const {
return value_.Begin(); }
2523 ValueIterator end()
const {
return value_.End(); }
2537 template <
bool Const,
typename ValueT>
2549 typedef typename ValueType::Ch
Ch;
2551 template <
typename,
typename>
2562 #if RAPIDJSON_HAS_STDSTRING 2563 ValueType& operator[](
const std::basic_string<Ch>&
name)
const {
return value_[
name]; }
2566 MemberIterator
MemberEnd()
const {
return value_.MemberEnd(); }
2567 bool HasMember(
const Ch* name)
const {
return value_.HasMember(name); }
2568 #if RAPIDJSON_HAS_STDSTRING 2569 bool HasMember(
const std::basic_string<Ch>& name)
const {
return value_.HasMember(name); }
2572 MemberIterator
FindMember(
const Ch* name)
const {
return value_.FindMember(name); }
2574 #if RAPIDJSON_HAS_STDSTRING 2575 MemberIterator FindMember(
const std::basic_string<Ch>& name)
const {
return value_.FindMember(name); }
2579 #if RAPIDJSON_HAS_STDSTRING 2580 GenericObject AddMember(ValueType& name, std::basic_string<Ch>&
value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2583 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2584 GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2585 GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2586 GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2587 GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2588 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 2593 bool RemoveMember(
const Ch* name)
const {
return value_.RemoveMember(name); }
2594 #if RAPIDJSON_HAS_STDSTRING 2595 bool RemoveMember(
const std::basic_string<Ch>& name)
const {
return value_.RemoveMember(name); }
2598 MemberIterator
RemoveMember(MemberIterator m)
const {
return value_.RemoveMember(m); }
2599 MemberIterator
EraseMember(ConstMemberIterator pos)
const {
return value_.EraseMember(pos); }
2600 MemberIterator
EraseMember(ConstMemberIterator first, ConstMemberIterator last)
const {
return value_.EraseMember(first, last); }
2601 bool EraseMember(
const Ch* name)
const {
return value_.EraseMember(name); }
2602 #if RAPIDJSON_HAS_STDSTRING 2603 bool EraseMember(
const std::basic_string<Ch>& name)
const {
return EraseMember(
ValueType(
StringRef(name))); }
2607 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 2608 MemberIterator begin()
const {
return value_.MemberBegin(); }
2609 MemberIterator end()
const {
return value_.MemberEnd(); }
2619 #ifdef _MINWINDEF_ // see: http://stackoverflow.com/questions/22744262/cant-call-stdmax-because-minwindef-h-defines-max 2621 #pragma pop_macro("min") 2622 #pragma pop_macro("max") 2627 #endif // RAPIDJSON_DOCUMENT_H_ GenericValue(int i) RAPIDJSON_NOEXCEPT
Constructor for int value.
bool RemoveMember(const GenericValue< EncodingType, SourceAllocator > &name) const
GenericMemberIterator()
Default constructor (singular value)
void SetLength(SizeType len)
GenericValue(const Ch *s, SizeType length, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
GenericValue< Encoding, Allocator > name
name of member (must be a string)
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
static ArrayType Get(const ValueType &v)
SizeType NotNullStrLen(const CharType *str)
GenericObject(ValueType &value)
bool EndArray(SizeType elementCount)
Allocator AllocatorType
Allocator type from template parameter.
SizeType GetLength() const
GenericStringRef(const GenericStringRef &rhs)
GenericArray PushBack(StringRefType value, AllocatorType &allocator) const
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
GenericObject AddMember(StringRefType name, ValueType &value, AllocatorType &allocator) const
static ValueType & Set(ValueType &v, uint64_t data)
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
static ArrayType Get(ValueType &v)
Represents an in-memory input byte stream.
GenericObject AddMember(ValueType &name, ValueType &value, AllocatorType &allocator) const
bool String(const Ch *str, SizeType length, bool copy)
GenericValue(Object o) RAPIDJSON_NOEXCEPT
Constructor for Object.
#define RAPIDJSON_ASSERT(x)
Assertion.
ValueType::EncodingType EncodingType
static bool Is(const ValueType &v)
BaseType::pointer Pointer
Pointer to (const) GenericMember.
ClearStackOnExit(GenericDocument &d)
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
static ObjectType Get(ValueType &v)
GenericArray< true, ValueT > ConstArray
static bool Get(const ValueType &v)
Helper class for accessing Value of array type.
GenericValue(Type type) RAPIDJSON_NOEXCEPT
Constructor with JSON value type.
bool StringEqual(const GenericValue< Encoding, SourceAllocator > &rhs) const
friend void swap(GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
ValueType::Array ArrayType
GenericValue(float f) RAPIDJSON_NOEXCEPT
Constructor for float value.
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
GenericValue< Encoding, Allocator > value
value of member.
GenericDocument & Populate(Generator &g)
Populate this document by a generator which produces SAX events.
(Constant) member iterator for a JSON object value
const Ch *const s
plain CharType pointer
static ValueType & Set(ValueType &v, ObjectType data)
GenericArray PopBack() const
static ValueType & Set(ValueType &v, ArrayType data)
static bool Is(const ValueType &v)
GenericMemberIterator Iterator
Iterator type itself.
GenericMemberIterator(Pointer p)
Internal constructor from plain pointer.
ValueType & operator[](SizeType index) const
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
GenericDocument & Parse(const Ch *str, size_t length)
GenericDocument & Parse(const Ch *str, size_t length)
Encoding::Ch Ch
Character type derived from Encoding.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
ValueType::StringRefType StringRefType
internal::Stack< StackAllocator > stack_
MemberIterator MemberEnd() const
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
std::iterator< std::random_access_iterator_tag, ValueType > BaseType
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
const ValueType::Ch * StringType
static bool Is(const ValueType &v)
ValueIterator Erase(ConstValueIterator pos) const
bool operator!=(ConstIterator that) const
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
static ValueType & Set(ValueType &v, double data, typename ValueType::AllocatorType &)
GenericArray PushBack(ValueType &value, AllocatorType &allocator) const
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, bool data)
GenericValue(const Ch *s, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
static ObjectType Get(const ValueType &v)
bool EraseMember(const Ch *name) const
ValueType & operator[](T *name) const
SizeType Capacity() const
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
MemberIterator FindMember(const GenericValue< EncodingType, SourceAllocator > &name) const
void SetArrayRaw(GenericValue *values, SizeType count, Allocator &allocator)
MemberIterator MemberBegin() const
static ValueType & Set(ValueType &v, ArrayType data, typename ValueType::AllocatorType &)
Result of parsing (wraps ParseErrorCode)
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
friend class GenericDocument
Encoding EncodingType
Encoding type from template parameter.
bool operator<(ConstIterator that) const
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags)
Pointer operator->() const
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
ValueType::ConstObject ObjectType
internal::MaybeAddConst< Const, PlainType >::Type ValueType
static unsigned Get(const ValueType &v)
GenericArray(const GenericArray &rhs)
ValueType::StringRefType StringRefType
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
A document for parsing JSON text as DOM.
bool HasMember(const GenericValue< EncodingType, SourceAllocator > &name) const
static bool Is(const ValueType &v)
A read-write string stream.
GenericArray & operator=(const GenericArray &rhs)
GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT
Constructor for int64_t value.
bool operator==(ConstIterator that) const
GenericValue(const Ch *s, SizeType length) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
GenericDocument(Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
static ValueType & Set(ValueType &v, double data)
bool HasMember(const Ch *name) const
GenericMemberIterator< true, typename ValueT::EncodingType, typename ValueT::AllocatorType > ConstMemberIterator
Allocator AllocatorType
Allocator type from template parameter.
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
Constructor for boolean value.
Reference operator[](DifferenceType n) const
bool EndObject(SizeType memberCount)
Allocator * ownAllocator_
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
GenericArray(ValueType &value)
Encoding::Ch Ch
Character type derived from Encoding.
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
static ValueType & Set(ValueType &v, ObjectType data, typename ValueType::AllocatorType &)
static bool Is(const ValueType &v)
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
static StringType Get(const ValueType &v)
static ValueType & Set(ValueType &v, float data, typename ValueType::AllocatorType &)
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
ParseErrorCode
Error code of parsing.
bool RawNumber(const Ch *str, SizeType length, bool copy)
static bool Is(const ValueType &v)
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
Helper class for accessing Value of object type.
GenericObject< true, ValueT > ConstObject
static ValueType & Set(ValueType &v, float data)
RAPIDJSON_FORCEINLINE const Ch * SetStringPointer(const Ch *str)
bool operator<=(ConstIterator that) const
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
GenericStringRef(const CharType(&str)[N]) RAPIDJSON_NOEXCEPT
Create string reference from const character array.
GenericStringRef< Ch > StringRefType
Reference to a constant string.
GenericObject(const GenericObject &rhs)
unsigned __int64 uint64_t
ValueType::AllocatorType AllocatorType
bool operator>(ConstIterator that) const
Allocator & GetAllocator()
Get the allocator of this document.
static bool Usable(SizeType len)
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
static bool Is(const ValueType &v)
GenericArray< false, ValueType > Array
GenericValue< Encoding, Allocator > ValueType
Value type of itself.
internal::MaybeAddConst< Const, PlainType >::Type ValueType
const SizeType length
length of the string (excluding the trailing NULL terminator)
const ValueT * ConstValueIterator
ValueIterator Begin() const
static bool Is(const ValueType &v)
Name-value pair in a JSON object value.
ValueType * ValueIterator
SizeType hashcode
reserved
Iterator & operator+=(DifferenceType n)
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
GenericArray< true, ValueType > ConstArray
#define RAPIDJSON_DELETE(x)
! customization point for global delete
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
ValueIterator End() const
static ValueType & Set(ValueType &v, unsigned data)
~GenericValue()
Destructor.
static int Get(const ValueType &v)
GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType &allocator) const
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with kParseDefaultFlags)
GenericObject< false, ValueT > Object
SizeType MemberCount() const
#define RAPIDJSON_SETPOINTER(type, p, x)
static ValueType & Set(ValueType &v, unsigned data, typename ValueType::AllocatorType &)
MemberIterator FindMember(const Ch *name) const
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
CharType Ch
character type of the string
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
DifferenceType operator-(ConstIterator that) const
Distance.
static bool Is(const ValueType &v)
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
MemberIterator RemoveMember(MemberIterator m) const
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
GenericMember< Encoding, Allocator > PlainType
Reference operator*() const
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
Iterator & operator=(const NonConstIterator &it)
MemberIterator EraseMember(ConstMemberIterator pos) const
ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const
static bool Is(const ValueType &v)
void SetStringRaw(StringRefType s, Allocator &allocator)
Initialize this value as copy string with initial data, without calling destructor.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
internal::MaybeAddConst< Const, PlainType >::Type ValueType
bool operator>=(ConstIterator that) const
GenericDocument & Parse(const typename SourceEncoding::Ch *str, size_t length)
static int64_t Get(const ValueType &v)
ValueType::AllocatorType AllocatorType
GenericObject< true, ValueType > ConstObject
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
GenericValue(unsigned u) RAPIDJSON_NOEXCEPT
Constructor for unsigned value.
static ValueType & Set(ValueType &v, int64_t data)
#define RAPIDJSON_GETPOINTER(type, p)
GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT
Constructor for uint64_t value.
Iterator operator-(DifferenceType n) const
GenericValue * ValueIterator
Value iterator for iterating in array.
ValueType::ConstArray ArrayType
GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
static const SizeType kDefaultObjectCapacity
GenericObject< false, ValueType > Object
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
static const SizeType kDefaultArrayCapacity
GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const
static float Get(const ValueType &v)
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
static ValueType & Set(ValueType &v, const StringType data)
Reference to a constant string (not taking a copy)
BaseType::difference_type DifferenceType
Signed integer type (e.g. ptrdiff_t)
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
static ValueType & Set(ValueType &v, int data)
bool EraseMember(const GenericValue< EncodingType, SourceAllocator > &name) const
const GenericPointer< typename T::ValueType > & pointer
GenericValue() RAPIDJSON_NOEXCEPT
Default constructor creates a null value.
static double Get(const ValueType &v)
Iterator operator+(DifferenceType n) const
ValueType & operator[](const GenericValue< EncodingType, SourceAllocator > &name) const
GenericValue(double d) RAPIDJSON_NOEXCEPT
Constructor for double value.
GenericArray< false, ValueT > Array
bool RemoveMember(const Ch *name) const
GenericValue & operator=(StringRefType str) RAPIDJSON_NOEXCEPT
Assignment of constant string reference (no copy)
BaseType::reference Reference
Reference to (const) GenericMember.
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags)
GenericStringRef(const CharType *str, SizeType len)
Create constant string reference from pointer and length.
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
GenericObject & operator=(const GenericObject &rhs)
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T2 >, internal::IsGenericValue< T2 > >),(typename T::ValueType &)) GetValueByPointerWithDefault(T &root
static ValueType & Set(ValueType &v, uint64_t data, typename ValueType::AllocatorType &)
ValueType::Object ObjectType
size_t GetStackCapacity() const
Get the capacity of stack in bytes.
GenericObject AddMember(ValueType &name, StringRefType value, AllocatorType &allocator) const
GenericValue(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
Explicit copy constructor (with allocator)
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
static ValueType & Set(ValueType &v, int data, typename ValueType::AllocatorType &)
static ValueType & Set(ValueType &v, int64_t data, typename ValueType::AllocatorType &)
In-situ(destructive) parsing.
static bool Is(const ValueType &v)
Iterator & operator-=(DifferenceType n)
static uint64_t Get(const ValueType &v)
bool HasParseError() const
Whether a parse error has occured in the last parsing.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
static ValueType & Set(ValueType &v, const StringType data, typename ValueType::AllocatorType &a)
GenericMemberIterator< Const, typename ValueT::EncodingType, typename ValueT::AllocatorType > MemberIterator
static ValueType & Set(ValueType &v, bool data, typename ValueType::AllocatorType &)
bool Key(const Ch *str, SizeType length, bool copy)
GenericValue(Array a) RAPIDJSON_NOEXCEPT
Constructor for Array.