15 #ifndef RAPIDJSON_DOCUMENT_H_ 16 #define RAPIDJSON_DOCUMENT_H_ 30 RAPIDJSON_DIAG_OFF(padded)
31 RAPIDJSON_DIAG_OFF(
switch-enum)
32 RAPIDJSON_DIAG_OFF(
c++98-compat)
33 #elif defined(_MSC_VER) 34 RAPIDJSON_DIAG_OFF(4127)
35 RAPIDJSON_DIAG_OFF(4244)
39 RAPIDJSON_DIAG_OFF(effc++)
41 RAPIDJSON_DIAG_OFF(terminate)
45 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 49 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 56 template <
typename Encoding,
typename Allocator>
59 template <
typename Encoding,
typename Allocator,
typename StackAllocator>
68 template <
typename Encoding,
typename Allocator>
77 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 98 template <
bool Const,
typename Encoding,
typename Allocator>
200 #else // RAPIDJSON_NOMEMBERITERATORCLASS 204 template <
bool Const,
typename Encoding,
typename Allocator>
208 template <
typename Encoding,
typename Allocator>
214 template <
typename Encoding,
typename Allocator>
220 #endif // RAPIDJSON_NOMEMBERITERATORCLASS 252 template<
typename CharType>
257 #ifndef __clang__ // -Wdocumentation 283 :
s(
str), length(
N-1) {}
286 #ifndef __clang__ // -Wdocumentation 307 :
s(str), length(NotNullStrLen(str)) {}
310 #ifndef __clang__ // -Wdocumentation 324 operator const Ch *()
const {
return s; }
336 static const Ch emptyString[];
345 template<
typename CharType>
360 template<
typename CharType>
380 template<
typename CharType>
385 #if RAPIDJSON_HAS_STDSTRING 398 template<
typename CharType>
408 template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
413 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>
::Type {};
425 template <
typename ValueType,
typename T>
428 template<
typename ValueType>
430 static bool Is(
const ValueType& v) {
return v.IsBool(); }
431 static bool Get(
const ValueType& v) {
return v.GetBool(); }
432 static ValueType&
Set(ValueType& v,
bool data) {
return v.SetBool(data); }
433 static ValueType&
Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&) {
return v.SetBool(data); }
436 template<
typename ValueType>
438 static bool Is(
const ValueType& v) {
return v.IsInt(); }
439 static int Get(
const ValueType& v) {
return v.GetInt(); }
440 static ValueType&
Set(ValueType& v,
int data) {
return v.SetInt(data); }
441 static ValueType&
Set(ValueType& v,
int data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
444 template<
typename ValueType>
446 static bool Is(
const ValueType& v) {
return v.IsUint(); }
447 static unsigned Get(
const ValueType& v) {
return v.GetUint(); }
448 static ValueType&
Set(ValueType& v,
unsigned data) {
return v.SetUint(data); }
449 static ValueType&
Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
454 template<
typename ValueType>
456 static bool Is(
const ValueType& v) {
return v.IsInt(); }
457 static long Get(
const ValueType& v) {
return v.GetInt(); }
458 static ValueType&
Set(ValueType& v,
long data) {
return v.SetInt(data); }
459 static ValueType&
Set(ValueType& v,
long data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
463 template<
typename ValueType>
465 static bool Is(
const ValueType& v) {
return v.IsUint(); }
466 static unsigned long Get(
const ValueType& v) {
return v.GetUint(); }
467 static ValueType&
Set(ValueType& v,
unsigned long data) {
return v.SetUint(data); }
468 static ValueType&
Set(ValueType& v,
unsigned long data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
472 template<
typename ValueType>
474 static bool Is(
const ValueType& v) {
return v.IsInt64(); }
475 static int64_t Get(
const ValueType& v) {
return v.GetInt64(); }
477 static ValueType&
Set(ValueType& v,
int64_t data,
typename ValueType::AllocatorType&) {
return v.SetInt64(data); }
480 template<
typename ValueType>
482 static bool Is(
const ValueType& v) {
return v.IsUint64(); }
485 static ValueType&
Set(ValueType& v,
uint64_t data,
typename ValueType::AllocatorType&) {
return v.SetUint64(data); }
488 template<
typename ValueType>
490 static bool Is(
const ValueType& v) {
return v.IsDouble(); }
491 static double Get(
const ValueType& v) {
return v.GetDouble(); }
492 static ValueType&
Set(ValueType& v,
double data) {
return v.SetDouble(data); }
493 static ValueType&
Set(ValueType& v,
double data,
typename ValueType::AllocatorType&) {
return v.SetDouble(data); }
496 template<
typename ValueType>
498 static bool Is(
const ValueType& v) {
return v.IsFloat(); }
499 static float Get(
const ValueType& v) {
return v.GetFloat(); }
500 static ValueType&
Set(ValueType& v,
float data) {
return v.SetFloat(data); }
501 static ValueType&
Set(ValueType& v,
float data,
typename ValueType::AllocatorType&) {
return v.SetFloat(data); }
504 template<
typename ValueType>
507 static bool Is(
const ValueType& v) {
return v.IsString(); }
508 static StringType
Get(
const ValueType& v) {
return v.GetString(); }
509 static ValueType&
Set(ValueType& v,
const StringType
data) {
return v.SetString(
typename ValueType::StringRefType(data)); }
510 static ValueType&
Set(ValueType& v,
const StringType
data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data, a); }
513 #if RAPIDJSON_HAS_STDSTRING 514 template<
typename ValueType>
515 struct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch> > {
516 typedef std::basic_string<typename ValueType::Ch>
StringType;
517 static bool Is(
const ValueType& v) {
return v.IsString(); }
518 static StringType Get(
const ValueType& v) {
return StringType(v.GetString(), v.GetStringLength()); }
519 static ValueType&
Set(ValueType& v,
const StringType&
data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data, a); }
523 template<
typename ValueType>
526 static bool Is(
const ValueType& v) {
return v.IsArray(); }
527 static ArrayType
Get(ValueType& v) {
return v.GetArray(); }
528 static ValueType&
Set(ValueType& v, ArrayType
data) {
return v =
data; }
529 static ValueType&
Set(ValueType& v, ArrayType
data,
typename ValueType::AllocatorType&) {
return v =
data; }
532 template<
typename ValueType>
533 struct TypeHelper<ValueType, typename ValueType::ConstArray> {
535 static bool Is(
const ValueType& v) {
return v.IsArray(); }
536 static ArrayType
Get(
const ValueType& v) {
return v.GetArray(); }
539 template<
typename ValueType>
542 static bool Is(
const ValueType& v) {
return v.IsObject(); }
543 static ObjectType
Get(ValueType& v) {
return v.GetObject(); }
544 static ValueType&
Set(ValueType& v, ObjectType
data) {
return v =
data; }
545 static ValueType&
Set(ValueType& v, ObjectType
data,
typename ValueType::AllocatorType&) {
return v =
data; }
548 template<
typename ValueType>
549 struct TypeHelper<ValueType, typename ValueType::ConstObject> {
551 static bool Is(
const ValueType& v) {
return v.IsObject(); }
552 static ObjectType
Get(
const ValueType& v) {
return v.GetObject(); }
574 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
581 typedef typename Encoding::Ch
Ch;
597 GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; }
599 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 610 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 612 template <
typename StackAllocator>
616 template <
typename StackAllocator>
628 static const uint16_t defaultFlags[7] = {
629 kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kShortStringFlag,
633 data_.f.flags = defaultFlags[
type];
637 data_.ss.SetLength(0);
648 template <
typename SourceAllocator>
650 switch (rhs.GetType()) {
653 Member* lm =
reinterpret_cast<Member*
>(allocator.Malloc(count *
sizeof(Member)));
655 for (
SizeType i = 0; i < count; i++) {
659 data_.f.flags = kObjectFlag;
660 data_.o.size = data_.o.capacity = count;
661 SetMembersPointer(lm);
668 for (
SizeType i = 0; i < count; i++)
669 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
670 data_.f.flags = kArrayFlag;
671 data_.a.size = data_.a.capacity = count;
672 SetElementsPointer(le);
676 if (rhs.
data_.f.flags == kConstStringFlag && !copyConstStrings) {
677 data_.f.flags = rhs.
data_.f.flags;
678 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
681 SetStringRaw(
StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
684 data_.f.flags = rhs.
data_.f.flags;
685 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
696 #ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen 697 template <
typename T>
698 explicit GenericValue(
T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT
705 data_.f.flags = b ? kTrueFlag : kFalseFlag;
711 data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;
717 data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
723 data_.f.flags = kNumberInt64Flag;
725 data_.f.flags |= kNumberUint64Flag;
727 data_.f.flags |= kUintFlag;
729 data_.f.flags |= kIntFlag;
732 data_.f.flags |= kIntFlag;
738 data_.f.flags = kNumberUint64Flag;
740 data_.f.flags |= kInt64Flag;
742 data_.f.flags |= kUintFlag;
744 data_.f.flags |= kIntFlag;
748 explicit GenericValue(
double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d =
d; data_.f.flags = kNumberDoubleFlag; }
751 explicit GenericValue(
float f) RAPIDJSON_NOEXCEPT : data_() { data_.n.d =
static_cast<double>(
f); data_.f.flags = kNumberDoubleFlag; }
757 explicit GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(s); }
765 #if RAPIDJSON_HAS_STDSTRING 769 GenericValue(
const std::basic_string<Ch>& s, Allocator& allocator) : data_() { SetStringRaw(
StringRef(s), allocator); }
779 a.value_.data_ =
Data();
780 a.value_.data_.f.flags = kArrayFlag;
790 o.value_.data_ =
Data();
791 o.value_.data_.f.flags = kObjectFlag;
798 if (Allocator::kNeedFree) {
799 switch(data_.f.flags) {
810 for (MemberIterator
m = MemberBegin();
m != MemberEnd(); ++
m)
812 Allocator::Free(GetMembersPointer());
815 case kCopyStringFlag:
816 Allocator::Free(const_cast<Ch*>(GetStringPointer()));
840 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 843 return *
this = rhs.Move();
869 template <
typename T>
883 template <
typename SourceAllocator>
885 RAPIDJSON_ASSERT(static_cast<void*>(
this) != static_cast<void const*>(&rhs));
887 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
920 GenericValue& Move() RAPIDJSON_NOEXCEPT {
return *
this; }
930 template <
typename SourceAllocator>
933 if (GetType() != rhs.GetType())
940 for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
941 typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
942 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
950 for (
SizeType i = 0; i < data_.a.size; i++)
951 if ((*
this)[i] != rhs[i])
956 return StringEqual(rhs);
959 if (IsDouble() || rhs.IsDouble()) {
961 double b = rhs.GetDouble();
962 return a >= b && a <=
b;
965 return data_.n.u64 == rhs.
data_.n.u64;
975 #if RAPIDJSON_HAS_STDSTRING 990 template <
typename SourceAllocator>
994 bool operator!=(
const Ch* rhs)
const {
return !(*
this == rhs); }
1015 Type GetType()
const {
return static_cast<Type>(data_.f.flags & kTypeMask); }
1016 bool IsNull()
const {
return data_.f.flags == kNullFlag; }
1017 bool IsFalse()
const {
return data_.f.flags == kFalseFlag; }
1018 bool IsTrue()
const {
return data_.f.flags == kTrueFlag; }
1019 bool IsBool()
const {
return (data_.f.flags & kBoolFlag) != 0; }
1020 bool IsObject()
const {
return data_.f.flags == kObjectFlag; }
1021 bool IsArray()
const {
return data_.f.flags == kArrayFlag; }
1022 bool IsNumber()
const {
return (data_.f.flags & kNumberFlag) != 0; }
1023 bool IsInt()
const {
return (data_.f.flags & kIntFlag) != 0; }
1024 bool IsUint()
const {
return (data_.f.flags & kUintFlag) != 0; }
1025 bool IsInt64()
const {
return (data_.f.flags & kInt64Flag) != 0; }
1026 bool IsUint64()
const {
return (data_.f.flags & kUint64Flag) != 0; }
1027 bool IsDouble()
const {
return (data_.f.flags & kDoubleFlag) != 0; }
1028 bool IsString()
const {
return (data_.f.flags & kStringFlag) != 0; }
1031 bool IsLosslessDouble()
const {
1032 if (!IsNumber())
return false;
1035 volatile double d =
static_cast<double>(u);
1042 volatile double d =
static_cast<double>(i);
1045 && (i == static_cast<int64_t>(d));
1051 bool IsFloat()
const {
1052 if ((data_.f.flags & kDoubleFlag) == 0)
1055 return d >= -3.4028234e38 && d <= 3.4028234e38;
1058 bool IsLosslessFloat()
const {
1059 if (!IsNumber())
return false;
1064 double b =
static_cast<double>(
static_cast<float>(
a));
1065 return a >= b && a <=
b;
1101 bool ObjectEmpty()
const {
RAPIDJSON_ASSERT(IsObject());
return data_.o.size == 0; }
1112 template <
typename T>
1117 template <
typename T>
1129 template <
typename SourceAllocator>
1131 MemberIterator member = FindMember(name);
1132 if (member != MemberEnd())
1133 return member->value;
1146 template <
typename SourceAllocator>
1149 #if RAPIDJSON_HAS_STDSTRING 1157 ConstMemberIterator MemberBegin()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstMemberIterator(GetMembersPointer()); }
1160 ConstMemberIterator MemberEnd()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstMemberIterator(GetMembersPointer() + data_.o.size); }
1163 MemberIterator MemberBegin() {
RAPIDJSON_ASSERT(IsObject());
return MemberIterator(GetMembersPointer()); }
1166 MemberIterator MemberEnd() {
RAPIDJSON_ASSERT(IsObject());
return MemberIterator(GetMembersPointer() + data_.o.size); }
1176 if (newCapacity > data_.o.capacity) {
1177 SetMembersPointer(reinterpret_cast<Member*>(allocator.Realloc(GetMembersPointer(), data_.o.capacity *
sizeof(Member), newCapacity *
sizeof(Member))));
1178 data_.o.capacity = newCapacity;
1191 bool HasMember(
const Ch* name)
const {
return FindMember(name) != MemberEnd(); }
1193 #if RAPIDJSON_HAS_STDSTRING 1202 bool HasMember(
const std::basic_string<Ch>& name)
const {
return FindMember(name) != MemberEnd(); }
1214 template <
typename SourceAllocator>
1229 MemberIterator FindMember(
const Ch* name) {
1231 return FindMember(n);
1234 ConstMemberIterator FindMember(
const Ch* name)
const {
return const_cast<GenericValue&
>(*this).FindMember(name); }
1249 template <
typename SourceAllocator>
1253 MemberIterator member = MemberBegin();
1254 for ( ; member != MemberEnd(); ++member)
1261 #if RAPIDJSON_HAS_STDSTRING 1269 MemberIterator FindMember(
const std::basic_string<Ch>& name) {
return FindMember(
GenericValue(
StringRef(name))); }
1270 ConstMemberIterator FindMember(
const std::basic_string<Ch>& name)
const {
return FindMember(
GenericValue(
StringRef(name))); }
1287 ObjectData& o = data_.o;
1288 if (o.size >= o.capacity)
1289 MemberReserve(o.capacity == 0 ? kDefaultObjectCapacity : (o.capacity + (o.capacity + 1) / 2), allocator);
1290 Member* members = GetMembersPointer();
1291 members[o.size].
name.RawAssign(name);
1292 members[o.size].
value.RawAssign(value);
1308 return AddMember(name, v, allocator);
1311 #if RAPIDJSON_HAS_STDSTRING 1323 return AddMember(name, v, allocator);
1344 template <
typename T>
1346 AddMember(
GenericValue& name,
T value, Allocator& allocator) {
1348 return AddMember(name, v, allocator);
1351 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1353 return AddMember(name, value, allocator);
1356 return AddMember(name, value, allocator);
1359 return AddMember(name, value, allocator);
1363 return AddMember(n, value, allocator);
1365 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1380 return AddMember(n, value, allocator);
1392 GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator) {
1394 return AddMember(name, v, allocator);
1414 template <
typename T>
1416 AddMember(StringRefType name,
T value, Allocator& allocator) {
1418 return AddMember(n, value, allocator);
1425 void RemoveAllMembers() {
1427 for (MemberIterator
m = MemberBegin();
m != MemberEnd(); ++
m)
1440 bool RemoveMember(
const Ch* name) {
1442 return RemoveMember(n);
1445 #if RAPIDJSON_HAS_STDSTRING 1446 bool RemoveMember(
const std::basic_string<Ch>& name) {
return RemoveMember(
GenericValue(
StringRef(name))); }
1449 template <
typename SourceAllocator>
1451 MemberIterator
m = FindMember(name);
1452 if (m != MemberEnd()) {
1468 MemberIterator RemoveMember(MemberIterator
m) {
1474 MemberIterator last(GetMembersPointer() + (data_.o.size - 1));
1475 if (data_.o.size > 1 && m != last)
1492 MemberIterator EraseMember(ConstMemberIterator
pos) {
1493 return EraseMember(pos, pos +1);
1505 MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) {
1513 MemberIterator pos = MemberBegin() + (first - MemberBegin());
1514 for (MemberIterator itr = pos; itr != last; ++itr)
1516 std::memmove(static_cast<void*>(&*pos), &*last, static_cast<size_t>(MemberEnd() - last) *
sizeof(Member));
1517 data_.o.size -=
static_cast<SizeType>(last - first);
1526 bool EraseMember(
const Ch* name) {
1528 return EraseMember(n);
1531 #if RAPIDJSON_HAS_STDSTRING 1532 bool EraseMember(
const std::basic_string<Ch>& name) {
return EraseMember(
GenericValue(
StringRef(name))); }
1535 template <
typename SourceAllocator>
1537 MemberIterator m = FindMember(name);
1538 if (m != MemberEnd()) {
1547 ConstObject GetObject()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstObject(*
this); }
1565 bool Empty()
const {
RAPIDJSON_ASSERT(IsArray());
return data_.a.size == 0; }
1587 return GetElementsPointer()[
index];
1593 ValueIterator Begin() {
RAPIDJSON_ASSERT(IsArray());
return GetElementsPointer(); }
1596 ValueIterator
End() {
RAPIDJSON_ASSERT(IsArray());
return GetElementsPointer() + data_.a.size; }
1599 ConstValueIterator Begin()
const {
return const_cast<GenericValue&
>(*this).Begin(); }
1602 ConstValueIterator
End()
const {
return const_cast<GenericValue&
>(*this).End(); }
1612 if (newCapacity > data_.a.capacity) {
1613 SetElementsPointer(reinterpret_cast<GenericValue*>(allocator.Realloc(GetElementsPointer(), data_.a.capacity *
sizeof(
GenericValue), newCapacity *
sizeof(
GenericValue))));
1614 data_.a.capacity = newCapacity;
1631 if (data_.a.size >= data_.a.capacity)
1632 Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2), allocator);
1633 GetElementsPointer()[data_.a.size++].RawAssign(value);
1637 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1639 return PushBack(value, allocator);
1641 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1652 GenericValue& PushBack(StringRefType value, Allocator& allocator) {
1653 return (*this).template PushBack<StringRefType>(value, allocator);
1673 template <
typename T>
1675 PushBack(
T value, Allocator& allocator) {
1677 return PushBack(v, allocator);
1687 GetElementsPointer()[--data_.a.size].~GenericValue();
1698 ValueIterator Erase(ConstValueIterator pos) {
1699 return Erase(pos, pos + 1);
1710 ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) {
1717 ValueIterator pos = Begin() + (first - Begin());
1718 for (ValueIterator itr = pos; itr != last; ++itr)
1720 std::memmove(static_cast<void*>(pos), last, static_cast<size_t>(
End() - last) *
sizeof(
GenericValue));
1721 data_.a.size -=
static_cast<SizeType>(last - first);
1726 ConstArray GetArray()
const {
RAPIDJSON_ASSERT(IsArray());
return ConstArray(*
this); }
1734 unsigned GetUint()
const {
RAPIDJSON_ASSERT(data_.f.flags & kUintFlag);
return data_.n.u.u; }
1743 if ((data_.f.flags & kDoubleFlag) != 0)
return data_.n.d;
1744 if ((data_.f.flags & kIntFlag) != 0)
return data_.n.i.i;
1745 if ((data_.f.flags & kUintFlag) != 0)
return data_.n.u.u;
1746 if ((data_.f.flags & kInt64Flag) != 0)
return static_cast<double>(data_.n.i64);
1747 RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0);
return static_cast<double>(data_.n.u64);
1753 float GetFloat()
const {
1769 const Ch*
GetString()
const {
RAPIDJSON_ASSERT(IsString());
return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer(); }
1774 SizeType GetStringLength()
const {
RAPIDJSON_ASSERT(IsString());
return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength()) : data_.s.length); }
1809 GenericValue& SetString(
const Ch* s, Allocator& allocator) {
return SetString(
StringRef(s), allocator); }
1817 GenericValue& SetString(StringRefType s, Allocator& allocator) { this->~
GenericValue(); SetStringRaw(s, allocator);
return *
this; }
1819 #if RAPIDJSON_HAS_STDSTRING 1827 GenericValue& SetString(
const std::basic_string<Ch>& s, Allocator& allocator) {
return SetString(
StringRef(s), allocator); }
1839 template <
typename T>
1842 template <
typename T>
1845 template <
typename T>
1848 template<
typename T>
1851 template<
typename T>
1863 template <
typename Handler>
1864 bool Accept(Handler&
handler)
const {
1868 case kTrueType:
return handler.Bool(
true);
1873 for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++
m) {
1875 if (
RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0)))
1880 return handler.EndObject(data_.o.size);
1888 return handler.EndArray(data_.a.size);
1891 return handler.String(
GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0);
1895 if (IsDouble())
return handler.Double(data_.n.d);
1896 else if (IsInt())
return handler.Int(data_.n.i.i);
1897 else if (IsUint())
return handler.Uint(data_.n.u.u);
1898 else if (IsInt64())
return handler.Int64(data_.n.i64);
1899 else return handler.Uint64(data_.n.u64);
1904 template <
typename,
typename>
friend class GenericValue;
1942 #if RAPIDJSON_48BITPOINTER_OPTIMIZATION 1943 char payload[
sizeof(
SizeType) * 2 + 6];
1944 #elif RAPIDJSON_64BIT 1945 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 6];
1947 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 2];
1967 enum { MaxChars =
sizeof(
static_cast<Flag*
>(0)->payload) /
sizeof(Ch), MaxSize = MaxChars - 1, LenPos = MaxSize };
1977 #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN 2031 data_.f.flags = kArrayFlag;
2034 SetElementsPointer(e);
2035 std::memcpy(static_cast<void*>(e), values, count *
sizeof(
GenericValue));
2038 SetElementsPointer(0);
2039 data_.a.size = data_.a.capacity = count;
2044 data_.f.flags = kObjectFlag;
2046 Member* m =
static_cast<Member*
>(allocator.Malloc(count *
sizeof(Member)));
2047 SetMembersPointer(m);
2048 std::memcpy(static_cast<void*>(m), members, count *
sizeof(Member));
2051 SetMembersPointer(0);
2052 data_.o.size = data_.o.capacity = count;
2057 data_.f.flags = kConstStringFlag;
2058 SetStringPointer(s);
2059 data_.s.length = s.length;
2065 if (ShortString::Usable(s.
length)) {
2066 data_.f.flags = kShortStringFlag;
2067 data_.ss.SetLength(s.
length);
2070 data_.f.flags = kCopyStringFlag;
2071 data_.s.length = s.
length;
2072 str =
static_cast<Ch *
>(allocator.Malloc((s.
length + 1) *
sizeof(Ch)));
2073 SetStringPointer(str);
2075 std::memcpy(str, s, s.
length *
sizeof(Ch));
2086 template <
typename SourceAllocator>
2091 const SizeType len1 = GetStringLength();
2092 const SizeType len2 = rhs.GetStringLength();
2093 if(len1 != len2) {
return false; }
2096 const Ch*
const str2 = rhs.GetString();
2097 if(str1 == str2) {
return true; }
2099 return (std::memcmp(str1, str2,
sizeof(Ch) * len1) == 0);
2119 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>,
typename StackAllocator = CrtAllocator>
2122 typedef typename Encoding::Ch
Ch;
2133 explicit GenericDocument(
Type type, Allocator* allocator = 0,
size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2134 GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2146 GenericDocument(Allocator* allocator = 0,
size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2147 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2153 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2156 : ValueType(std::forward<ValueType>(rhs)),
2157 allocator_(rhs.allocator_),
2158 ownAllocator_(rhs.ownAllocator_),
2160 parseResult_(rhs.parseResult_)
2163 rhs.ownAllocator_ = 0;
2172 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2178 ValueType::operator=(std::forward<ValueType>(rhs));
2183 allocator_ = rhs.allocator_;
2184 ownAllocator_ = rhs.ownAllocator_;
2186 parseResult_ = rhs.parseResult_;
2189 rhs.ownAllocator_ = 0;
2204 stack_.Swap(rhs.stack_);
2234 template <
typename Generator>
2239 ValueType::operator=(*stack_.template Pop<ValueType>(1));
2254 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
2257 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2259 parseResult_ = reader.template Parse<parseFlags>(is, *
this);
2262 ValueType::operator=(*stack_.template Pop<ValueType>(1));
2273 template <
unsigned parseFlags,
typename InputStream>
2275 return ParseStream<parseFlags, Encoding, InputStream>(is);
2283 template <
typename InputStream>
2285 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2297 template <
unsigned parseFlags>
2300 return ParseStream<parseFlags | kParseInsituFlag>(
s);
2308 return ParseInsitu<kParseDefaultFlags>(
str);
2320 template <
unsigned parseFlags,
typename SourceEncoding>
2324 return ParseStream<parseFlags, SourceEncoding>(
s);
2331 template <
unsigned parseFlags>
2333 return Parse<parseFlags, Encoding>(
str);
2340 return Parse<kParseDefaultFlags>(
str);
2343 template <
unsigned parseFlags,
typename SourceEncoding>
2346 MemoryStream ms(reinterpret_cast<const char*>(str), length *
sizeof(
typename SourceEncoding::Ch));
2348 ParseStream<parseFlags, SourceEncoding>(is);
2352 template <
unsigned parseFlags>
2354 return Parse<parseFlags, Encoding>(
str, length);
2358 return Parse<kParseDefaultFlags>(
str, length);
2361 #if RAPIDJSON_HAS_STDSTRING 2362 template <
unsigned parseFlags,
typename SourceEncoding>
2363 GenericDocument& Parse(
const std::basic_string<typename SourceEncoding::Ch>& str) {
2365 return Parse<parseFlags, SourceEncoding>(str.c_str());
2368 template <
unsigned parseFlags>
2370 return Parse<parseFlags, Encoding>(str.c_str());
2374 return Parse<kParseDefaultFlags>(
str);
2376 #endif // RAPIDJSON_HAS_STDSTRING 2393 #ifndef __clang // -Wdocumentation 2433 bool Null() {
new (stack_.template Push<ValueType>())
ValueType();
return true; }
2434 bool Bool(
bool b) {
new (stack_.template Push<ValueType>())
ValueType(b);
return true; }
2435 bool Int(
int i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2436 bool Uint(
unsigned i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2443 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
2445 new (stack_.template Push<ValueType>())
ValueType(str, length);
2451 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
2453 new (stack_.template Push<ValueType>())
ValueType(str, length);
2462 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2463 stack_.template Top<ValueType>()->
SetObjectRaw(members, memberCount, GetAllocator());
2470 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2471 stack_.template Top<ValueType>()->
SetArrayRaw(elements, elementCount, GetAllocator());
2482 if (Allocator::kNeedFree)
2483 while (stack_.GetSize() > 0)
2484 (stack_.template Pop<ValueType>(1))->~
ValueType();
2487 stack_.ShrinkToFit();
2494 static const size_t kDefaultStackCapacity = 1024;
2509 template <
bool Const,
typename ValueT>
2521 template <
typename,
typename>
2530 bool Empty()
const {
return value_.Empty(); }
2533 ValueIterator
Begin()
const {
return value_.Begin(); }
2534 ValueIterator
End()
const {
return value_.End(); }
2537 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2539 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 2543 ValueIterator
Erase(ConstValueIterator
pos)
const {
return value_.Erase(pos); }
2544 ValueIterator
Erase(ConstValueIterator first, ConstValueIterator last)
const {
return value_.Erase(first, last); }
2546 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 2547 ValueIterator
begin()
const {
return value_.Begin(); }
2548 ValueIterator
end()
const {
return value_.End(); }
2562 template <
bool Const,
typename ValueT>
2574 typedef typename ValueType::Ch
Ch;
2576 template <
typename,
typename>
2588 #if RAPIDJSON_HAS_STDSTRING 2589 ValueType& operator[](
const std::basic_string<Ch>&
name)
const {
return value_[
name]; }
2592 MemberIterator
MemberEnd()
const {
return value_.MemberEnd(); }
2594 bool HasMember(
const Ch* name)
const {
return value_.HasMember(name); }
2595 #if RAPIDJSON_HAS_STDSTRING 2596 bool HasMember(
const std::basic_string<Ch>& name)
const {
return value_.HasMember(name); }
2599 MemberIterator
FindMember(
const Ch* name)
const {
return value_.FindMember(name); }
2601 #if RAPIDJSON_HAS_STDSTRING 2602 MemberIterator FindMember(
const std::basic_string<Ch>& name)
const {
return value_.FindMember(name); }
2606 #if RAPIDJSON_HAS_STDSTRING 2607 GenericObject AddMember(ValueType& name, std::basic_string<Ch>&
value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2610 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2611 GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2612 GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2613 GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2614 GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator)
const { value_.
AddMember(name, value, allocator);
return *
this; }
2615 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 2620 bool RemoveMember(
const Ch* name)
const {
return value_.RemoveMember(name); }
2621 #if RAPIDJSON_HAS_STDSTRING 2622 bool RemoveMember(
const std::basic_string<Ch>& name)
const {
return value_.RemoveMember(name); }
2625 MemberIterator
RemoveMember(MemberIterator
m)
const {
return value_.RemoveMember(m); }
2626 MemberIterator
EraseMember(ConstMemberIterator
pos)
const {
return value_.EraseMember(pos); }
2627 MemberIterator
EraseMember(ConstMemberIterator first, ConstMemberIterator last)
const {
return value_.EraseMember(first, last); }
2628 bool EraseMember(
const Ch* name)
const {
return value_.EraseMember(name); }
2629 #if RAPIDJSON_HAS_STDSTRING 2630 bool EraseMember(
const std::basic_string<Ch>& name)
const {
return EraseMember(
ValueType(
StringRef(name))); }
2634 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 2635 MemberIterator
begin()
const {
return value_.MemberBegin(); }
2636 MemberIterator
end()
const {
return value_.MemberEnd(); }
2648 #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)
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
GenericValue< Encoding, Allocator > name
name of member (must be a string)
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
static ArrayType Get(const ValueType &v)
SizeType NotNullStrLen(const CharType *str)
GenericObject(ValueType &value)
bool EndArray(SizeType elementCount)
Allocator AllocatorType
Allocator type from template parameter.
SizeType GetLength() const
GenericStringRef(const GenericStringRef &rhs)
GenericArray PushBack(StringRefType value, AllocatorType &allocator) const
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
GenericObject AddMember(StringRefType name, ValueType &value, AllocatorType &allocator) const
static ValueType & Set(ValueType &v, uint64_t data)
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
static ArrayType Get(ValueType &v)
Represents an in-memory input byte stream.
GenericObject AddMember(ValueType &name, ValueType &value, AllocatorType &allocator) const
bool String(const Ch *str, SizeType length, bool copy)
GenericValue(Object o) RAPIDJSON_NOEXCEPT
Constructor for Object.
#define RAPIDJSON_ASSERT(x)
Assertion.
reference Reference
Reference to (const) GenericMember.
ValueType::EncodingType EncodingType
static bool Is(const ValueType &v)
ClearStackOnExit(GenericDocument &d)
bool operator>(ScheduleID const left, ScheduleID const right) noexcept
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
static ObjectType Get(ValueType &v)
GenericArray< true, ValueT > ConstArray
static bool Get(const ValueType &v)
Helper class for accessing Value of array type.
GenericValue(Type type) RAPIDJSON_NOEXCEPT
Constructor with JSON value type.
bool StringEqual(const GenericValue< Encoding, SourceAllocator > &rhs) const
friend void swap(GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
ValueType::Array ArrayType
GenericValue(float f) RAPIDJSON_NOEXCEPT
Constructor for float value.
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
GenericValue< Encoding, Allocator > value
value of member.
GenericDocument & Populate(Generator &g)
Populate this document by a generator which produces SAX events.
(Constant) member iterator for a JSON object value
const Ch *const s
plain CharType pointer
static ValueType & Set(ValueType &v, ObjectType data)
GenericArray PopBack() const
static ValueType & Set(ValueType &v, ArrayType data)
static bool Is(const ValueType &v)
GenericMemberIterator Iterator
Iterator type itself.
GenericMemberIterator(Pointer p)
Internal constructor from plain pointer.
ValueType & operator[](SizeType index) const
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
GenericDocument & Parse(const Ch *str, size_t length)
GenericDocument & Parse(const Ch *str, size_t length)
Encoding::Ch Ch
Character type derived from Encoding.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
ValueType::StringRefType StringRefType
internal::Stack< StackAllocator > stack_
MemberIterator MemberEnd() const
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
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
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
MemberIterator FindMember(const GenericValue< EncodingType, SourceAllocator > &name) const
void SetArrayRaw(GenericValue *values, SizeType count, Allocator &allocator)
MemberIterator MemberBegin() const
static ValueType & Set(ValueType &v, ArrayType data, typename ValueType::AllocatorType &)
Result of parsing (wraps ParseErrorCode)
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
friend class GenericDocument
Encoding EncodingType
Encoding type from template parameter.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags)
bool operator!=(ModuleKeyAndType const &a, ModuleKeyAndType const &b) noexcept
Pointer operator->() const
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
ValueType::ConstObject ObjectType
internal::MaybeAddConst< Const, PlainType >::Type ValueType
static unsigned Get(const ValueType &v)
GenericArray(const GenericArray &rhs)
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
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
bool operator<(ProductInfo const &a, ProductInfo const &b)
GenericMemberIterator< true, typename ValueT::EncodingType, typename ValueT::AllocatorType > ConstMemberIterator
Allocator AllocatorType
Allocator type from template parameter.
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
Constructor for boolean value.
Reference operator[](DifferenceType n) const
bool EndObject(SizeType memberCount)
Allocator * ownAllocator_
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
GenericArray(ValueType &value)
Encoding::Ch Ch
Character type derived from Encoding.
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
static ValueType & Set(ValueType &v, ObjectType data, typename ValueType::AllocatorType &)
void swap(Handle< T > &a, Handle< T > &b)
static bool Is(const ValueType &v)
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
static StringType Get(const ValueType &v)
static ValueType & Set(ValueType &v, float data, typename ValueType::AllocatorType &)
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
ParseErrorCode
Error code of parsing.
bool RawNumber(const Ch *str, SizeType length, bool copy)
static bool Is(const ValueType &v)
GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocator) const
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
constexpr BitMask< Storage > Set(Flag_t< Storage > flag)
Returns a bit mask which sets the specified flag.
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
JAVACC_STRING_TYPE String
Allocator & GetAllocator()
Get the allocator of this document.
static bool Usable(SizeType len)
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
static bool Is(const ValueType &v)
GenericArray< false, ValueType > Array
GenericValue< Encoding, Allocator > ValueType
Value type of itself.
internal::MaybeAddConst< Const, PlainType >::Type ValueType
const SizeType length
length of the string (excluding the trailing NULL terminator)
const ValueT * ConstValueIterator
ValueIterator Begin() const
static bool Is(const ValueType &v)
Name-value pair in a JSON object value.
ValueType * ValueIterator
static int max(int a, int b)
SizeType hashcode
reserved
Iterator & operator+=(DifferenceType n)
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
struct Object Object
Object type.
GenericArray< true, ValueType > ConstArray
#define RAPIDJSON_DELETE(x)
! customization point for global delete
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
ValueIterator End() const
static ValueType & Set(ValueType &v, unsigned data)
~GenericValue()
Destructor.
static int Get(const ValueType &v)
GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType &allocator) const
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with kParseDefaultFlags)
GenericObject< false, ValueT > Object
SizeType MemberCount() const
#define RAPIDJSON_SETPOINTER(type, p, x)
static ValueType & Set(ValueType &v, unsigned data, typename ValueType::AllocatorType &)
MemberIterator FindMember(const Ch *name) const
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
CharType Ch
character type of the string
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
DifferenceType operator-(ConstIterator that) const
Distance.
static bool Is(const ValueType &v)
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
MemberIterator RemoveMember(MemberIterator m) const
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.
GenericMember< Encoding, Allocator > PlainType
Reference operator*() const
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
Iterator & operator=(const NonConstIterator &it)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
MemberIterator EraseMember(ConstMemberIterator pos) const
ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const
static bool Is(const ValueType &v)
void SetStringRaw(StringRefType s, Allocator &allocator)
Initialize this value as copy string with initial data, without calling destructor.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
internal::MaybeAddConst< Const, PlainType >::Type ValueType
int GetInt(xmlDocPtr xml_doc, string node_path)
bool operator>=(ConstIterator that) const
GenericDocument & Parse(const typename SourceEncoding::Ch *str, size_t length)
static int64_t Get(const ValueType &v)
ValueType::AllocatorType AllocatorType
GenericObject< true, ValueType > ConstObject
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
GenericValue(unsigned u) RAPIDJSON_NOEXCEPT
Constructor for unsigned value.
static ValueType & Set(ValueType &v, int64_t data)
#define RAPIDJSON_GETPOINTER(type, p)
GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT
Constructor for uint64_t value.
Iterator operator-(DifferenceType n) const
GenericValue * ValueIterator
Value iterator for iterating in array.
ValueType::ConstArray ArrayType
GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
static const SizeType kDefaultObjectCapacity
GenericObject< false, ValueType > Object
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
static msg_handler handler
static const SizeType kDefaultArrayCapacity
GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const
static float Get(const ValueType &v)
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
static ValueType & Set(ValueType &v, const StringType data)
Reference to a constant string (not taking a copy)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
static ValueType & Set(ValueType &v, int data)
bool EraseMember(const GenericValue< EncodingType, SourceAllocator > &name) const
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)
double GetDouble(xmlDocPtr xml_doc, string node_path)
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags)
GenericStringRef(const CharType *str, SizeType len)
Create constant string reference from pointer and length.
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
GenericObject & operator=(const GenericObject &rhs)
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T2 >, internal::IsGenericValue< T2 > >),(typename T::ValueType &)) GetValueByPointerWithDefault(T &root
static ValueType & Set(ValueType &v, uint64_t data, typename ValueType::AllocatorType &)
ValueType::Object ObjectType
size_t GetStackCapacity() const
Get the capacity of stack in bytes.
GenericObject AddMember(ValueType &name, StringRefType value, AllocatorType &allocator) const
GenericValue(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
Explicit copy constructor (with allocator)
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
static ValueType & Set(ValueType &v, int data, typename ValueType::AllocatorType &)
static ValueType & Set(ValueType &v, int64_t data, typename ValueType::AllocatorType &)
In-situ(destructive) parsing.
static bool Is(const ValueType &v)
Iterator & operator-=(DifferenceType n)
static uint64_t Get(const ValueType &v)
bool HasParseError() const
Whether a parse error has 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
bool operator==(ModuleKeyAndType const &a, ModuleKeyAndType const &b) noexcept
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.