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++)
42 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 46 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 53 template <
typename Encoding,
typename Allocator>
56 template <
typename Encoding,
typename Allocator,
typename StackAllocator>
66 template <
typename Encoding,
typename Allocator>
76 a.value.Swap(b.value);
83 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS 104 template <
bool Const,
typename Encoding,
typename Allocator>
108 template <
bool,
typename,
typename>
279 #else // RAPIDJSON_NOMEMBERITERATORCLASS 283 template <
bool Const,
typename Encoding,
typename Allocator>
287 template <
typename Encoding,
typename Allocator>
294 template <
typename Encoding,
typename Allocator>
301 #endif // RAPIDJSON_NOMEMBERITERATORCLASS 333 template <
typename CharType>
339 #ifndef __clang__ // -Wdocumentation 363 template <SizeType N>
369 #ifndef __clang__ // -Wdocumentation 394 #ifndef __clang__ // -Wdocumentation 412 operator const Ch*()
const 428 static const Ch emptyString[];
431 template <SizeType N>
437 template <
typename CharType>
453 template <
typename CharType>
474 template <
typename CharType>
480 #if RAPIDJSON_HAS_STDSTRING 493 template <
typename CharType>
504 template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
510 template <
typename T>
512 typename Void<typename T::AllocatorType>
::Type>
513 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>
::Type 518 template <
typename T>
530 template <
typename ValueType,
typename T>
535 template <
typename ValueType>
538 static bool Is(
const ValueType& v)
542 static bool Get(
const ValueType& v)
546 static ValueType&
Set(ValueType& v,
bool data)
548 return v.SetBool(data);
550 static ValueType&
Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&)
552 return v.SetBool(data);
556 template <
typename ValueType>
559 static bool Is(
const ValueType& v)
563 static int Get(
const ValueType& v)
567 static ValueType&
Set(ValueType& v,
int data)
569 return v.SetInt(data);
571 static ValueType&
Set(ValueType& v,
int data,
typename ValueType::AllocatorType&)
573 return v.SetInt(data);
577 template <
typename ValueType>
580 static bool Is(
const ValueType& v)
584 static unsigned Get(
const ValueType& v)
588 static ValueType&
Set(ValueType& v,
unsigned data)
590 return v.SetUint(data);
592 static ValueType&
Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&)
594 return v.SetUint(data);
600 template <
typename ValueType>
603 static bool Is(
const ValueType& v)
607 static long Get(
const ValueType& v)
611 static ValueType& Set(ValueType& v,
long data)
613 return v.SetInt(data);
615 static ValueType& Set(ValueType& v,
long data,
typename ValueType::AllocatorType&)
617 return v.SetInt(data);
622 template <
typename ValueType>
625 static bool Is(
const ValueType& v)
629 static unsigned long Get(
const ValueType& v)
633 static ValueType& Set(ValueType& v,
unsigned long data)
635 return v.SetUint(data);
637 static ValueType& Set(ValueType& v,
unsigned long data,
typename ValueType::AllocatorType&)
639 return v.SetUint(data);
644 template <
typename ValueType>
647 static bool Is(
const ValueType& v)
657 return v.SetInt64(data);
659 static ValueType&
Set(ValueType& v,
int64_t data,
typename ValueType::AllocatorType&)
661 return v.SetInt64(data);
665 template <
typename ValueType>
668 static bool Is(
const ValueType& v)
674 return v.GetUint64();
678 return v.SetUint64(data);
680 static ValueType&
Set(ValueType& v,
uint64_t data,
typename ValueType::AllocatorType&)
682 return v.SetUint64(data);
686 template <
typename ValueType>
689 static bool Is(
const ValueType& v)
693 static double Get(
const ValueType& v)
695 return v.GetDouble();
697 static ValueType&
Set(ValueType& v,
double data)
699 return v.SetDouble(data);
701 static ValueType&
Set(ValueType& v,
double data,
typename ValueType::AllocatorType&)
703 return v.SetDouble(data);
707 template <
typename ValueType>
710 static bool Is(
const ValueType& v)
714 static float Get(
const ValueType& v)
718 static ValueType&
Set(ValueType& v,
float data)
720 return v.SetFloat(data);
722 static ValueType&
Set(ValueType& v,
float data,
typename ValueType::AllocatorType&)
724 return v.SetFloat(data);
728 template <
typename ValueType>
732 static bool Is(
const ValueType& v)
736 static StringType
Get(
const ValueType& v)
738 return v.GetString();
740 static ValueType&
Set(ValueType& v,
const StringType data)
742 return v.SetString(
typename ValueType::StringRefType(data));
744 static ValueType&
Set(ValueType& v,
const StringType data,
typename ValueType::AllocatorType&
a)
746 return v.SetString(data, a);
750 #if RAPIDJSON_HAS_STDSTRING 751 template <
typename ValueType>
752 struct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch> >
754 typedef std::basic_string<typename ValueType::Ch>
StringType;
755 static bool Is(
const ValueType& v)
759 static StringType Get(
const ValueType& v)
761 return StringType(v.GetString(), v.GetStringLength());
763 static ValueType& Set(ValueType& v,
const StringType& data,
typename ValueType::AllocatorType&
a)
765 return v.SetString(data, a);
770 template <
typename ValueType>
774 static bool Is(
const ValueType& v)
778 static ArrayType
Get(ValueType& v)
782 static ValueType&
Set(ValueType& v, ArrayType data)
786 static ValueType&
Set(ValueType& v, ArrayType data,
typename ValueType::AllocatorType&)
792 template <
typename ValueType>
796 static bool Is(
const ValueType& v)
800 static ArrayType
Get(
const ValueType& v)
806 template <
typename ValueType>
810 static bool Is(
const ValueType& v)
814 static ObjectType
Get(ValueType& v)
816 return v.GetObject();
818 static ValueType&
Set(ValueType& v, ObjectType data)
822 static ValueType&
Set(ValueType& v, ObjectType data,
typename ValueType::AllocatorType&)
828 template <
typename ValueType>
829 struct TypeHelper<ValueType, typename ValueType::ConstObject>
832 static bool Is(
const ValueType& v)
836 static ObjectType
Get(
const ValueType& v)
838 return v.GetObject();
845 template <
bool,
typename>
847 template <
bool,
typename>
863 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
871 typedef typename Encoding::Ch
Ch;
893 data_.f.flags = kNullFlag;
896 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 908 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 909 template <
typename StackAllocator>
914 template <
typename StackAllocator>
926 static const uint16_t defaultFlags[] = { kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag,
927 kArrayFlag, kShortStringFlag, kNumberAnyFlag };
929 data_.f.flags = defaultFlags[type];
933 data_.ss.SetLength(0);
945 template <
typename SourceAllocator>
948 switch (rhs.GetType())
953 Member* lm =
reinterpret_cast<Member*
>(allocator.Malloc(count *
sizeof(Member)));
960 data_.f.flags = kObjectFlag;
961 data_.o.size = data_.o.capacity =
count;
962 SetMembersPointer(lm);
971 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
972 data_.f.flags = kArrayFlag;
973 data_.a.size = data_.a.capacity =
count;
974 SetElementsPointer(le);
978 if (rhs.
data_.f.flags == kConstStringFlag && !copyConstStrings)
980 data_.f.flags = rhs.
data_.f.flags;
981 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
984 SetStringRaw(
StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
987 data_.f.flags = rhs.
data_.f.flags;
988 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
999 #ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen 1000 template <
typename T>
1001 explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT
1009 data_.f.flags = b ? kTrueFlag : kFalseFlag;
1016 data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;
1023 data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
1030 data_.f.flags = kNumberInt64Flag;
1033 data_.f.flags |= kNumberUint64Flag;
1035 data_.f.flags |= kUintFlag;
1037 data_.f.flags |= kIntFlag;
1040 data_.f.flags |= kIntFlag;
1047 data_.f.flags = kNumberUint64Flag;
1049 data_.f.flags |= kInt64Flag;
1051 data_.f.flags |= kUintFlag;
1053 data_.f.flags |= kIntFlag;
1060 data_.f.flags = kNumberDoubleFlag;
1066 data_.n.d =
static_cast<double>(
f);
1067 data_.f.flags = kNumberDoubleFlag;
1085 SetStringRaw(
StringRef(s, length), allocator);
1094 #if RAPIDJSON_HAS_STDSTRING 1098 GenericValue(
const std::basic_string<Ch>& s, Allocator& allocator) : data_()
1112 a.value_.data_ = Data();
1113 a.value_.data_.f.flags = kArrayFlag;
1124 o.value_.data_ = Data();
1125 o.value_.data_.f.flags = kObjectFlag;
1133 if (Allocator::kNeedFree)
1135 switch (data_.f.flags)
1147 for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
1149 Allocator::Free(GetMembersPointer());
1152 case kCopyStringFlag:
1153 Allocator::Free(const_cast<Ch*>(GetStringPointer()));
1180 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1184 return *
this = rhs.Move();
1211 template <
typename T>
1226 template <
typename SourceAllocator>
1228 bool copyConstStrings =
false)
1230 RAPIDJSON_ASSERT(static_cast<void*>(
this) != static_cast<void const*>(&rhs));
1232 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
1283 template <
typename SourceAllocator>
1287 if (GetType() != rhs.GetType())
1293 if (data_.o.size != rhs.
data_.o.size)
1295 for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr)
1297 typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
1298 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
1304 if (data_.a.size != rhs.
data_.a.size)
1306 for (
SizeType i = 0; i < data_.a.size; i++)
1307 if ((*
this)[i] != rhs[i])
1312 return StringEqual(rhs);
1315 if (IsDouble() || rhs.IsDouble())
1317 double a = GetDouble();
1318 double b = rhs.GetDouble();
1319 return a >= b && a <= b;
1322 return data_.n.u64 == rhs.
data_.n.u64;
1330 bool operator==(
const Ch* rhs)
const 1335 #if RAPIDJSON_HAS_STDSTRING 1339 bool operator==(
const std::basic_string<Ch>& rhs)
const 1348 template <
typename T>
1350 operator==(
const T& rhs)
const 1358 template <
typename SourceAllocator>
1361 return !(*
this == rhs);
1365 bool operator!=(
const Ch* rhs)
const 1367 return !(*
this == rhs);
1373 template <
typename T>
1375 operator!=(
const T& rhs)
const 1377 return !(*
this == rhs);
1383 template <
typename T>
1393 template <
typename T>
1397 return !(rhs == lhs);
1404 Type GetType()
const 1406 return static_cast<Type>(data_.f.flags & kTypeMask);
1410 return data_.f.flags == kNullFlag;
1412 bool IsFalse()
const 1414 return data_.f.flags == kFalseFlag;
1418 return data_.f.flags == kTrueFlag;
1422 return (data_.f.flags & kBoolFlag) != 0;
1424 bool IsObject()
const 1426 return data_.f.flags == kObjectFlag;
1428 bool IsArray()
const 1430 return data_.f.flags == kArrayFlag;
1432 bool IsNumber()
const 1434 return (data_.f.flags & kNumberFlag) != 0;
1438 return (data_.f.flags & kIntFlag) != 0;
1442 return (data_.f.flags & kUintFlag) != 0;
1444 bool IsInt64()
const 1446 return (data_.f.flags & kInt64Flag) != 0;
1448 bool IsUint64()
const 1450 return (data_.f.flags & kUint64Flag) != 0;
1452 bool IsDouble()
const 1454 return (data_.f.flags & kDoubleFlag) != 0;
1456 bool IsString()
const 1458 return (data_.f.flags & kStringFlag) != 0;
1462 bool IsLosslessDouble()
const 1469 volatile double d =
static_cast<double>(u);
1470 return (d >= 0.0) && (d < static_cast<double>((std::numeric_limits<uint64_t>::max)())) &&
1476 volatile double d =
static_cast<double>(i);
1477 return (d >= static_cast<double>((std::numeric_limits<int64_t>::min)())) &&
1478 (d < static_cast<double>((std::numeric_limits<int64_t>::max)())) && (i == static_cast<int64_t>(d));
1484 bool IsFloat()
const 1486 if ((data_.f.flags & kDoubleFlag) == 0)
1488 double d = GetDouble();
1489 return d >= -3.4028234e38 && d <= 3.4028234e38;
1492 bool IsLosslessFloat()
const 1496 double a = GetDouble();
1497 if (a < static_cast<double>(-(std::numeric_limits<float>::max)()) ||
1498 a > static_cast<double>((std::numeric_limits<float>::max)()))
1500 double b =
static_cast<double>(
static_cast<float>(
a));
1501 return a >= b && a <= b;
1521 bool GetBool()
const 1524 return data_.f.flags == kTrueFlag;
1553 return data_.o.size;
1560 return data_.o.capacity;
1564 bool ObjectEmpty()
const 1567 return data_.o.size == 0;
1579 template <
typename T>
1587 template <
typename T>
1590 operator[](T* name)
const 1604 template <
typename SourceAllocator>
1607 MemberIterator member = FindMember(name);
1608 if (member != MemberEnd())
1609 return member->value;
1623 template <
typename SourceAllocator>
1629 #if RAPIDJSON_HAS_STDSTRING 1630 GenericValue& operator[](
const std::basic_string<Ch>& name)
1635 const GenericValue& operator[](
const std::basic_string<Ch>& name)
const 1643 ConstMemberIterator MemberBegin()
const 1646 return ConstMemberIterator(GetMembersPointer());
1650 ConstMemberIterator MemberEnd()
const 1653 return ConstMemberIterator(GetMembersPointer() + data_.o.size);
1657 MemberIterator MemberBegin()
1660 return MemberIterator(GetMembersPointer());
1664 MemberIterator MemberEnd()
1667 return MemberIterator(GetMembersPointer() + data_.o.size);
1680 if (newCapacity > data_.o.capacity)
1682 SetMembersPointer(reinterpret_cast<Member*>(
1683 allocator.Realloc(GetMembersPointer(), data_.o.capacity *
sizeof(Member), newCapacity *
sizeof(Member))));
1684 data_.o.capacity = newCapacity;
1697 bool HasMember(
const Ch* name)
const 1699 return FindMember(name) != MemberEnd();
1702 #if RAPIDJSON_HAS_STDSTRING 1711 bool HasMember(
const std::basic_string<Ch>& name)
const 1713 return FindMember(name) != MemberEnd();
1726 template <
typename SourceAllocator>
1729 return FindMember(name) != MemberEnd();
1744 MemberIterator FindMember(
const Ch* name)
1747 return FindMember(n);
1750 ConstMemberIterator FindMember(
const Ch* name)
const 1752 return const_cast<GenericValue&
>(*this).FindMember(name);
1768 template <
typename SourceAllocator>
1773 MemberIterator member = MemberBegin();
1774 for (; member != MemberEnd(); ++member)
1779 template <
typename SourceAllocator>
1782 return const_cast<GenericValue&
>(*this).FindMember(name);
1785 #if RAPIDJSON_HAS_STDSTRING 1793 MemberIterator FindMember(
const std::basic_string<Ch>& name)
1797 ConstMemberIterator FindMember(
const std::basic_string<Ch>& name)
const 1819 ObjectData& o = data_.o;
1820 if (o.size >= o.capacity)
1821 MemberReserve(o.capacity == 0 ? kDefaultObjectCapacity : (o.capacity + (o.capacity + 1) / 2), allocator);
1822 Member* members = GetMembersPointer();
1823 members[o.size].
name.RawAssign(name);
1824 members[o.size].
value.RawAssign(value);
1843 return AddMember(name, v, allocator);
1846 #if RAPIDJSON_HAS_STDSTRING 1861 return AddMember(name, v, allocator);
1882 template <
typename T>
1884 AddMember(
GenericValue& name, T value, Allocator& allocator)
1887 return AddMember(name, v, allocator);
1890 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 1893 return AddMember(name, value, allocator);
1897 return AddMember(name, value, allocator);
1901 return AddMember(name, value, allocator);
1906 return AddMember(n, value, allocator);
1908 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 1924 return AddMember(n, value, allocator);
1938 GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator)
1941 return AddMember(name, v, allocator);
1961 template <
typename T>
1963 AddMember(StringRefType name, T value, Allocator& allocator)
1966 return AddMember(n, value, allocator);
1973 void RemoveAllMembers()
1976 for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
1989 bool RemoveMember(
const Ch* name)
1992 return RemoveMember(n);
1995 #if RAPIDJSON_HAS_STDSTRING 1996 bool RemoveMember(
const std::basic_string<Ch>& name)
2002 template <
typename SourceAllocator>
2005 MemberIterator m = FindMember(name);
2006 if (m != MemberEnd())
2023 MemberIterator RemoveMember(MemberIterator m)
2030 MemberIterator last(GetMembersPointer() + (data_.o.size - 1));
2031 if (data_.o.size > 1 && m != last)
2048 MemberIterator EraseMember(ConstMemberIterator pos)
2050 return EraseMember(pos, pos + 1);
2062 MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last)
2071 MemberIterator pos = MemberBegin() + (first - MemberBegin());
2072 for (MemberIterator itr = pos; itr != last; ++itr)
2074 std::memmove(static_cast<void*>(&*pos), &*last, static_cast<size_t>(MemberEnd() - last) *
sizeof(Member));
2075 data_.o.size -=
static_cast<SizeType>(last - first);
2084 bool EraseMember(
const Ch* name)
2087 return EraseMember(n);
2090 #if RAPIDJSON_HAS_STDSTRING 2091 bool EraseMember(
const std::basic_string<Ch>& name)
2097 template <
typename SourceAllocator>
2100 MemberIterator m = FindMember(name);
2101 if (m != MemberEnd())
2113 return Object(*
this);
2115 ConstObject GetObject()
const 2118 return ConstObject(*
this);
2139 return data_.a.size;
2146 return data_.a.capacity;
2153 return data_.a.size == 0;
2178 return GetElementsPointer()[index];
2187 ValueIterator Begin()
2190 return GetElementsPointer();
2197 return GetElementsPointer() + data_.a.size;
2201 ConstValueIterator Begin()
const 2207 ConstValueIterator End()
const 2222 if (newCapacity > data_.a.capacity)
2224 SetElementsPointer(reinterpret_cast<GenericValue*>(allocator.Realloc(
2226 data_.a.capacity = newCapacity;
2245 if (data_.a.size >= data_.a.capacity)
2246 Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2),
2248 GetElementsPointer()[data_.a.size++].RawAssign(value);
2252 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2255 return PushBack(value, allocator);
2257 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 2269 GenericValue& PushBack(StringRefType value, Allocator& allocator)
2271 return (*this).template PushBack<StringRefType>(value, allocator);
2292 template <
typename T>
2294 PushBack(T value, Allocator& allocator)
2297 return PushBack(v, allocator);
2308 GetElementsPointer()[--data_.a.size].~GenericValue();
2320 ValueIterator Erase(ConstValueIterator pos)
2322 return Erase(pos, pos + 1);
2333 ValueIterator Erase(ConstValueIterator first, ConstValueIterator last)
2341 ValueIterator pos = Begin() + (first - Begin());
2342 for (ValueIterator itr = pos; itr != last; ++itr)
2344 std::memmove(static_cast<void*>(pos), last, static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
2345 data_.a.size -=
static_cast<SizeType>(last - first);
2352 return Array(*
this);
2354 ConstArray GetArray()
const 2357 return ConstArray(*
this);
2370 unsigned GetUint()
const 2390 double GetDouble()
const 2393 if ((data_.f.flags & kDoubleFlag) != 0)
2395 if ((data_.f.flags & kIntFlag) != 0)
2397 if ((data_.f.flags & kUintFlag) != 0)
2399 if ((data_.f.flags & kInt64Flag) != 0)
2400 return static_cast<double>(data_.n.i64);
2402 return static_cast<double>(data_.n.u64);
2409 float GetFloat()
const 2411 return static_cast<float>(GetDouble());
2456 const Ch* GetString()
const 2459 return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer();
2468 return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength()) : data_.s.length);
2506 return SetString(
StringRef(s, length), allocator);
2515 GenericValue& SetString(
const Ch* s, Allocator& allocator)
2517 return SetString(
StringRef(s), allocator);
2526 GenericValue& SetString(StringRefType s, Allocator& allocator)
2529 SetStringRaw(s, allocator);
2533 #if RAPIDJSON_HAS_STDSTRING 2542 GenericValue& SetString(
const std::basic_string<Ch>& s, Allocator& allocator)
2544 return SetString(
StringRef(s), allocator);
2558 template <
typename T>
2564 template <
typename T>
2570 template <
typename T>
2576 template <
typename T>
2577 ValueType& Set(
const T& data)
2582 template <
typename T>
2583 ValueType& Set(
const T& data, AllocatorType& allocator)
2597 template <
typename Handler>
2598 bool Accept(Handler& handler)
const 2603 return handler.Null();
2605 return handler.Bool(
false);
2607 return handler.Bool(
true);
2612 for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
2616 (m->name.data_.f.flags & kCopyFlag) != 0)))
2621 return handler.EndObject(data_.o.size);
2629 return handler.EndArray(data_.a.size);
2632 return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0);
2637 return handler.Double(data_.n.d);
2639 return handler.Int(data_.n.i.i);
2641 return handler.Uint(data_.n.u.u);
2643 return handler.Int64(data_.n.i64);
2645 return handler.Uint64(data_.n.u64);
2650 template <
typename,
typename>
2652 template <
typename,
typename,
typename>
2692 #if RAPIDJSON_48BITPOINTER_OPTIMIZATION 2693 char payload[
sizeof(
SizeType) * 2 + 6];
2694 #elif RAPIDJSON_64BIT 2695 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 6];
2697 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 2];
2721 MaxChars =
sizeof(
static_cast<Flag*
>(0)->payload) /
sizeof(Ch),
2722 MaxSize = MaxChars - 1,
2729 return (MaxSize >= len);
2733 str[LenPos] =
static_cast<Ch
>(MaxSize - len);
2737 return static_cast<SizeType>(MaxSize - str[LenPos]);
2744 #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN 2824 data_.f.flags = kArrayFlag;
2828 SetElementsPointer(e);
2829 std::memcpy(static_cast<void*>(e), values, count *
sizeof(
GenericValue));
2832 SetElementsPointer(0);
2833 data_.a.size = data_.a.capacity =
count;
2839 data_.f.flags = kObjectFlag;
2842 Member* m =
static_cast<Member*
>(allocator.Malloc(count *
sizeof(Member)));
2843 SetMembersPointer(m);
2844 std::memcpy(static_cast<void*>(m), members, count *
sizeof(Member));
2847 SetMembersPointer(0);
2848 data_.o.size = data_.o.capacity =
count;
2854 data_.f.flags = kConstStringFlag;
2855 SetStringPointer(s);
2856 data_.s.length = s.length;
2863 if (ShortString::Usable(s.
length))
2865 data_.f.flags = kShortStringFlag;
2866 data_.ss.SetLength(s.
length);
2871 data_.f.flags = kCopyStringFlag;
2872 data_.s.length = s.
length;
2873 str =
static_cast<Ch*
>(allocator.Malloc((s.
length + 1) *
sizeof(Ch)));
2874 SetStringPointer(str);
2876 std::memcpy(str, s, s.
length *
sizeof(Ch));
2888 template <
typename SourceAllocator>
2894 const SizeType len1 = GetStringLength();
2895 const SizeType len2 = rhs.GetStringLength();
2901 const Ch*
const str1 = GetString();
2902 const Ch*
const str2 = rhs.GetString();
2908 return (std::memcmp(str1, str2,
sizeof(Ch) * len1) == 0);
2930 template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>,
typename StackAllocator = CrtAllocator>
2934 typedef typename Encoding::Ch
Ch;
2946 StackAllocator* stackAllocator = 0)
2948 , allocator_(allocator)
2950 , stack_(stackAllocator, stackCapacity)
2964 StackAllocator* stackAllocator = 0)
2965 : allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2971 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2974 : ValueType(std::forward<ValueType>(rhs)),
2975 allocator_(rhs.allocator_),
2976 ownAllocator_(rhs.ownAllocator_),
2977 stack_(std::move(rhs.stack_)),
2978 parseResult_(rhs.parseResult_)
2981 rhs.ownAllocator_ = 0;
2991 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 2997 ValueType::operator=(std::forward<ValueType>(rhs));
3002 allocator_ = rhs.allocator_;
3003 ownAllocator_ = rhs.ownAllocator_;
3004 stack_ = std::move(rhs.stack_);
3005 parseResult_ = rhs.parseResult_;
3008 rhs.ownAllocator_ = 0;
3024 stack_.Swap(rhs.stack_);
3057 template <
typename Generator>
3064 ValueType::operator=(*stack_.template Pop<ValueType>(1));
3079 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
3084 parseResult_ = reader.template Parse<parseFlags>(is, *
this);
3088 ValueType::operator=(*stack_.template Pop<ValueType>(1));
3099 template <
unsigned parseFlags,
typename InputStream>
3102 return ParseStream<parseFlags, Encoding, InputStream>(is);
3110 template <
typename InputStream>
3113 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
3125 template <
unsigned parseFlags>
3129 return ParseStream<parseFlags | kParseInsituFlag>(s);
3138 return ParseInsitu<kParseDefaultFlags>(str);
3150 template <
unsigned parseFlags,
typename SourceEncoding>
3155 return ParseStream<parseFlags, SourceEncoding>(s);
3162 template <
unsigned parseFlags>
3165 return Parse<parseFlags, Encoding>(str);
3173 return Parse<kParseDefaultFlags>(str);
3176 template <
unsigned parseFlags,
typename SourceEncoding>
3180 MemoryStream ms(reinterpret_cast<const char*>(str), length *
sizeof(
typename SourceEncoding::Ch));
3182 ParseStream<parseFlags, SourceEncoding>(is);
3186 template <
unsigned parseFlags>
3189 return Parse<parseFlags, Encoding>(str, length);
3194 return Parse<kParseDefaultFlags>(str, length);
3197 #if RAPIDJSON_HAS_STDSTRING 3198 template <
unsigned parseFlags,
typename SourceEncoding>
3199 GenericDocument& Parse(
const std::basic_string<typename SourceEncoding::Ch>& str)
3202 return Parse<parseFlags, SourceEncoding>(str.c_str());
3205 template <
unsigned parseFlags>
3208 return Parse<parseFlags, Encoding>(str.c_str());
3213 return Parse<kParseDefaultFlags>(str);
3215 #endif // RAPIDJSON_HAS_STDSTRING 3225 return parseResult_.IsError();
3231 return parseResult_.Code();
3237 return parseResult_.Offset();
3241 #ifndef __clang // -Wdocumentation 3254 return parseResult_;
3268 return stack_.GetCapacity();
3291 template <
typename,
typename>
3298 new (stack_.template Push<ValueType>())
ValueType();
3303 new (stack_.template Push<ValueType>())
ValueType(b);
3308 new (stack_.template Push<ValueType>())
ValueType(i);
3313 new (stack_.template Push<ValueType>())
ValueType(i);
3318 new (stack_.template Push<ValueType>())
ValueType(i);
3323 new (stack_.template Push<ValueType>())
ValueType(i);
3328 new (stack_.template Push<ValueType>())
ValueType(d);
3335 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
3337 new (stack_.template Push<ValueType>())
ValueType(str, length);
3344 new (stack_.template Push<ValueType>())
ValueType(str, length, GetAllocator());
3346 new (stack_.template Push<ValueType>())
ValueType(str, length);
3358 return String(str, length, copy);
3363 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
3364 stack_.template Top<ValueType>()->
SetObjectRaw(members, memberCount, GetAllocator());
3376 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
3377 stack_.template Top<ValueType>()->
SetArrayRaw(elements, elementCount, GetAllocator());
3389 if (Allocator::kNeedFree)
3390 while (stack_.GetSize() > 0)
3392 (stack_.template Pop<ValueType>(1))->~
ValueType();
3395 stack_.ShrinkToFit();
3403 static const size_t kDefaultStackCapacity = 1024;
3418 template <
bool Const,
typename ValueT>
3431 template <
typename,
typename>
3448 return value_.Size();
3452 return value_.Capacity();
3456 return value_.Empty();
3464 return value_[index];
3468 return value_.Begin();
3472 return value_.End();
3476 value_.
Reserve(newCapacity, allocator);
3484 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 3490 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 3496 template <
typename T>
3499 PushBack(T
value, AllocatorType& allocator)
const 3501 value_.PushBack(value, allocator);
3509 ValueIterator
Erase(ConstValueIterator pos)
const 3511 return value_.Erase(pos);
3513 ValueIterator
Erase(ConstValueIterator first, ConstValueIterator last)
const 3515 return value_.Erase(first, last);
3518 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 3519 ValueIterator begin()
const 3521 return value_.Begin();
3523 ValueIterator end()
const 3525 return value_.End();
3542 template <
bool Const,
typename ValueT>
3557 typedef typename ValueType::Ch
Ch;
3559 template <
typename,
typename>
3576 return value_.MemberCount();
3580 return value_.MemberCapacity();
3584 return value_.ObjectEmpty();
3586 template <
typename T>
3589 return value_[
name];
3591 template <
typename SourceAllocator>
3594 return value_[
name];
3596 #if RAPIDJSON_HAS_STDSTRING 3597 ValueType& operator[](
const std::basic_string<Ch>&
name)
const 3599 return value_[
name];
3604 return value_.MemberBegin();
3608 return value_.MemberEnd();
3617 return value_.HasMember(name);
3619 #if RAPIDJSON_HAS_STDSTRING 3620 bool HasMember(
const std::basic_string<Ch>& name)
const 3622 return value_.HasMember(name);
3625 template <
typename SourceAllocator>
3628 return value_.HasMember(name);
3632 return value_.FindMember(name);
3634 template <
typename SourceAllocator>
3637 return value_.FindMember(name);
3639 #if RAPIDJSON_HAS_STDSTRING 3640 MemberIterator FindMember(
const std::basic_string<Ch>& name)
const 3642 return value_.FindMember(name);
3647 value_.
AddMember(name, value, allocator);
3652 value_.
AddMember(name, value, allocator);
3655 #if RAPIDJSON_HAS_STDSTRING 3656 GenericObject AddMember(ValueType& name, std::basic_string<Ch>&
value, AllocatorType& allocator)
const 3658 value_.
AddMember(name, value, allocator);
3662 template <
typename T>
3664 AddMember(ValueType& name, T value, AllocatorType& allocator)
const 3666 value_.AddMember(name, value, allocator);
3669 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 3680 GenericObject AddMember(ValueType&
name, ValueType&& value, AllocatorType& allocator)
const 3682 value_.
AddMember(name, value, allocator);
3685 GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator)
const 3687 value_.
AddMember(name, value, allocator);
3690 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS 3693 value_.
AddMember(name, value, allocator);
3698 value_.
AddMember(name, value, allocator);
3701 template <
typename T>
3703 AddMember(StringRefType name, T value, AllocatorType& allocator)
const 3705 value_.AddMember(name, value, allocator);
3710 value_.RemoveAllMembers();
3714 return value_.RemoveMember(name);
3716 #if RAPIDJSON_HAS_STDSTRING 3717 bool RemoveMember(
const std::basic_string<Ch>& name)
const 3719 return value_.RemoveMember(name);
3722 template <
typename SourceAllocator>
3725 return value_.RemoveMember(name);
3729 return value_.RemoveMember(m);
3733 return value_.EraseMember(pos);
3735 MemberIterator
EraseMember(ConstMemberIterator first, ConstMemberIterator last)
const 3737 return value_.EraseMember(first, last);
3741 return value_.EraseMember(name);
3743 #if RAPIDJSON_HAS_STDSTRING 3744 bool EraseMember(
const std::basic_string<Ch>& name)
const 3749 template <
typename SourceAllocator>
3752 return value_.EraseMember(name);
3755 #if RAPIDJSON_HAS_CXX11_RANGE_FOR 3756 MemberIterator begin()
const 3758 return value_.MemberBegin();
3760 MemberIterator end()
const 3762 return value_.MemberEnd();
3777 #endif // RAPIDJSON_DOCUMENT_H_ GenericValue(int i) RAPIDJSON_NOEXCEPT
Constructor for int value.
bool RemoveMember(const GenericValue< EncodingType, SourceAllocator > &name) const
GenericMemberIterator()
Default constructor (singular value)
void SetLength(SizeType len)
GenericValue(const Ch *s, SizeType length, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
GenericValue< Encoding, Allocator > name
name of member (must be a string)
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
static ArrayType Get(const ValueType &v)
SizeType NotNullStrLen(const CharType *str)
GenericObject(ValueType &value)
bool EndArray(SizeType elementCount)
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)
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
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.
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
GenericValue(const Ch *s, SizeType length) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
GenericDocument(Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
static ValueType & Set(ValueType &v, double data)
bool HasMember(const Ch *name) const
GenericMemberIterator< true, typename ValueT::EncodingType, typename ValueT::AllocatorType > ConstMemberIterator
Allocator AllocatorType
Allocator type from template parameter.
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
Constructor for boolean value.
Reference operator[](DifferenceType n) const
bool EndObject(SizeType memberCount)
Allocator * ownAllocator_
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
GenericArray(ValueType &value)
Encoding::Ch Ch
Character type derived from Encoding.
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
static ValueType & Set(ValueType &v, ObjectType data, typename ValueType::AllocatorType &)
static bool Is(const ValueType &v)
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
static StringType Get(const ValueType &v)
static ValueType & Set(ValueType &v, float data, typename ValueType::AllocatorType &)
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 SizeType length
length of the string (excluding the trailing NULL terminator)
friend void swap(GenericMember &a, GenericMember &b) RAPIDJSON_NOEXCEPT
const ValueT * ConstValueIterator
ValueIterator Begin() const
static bool Is(const ValueType &v)
Name-value pair in a JSON object value.
ValueType * ValueIterator
SizeType hashcode
reserved
Iterator & operator+=(DifferenceType n)
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
GenericArray< true, ValueType > ConstArray
#define RAPIDJSON_DELETE(x)
! customization point for global delete
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
ValueIterator End() const
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)
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.
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)
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.
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
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.
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
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)
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.
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
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.