15 #ifndef RAPIDJSON_DOCUMENT_H_ 16 #define RAPIDJSON_DOCUMENT_H_ 21 #include "internal/meta.h" 22 #include "internal/strfunc.h" 23 #include "memorystream.h" 24 #include "encodedstream.h" 27 #ifdef __cpp_lib_three_way_comparison 33 RAPIDJSON_DIAG_OFF(padded)
34 RAPIDJSON_DIAG_OFF(
switch-
enum)
35 RAPIDJSON_DIAG_OFF(c++98-compat)
36 #elif defined(_MSC_VER) 37 RAPIDJSON_DIAG_OFF(4127)
38 RAPIDJSON_DIAG_OFF(4244)
42 RAPIDJSON_DIAG_OFF(effc++)
49 #pragma push_macro("GetObject") 50 #define RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED 54 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 58 #if RAPIDJSON_USE_MEMBERSMAP 65 template <
typename Encoding,
typename Allocator>
68 template <
typename Encoding,
typename Allocator,
typename StackAllocator>
77 #ifndef RAPIDJSON_DEFAULT_ALLOCATOR 78 #define RAPIDJSON_DEFAULT_ALLOCATOR MemoryPoolAllocator<CrtAllocator> 87 #ifndef RAPIDJSON_DEFAULT_STACK_ALLOCATOR 88 #define RAPIDJSON_DEFAULT_STACK_ALLOCATOR CrtAllocator 97 #ifndef RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY 99 #define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY 16 108 #ifndef RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY 110 #define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY 16 119 template <
typename Encoding,
typename Allocator>
125 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 128 :
name(std::move(rhs.name)),
129 value(std::move(rhs.value))
164 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 185 template <
bool Const,
typename Encoding,
typename Allocator>
192 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
204 typedef ValueType value_type;
205 typedef ValueType * pointer;
206 typedef ValueType & reference;
207 typedef std::ptrdiff_t difference_type;
208 typedef std::random_access_iterator_tag iterator_category;
241 Iterator&
operator=(
const NonConstIterator & it) { ptr_ = it.ptr_;
return *
this; }
245 Iterator& operator++(){ ++ptr_;
return *
this; }
246 Iterator& operator--(){ --ptr_;
return *
this; }
247 Iterator operator++(
int){ Iterator old(*
this); ++ptr_;
return old; }
248 Iterator operator--(
int){ Iterator old(*
this); --ptr_;
return old; }
253 Iterator operator+(DifferenceType n)
const {
return Iterator(ptr_+n); }
254 Iterator operator-(DifferenceType n)
const {
return Iterator(ptr_-n); }
256 Iterator& operator+=(DifferenceType n) { ptr_+=n;
return *
this; }
257 Iterator& operator-=(DifferenceType n) { ptr_-=n;
return *
this; }
264 template <
bool Const_>
bool operator<=(const GenericMemberIterator<Const_, Encoding, Allocator>& that)
const {
return ptr_ <= that.ptr_; }
266 template <
bool Const_>
bool operator< (const GenericMemberIterator<Const_, Encoding, Allocator>& that)
const {
return ptr_ < that.ptr_; }
269 #ifdef __cpp_lib_three_way_comparison 276 Reference operator*()
const {
return *ptr_; }
277 Pointer operator->()
const {
return ptr_; }
278 Reference operator[](DifferenceType n)
const {
return ptr_[n]; }
282 DifferenceType
operator-(ConstIterator that)
const {
return ptr_-that.ptr_; }
291 #else // RAPIDJSON_NOMEMBERITERATORCLASS 295 template <
bool Const,
typename Encoding,
typename Allocator>
299 template <
typename Encoding,
typename Allocator>
306 template <
typename Encoding,
typename Allocator>
313 #endif // RAPIDJSON_NOMEMBERITERATORCLASS 345 template<
typename CharType>
350 #ifndef __clang__ // -Wdocumentation 376 : s(str), length(N-1) {}
379 #ifndef __clang__ // -Wdocumentation 400 : s(str), length(NotNullStrLen(str)) {}
403 #ifndef __clang__ // -Wdocumentation 417 operator const Ch *()
const {
return s; }
423 SizeType NotNullStrLen(
const CharType* str) {
425 return internal::StrLen(str);
429 static const Ch emptyString[];
438 template<
typename CharType>
453 template<
typename CharType>
473 template<
typename CharType>
478 #if RAPIDJSON_HAS_STDSTRING 491 template<
typename CharType>
501 template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
505 template <
typename T>
struct IsGenericValueImpl<T, typename Void<typename T::EncodingType>::Type, typename Void<typename T::AllocatorType>::Type>
506 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>::Type {};
518 template <
typename ValueType,
typename T>
521 template<
typename ValueType>
523 static bool Is(
const ValueType& v) {
return v.IsBool(); }
524 static bool Get(
const ValueType& v) {
return v.GetBool(); }
525 static ValueType& Set(ValueType& v,
bool data) {
return v.SetBool(data); }
526 static ValueType& Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&) {
return v.SetBool(data); }
529 template<
typename ValueType>
531 static bool Is(
const ValueType& v) {
return v.IsInt(); }
532 static int Get(
const ValueType& v) {
return v.GetInt(); }
533 static ValueType& Set(ValueType& v,
int data) {
return v.SetInt(data); }
534 static ValueType& Set(ValueType& v,
int data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
537 template<
typename ValueType>
539 static bool Is(
const ValueType& v) {
return v.IsUint(); }
540 static unsigned Get(
const ValueType& v) {
return v.GetUint(); }
541 static ValueType& Set(ValueType& v,
unsigned data) {
return v.SetUint(data); }
542 static ValueType& Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
546 RAPIDJSON_STATIC_ASSERT(
sizeof(
long) ==
sizeof(
int));
547 template<
typename ValueType>
549 static bool Is(
const ValueType& v) {
return v.IsInt(); }
550 static long Get(
const ValueType& v) {
return v.GetInt(); }
551 static ValueType& Set(ValueType& v,
long data) {
return v.SetInt(data); }
552 static ValueType& Set(ValueType& v,
long data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
555 RAPIDJSON_STATIC_ASSERT(
sizeof(
unsigned long) ==
sizeof(
unsigned));
556 template<
typename ValueType>
558 static bool Is(
const ValueType& v) {
return v.IsUint(); }
559 static unsigned long Get(
const ValueType& v) {
return v.GetUint(); }
560 static ValueType& Set(ValueType& v,
unsigned long data) {
return v.SetUint(data); }
561 static ValueType& Set(ValueType& v,
unsigned long data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
565 template<
typename ValueType>
567 static bool Is(
const ValueType& v) {
return v.IsInt64(); }
568 static int64_t Get(
const ValueType& v) {
return v.GetInt64(); }
569 static ValueType& Set(ValueType& v, int64_t data) {
return v.SetInt64(data); }
570 static ValueType& Set(ValueType& v, int64_t data,
typename ValueType::AllocatorType&) {
return v.SetInt64(data); }
573 template<
typename ValueType>
575 static bool Is(
const ValueType& v) {
return v.IsUint64(); }
576 static uint64_t Get(
const ValueType& v) {
return v.GetUint64(); }
577 static ValueType& Set(ValueType& v, uint64_t data) {
return v.SetUint64(data); }
578 static ValueType& Set(ValueType& v, uint64_t data,
typename ValueType::AllocatorType&) {
return v.SetUint64(data); }
581 template<
typename ValueType>
583 static bool Is(
const ValueType& v) {
return v.IsDouble(); }
584 static double Get(
const ValueType& v) {
return v.GetDouble(); }
585 static ValueType& Set(ValueType& v,
double data) {
return v.SetDouble(data); }
586 static ValueType& Set(ValueType& v,
double data,
typename ValueType::AllocatorType&) {
return v.SetDouble(data); }
589 template<
typename ValueType>
591 static bool Is(
const ValueType& v) {
return v.IsFloat(); }
592 static float Get(
const ValueType& v) {
return v.GetFloat(); }
593 static ValueType& Set(ValueType& v,
float data) {
return v.SetFloat(data); }
594 static ValueType& Set(ValueType& v,
float data,
typename ValueType::AllocatorType&) {
return v.SetFloat(data); }
597 template<
typename ValueType>
598 struct TypeHelper<ValueType, const typename ValueType::Ch*> {
599 typedef const typename ValueType::Ch* StringType;
600 static bool Is(
const ValueType& v) {
return v.IsString(); }
601 static StringType Get(
const ValueType& v) {
return v.GetString(); }
602 static ValueType& Set(ValueType& v,
const StringType data) {
return v.SetString(
typename ValueType::StringRefType(data)); }
603 static ValueType& Set(ValueType& v,
const StringType data,
typename ValueType::AllocatorType& a) {
return v.SetString(data, a); }
606 #if RAPIDJSON_HAS_STDSTRING 607 template<
typename ValueType>
608 struct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch> > {
609 typedef std::basic_string<typename ValueType::Ch> StringType;
610 static bool Is(
const ValueType& v) {
return v.IsString(); }
611 static StringType Get(
const ValueType& v) {
return StringType(v.GetString(), v.GetStringLength()); }
612 static ValueType& Set(ValueType& v,
const StringType& data,
typename ValueType::AllocatorType& a) {
return v.SetString(data, a); }
616 template<
typename ValueType>
618 typedef typename ValueType::Array ArrayType;
619 static bool Is(
const ValueType& v) {
return v.IsArray(); }
620 static ArrayType Get(ValueType& v) {
return v.GetArray(); }
621 static ValueType& Set(ValueType& v, ArrayType data) {
return v = data; }
622 static ValueType& Set(ValueType& v, ArrayType data,
typename ValueType::AllocatorType&) {
return v = data; }
625 template<
typename ValueType>
626 struct TypeHelper<ValueType, typename ValueType::ConstArray> {
627 typedef typename ValueType::ConstArray ArrayType;
628 static bool Is(
const ValueType& v) {
return v.IsArray(); }
629 static ArrayType Get(
const ValueType& v) {
return v.GetArray(); }
632 template<
typename ValueType>
634 typedef typename ValueType::Object ObjectType;
635 static bool Is(
const ValueType& v) {
return v.IsObject(); }
636 static ObjectType Get(ValueType& v) {
return v.GetObject(); }
637 static ValueType& Set(ValueType& v, ObjectType data) {
return v = data; }
638 static ValueType& Set(ValueType& v, ObjectType data,
typename ValueType::AllocatorType&) {
return v = data; }
641 template<
typename ValueType>
642 struct TypeHelper<ValueType, typename ValueType::ConstObject> {
643 typedef typename ValueType::ConstObject ObjectType;
644 static bool Is(
const ValueType& v) {
return v.IsObject(); }
645 static ObjectType Get(
const ValueType& v) {
return v.GetObject(); }
667 template <
typename Encoding,
typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR >
674 typedef typename Encoding::Ch
Ch;
690 GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; }
692 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 695 rhs.data_.f.flags = kNullFlag;
703 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 704 template <
typename StackAllocator>
709 template <
typename StackAllocator>
721 static const uint16_t defaultFlags[] = {
722 kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kShortStringFlag,
726 data_.f.flags = defaultFlags[type];
729 if (type == kStringType)
730 data_.ss.SetLength(0);
741 template <
typename SourceAllocator>
743 switch (rhs.GetType()) {
745 DoCopyMembers(rhs, allocator, copyConstStrings);
748 SizeType count = rhs.data_.a.size;
751 for (SizeType i = 0; i < count; i++)
752 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
753 data_.f.flags = kArrayFlag;
754 data_.a.size = data_.a.capacity = count;
755 SetElementsPointer(le);
759 if (rhs.data_.f.flags == kConstStringFlag && !copyConstStrings) {
760 data_.f.flags = rhs.data_.f.flags;
761 data_ = *
reinterpret_cast<const Data*
>(&rhs.data_);
764 SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
767 data_.f.flags = rhs.data_.f.flags;
768 data_ = *
reinterpret_cast<const Data*
>(&rhs.data_);
779 #ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen 780 template <
typename T>
781 explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT
787 RAPIDJSON_STATIC_ASSERT((internal::IsSame<bool,T>::Value));
788 data_.f.flags = b ? kTrueFlag : kFalseFlag;
794 data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;
800 data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
806 data_.f.flags = kNumberInt64Flag;
808 data_.f.flags |= kNumberUint64Flag;
809 if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
810 data_.f.flags |= kUintFlag;
811 if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
812 data_.f.flags |= kIntFlag;
814 else if (i64 >= static_cast<int64_t>(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
815 data_.f.flags |= kIntFlag;
821 data_.f.flags = kNumberUint64Flag;
822 if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)))
823 data_.f.flags |= kInt64Flag;
824 if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
825 data_.f.flags |= kUintFlag;
826 if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
827 data_.f.flags |= kIntFlag;
831 explicit GenericValue(
double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d = d; data_.f.flags = kNumberDoubleFlag; }
834 explicit GenericValue(
float f) RAPIDJSON_NOEXCEPT : data_() { data_.n.d =
static_cast<double>(f); data_.f.flags = kNumberDoubleFlag; }
837 GenericValue(
const Ch* s, SizeType length) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(StringRef(s, length)); }
840 explicit GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(s); }
843 GenericValue(
const Ch* s, SizeType length, Allocator& allocator) : data_() { SetStringRaw(StringRef(s, length), allocator); }
846 GenericValue(
const Ch*s, Allocator& allocator) : data_() { SetStringRaw(StringRef(s), allocator); }
848 #if RAPIDJSON_HAS_STDSTRING 852 GenericValue(
const std::basic_string<Ch>& s, Allocator& allocator) : data_() { SetStringRaw(StringRef(s), allocator); }
862 a.value_.data_ = Data();
863 a.value_.data_.f.flags = kArrayFlag;
873 o.value_.data_ = Data();
874 o.value_.data_.f.flags = kObjectFlag;
885 switch(data_.f.flags) {
891 if (Allocator::kNeedFree) {
901 case kCopyStringFlag:
902 if (Allocator::kNeedFree) {
903 Allocator::Free(const_cast<Ch*>(GetStringPointer()));
934 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 937 return *
this = rhs.Move();
963 template <
typename T>
964 RAPIDJSON_DISABLEIF_RETURN((internal::IsPointer<T>), (
GenericValue&))
977 template <
typename SourceAllocator>
979 RAPIDJSON_ASSERT(static_cast<void*>(
this) != static_cast<void const*>(&rhs));
981 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
1014 GenericValue& Move() RAPIDJSON_NOEXCEPT {
return *
this; }
1024 template <
typename SourceAllocator>
1027 if (GetType() != rhs.GetType())
1030 switch (GetType()) {
1032 if (data_.o.size != rhs.data_.o.size)
1034 for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
1035 typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
1036 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
1042 if (data_.a.size != rhs.data_.a.size)
1044 for (SizeType i = 0; i < data_.a.size; i++)
1045 if ((*
this)[i] != rhs[i])
1050 return StringEqual(rhs);
1053 if (IsDouble() || rhs.IsDouble()) {
1054 double a = GetDouble();
1055 double b = rhs.GetDouble();
1056 return a >= b && a <= b;
1059 return data_.n.u64 == rhs.data_.n.u64;
1067 bool operator==(
const Ch* rhs)
const {
return *
this ==
GenericValue(StringRef(rhs)); }
1069 #if RAPIDJSON_HAS_STDSTRING 1073 bool operator==(
const std::basic_string<Ch>& rhs)
const {
return *
this ==
GenericValue(StringRef(rhs)); }
1079 template <
typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,
internal::IsGenericValue<T> >), (
bool)) operator==(
const T& rhs)
const {
return *
this ==
GenericValue(rhs); }
1084 template <
typename SourceAllocator>
1088 bool operator!=(
const Ch* rhs)
const {
return !(*
this == rhs); }
1093 template <
typename T> RAPIDJSON_DISABLEIF_RETURN((
internal::IsGenericValue<T>), (
bool)) operator!=(
const T& rhs)
const {
return !(*
this == rhs); }
1095 #ifndef __cpp_lib_three_way_comparison 1111 Type GetType()
const {
return static_cast<Type
>(data_.f.flags & kTypeMask); }
1112 bool IsNull()
const {
return data_.f.flags == kNullFlag; }
1113 bool IsFalse()
const {
return data_.f.flags == kFalseFlag; }
1114 bool IsTrue()
const {
return data_.f.flags == kTrueFlag; }
1115 bool IsBool()
const {
return (data_.f.flags & kBoolFlag) != 0; }
1116 bool IsObject()
const {
return data_.f.flags == kObjectFlag; }
1117 bool IsArray()
const {
return data_.f.flags == kArrayFlag; }
1118 bool IsNumber()
const {
return (data_.f.flags & kNumberFlag) != 0; }
1119 bool IsInt()
const {
return (data_.f.flags & kIntFlag) != 0; }
1120 bool IsUint()
const {
return (data_.f.flags & kUintFlag) != 0; }
1121 bool IsInt64()
const {
return (data_.f.flags & kInt64Flag) != 0; }
1122 bool IsUint64()
const {
return (data_.f.flags & kUint64Flag) != 0; }
1123 bool IsDouble()
const {
return (data_.f.flags & kDoubleFlag) != 0; }
1124 bool IsString()
const {
return (data_.f.flags & kStringFlag) != 0; }
1127 bool IsLosslessDouble()
const {
1128 if (!IsNumber())
return false;
1130 uint64_t u = GetUint64();
1131 volatile double d =
static_cast<double>(u);
1133 && (d < static_cast<double>((std::numeric_limits<uint64_t>::max)()))
1134 && (u ==
static_cast<uint64_t
>(d));
1137 int64_t i = GetInt64();
1138 volatile double d =
static_cast<double>(i);
1139 return (d >= static_cast<double>((std::numeric_limits<int64_t>::min)()))
1140 && (d < static_cast<double>((std::numeric_limits<int64_t>::max)()))
1141 && (i == static_cast<int64_t>(d));
1147 bool IsFloat()
const {
1148 if ((data_.f.flags & kDoubleFlag) == 0)
1150 double d = GetDouble();
1151 return d >= -3.4028234e38 && d <= 3.4028234e38;
1154 bool IsLosslessFloat()
const {
1155 if (!IsNumber())
return false;
1156 double a = GetDouble();
1157 if (a < static_cast<double>(-(std::numeric_limits<float>::max)())
1158 || a > static_cast<double>((std::numeric_limits<float>::max)()))
1160 double b =
static_cast<double>(
static_cast<float>(a));
1161 return a >= b && a <= b;
1176 bool GetBool()
const {
RAPIDJSON_ASSERT(IsBool());
return data_.f.flags == kTrueFlag; }
1191 SizeType MemberCount()
const {
RAPIDJSON_ASSERT(IsObject());
return data_.o.size; }
1194 SizeType MemberCapacity()
const {
RAPIDJSON_ASSERT(IsObject());
return data_.o.capacity; }
1197 bool ObjectEmpty()
const {
RAPIDJSON_ASSERT(IsObject());
return data_.o.size == 0; }
1208 template <
typename T>
1209 RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<
typename internal::RemoveConst<T>::Type, Ch> >),(
GenericValue&)) operator[](T* name) {
1213 template <
typename T>
1214 RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<
typename internal::RemoveConst<T>::Type, Ch> >),(
const GenericValue&)) operator[](T* name)
const {
return const_cast<GenericValue&
>(*this)[
name]; }
1225 template <
typename SourceAllocator>
1227 MemberIterator member = FindMember(name);
1228 if (member != MemberEnd())
1229 return member->value;
1242 template <
typename SourceAllocator>
1245 #if RAPIDJSON_HAS_STDSTRING 1248 const GenericValue& operator[](
const std::basic_string<Ch>& name)
const {
return (*
this)[
GenericValue(StringRef(name))]; }
1253 ConstMemberIterator MemberBegin()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstMemberIterator(GetMembersPointer()); }
1256 ConstMemberIterator MemberEnd()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstMemberIterator(GetMembersPointer() + data_.o.size); }
1259 MemberIterator MemberBegin() {
RAPIDJSON_ASSERT(IsObject());
return MemberIterator(GetMembersPointer()); }
1262 MemberIterator MemberEnd() {
RAPIDJSON_ASSERT(IsObject());
return MemberIterator(GetMembersPointer() + data_.o.size); }
1270 GenericValue& MemberReserve(SizeType newCapacity, Allocator &allocator) {
1272 DoReserveMembers(newCapacity, allocator);
1284 bool HasMember(
const Ch* name)
const {
return FindMember(name) != MemberEnd(); }
1286 #if RAPIDJSON_HAS_STDSTRING 1295 bool HasMember(
const std::basic_string<Ch>& name)
const {
return FindMember(name) != MemberEnd(); }
1307 template <
typename SourceAllocator>
1322 MemberIterator FindMember(
const Ch* name) {
1324 return FindMember(n);
1327 ConstMemberIterator FindMember(
const Ch* name)
const {
return const_cast<GenericValue&
>(*this).FindMember(name); }
1342 template <
typename SourceAllocator>
1346 return DoFindMember(name);
1350 #if RAPIDJSON_HAS_STDSTRING 1358 MemberIterator FindMember(
const std::basic_string<Ch>& name) {
return FindMember(
GenericValue(StringRef(name))); }
1359 ConstMemberIterator FindMember(
const std::basic_string<Ch>& name)
const {
return FindMember(
GenericValue(StringRef(name))); }
1375 DoAddMember(name, value, allocator);
1390 return AddMember(name, v, allocator);
1393 #if RAPIDJSON_HAS_STDSTRING 1405 return AddMember(name, v, allocator);
1426 template <
typename T>
1428 AddMember(
GenericValue& name, T value, Allocator& allocator) {
1430 return AddMember(name, v, allocator);
1433 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1435 return AddMember(name, value, allocator);
1438 return AddMember(name, value, allocator);
1441 return AddMember(name, value, allocator);
1445 return AddMember(n, value, allocator);
1447 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1462 return AddMember(n, value, allocator);
1474 GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator) {
1476 return AddMember(name, v, allocator);
1496 template <
typename T>
1498 AddMember(StringRefType name, T value, Allocator& allocator) {
1500 return AddMember(n, value, allocator);
1507 void RemoveAllMembers() {
1520 bool RemoveMember(
const Ch* name) {
1522 return RemoveMember(n);
1525 #if RAPIDJSON_HAS_STDSTRING 1526 bool RemoveMember(
const std::basic_string<Ch>& name) {
return RemoveMember(
GenericValue(StringRef(name))); }
1529 template <
typename SourceAllocator>
1531 MemberIterator m = FindMember(name);
1532 if (m != MemberEnd()) {
1548 MemberIterator RemoveMember(MemberIterator m) {
1553 return DoRemoveMember(m);
1565 MemberIterator EraseMember(ConstMemberIterator pos) {
1566 return EraseMember(pos, pos +1);
1578 MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) {
1585 return DoEraseMembers(first, last);
1593 bool EraseMember(
const Ch* name) {
1595 return EraseMember(n);
1598 #if RAPIDJSON_HAS_STDSTRING 1599 bool EraseMember(
const std::basic_string<Ch>& name) {
return EraseMember(
GenericValue(StringRef(name))); }
1602 template <
typename SourceAllocator>
1604 MemberIterator m = FindMember(name);
1605 if (m != MemberEnd()) {
1615 ConstObject GetObject()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstObject(*
this); }
1616 ConstObject GetObj()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstObject(*
this); }
1628 SizeType Size()
const {
RAPIDJSON_ASSERT(IsArray());
return data_.a.size; }
1631 SizeType Capacity()
const {
RAPIDJSON_ASSERT(IsArray());
return data_.a.capacity; }
1634 bool Empty()
const {
RAPIDJSON_ASSERT(IsArray());
return data_.a.size == 0; }
1656 return GetElementsPointer()[index];
1662 ValueIterator Begin() {
RAPIDJSON_ASSERT(IsArray());
return GetElementsPointer(); }
1665 ValueIterator End() {
RAPIDJSON_ASSERT(IsArray());
return GetElementsPointer() + data_.a.size; }
1668 ConstValueIterator Begin()
const {
return const_cast<GenericValue&
>(*this).Begin(); }
1671 ConstValueIterator End()
const {
return const_cast<GenericValue&
>(*this).End(); }
1679 GenericValue& Reserve(SizeType newCapacity, Allocator &allocator) {
1681 if (newCapacity > data_.a.capacity) {
1682 SetElementsPointer(reinterpret_cast<GenericValue*>(allocator.Realloc(GetElementsPointer(), data_.a.capacity *
sizeof(
GenericValue), newCapacity *
sizeof(
GenericValue))));
1683 data_.a.capacity = newCapacity;
1700 if (data_.a.size >= data_.a.capacity)
1701 Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2), allocator);
1702 GetElementsPointer()[data_.a.size++].RawAssign(value);
1706 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1708 return PushBack(value, allocator);
1710 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1721 GenericValue& PushBack(StringRefType value, Allocator& allocator) {
1722 return (*this).template PushBack<StringRefType>(value, allocator);
1742 template <
typename T>
1744 PushBack(T value, Allocator& allocator) {
1746 return PushBack(v, allocator);
1756 GetElementsPointer()[--data_.a.size].~GenericValue();
1767 ValueIterator Erase(ConstValueIterator pos) {
1768 return Erase(pos, pos + 1);
1779 ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) {
1786 ValueIterator pos = Begin() + (first - Begin());
1787 for (ValueIterator itr = pos; itr != last; ++itr)
1789 std::memmove(static_cast<void*>(pos), last, static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
1790 data_.a.size -=
static_cast<SizeType
>(last - first);
1795 ConstArray GetArray()
const {
RAPIDJSON_ASSERT(IsArray());
return ConstArray(*
this); }
1802 int GetInt()
const {
RAPIDJSON_ASSERT(data_.f.flags & kIntFlag);
return data_.n.i.i; }
1803 unsigned GetUint()
const {
RAPIDJSON_ASSERT(data_.f.flags & kUintFlag);
return data_.n.u.u; }
1804 int64_t GetInt64()
const {
RAPIDJSON_ASSERT(data_.f.flags & kInt64Flag);
return data_.n.i64; }
1805 uint64_t GetUint64()
const {
RAPIDJSON_ASSERT(data_.f.flags & kUint64Flag);
return data_.n.u64; }
1810 double GetDouble()
const {
1812 if ((data_.f.flags & kDoubleFlag) != 0)
return data_.n.d;
1813 if ((data_.f.flags & kIntFlag) != 0)
return data_.n.i.i;
1814 if ((data_.f.flags & kUintFlag) != 0)
return data_.n.u.u;
1815 if ((data_.f.flags & kInt64Flag) != 0)
return static_cast<double>(data_.n.i64);
1816 RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0);
return static_cast<double>(data_.n.u64);
1822 float GetFloat()
const {
1823 return static_cast<float>(GetDouble());
1838 const Ch* GetString()
const {
RAPIDJSON_ASSERT(IsString());
return DataString(data_); }
1843 SizeType GetStringLength()
const {
RAPIDJSON_ASSERT(IsString());
return DataStringLength(data_); }
1853 GenericValue& SetString(
const Ch* s, SizeType length) {
return SetString(StringRef(s, length)); }
1870 GenericValue& SetString(
const Ch* s, SizeType length, Allocator& allocator) {
return SetString(StringRef(s, length), allocator); }
1878 GenericValue& SetString(
const Ch* s, Allocator& allocator) {
return SetString(StringRef(s), allocator); }
1886 GenericValue& SetString(StringRefType s, Allocator& allocator) { this->~
GenericValue(); SetStringRaw(s, allocator);
return *
this; }
1888 #if RAPIDJSON_HAS_STDSTRING 1896 GenericValue& SetString(
const std::basic_string<Ch>& s, Allocator& allocator) {
return SetString(StringRef(s), allocator); }
1908 template <
typename T>
1911 template <
typename T>
1914 template <
typename T>
1917 template<
typename T>
1920 template<
typename T>
1923 GenericValue& SetRawOutput(
bool state) { state ? data_.f.flags |= kRawOutputStrFlag : data_.f.flags &= ~kRawOutputStrFlag;
return *
this; }
1934 template <
typename Handler>
1935 bool Accept(Handler& handler)
const {
1937 case kNullType:
return handler.Null();
1938 case kFalseType:
return handler.Bool(
false);
1939 case kTrueType:
return handler.Bool(
true);
1944 for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m) {
1946 if (
RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0)))
1951 return handler.EndObject(data_.o.size);
1956 for (ConstValueIterator v = Begin(); v != End(); ++v)
1959 return handler.EndArray(data_.a.size);
1962 return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0, (data_.f.flags & kRawOutputStrFlag) != 0);
1966 if (IsDouble())
return handler.Double(data_.n.d);
1967 else if (IsInt())
return handler.Int(data_.n.i.i);
1968 else if (IsUint())
return handler.Uint(data_.n.u.u);
1969 else if (IsInt64())
return handler.Int64(data_.n.i64);
1970 else return handler.Uint64(data_.n.u64);
1975 template <
typename,
typename>
friend class GenericValue;
1980 kNumberFlag = 0x0010,
1983 kInt64Flag = 0x0080,
1984 kUint64Flag = 0x0100,
1985 kDoubleFlag = 0x0200,
1986 kStringFlag = 0x0400,
1988 kInlineStrFlag = 0x1000,
1989 kRawOutputStrFlag = 0x8000,
1992 kNullFlag = kNullType,
1994 kTrueFlag =
static_cast<int>(kTrueType) | static_cast<int>(kBoolFlag),
1995 kFalseFlag =
static_cast<int>(kFalseType) | static_cast<int>(kBoolFlag),
1996 kNumberIntFlag =
static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kIntFlag | kInt64Flag),
1997 kNumberUintFlag =
static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag),
1998 kNumberInt64Flag =
static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kInt64Flag),
1999 kNumberUint64Flag =
static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kUint64Flag),
2000 kNumberDoubleFlag =
static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kDoubleFlag),
2001 kNumberAnyFlag =
static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag),
2002 kConstStringFlag =
static_cast<int>(kStringType) | static_cast<int>(kStringFlag),
2003 kCopyStringFlag =
static_cast<int>(kStringType) | static_cast<int>(kStringFlag | kCopyFlag),
2004 kShortStringFlag =
static_cast<int>(kStringType) | static_cast<int>(kStringFlag | kCopyFlag | kInlineStrFlag),
2005 kObjectFlag = kObjectType,
2006 kArrayFlag = kArrayType,
2015 #if RAPIDJSON_48BITPOINTER_OPTIMIZATION 2016 char payload[
sizeof(SizeType) * 2 + 6];
2017 #elif RAPIDJSON_64BIT 2018 char payload[
sizeof(SizeType) * 2 +
sizeof(
void*) + 6];
2020 char payload[
sizeof(SizeType) * 2 +
sizeof(
void*) + 2];
2040 enum { MaxChars =
sizeof(
static_cast<Flag*
>(0)->payload) /
sizeof(Ch), MaxSize = MaxChars - 1, LenPos = MaxSize };
2043 inline static bool Usable(SizeType len) {
return (MaxSize >= len); }
2044 inline void SetLength(SizeType len) { str[LenPos] =
static_cast<Ch
>(MaxSize - len); }
2045 inline SizeType GetLength()
const {
return static_cast<SizeType
>(MaxSize - str[LenPos]); }
2050 #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN 2095 static RAPIDJSON_FORCEINLINE
const Ch* DataString(
const Data& data) {
2096 return (data.f.flags & kInlineStrFlag) ? data.ss.str : RAPIDJSON_GETPOINTER(Ch, data.s.str);
2098 static RAPIDJSON_FORCEINLINE SizeType DataStringLength(
const Data& data) {
2099 return (data.f.flags & kInlineStrFlag) ? data.ss.GetLength() : data.s.length;
2102 RAPIDJSON_FORCEINLINE
const Ch* GetStringPointer()
const {
return RAPIDJSON_GETPOINTER(Ch, data_.s.str); }
2103 RAPIDJSON_FORCEINLINE
const Ch* SetStringPointer(
const Ch* str) {
return RAPIDJSON_SETPOINTER(Ch, data_.s.str, str); }
2104 RAPIDJSON_FORCEINLINE
GenericValue* GetElementsPointer()
const {
return RAPIDJSON_GETPOINTER(
GenericValue, data_.a.elements); }
2106 RAPIDJSON_FORCEINLINE Member* GetMembersPointer()
const {
return RAPIDJSON_GETPOINTER(Member, data_.o.members); }
2107 RAPIDJSON_FORCEINLINE Member* SetMembersPointer(Member* members) {
return RAPIDJSON_SETPOINTER(Member, data_.o.members, members); }
2109 #if RAPIDJSON_USE_MEMBERSMAP 2113 bool operator()(
const Data& s1,
const Data& s2)
const {
2114 SizeType n1 = DataStringLength(s1), n2 = DataStringLength(s2);
2115 int cmp = std::memcmp(DataString(s1), DataString(s2),
sizeof(Ch) * (n1 < n2 ? n1 : n2));
2116 return cmp < 0 || (cmp == 0 && n1 < n2);
2119 typedef std::pair<const Data, SizeType> Pair;
2120 typedef std::multimap<Data, SizeType, Less, StdAllocator<Pair, Allocator> > Map;
2121 typedef typename Map::iterator Iterator;
2123 typedef typename MapTraits::Map Map;
2124 typedef typename MapTraits::Less MapLess;
2125 typedef typename MapTraits::Pair MapPair;
2126 typedef typename MapTraits::Iterator MapIterator;
2136 static RAPIDJSON_FORCEINLINE
size_t GetMapLayoutSize(SizeType capacity) {
2140 capacity *
sizeof(MapIterator);
2143 static RAPIDJSON_FORCEINLINE SizeType &GetMapCapacity(Map* &map) {
2144 return *
reinterpret_cast<SizeType*
>(
reinterpret_cast<uintptr_t
>(&map) +
2148 static RAPIDJSON_FORCEINLINE Member* GetMapMembers(Map* &map) {
2149 return reinterpret_cast<Member*
>(
reinterpret_cast<uintptr_t
>(&map) +
2154 static RAPIDJSON_FORCEINLINE MapIterator* GetMapIterators(Map* &map) {
2155 return reinterpret_cast<MapIterator*
>(
reinterpret_cast<uintptr_t
>(&map) +
2161 static RAPIDJSON_FORCEINLINE Map* &GetMap(Member* members) {
2163 return *
reinterpret_cast<Map**
>(
reinterpret_cast<uintptr_t
>(members) -
2169 RAPIDJSON_FORCEINLINE MapIterator DropMapIterator(MapIterator& rhs) {
2170 #if RAPIDJSON_HAS_CXX11 2171 MapIterator ret = std::move(rhs);
2173 MapIterator ret = rhs;
2179 Map* &DoReallocMap(Map** oldMap, SizeType newCapacity, Allocator& allocator) {
2180 Map **newMap =
static_cast<Map**
>(allocator.Malloc(GetMapLayoutSize(newCapacity)));
2181 GetMapCapacity(*newMap) = newCapacity;
2183 *newMap =
new (allocator.Malloc(
sizeof(Map))) Map(MapLess(), allocator);
2187 size_t count = (*oldMap)->size();
2188 std::memcpy(static_cast<void*>(GetMapMembers(*newMap)),
2189 static_cast<void*>(GetMapMembers(*oldMap)),
2190 count *
sizeof(Member));
2191 MapIterator *oldIt = GetMapIterators(*oldMap),
2192 *newIt = GetMapIterators(*newMap);
2194 new (&newIt[count]) MapIterator(DropMapIterator(oldIt[count]));
2196 Allocator::Free(oldMap);
2201 RAPIDJSON_FORCEINLINE Member* DoAllocMembers(SizeType capacity, Allocator& allocator) {
2202 return GetMapMembers(DoReallocMap(0, capacity, allocator));
2205 void DoReserveMembers(SizeType newCapacity, Allocator& allocator) {
2207 if (newCapacity > o.capacity) {
2208 Member* oldMembers = GetMembersPointer();
2209 Map **oldMap = oldMembers ? &GetMap(oldMembers) : 0,
2210 *&newMap = DoReallocMap(oldMap, newCapacity, allocator);
2211 RAPIDJSON_SETPOINTER(Member, o.members, GetMapMembers(newMap));
2212 o.capacity = newCapacity;
2216 template <
typename SourceAllocator>
2218 if (Member* members = GetMembersPointer()) {
2219 Map* &map = GetMap(members);
2220 MapIterator mit = map->find(reinterpret_cast<const Data&>(name.data_));
2221 if (mit != map->end()) {
2222 return MemberIterator(&members[mit->second]);
2228 void DoClearMembers() {
2229 if (Member* members = GetMembersPointer()) {
2230 Map* &map = GetMap(members);
2231 MapIterator* mit = GetMapIterators(map);
2232 for (SizeType i = 0; i < data_.o.size; i++) {
2233 map->erase(DropMapIterator(mit[i]));
2234 members[i].~Member();
2240 void DoFreeMembers() {
2241 if (Member* members = GetMembersPointer()) {
2242 GetMap(members)->~Map();
2243 for (SizeType i = 0; i < data_.o.size; i++) {
2244 members[i].~Member();
2246 if (Allocator::kNeedFree) {
2247 Map** map = &GetMap(members);
2248 Allocator::Free(*map);
2249 Allocator::Free(map);
2254 #else // !RAPIDJSON_USE_MEMBERSMAP 2256 RAPIDJSON_FORCEINLINE Member* DoAllocMembers(SizeType capacity, Allocator& allocator) {
2257 return Malloc<Member>(allocator, capacity);
2260 void DoReserveMembers(SizeType newCapacity, Allocator& allocator) {
2262 if (newCapacity > o.capacity) {
2263 Member* newMembers = Realloc<Member>(allocator, GetMembersPointer(), o.capacity, newCapacity);
2264 RAPIDJSON_SETPOINTER(Member, o.members, newMembers);
2265 o.capacity = newCapacity;
2269 template <
typename SourceAllocator>
2271 MemberIterator member = MemberBegin();
2272 for ( ; member != MemberEnd(); ++member)
2273 if (name.StringEqual(member->name))
2278 void DoClearMembers() {
2279 for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
2284 void DoFreeMembers() {
2285 for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
2287 Allocator::Free(GetMembersPointer());
2290 #endif // !RAPIDJSON_USE_MEMBERSMAP 2294 if (o.size >= o.capacity)
2295 DoReserveMembers(o.capacity ? (o.capacity + (o.capacity + 1) / 2) : kDefaultObjectCapacity, allocator);
2296 Member* members = GetMembersPointer();
2297 Member* m = members + o.size;
2298 m->
name.RawAssign(name);
2299 m->
value.RawAssign(value);
2300 #if RAPIDJSON_USE_MEMBERSMAP 2301 Map* &map = GetMap(members);
2302 MapIterator* mit = GetMapIterators(map);
2303 new (&mit[o.size]) MapIterator(map->insert(MapPair(m->
name.data_, o.size)));
2308 MemberIterator DoRemoveMember(MemberIterator m) {
2310 Member* members = GetMembersPointer();
2311 #if RAPIDJSON_USE_MEMBERSMAP 2312 Map* &map = GetMap(members);
2313 MapIterator* mit = GetMapIterators(map);
2314 SizeType mpos =
static_cast<SizeType
>(&*m - members);
2315 map->erase(DropMapIterator(mit[mpos]));
2317 MemberIterator last(members + (o.size - 1));
2318 if (o.size > 1 && m != last) {
2319 #if RAPIDJSON_USE_MEMBERSMAP 2320 new (&mit[mpos]) MapIterator(DropMapIterator(mit[&*last - members]));
2321 mit[mpos]->second = mpos;
2332 MemberIterator DoEraseMembers(ConstMemberIterator first, ConstMemberIterator last) {
2334 MemberIterator beg = MemberBegin(),
2335 pos = beg + (first - beg),
2337 #if RAPIDJSON_USE_MEMBERSMAP 2338 Map* &map = GetMap(GetMembersPointer());
2339 MapIterator* mit = GetMapIterators(map);
2341 for (MemberIterator itr = pos; itr != last; ++itr) {
2342 #if RAPIDJSON_USE_MEMBERSMAP 2343 map->erase(DropMapIterator(mit[itr - beg]));
2347 #if RAPIDJSON_USE_MEMBERSMAP 2348 if (first != last) {
2350 MemberIterator next = pos + (last - first);
2351 for (MemberIterator itr = pos; next != end; ++itr, ++next) {
2352 std::memcpy(static_cast<void*>(&*itr), &*next,
sizeof(Member));
2353 SizeType mpos =
static_cast<SizeType
>(itr - beg);
2354 new (&mit[mpos]) MapIterator(DropMapIterator(mit[next - beg]));
2355 mit[mpos]->second = mpos;
2359 std::memmove(static_cast<void*>(&*pos), &*last,
2360 static_cast<size_t>(end - last) *
sizeof(Member));
2362 o.size -=
static_cast<SizeType
>(last - first);
2366 template <
typename SourceAllocator>
2370 data_.f.flags = kObjectFlag;
2371 SizeType count = rhs.data_.o.size;
2372 Member* lm = DoAllocMembers(count, allocator);
2374 #if RAPIDJSON_USE_MEMBERSMAP 2375 Map* &map = GetMap(lm);
2376 MapIterator* mit = GetMapIterators(map);
2378 for (SizeType i = 0; i < count; i++) {
2381 #if RAPIDJSON_USE_MEMBERSMAP 2382 new (&mit[i]) MapIterator(map->insert(MapPair(lm[i].name.data_, i)));
2385 data_.o.size = data_.o.capacity = count;
2386 SetMembersPointer(lm);
2390 void SetArrayRaw(
GenericValue* values, SizeType count, Allocator& allocator) {
2391 data_.f.flags = kArrayFlag;
2394 SetElementsPointer(e);
2395 std::memcpy(static_cast<void*>(e), values, count *
sizeof(
GenericValue));
2398 SetElementsPointer(0);
2399 data_.a.size = data_.a.capacity = count;
2404 data_.f.flags = kObjectFlag;
2406 Member* m = DoAllocMembers(count, allocator);
2407 SetMembersPointer(m);
2408 std::memcpy(static_cast<void*>(m), members, count *
sizeof(Member));
2409 #if RAPIDJSON_USE_MEMBERSMAP 2410 Map* &map = GetMap(m);
2411 MapIterator* mit = GetMapIterators(map);
2412 for (SizeType i = 0; i < count; i++) {
2413 new (&mit[i]) MapIterator(map->insert(MapPair(m[i].name.data_, i)));
2418 SetMembersPointer(0);
2419 data_.o.size = data_.o.capacity = count;
2424 data_.f.flags = kConstStringFlag;
2425 SetStringPointer(s);
2426 data_.s.length = s.length;
2432 if (ShortString::Usable(s.
length)) {
2433 data_.f.flags = kShortStringFlag;
2434 data_.ss.SetLength(s.
length);
2437 data_.f.flags = kCopyStringFlag;
2438 data_.s.length = s.
length;
2439 str =
static_cast<Ch *
>(allocator.Malloc((s.
length + 1) *
sizeof(Ch)));
2440 SetStringPointer(str);
2442 std::memcpy(str, s, s.
length *
sizeof(Ch));
2450 rhs.data_.f.flags = kNullFlag;
2453 template <
typename SourceAllocator>
2458 const SizeType len1 = GetStringLength();
2459 const SizeType len2 = rhs.GetStringLength();
2460 if(len1 != len2) {
return false; }
2462 const Ch*
const str1 = GetString();
2463 const Ch*
const str2 = rhs.GetString();
2464 if(str1 == str2) {
return true; }
2466 return (std::memcmp(str1, str2,
sizeof(Ch) * len1) == 0);
2486 template <
typename Encoding,
typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR,
typename StackAllocator = RAPIDJSON_DEFAULT_STACK_ALLOCATOR >
2489 typedef typename Encoding::Ch
Ch;
2500 explicit GenericDocument(Type type, Allocator* allocator = 0,
size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2501 GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2504 ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2513 GenericDocument(Allocator* allocator = 0,
size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2514 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2517 ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2520 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2523 : ValueType(std::forward<ValueType>(rhs)),
2524 allocator_(rhs.allocator_),
2525 ownAllocator_(rhs.ownAllocator_),
2526 stack_(std::move(rhs.stack_)),
2527 parseResult_(rhs.parseResult_)
2530 rhs.ownAllocator_ = 0;
2540 if (ownAllocator_) {
2541 ValueType::SetNull();
2546 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2552 ValueType::operator=(std::forward<ValueType>(rhs));
2557 allocator_ = rhs.allocator_;
2558 ownAllocator_ = rhs.ownAllocator_;
2559 stack_ = std::move(rhs.stack_);
2560 parseResult_ = rhs.parseResult_;
2563 rhs.ownAllocator_ = 0;
2577 ValueType::Swap(rhs);
2578 stack_.Swap(rhs.stack_);
2579 internal::Swap(allocator_, rhs.allocator_);
2580 internal::Swap(ownAllocator_, rhs.ownAllocator_);
2581 internal::Swap(parseResult_, rhs.parseResult_);
2587 using ValueType::Swap;
2608 template <
typename Generator>
2610 ClearStackOnExit scope(*
this);
2613 ValueType::operator=(*stack_.template Pop<ValueType>(1));
2628 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
2631 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2632 ClearStackOnExit scope(*
this);
2633 parseResult_ = reader.template Parse<parseFlags>(is, *
this);
2636 ValueType::operator=(*stack_.template Pop<ValueType>(1));
2647 template <
unsigned parseFlags,
typename InputStream>
2649 return ParseStream<parseFlags, Encoding, InputStream>(is);
2657 template <
typename InputStream>
2659 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2671 template <
unsigned parseFlags>
2674 return ParseStream<parseFlags | kParseInsituFlag>(s);
2682 return ParseInsitu<kParseDefaultFlags>(str);
2694 template <
unsigned parseFlags,
typename SourceEncoding>
2698 return ParseStream<parseFlags, SourceEncoding>(s);
2705 template <
unsigned parseFlags>
2707 return Parse<parseFlags, Encoding>(str);
2714 return Parse<kParseDefaultFlags>(str);
2717 template <
unsigned parseFlags,
typename SourceEncoding>
2718 GenericDocument& Parse(
const typename SourceEncoding::Ch* str,
size_t length) {
2720 MemoryStream ms(reinterpret_cast<const char*>(str), length *
sizeof(
typename SourceEncoding::Ch));
2722 ParseStream<parseFlags, SourceEncoding>(is);
2726 template <
unsigned parseFlags>
2728 return Parse<parseFlags, Encoding>(str, length);
2732 return Parse<kParseDefaultFlags>(str, length);
2735 #if RAPIDJSON_HAS_STDSTRING 2736 template <
unsigned parseFlags,
typename SourceEncoding>
2737 GenericDocument& Parse(
const std::basic_string<typename SourceEncoding::Ch>& str) {
2739 return Parse<parseFlags, SourceEncoding>(str.c_str());
2742 template <
unsigned parseFlags>
2744 return Parse<parseFlags, Encoding>(str.c_str());
2748 return Parse<kParseDefaultFlags>(str);
2750 #endif // RAPIDJSON_HAS_STDSTRING 2767 #ifndef __clang // -Wdocumentation 2792 struct ClearStackOnExit {
2794 ~ClearStackOnExit() { d_.ClearStack(); }
2796 ClearStackOnExit(
const ClearStackOnExit&);
2797 ClearStackOnExit&
operator=(
const ClearStackOnExit&);
2803 template <
typename,
typename>
friend class GenericValue;
2807 bool Null() {
new (stack_.template Push<ValueType>())
ValueType();
return true; }
2808 bool Bool(
bool b) {
new (stack_.template Push<ValueType>())
ValueType(b);
return true; }
2809 bool Int(
int i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2810 bool Uint(
unsigned i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2811 bool Int64(int64_t i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2812 bool Uint64(uint64_t i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2813 bool Double(
double d) {
new (stack_.template Push<ValueType>())
ValueType(d);
return true; }
2815 bool RawNumber(
const Ch* str, SizeType length,
bool copy) {
2817 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
2819 new (stack_.template Push<ValueType>())
ValueType(str, length);
2823 bool String(
const Ch* str, SizeType length,
bool copy) {
2825 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
2827 new (stack_.template Push<ValueType>())
ValueType(str, length);
2831 bool StartObject() {
new (stack_.template Push<ValueType>())
ValueType(kObjectType);
return true; }
2833 bool Key(
const Ch* str, SizeType length,
bool copy) {
return String(str, length, copy); }
2835 bool EndObject(SizeType memberCount) {
2836 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2837 stack_.template Top<ValueType>()->
SetObjectRaw(members, memberCount, GetAllocator());
2841 bool StartArray() {
new (stack_.template Push<ValueType>())
ValueType(kArrayType);
return true; }
2843 bool EndArray(SizeType elementCount) {
2844 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2845 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());
2856 if (Allocator::kNeedFree)
2857 while (stack_.GetSize() > 0)
2858 (stack_.template Pop<ValueType>(1))->~
ValueType();
2861 stack_.ShrinkToFit();
2865 RAPIDJSON_DELETE(ownAllocator_);
2868 static const size_t kDefaultStackCapacity = 1024;
2869 Allocator* allocator_;
2870 Allocator* ownAllocator_;
2884 template <
bool Const,
typename ValueT>
2889 typedef ValueT PlainType;
2890 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
2891 typedef ValueType* ValueIterator;
2892 typedef const ValueT* ConstValueIterator;
2896 template <
typename,
typename>
2903 operator ValueType&()
const {
return value_; }
2904 SizeType Size()
const {
return value_.Size(); }
2905 SizeType Capacity()
const {
return value_.Capacity(); }
2906 bool Empty()
const {
return value_.Empty(); }
2907 void Clear()
const { value_.Clear(); }
2908 ValueType& operator[](SizeType index)
const {
return value_[index]; }
2909 ValueIterator Begin()
const {
return value_.Begin(); }
2910 ValueIterator End()
const {
return value_.End(); }
2911 GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator)
const { value_.Reserve(newCapacity, allocator);
return *
this; }
2912 GenericArray PushBack(ValueType& value, AllocatorType& allocator)
const { value_.PushBack(value, allocator);
return *
this; }
2913 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2914 GenericArray PushBack(ValueType&& value, AllocatorType& allocator)
const { value_.PushBack(value, allocator);
return *
this; }
2915 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 2916 GenericArray PushBack(StringRefType value, AllocatorType& allocator)
const { value_.PushBack(value, allocator);
return *
this; }
2918 GenericArray PopBack()
const { value_.PopBack();
return *
this; }
2919 ValueIterator Erase(ConstValueIterator pos)
const {
return value_.Erase(pos); }
2920 ValueIterator Erase(ConstValueIterator first, ConstValueIterator last)
const {
return value_.Erase(first, last); }
2922 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 2923 ValueIterator begin()
const {
return value_.Begin(); }
2924 ValueIterator end()
const {
return value_.End(); }
2938 template <
bool Const,
typename ValueT>
2943 typedef ValueT PlainType;
2944 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
2952 template <
typename,
typename>
2959 operator ValueType&()
const {
return value_; }
2960 SizeType MemberCount()
const {
return value_.MemberCount(); }
2961 SizeType MemberCapacity()
const {
return value_.MemberCapacity(); }
2962 bool ObjectEmpty()
const {
return value_.ObjectEmpty(); }
2963 template <
typename T> ValueType& operator[](T* name)
const {
return value_[
name]; }
2965 #if RAPIDJSON_HAS_STDSTRING 2966 ValueType& operator[](
const std::basic_string<Ch>& name)
const {
return value_[
name]; }
2968 MemberIterator MemberBegin()
const {
return value_.MemberBegin(); }
2969 MemberIterator MemberEnd()
const {
return value_.MemberEnd(); }
2970 GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocator)
const { value_.MemberReserve(newCapacity, allocator);
return *
this; }
2971 bool HasMember(
const Ch* name)
const {
return value_.HasMember(name); }
2972 #if RAPIDJSON_HAS_STDSTRING 2973 bool HasMember(
const std::basic_string<Ch>& name)
const {
return value_.HasMember(name); }
2976 MemberIterator FindMember(
const Ch* name)
const {
return value_.FindMember(name); }
2978 #if RAPIDJSON_HAS_STDSTRING 2979 MemberIterator FindMember(
const std::basic_string<Ch>& name)
const {
return value_.FindMember(name); }
2981 GenericObject AddMember(ValueType& name, ValueType& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2982 GenericObject AddMember(ValueType& name, StringRefType value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2983 #if RAPIDJSON_HAS_STDSTRING 2984 GenericObject AddMember(ValueType& name, std::basic_string<Ch>& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2986 template <
typename T>
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,
internal::IsGenericValue<T> >), (ValueType&)) AddMember(ValueType& name, T value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2987 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2988 GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2989 GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2990 GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2991 GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2992 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 2993 GenericObject AddMember(StringRefType name, ValueType& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2994 GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2996 void RemoveAllMembers() { value_.RemoveAllMembers(); }
2997 bool RemoveMember(
const Ch* name)
const {
return value_.RemoveMember(name); }
2998 #if RAPIDJSON_HAS_STDSTRING 2999 bool RemoveMember(
const std::basic_string<Ch>& name)
const {
return value_.RemoveMember(name); }
3002 MemberIterator RemoveMember(MemberIterator m)
const {
return value_.RemoveMember(m); }
3003 MemberIterator EraseMember(ConstMemberIterator pos)
const {
return value_.EraseMember(pos); }
3004 MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last)
const {
return value_.EraseMember(first, last); }
3005 bool EraseMember(
const Ch* name)
const {
return value_.EraseMember(name); }
3006 #if RAPIDJSON_HAS_STDSTRING 3007 bool EraseMember(
const std::basic_string<Ch>& name)
const {
return EraseMember(
ValueType(StringRef(name))); }
3011 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 3012 MemberIterator begin()
const {
return value_.MemberBegin(); }
3013 MemberIterator end()
const {
return value_.MemberEnd(); }
3025 #ifdef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED 3026 #pragma pop_macro("GetObject") 3027 #undef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED 3030 #endif // RAPIDJSON_DOCUMENT_H_ GenericValue(Object o) RAPIDJSON_NOEXCEPT
Constructor for Object.
Definition: document.h:872
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
Definition: document.h:2576
GenericValue< Encoding, Allocator > value
value of member.
Definition: document.h:123
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags)
Definition: document.h:2713
GenericValue(Array a) RAPIDJSON_NOEXCEPT
Constructor for Array.
Definition: document.h:861
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
Definition: document.h:2761
Definition: document.h:2080
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
Definition: document.h:2648
Allocator AllocatorType
Allocator type from template parameter.
Definition: document.h:2491
GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
Constructor for boolean value.
Definition: document.h:781
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2490
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
Definition: document.h:240
GenericMemberIterator()
Default constructor (singular value)
Definition: document.h:222
GenericValue * ValueIterator
Value iterator for iterating in array.
Definition: document.h:678
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
Definition: document.h:679
DifferenceType operator-(ConstIterator that) const
Distance.
Definition: document.h:282
GenericValue(double d) RAPIDJSON_NOEXCEPT
Constructor for double value.
Definition: document.h:831
GenericValue(const Ch *s, SizeType length, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
Definition: document.h:843
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
Definition: document.h:2447
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
Definition: document.h:2672
GenericStringRef< Ch > StringRefType
Reference to a constant string.
Definition: document.h:675
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:66
Encoding EncodingType
Encoding type from template parameter.
Definition: document.h:672
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
Definition: document.h:2764
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:494
GenericValue< Encoding, Allocator > ValueType
Value type of itself.
Definition: document.h:680
Definition: document.h:2039
ParseErrorCode
Error code of parsing.
Definition: error.h:64
#define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
User defined kDefaultObjectCapacity value.
Definition: document.h:99
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:454
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with kParseDefaultFlags)
Definition: document.h:2681
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Definition: document.h:2513
GenericValue & operator=(StringRefType str) RAPIDJSON_NOEXCEPT
Assignment of constant string reference (no copy)
Definition: document.h:946
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:2782
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
Definition: document.h:399
Definition: document.h:502
const SizeType length
length of the string (excluding the trailing NULL terminator)
Definition: document.h:420
GenericStringRef(const CharType(&str)[N]) RAPIDJSON_NOEXCEPT
Create string reference from const character array.
Definition: document.h:375
A contiguous memory buffer with an optional growing ability.
Definition: core.h:778
Definition: document.h:509
void SetStringRaw(StringRefType s, Allocator &allocator)
Initialize this value as copy string with initial data, without calling destructor.
Definition: document.h:2430
#define RAPIDJSON_NOEXCEPT_ASSERT(x)
Assertion (in non-throwing contexts).
Definition: rapidjson.h:687
Reference to a constant string (not taking a copy)
Definition: document.h:346
GenericDocument & Populate(Generator &g)
Populate this document by a generator which produces SAX events.
Definition: document.h:2609
Represents an in-memory input byte stream.
Definition: memorystream.h:40
GenericValue() RAPIDJSON_NOEXCEPT
Default constructor creates a null value.
Definition: document.h:690
reference Reference
Reference to (const) GenericMember.
Definition: document.h:214
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
Definition: document.h:2403
GenericMemberIterator Iterator
Iterator type itself.
Definition: document.h:196
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Definition: document.h:2758
GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT
Constructor for uint64_t value.
Definition: document.h:819
Definition: document.h:2014
Read-only string stream.
Definition: fwd.h:47
const Ch *const s
plain CharType pointer
Definition: document.h:419
pointer Pointer
Pointer to (const) GenericMember.
Definition: document.h:212
Name-value pair in a JSON object value.
Definition: document.h:120
GenericStringRef(const CharType *str, SizeType len)
Create constant string reference from pointer and length.
Definition: document.h:411
#define RAPIDJSON_USE_MEMBERSMAP
Enable RapidJSON support for object members handling in a std::multimap.
Definition: rapidjson.h:180
Definition: document.h:2051
friend void swap(GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
Definition: document.h:2601
size_t GetStackCapacity() const
Get the capacity of stack in bytes.
Definition: document.h:2788
Definition: document.h:2086
GenericMember & operator=(GenericMember &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:142
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:507
GenericValue(const Ch *s, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
Definition: document.h:846
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
#define RAPIDJSON_ALIGN(x)
Data alignment of the machine.
Definition: rapidjson.h:307
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
Definition: document.h:198
GenericValue(const Ch *s, SizeType length) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
Definition: document.h:837
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
Definition: document.h:200
GenericStringRef< CharType > StringRef(const CharType *str, size_t length)
Mark a character pointer as constant string.
Definition: document.h:474
SizeType hashcode
reserved
Definition: document.h:2027
Helper class for accessing Value of array type.
Definition: document.h:651
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
Definition: document.h:2706
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition: document.h:2695
Definition: allocators.h:422
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition: fwd.h:88
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags)
Definition: document.h:2658
Definition: document.h:2025
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
Definition: document.h:676
GenericValue< Encoding, Allocator > name
name of member (must be a string)
Definition: document.h:122
CharType Ch
character type of the string
Definition: document.h:347
Helper class for accessing Value of object type.
Definition: document.h:652
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
Definition: document.h:677
Result of parsing (wraps ParseErrorCode)
Definition: error.h:106
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:921
~GenericValue()
Destructor.
Definition: document.h:880
#define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
User defined kDefaultArrayCapacity value.
Definition: document.h:110
difference_type DifferenceType
Signed integer type (e.g. ptrdiff_t)
Definition: document.h:216
RAPIDJSON_DISABLEIF_RETURN((internal::IsPointer< T >),(GenericValue &)) operator
Assignment with primitive types.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
Definition: document.h:2629
GenericValue(Type type) RAPIDJSON_NOEXCEPT
Constructor with JSON value type.
Definition: document.h:720
Definition: document.h:2055
Definition: document.h:519
A read-write string stream.
Definition: fwd.h:52
Definition: document.h:2049
(Constant) member iterator for a JSON object value
Definition: document.h:186
GenericDocument(Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Definition: document.h:2500
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition: document.h:2423
GenericValue(unsigned u) RAPIDJSON_NOEXCEPT
Constructor for unsigned value.
Definition: document.h:798
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:437
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:2489
A document for parsing JSON text as DOM.
Definition: document.h:69
Definition: allocators.h:424
GenericValue(float f) RAPIDJSON_NOEXCEPT
Constructor for float value.
Definition: document.h:834
GenericValue(int i) RAPIDJSON_NOEXCEPT
Constructor for int value.
Definition: document.h:792
Allocator AllocatorType
Allocator type from template parameter.
Definition: document.h:673
Definition: document.h:2074
GenericValue(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
Explicit copy constructor (with allocator)
Definition: document.h:742
GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT
Constructor for int64_t value.
Definition: document.h:804
GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
Definition: document.h:840
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:671
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:674