19 #ifndef RAPIDJSON_DOCUMENT_H_ 20 #define RAPIDJSON_DOCUMENT_H_ 34 RAPIDJSON_DIAG_OFF(padded)
35 RAPIDJSON_DIAG_OFF(switch - enum)
36 RAPIDJSON_DIAG_OFF(c++ 98 - compat)
37 #elif defined(_MSC_VER) 38 RAPIDJSON_DIAG_OFF(4127)
44 RAPIDJSON_DIAG_OFF(effc++)
47 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 51 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 58 template <
typename Encoding,
typename Allocator>
61 template <
typename Encoding,
typename Allocator,
typename StackAllocator>
71 template <
typename Encoding,
typename Allocator>
78 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 82 value(
std::move(rhs.value)) {}
106 a.value.Swap(b.value);
117 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 141 template <
bool Const,
typename Encoding,
typename Allocator>
144 template <
bool,
typename,
typename>
269 #else // RAPIDJSON_NOMEMBERITERATORCLASS 273 template <
bool Const,
typename Encoding,
typename Allocator>
277 template <
typename Encoding,
typename Allocator>
283 template <
typename Encoding,
typename Allocator>
289 #endif // RAPIDJSON_NOMEMBERITERATORCLASS 321 template <
typename CharType>
326 #ifndef __clang__ // -Wdocumentation 350 template <SizeType N>
356 #ifndef __clang__ // -Wdocumentation 377 :
s(str),
length(NotNullStrLen(str)) {}
380 #ifndef __clang__ // -Wdocumentation 398 operator const Ch *()
const {
return s; }
411 static const Ch emptyString[];
414 template <SizeType N>
420 template <
typename CharType>
438 template <
typename CharType>
458 template <
typename CharType>
464 #if RAPIDJSON_HAS_STDSTRING 477 template <
typename CharType>
479 const std::basic_string<CharType> &str) {
488 template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
492 template <
typename T>
494 typename Void<typename T::AllocatorType>
::Type>
496 GenericValue<typename T::EncodingType, typename T::AllocatorType>,
501 template <
typename T>
511 template <
typename ValueType,
typename T>
514 template <
typename ValueType>
516 static bool Is(
const ValueType &v) {
return v.IsBool(); }
517 static bool Get(
const ValueType &v) {
return v.GetBool(); }
518 static ValueType &
Set(ValueType &v,
bool data) {
return v.SetBool(data); }
519 static ValueType &
Set(ValueType &v,
bool data,
520 typename ValueType::AllocatorType &) {
521 return v.SetBool(data);
525 template <
typename ValueType>
527 static bool Is(
const ValueType &v) {
return v.IsInt(); }
528 static int Get(
const ValueType &v) {
return v.GetInt(); }
529 static ValueType &
Set(ValueType &v,
int data) {
return v.SetInt(data); }
530 static ValueType &
Set(ValueType &v,
int data,
531 typename ValueType::AllocatorType &) {
532 return v.SetInt(data);
536 template <
typename ValueType>
538 static bool Is(
const ValueType &v) {
return v.IsUint(); }
539 static unsigned Get(
const ValueType &v) {
return v.GetUint(); }
540 static ValueType &
Set(ValueType &v,
unsigned data) {
return v.SetUint(data); }
541 static ValueType &
Set(ValueType &v,
unsigned data,
542 typename ValueType::AllocatorType &) {
543 return v.SetUint(data);
549 template <
typename ValueType>
551 static bool Is(
const ValueType &v) {
return v.IsInt(); }
552 static long Get(
const ValueType &v) {
return v.GetInt(); }
553 static ValueType &Set(ValueType &v,
long data) {
return v.SetInt(data); }
554 static ValueType &Set(ValueType &v,
long data,
555 typename ValueType::AllocatorType &) {
556 return v.SetInt(data);
561 template <
typename ValueType>
563 static bool Is(
const ValueType &v) {
return v.IsUint(); }
564 static unsigned long Get(
const ValueType &v) {
return v.GetUint(); }
565 static ValueType &Set(ValueType &v,
unsigned long data) {
566 return v.SetUint(data);
568 static ValueType &Set(ValueType &v,
unsigned long data,
569 typename ValueType::AllocatorType &) {
570 return v.SetUint(data);
575 template <
typename ValueType>
577 static bool Is(
const ValueType &v) {
return v.IsInt64(); }
578 static int64_t Get(
const ValueType &v) {
return v.GetInt64(); }
579 static ValueType &
Set(ValueType &v,
int64_t data) {
return v.SetInt64(data); }
581 typename ValueType::AllocatorType &) {
582 return v.SetInt64(data);
586 template <
typename ValueType>
588 static bool Is(
const ValueType &v) {
return v.IsUint64(); }
591 return v.SetUint64(data);
594 typename ValueType::AllocatorType &) {
595 return v.SetUint64(data);
599 template <
typename ValueType>
601 static bool Is(
const ValueType &v) {
return v.IsDouble(); }
602 static double Get(
const ValueType &v) {
return v.GetDouble(); }
603 static ValueType &
Set(ValueType &v,
double data) {
return v.SetDouble(data); }
604 static ValueType &
Set(ValueType &v,
double data,
605 typename ValueType::AllocatorType &) {
606 return v.SetDouble(data);
610 template <
typename ValueType>
612 static bool Is(
const ValueType &v) {
return v.IsFloat(); }
613 static float Get(
const ValueType &v) {
return v.GetFloat(); }
614 static ValueType &
Set(ValueType &v,
float data) {
return v.SetFloat(data); }
615 static ValueType &
Set(ValueType &v,
float data,
616 typename ValueType::AllocatorType &) {
617 return v.SetFloat(data);
621 template <
typename ValueType>
622 struct TypeHelper<ValueType, const typename ValueType::Ch *> {
624 static bool Is(
const ValueType &v) {
return v.IsString(); }
625 static StringType
Get(
const ValueType &v) {
return v.GetString(); }
626 static ValueType &
Set(ValueType &v,
const StringType data) {
627 return v.SetString(
typename ValueType::StringRefType(data));
629 static ValueType &
Set(ValueType &v,
const StringType data,
630 typename ValueType::AllocatorType &
a) {
631 return v.SetString(data, a);
635 #if RAPIDJSON_HAS_STDSTRING 636 template <
typename ValueType>
637 struct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch>> {
638 typedef std::basic_string<typename ValueType::Ch>
StringType;
639 static bool Is(
const ValueType &v) {
return v.IsString(); }
640 static StringType Get(
const ValueType &v) {
641 return StringType(v.GetString(), v.GetStringLength());
643 static ValueType &Set(ValueType &v,
const StringType &data,
644 typename ValueType::AllocatorType &
a) {
645 return v.SetString(data, a);
650 template <
typename ValueType>
653 static bool Is(
const ValueType &v) {
return v.IsArray(); }
654 static ArrayType
Get(ValueType &v) {
return v.GetArray(); }
655 static ValueType &
Set(ValueType &v, ArrayType data) {
return v = data; }
656 static ValueType &
Set(ValueType &v, ArrayType data,
657 typename ValueType::AllocatorType &) {
662 template <
typename ValueType>
663 struct TypeHelper<ValueType, typename ValueType::ConstArray> {
665 static bool Is(
const ValueType &v) {
return v.IsArray(); }
666 static ArrayType
Get(
const ValueType &v) {
return v.GetArray(); }
669 template <
typename ValueType>
672 static bool Is(
const ValueType &v) {
return v.IsObject(); }
673 static ObjectType
Get(ValueType &v) {
return v.GetObject(); }
674 static ValueType &
Set(ValueType &v, ObjectType data) {
return v = data; }
675 static ValueType &
Set(ValueType &v, ObjectType data,
676 typename ValueType::AllocatorType &) {
681 template <
typename ValueType>
682 struct TypeHelper<ValueType, typename ValueType::ConstObject> {
684 static bool Is(
const ValueType &v) {
return v.IsObject(); }
685 static ObjectType
Get(
const ValueType &v) {
return v.GetObject(); }
691 template <
bool,
typename>
693 template <
bool,
typename>
710 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>>
717 typedef typename Encoding::Ch
Ch;
740 GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; }
742 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 753 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 754 template <
typename StackAllocator>
759 template <
typename StackAllocator>
771 static const uint16_t defaultFlags[] = {
772 kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag,
773 kArrayFlag, kShortStringFlag, kNumberAnyFlag};
775 data_.f.flags = defaultFlags[type];
790 template <
typename SourceAllocator>
792 Allocator &allocator,
bool copyConstStrings =
false) {
793 switch (rhs.GetType()) {
796 Member *lm =
reinterpret_cast<Member *
>(
797 allocator.Malloc(count *
sizeof(Member)));
800 for (
SizeType i = 0; i < count; i++) {
806 data_.f.flags = kObjectFlag;
807 data_.o.size = data_.o.capacity = count;
808 SetMembersPointer(lm);
816 for (
SizeType i = 0; i < count; i++)
817 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
818 data_.f.flags = kArrayFlag;
819 data_.a.size = data_.a.capacity = count;
820 SetElementsPointer(le);
823 if (rhs.
data_.f.flags == kConstStringFlag && !copyConstStrings) {
824 data_.f.flags = rhs.
data_.f.flags;
825 data_ = *
reinterpret_cast<const Data *
>(&rhs.
data_);
827 SetStringRaw(
StringRef(rhs.GetString(), rhs.GetStringLength()),
831 data_.f.flags = rhs.
data_.f.flags;
832 data_ = *
reinterpret_cast<const Data *
>(&rhs.
data_);
844 #ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen 845 template <
typename T>
846 explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>)))
854 data_.f.flags = b ? kTrueFlag : kFalseFlag;
861 (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;
867 data_.f.flags = (u & 0x80000000)
869 : (kNumberUintFlag | kIntFlag | kInt64Flag);
875 data_.f.flags = kNumberInt64Flag;
877 data_.f.flags |= kNumberUint64Flag;
878 if (!(static_cast<uint64_t>(i64) &
880 data_.f.flags |= kUintFlag;
881 if (!(static_cast<uint64_t>(i64) &
883 data_.f.flags |= kIntFlag;
884 }
else if (i64 >= static_cast<int64_t>(
886 data_.f.flags |= kIntFlag;
892 data_.f.flags = kNumberUint64Flag;
894 data_.f.flags |= kInt64Flag;
896 data_.f.flags |= kUintFlag;
898 data_.f.flags |= kIntFlag;
904 data_.f.flags = kNumberDoubleFlag;
909 data_.n.d =
static_cast<double>(
f);
910 data_.f.flags = kNumberDoubleFlag;
925 SetStringRaw(
StringRef(s, length), allocator);
933 #if RAPIDJSON_HAS_STDSTRING 939 GenericValue(
const std::basic_string<Ch> &s, Allocator &allocator) : data_() {
952 a.value_.data_ = Data();
953 a.value_.data_.f.flags = kArrayFlag;
964 o.value_.data_ = Data();
965 o.value_.data_.f.flags = kObjectFlag;
972 if (Allocator::kNeedFree) {
973 switch (data_.f.flags) {
984 Allocator::Free(GetMembersPointer());
987 case kCopyStringFlag:
988 Allocator::Free(const_cast<Ch *>(GetStringPointer()));
1014 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1017 return *
this = rhs.Move();
1043 template <
typename T>
1058 template <
typename SourceAllocator>
1060 Allocator &allocator,
bool copyConstStrings =
false) {
1062 static_cast<void const *>(&rhs));
1064 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
1097 GenericValue &Move() RAPIDJSON_NOEXCEPT {
return *
this; }
1109 template <
typename SourceAllocator>
1112 if (GetType() != rhs.GetType())
return false;
1114 switch (GetType()) {
1116 if (data_.o.size != rhs.
data_.o.size)
return false;
1118 lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
1119 typename RhsType::ConstMemberIterator rhsMemberItr =
1120 rhs.FindMember(lhsMemberItr->name);
1121 if (rhsMemberItr == rhs.MemberEnd() ||
1122 lhsMemberItr->value != rhsMemberItr->value)
1128 if (data_.a.size != rhs.
data_.a.size)
return false;
1129 for (
SizeType i = 0; i < data_.a.size; i++)
1130 if ((*
this)[i] != rhs[i])
return false;
1134 return StringEqual(rhs);
1137 if (IsDouble() || rhs.IsDouble()) {
1138 double a = GetDouble();
1139 double b = rhs.GetDouble();
1140 return a >= b && a <= b;
1142 return data_.n.u64 == rhs.
data_.n.u64;
1154 #if RAPIDJSON_HAS_STDSTRING 1159 bool operator==(
const std::basic_string<Ch> &rhs)
const {
1168 template <
typename T>
1179 template <
typename SourceAllocator>
1181 return !(*
this == rhs);
1185 bool operator!=(
const Ch *rhs)
const {
return !(*
this == rhs); }
1190 template <
typename T>
1193 return !(*
this == rhs);
1199 template <
typename T>
1208 template <
typename T>
1211 return !(rhs == lhs);
1218 Type GetType()
const {
return static_cast<Type>(data_.f.flags & kTypeMask); }
1219 bool IsNull()
const {
return data_.f.flags == kNullFlag; }
1220 bool IsFalse()
const {
return data_.f.flags == kFalseFlag; }
1221 bool IsTrue()
const {
return data_.f.flags == kTrueFlag; }
1222 bool IsBool()
const {
return (data_.f.flags & kBoolFlag) != 0; }
1223 bool IsObject()
const {
return data_.f.flags == kObjectFlag; }
1224 bool IsArray()
const {
return data_.f.flags == kArrayFlag; }
1225 bool IsNumber()
const {
return (data_.f.flags & kNumberFlag) != 0; }
1226 bool IsInt()
const {
return (data_.f.flags & kIntFlag) != 0; }
1227 bool IsUint()
const {
return (data_.f.flags & kUintFlag) != 0; }
1228 bool IsInt64()
const {
return (data_.f.flags & kInt64Flag) != 0; }
1229 bool IsUint64()
const {
return (data_.f.flags & kUint64Flag) != 0; }
1230 bool IsDouble()
const {
return (data_.f.flags & kDoubleFlag) != 0; }
1231 bool IsString()
const {
return (data_.f.flags & kStringFlag) != 0; }
1234 bool IsLosslessDouble()
const {
1235 if (!IsNumber())
return false;
1238 volatile double d =
static_cast<double>(u);
1239 return (d >= 0.0) &&
1241 static_cast<double>((std::numeric_limits<uint64_t>::max)())) &&
1246 volatile double d =
static_cast<double>(i);
1248 static_cast<double>((std::numeric_limits<int64_t>::min)())) &&
1249 (d < static_cast<double>((std::numeric_limits<int64_t>::max)())) &&
1250 (i == static_cast<int64_t>(d));
1256 bool IsFloat()
const {
1257 if ((data_.f.flags & kDoubleFlag) == 0)
return false;
1258 double d = GetDouble();
1259 return d >= -3.4028234e38 && d <= 3.4028234e38;
1262 bool IsLosslessFloat()
const {
1263 if (!IsNumber())
return false;
1264 double a = GetDouble();
1265 if (a < static_cast<double>(-(std::numeric_limits<float>::max)()) ||
1266 a > static_cast<double>((std::numeric_limits<float>::max)()))
1268 double b =
static_cast<double>(
static_cast<float>(
a));
1269 return a >= b && a <= b;
1288 bool GetBool()
const {
1290 return data_.f.flags == kTrueFlag;
1316 return data_.o.size;
1322 return data_.o.capacity;
1326 bool ObjectEmpty()
const {
1328 return data_.o.size == 0;
1340 template <
typename T>
1345 operator[](T *
name) {
1349 template <
typename T>
1354 operator[](T *name)
const {
1368 template <
typename SourceAllocator>
1372 if (member != MemberEnd())
1373 return member->value;
1386 template <
typename SourceAllocator>
1392 #if RAPIDJSON_HAS_STDSTRING 1393 GenericValue &operator[](
const std::basic_string<Ch> &name) {
1397 const GenericValue &operator[](
const std::basic_string<Ch> &name)
const {
1435 if (newCapacity > data_.o.capacity) {
1436 SetMembersPointer(reinterpret_cast<Member *>(allocator.Realloc(
1437 GetMembersPointer(), data_.o.capacity *
sizeof(Member),
1438 newCapacity *
sizeof(Member))));
1439 data_.o.capacity = newCapacity;
1452 bool HasMember(
const Ch *name)
const {
1453 return FindMember(name) != MemberEnd();
1456 #if RAPIDJSON_HAS_STDSTRING 1465 bool HasMember(
const std::basic_string<Ch> &name)
const {
1466 return FindMember(name) != MemberEnd();
1479 template <
typename SourceAllocator>
1481 return FindMember(name) != MemberEnd();
1498 return FindMember(n);
1502 return const_cast<GenericValue &
>(*this).FindMember(name);
1518 template <
typename SourceAllocator>
1524 for (; member != MemberEnd(); ++member)
1528 template <
typename SourceAllocator>
1531 return const_cast<GenericValue &
>(*this).FindMember(name);
1534 #if RAPIDJSON_HAS_STDSTRING 1561 Allocator &allocator) {
1565 ObjectData &o = data_.o;
1566 if (o.size >= o.capacity)
1567 MemberReserve(o.capacity == 0 ? kDefaultObjectCapacity
1568 : (o.capacity + (o.capacity + 1) / 2),
1570 Member *members = GetMembersPointer();
1571 members[o.size].
name.RawAssign(name);
1572 members[o.size].
value.RawAssign(value);
1588 Allocator &allocator) {
1590 return AddMember(name, v, allocator);
1593 #if RAPIDJSON_HAS_STDSTRING 1605 Allocator &allocator) {
1607 return AddMember(name, v, allocator);
1628 template <
typename T>
1632 AddMember(
GenericValue &name, T value, Allocator &allocator) {
1634 return AddMember(name, v, allocator);
1637 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1639 Allocator &allocator) {
1640 return AddMember(name, value, allocator);
1643 Allocator &allocator) {
1644 return AddMember(name, value, allocator);
1647 Allocator &allocator) {
1648 return AddMember(name, value, allocator);
1651 Allocator &allocator) {
1653 return AddMember(n, value, allocator);
1655 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1667 Allocator &allocator) {
1669 return AddMember(n, value, allocator);
1683 Allocator &allocator) {
1685 return AddMember(name, v, allocator);
1705 template <
typename T>
1709 AddMember(
StringRefType name, T value, Allocator &allocator) {
1711 return AddMember(n, value, allocator);
1718 void RemoveAllMembers() {
1720 for (
MemberIterator m = MemberBegin(); m != MemberEnd(); ++m) m->~Member();
1732 bool RemoveMember(
const Ch *name) {
1734 return RemoveMember(n);
1737 #if RAPIDJSON_HAS_STDSTRING 1738 bool RemoveMember(
const std::basic_string<Ch> &name) {
1743 template <
typename SourceAllocator>
1746 if (m != MemberEnd()) {
1768 if (data_.o.size > 1 && m != last)
1787 return EraseMember(pos, pos + 1);
1808 for (
MemberIterator itr = pos; itr != last; ++itr) itr->~Member();
1809 std::memmove(static_cast<void *>(&*pos), &*last,
1810 static_cast<size_t>(MemberEnd() - last) *
sizeof(Member));
1811 data_.o.size -=
static_cast<SizeType>(last - first);
1820 bool EraseMember(
const Ch *name) {
1822 return EraseMember(n);
1825 #if RAPIDJSON_HAS_STDSTRING 1826 bool EraseMember(
const std::basic_string<Ch> &name) {
1831 template <
typename SourceAllocator>
1834 if (m != MemberEnd()) {
1841 Object GetObject() {
1843 return Object(*
this);
1845 ConstObject GetObject()
const {
1847 return ConstObject(*
this);
1866 return data_.a.size;
1872 return data_.a.capacity;
1876 bool Empty()
const {
1878 return data_.a.size == 0;
1888 for (
GenericValue *v = e; v != e + data_.a.size; ++v) v->~GenericValue();
1900 return GetElementsPointer()[index];
1910 return GetElementsPointer();
1916 return GetElementsPointer() + data_.a.size;
1937 if (newCapacity > data_.a.capacity) {
1938 SetElementsPointer(reinterpret_cast<GenericValue *>(allocator.Realloc(
1939 GetElementsPointer(), data_.a.capacity *
sizeof(
GenericValue),
1941 data_.a.capacity = newCapacity;
1958 if (data_.a.size >= data_.a.capacity)
1959 Reserve(data_.a.capacity == 0
1960 ? kDefaultArrayCapacity
1961 : (data_.a.capacity + (data_.a.capacity + 1) / 2),
1963 GetElementsPointer()[data_.a.size++].RawAssign(value);
1967 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1969 return PushBack(value, allocator);
1971 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1983 return (*this).template PushBack<StringRefType>(value, allocator);
2004 template <
typename T>
2008 PushBack(T value, Allocator &allocator) {
2010 return PushBack(v, allocator);
2020 GetElementsPointer()[--data_.a.size].~GenericValue();
2051 std::memmove(static_cast<void *>(pos), last,
2052 static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
2053 data_.a.size -=
static_cast<SizeType>(last - first);
2059 return Array(*
this);
2061 ConstArray GetArray()
const {
2063 return ConstArray(*
this);
2071 int GetInt()
const {
2075 unsigned GetUint()
const {
2092 double GetDouble()
const {
2094 if ((data_.f.flags & kDoubleFlag) != 0)
2096 if ((data_.f.flags & kIntFlag) != 0)
return data_.n.i.i;
2097 if ((data_.f.flags & kUintFlag) != 0)
2099 if ((data_.f.flags & kInt64Flag) != 0)
2100 return static_cast<double>(
2103 return static_cast<double>(
2111 float GetFloat()
const {
return static_cast<float>(GetDouble()); }
2149 const Ch *GetString()
const {
2151 return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer();
2160 return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength())
2198 return SetString(
StringRef(s, length), allocator);
2208 GenericValue &SetString(
const Ch *s, Allocator &allocator) {
2209 return SetString(
StringRef(s), allocator);
2221 SetStringRaw(s, allocator);
2225 #if RAPIDJSON_HAS_STDSTRING 2235 GenericValue &SetString(
const std::basic_string<Ch> &s,
2236 Allocator &allocator) {
2237 return SetString(
StringRef(s), allocator);
2251 template <
typename T>
2256 template <
typename T>
2261 template <
typename T>
2266 template <
typename T>
2271 template <
typename T>
2272 ValueType &Set(
const T &data, AllocatorType &allocator) {
2285 template <
typename Handler>
2286 bool Accept(Handler &handler)
const {
2287 switch (GetType()) {
2289 return handler.Null();
2291 return handler.Bool(
false);
2293 return handler.Bool(
true);
2301 !handler.Key(m->name.GetString(), m->name.GetStringLength(),
2302 (m->name.data_.f.flags & kCopyFlag) != 0)))
2306 return handler.EndObject(data_.o.size);
2312 return handler.EndArray(data_.a.size);
2315 return handler.String(GetString(), GetStringLength(),
2316 (data_.f.flags & kCopyFlag) != 0);
2321 return handler.Double(data_.n.d);
2323 return handler.Int(data_.n.i.i);
2325 return handler.Uint(data_.n.u.u);
2327 return handler.Int64(data_.n.i64);
2329 return handler.Uint64(data_.n.u64);
2334 template <
typename,
typename>
2336 template <
typename,
typename,
typename>
2376 #if RAPIDJSON_48BITPOINTER_OPTIMIZATION 2377 char payload[
sizeof(
SizeType) * 2 +
2379 #elif RAPIDJSON_64BIT 2380 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void *) + 6];
2382 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void *) +
2406 MaxChars =
sizeof(
static_cast<Flag *
>(0)->payload) /
sizeof(Ch),
2407 MaxSize = MaxChars - 1,
2414 str[LenPos] =
static_cast<Ch
>(MaxSize - len);
2417 return static_cast<SizeType>(MaxSize - str[LenPos]);
2425 #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN 2494 data_.f.flags = kArrayFlag;
2498 SetElementsPointer(e);
2499 std::memcpy(static_cast<void *>(e), values, count *
sizeof(
GenericValue));
2501 SetElementsPointer(0);
2502 data_.a.size = data_.a.capacity = count;
2508 data_.f.flags = kObjectFlag;
2511 static_cast<Member *
>(allocator.Malloc(count *
sizeof(Member)));
2512 SetMembersPointer(m);
2513 std::memcpy(static_cast<void *>(m), members, count *
sizeof(Member));
2515 SetMembersPointer(0);
2516 data_.o.size = data_.o.capacity = count;
2521 data_.f.flags = kConstStringFlag;
2522 SetStringPointer(s);
2523 data_.s.length = s.length;
2530 if (ShortString::Usable(s.
length)) {
2531 data_.f.flags = kShortStringFlag;
2532 data_.ss.SetLength(s.
length);
2535 data_.f.flags = kCopyStringFlag;
2536 data_.s.length = s.
length;
2537 str =
static_cast<Ch *
>(allocator.Malloc((s.
length + 1) *
sizeof(Ch)));
2538 SetStringPointer(str);
2540 std::memcpy(str, s, s.
length *
sizeof(Ch));
2551 template <
typename SourceAllocator>
2556 const SizeType len1 = GetStringLength();
2557 const SizeType len2 = rhs.GetStringLength();
2562 const Ch *
const str1 = GetString();
2563 const Ch *
const str2 = rhs.GetString();
2568 return (std::memcmp(str1, str2,
sizeof(Ch) * len1) == 0);
2591 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>,
2592 typename StackAllocator = CrtAllocator>
2595 typedef typename Encoding::Ch
Ch;
2609 size_t stackCapacity = kDefaultStackCapacity,
2610 StackAllocator *stackAllocator = 0)
2612 allocator_(allocator),
2614 stack_(stackAllocator, stackCapacity),
2616 if (!allocator_) ownAllocator_ = allocator_ =
RAPIDJSON_NEW(Allocator)();
2627 size_t stackCapacity = kDefaultStackCapacity,
2628 StackAllocator *stackAllocator = 0)
2629 : allocator_(allocator),
2631 stack_(stackAllocator, stackCapacity),
2633 if (!allocator_) ownAllocator_ = allocator_ =
RAPIDJSON_NEW(Allocator)();
2636 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2641 allocator_(rhs.allocator_),
2642 ownAllocator_(rhs.ownAllocator_),
2643 stack_(std::move(rhs.stack_)),
2644 parseResult_(rhs.parseResult_) {
2646 rhs.ownAllocator_ = 0;
2653 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2658 ValueType::operator=(std::forward<ValueType>(rhs));
2663 allocator_ = rhs.allocator_;
2664 ownAllocator_ = rhs.ownAllocator_;
2665 stack_ = std::move(rhs.stack_);
2666 parseResult_ = rhs.parseResult_;
2669 rhs.ownAllocator_ = 0;
2684 stack_.Swap(rhs.stack_);
2715 template <
typename Generator>
2721 ValueType::operator=(*stack_.template Pop<ValueType>(
2737 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
2740 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2742 parseResult_ = reader.template Parse<parseFlags>(is, *
this);
2746 ValueType::operator=(*stack_.template Pop<ValueType>(
2758 template <
unsigned parseFlags,
typename InputStream>
2760 return ParseStream<parseFlags, Encoding, InputStream>(is);
2768 template <
typename InputStream>
2770 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2782 template <
unsigned parseFlags>
2785 return ParseStream<parseFlags | kParseInsituFlag>(s);
2793 return ParseInsitu<kParseDefaultFlags>(str);
2805 template <
unsigned parseFlags,
typename SourceEncoding>
2809 return ParseStream<parseFlags, SourceEncoding>(s);
2817 template <
unsigned parseFlags>
2819 return Parse<parseFlags, Encoding>(str);
2826 return Parse<kParseDefaultFlags>(str);
2829 template <
unsigned parseFlags,
typename SourceEncoding>
2834 length *
sizeof(
typename SourceEncoding::Ch));
2836 ParseStream<parseFlags, SourceEncoding>(is);
2840 template <
unsigned parseFlags>
2842 return Parse<parseFlags, Encoding>(str, length);
2846 return Parse<kParseDefaultFlags>(str, length);
2849 #if RAPIDJSON_HAS_STDSTRING 2850 template <
unsigned parseFlags,
typename SourceEncoding>
2852 const std::basic_string<typename SourceEncoding::Ch> &str) {
2855 return Parse<parseFlags, SourceEncoding>(str.c_str());
2858 template <
unsigned parseFlags>
2860 return Parse<parseFlags, Encoding>(str.c_str());
2864 return Parse<kParseDefaultFlags>(str);
2866 #endif // RAPIDJSON_HAS_STDSTRING 2883 #ifndef __clang // -Wdocumentation 2921 template <
typename,
typename>
2927 new (stack_.template Push<ValueType>())
ValueType();
2931 new (stack_.template Push<ValueType>())
ValueType(b);
2935 new (stack_.template Push<ValueType>())
ValueType(i);
2939 new (stack_.template Push<ValueType>())
ValueType(i);
2943 new (stack_.template Push<ValueType>())
ValueType(i);
2947 new (stack_.template Push<ValueType>())
ValueType(i);
2951 new (stack_.template Push<ValueType>())
ValueType(d);
2957 new (stack_.template Push<ValueType>())
2960 new (stack_.template Push<ValueType>())
ValueType(str, length);
2966 new (stack_.template Push<ValueType>())
2969 new (stack_.template Push<ValueType>())
ValueType(str, length);
2979 return String(str, length, copy);
2984 stack_.template Pop<typename ValueType::Member>(memberCount);
2985 stack_.template Top<ValueType>()->
SetObjectRaw(members, memberCount,
2996 ValueType *elements = stack_.template Pop<ValueType>(elementCount);
2997 stack_.template Top<ValueType>()->
SetArrayRaw(elements, elementCount,
3009 if (Allocator::kNeedFree)
3010 while (stack_.GetSize() >
3013 (stack_.template Pop<ValueType>(1))->~
ValueType();
3016 stack_.ShrinkToFit();
3021 static const size_t kDefaultStackCapacity = 1024;
3037 template <
bool Const,
typename ValueT>
3049 template <
typename,
typename>
3061 bool Empty()
const {
return value_.Empty(); }
3064 ValueIterator
Begin()
const {
return value_.Begin(); }
3065 ValueIterator
End()
const {
return value_.End(); }
3067 value_.
Reserve(newCapacity, allocator);
3074 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 3079 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 3084 template <
typename T>
3088 PushBack(T
value, AllocatorType &allocator)
const {
3089 value_.PushBack(value, allocator);
3097 return value_.Erase(pos);
3100 return value_.Erase(first, last);
3103 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 3120 template <
bool Const,
typename ValueT>
3128 typename ValueT::AllocatorType>
3131 typename ValueT::AllocatorType>
3136 typedef typename ValueType::Ch
Ch;
3138 template <
typename,
typename>
3151 template <
typename T>
3153 return value_[
name];
3155 template <
typename SourceAllocator>
3158 return value_[
name];
3160 #if RAPIDJSON_HAS_STDSTRING 3161 ValueType &operator[](
const std::basic_string<Ch> &
name)
const {
3162 return value_[
name];
3168 AllocatorType &allocator)
const {
3172 bool HasMember(
const Ch *name)
const {
return value_.HasMember(name); }
3173 #if RAPIDJSON_HAS_STDSTRING 3174 bool HasMember(
const std::basic_string<Ch> &name)
const {
3175 return value_.HasMember(name);
3178 template <
typename SourceAllocator>
3181 return value_.HasMember(name);
3184 return value_.FindMember(name);
3186 template <
typename SourceAllocator>
3189 return value_.FindMember(name);
3191 #if RAPIDJSON_HAS_STDSTRING 3192 MemberIterator FindMember(
const std::basic_string<Ch> &name)
const {
3193 return value_.FindMember(name);
3197 AllocatorType &allocator)
const {
3198 value_.
AddMember(name, value, allocator);
3202 AllocatorType &allocator)
const {
3203 value_.
AddMember(name, value, allocator);
3206 #if RAPIDJSON_HAS_STDSTRING 3208 AllocatorType &allocator)
const {
3209 value_.
AddMember(name, value, allocator);
3213 template <
typename T>
3217 AddMember(ValueType &name, T value, AllocatorType &allocator)
const {
3218 value_.AddMember(name, value, allocator);
3221 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 3223 AllocatorType &allocator)
const {
3228 AllocatorType &allocator)
const {
3233 AllocatorType &allocator)
const {
3234 value_.
AddMember(name, value, allocator);
3238 AllocatorType &allocator)
const {
3239 value_.
AddMember(name, value, allocator);
3242 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 3244 AllocatorType &allocator)
const {
3245 value_.
AddMember(name, value, allocator);
3249 AllocatorType &allocator)
const {
3250 value_.
AddMember(name, value, allocator);
3253 template <
typename T>
3257 AddMember(
StringRefType name, T value, AllocatorType &allocator)
const {
3258 value_.AddMember(name, value, allocator);
3262 bool RemoveMember(
const Ch *name)
const {
return value_.RemoveMember(name); }
3263 #if RAPIDJSON_HAS_STDSTRING 3264 bool RemoveMember(
const std::basic_string<Ch> &name)
const {
3265 return value_.RemoveMember(name);
3268 template <
typename SourceAllocator>
3271 return value_.RemoveMember(name);
3274 return value_.RemoveMember(m);
3277 return value_.EraseMember(pos);
3281 return value_.EraseMember(first, last);
3283 bool EraseMember(
const Ch *name)
const {
return value_.EraseMember(name); }
3284 #if RAPIDJSON_HAS_STDSTRING 3285 bool EraseMember(
const std::basic_string<Ch> &name)
const {
3289 template <
typename SourceAllocator>
3292 return value_.EraseMember(name);
3295 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 3309 #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)
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
static ArrayType Get(const ValueType &v)
SizeType NotNullStrLen(const CharType *str)
GenericObject(ValueType &value)
bool EndArray(SizeType elementCount)
internal::MaybeAddConst< Const, PlainType >::Type ValueType
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.
reference Reference
Reference to (const) GenericMember.
internal::MaybeAddConst< Const, PlainType >::Type ValueType
ValueType::EncodingType EncodingType
static bool Is(const ValueType &v)
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)
GenericValue< Encoding, Allocator > name
name of member (must be a string)
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)
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
TFSIMD_FORCE_INLINE bool operator==(const Matrix3x3 &m1, const Matrix3x3 &m2)
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.
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
GenericMember< Encoding, Allocator > PlainType
const ValueType::Ch * StringType
std::ptrdiff_t difference_type
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.
pointer Pointer
Pointer to (const) GenericMember.
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
difference_type DifferenceType
Signed integer type (e.g. ptrdiff_t)
ValueType & operator[](T *name) const
SizeType Capacity() const
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.
GenericValue< Encoding, Allocator > value
value of member.
bool operator<(ConstIterator that) const
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags)
#define RAPIDJSON_NOEXCEPT_ASSERT(x)
Assertion (in non-throwing contexts).
Pointer operator->() const
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
ValueType::ConstObject ObjectType
static unsigned Get(const ValueType &v)
GenericArray(const GenericArray &rhs)
SizeType MemberCapacity() const
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
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
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_
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 &)
ParseErrorCode
Error code of parsing.
bool RawNumber(const Ch *str, SizeType length, bool copy)
static bool Is(const ValueType &v)
GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocator) const
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.
const ValueT * ConstValueIterator
ValueIterator Begin() const
static bool Is(const ValueType &v)
TFSIMD_FORCE_INLINE bool operator!=(const Vector3 &other) const
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
internal::MaybeAddConst< Const, PlainType >::Type ValueType
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)
friend void swap(GenericMember &a, GenericMember &b) RAPIDJSON_NOEXCEPT
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)
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
std::random_access_iterator_tag iterator_category
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Reference operator*() const
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)
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
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
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T2 >, internal::IsGenericValue< T2 >>),(typename T::ValueType &)) GetValueByPointerWithDefault(T &root
Name-value pair in a JSON object value.
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.
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
GenericMember(const GenericMember &rhs)
Copy constructor is not permitted.
static const SizeType kDefaultArrayCapacity
GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const
static float Get(const ValueType &v)
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
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)
GenericMember & operator=(GenericMember &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
static ValueType & Set(ValueType &v, int data)
bool EraseMember(const GenericValue< EncodingType, SourceAllocator > &name) const
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)
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.
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.
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
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 occurred 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.