15#ifndef RAPIDJSON_DOCUMENT_H_
16#define RAPIDJSON_DOCUMENT_H_
27#ifdef __cpp_lib_three_way_comparison
33RAPIDJSON_DIAG_OFF(padded)
34RAPIDJSON_DIAG_OFF(
switch -
enum)
35RAPIDJSON_DIAG_OFF(c++ 98 - compat)
36#elif defined(_MSC_VER)
37RAPIDJSON_DIAG_OFF(4127)
38RAPIDJSON_DIAG_OFF(4244)
42RAPIDJSON_DIAG_OFF(effc++)
49#pragma push_macro("GetObject")
50#define RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
54#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
58#if RAPIDJSON_USE_MEMBERSMAP
65template <
typename Encoding,
typename Allocator>
68template <
typename Encoding,
typename Allocator,
typename StackAllocator>
77#ifndef RAPIDJSON_DEFAULT_ALLOCATOR
78#define RAPIDJSON_DEFAULT_ALLOCATOR \
79 ::RAPIDJSON_NAMESPACE::MemoryPoolAllocator<::RAPIDJSON_NAMESPACE::CrtAllocator>
88#ifndef RAPIDJSON_DEFAULT_STACK_ALLOCATOR
89#define RAPIDJSON_DEFAULT_STACK_ALLOCATOR ::RAPIDJSON_NAMESPACE::CrtAllocator
98#ifndef RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
100#define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY 16
109#ifndef RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
111#define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY 16
120template <
typename Encoding,
typename Allocator>
127#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
129 GenericMember(GenericMember&& rhs) RAPIDJSON_NOEXCEPT :
name(std::move(rhs.name)),
130 value(std::move(rhs.value))
145 GenericMember&
operator=(GenericMember& rhs) RAPIDJSON_NOEXCEPT
156 friend inline void swap(GenericMember&
a, GenericMember& b) RAPIDJSON_NOEXCEPT
159 a.value.Swap(b.value);
170#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
192template <
bool Const,
typename Encoding,
typename Allocator>
197 template <
bool,
typename,
typename>
201 typedef typename internal::MaybeAddConst<Const, PlainType>::Type ValueType;
301 template <
bool Const_>
304 return ptr_ == that.ptr_;
306 template <
bool Const_>
309 return ptr_ != that.ptr_;
311 template <
bool Const_>
314 return ptr_ <= that.ptr_;
316 template <
bool Const_>
319 return ptr_ >= that.ptr_;
321 template <
bool Const_>
324 return ptr_ < that.ptr_;
326 template <
bool Const_>
329 return ptr_ > that.ptr_;
332#ifdef __cpp_lib_three_way_comparison
333 template <
bool Const_>
337 return ptr_ <=> that.ptr_;
363template <
bool Const,
typename Encoding,
typename Allocator>
367template <
typename Encoding,
typename Allocator>
372 typedef GenericMember<Encoding, Allocator>*
Iterator;
375template <
typename Encoding,
typename Allocator>
380 typedef const GenericMember<Encoding, Allocator>*
Iterator;
415template <
typename CharType>
445 template <SizeType N>
491 operator const Ch*()
const {
return s; }
497 SizeType NotNullStrLen(
const CharType* str)
507 template <SizeType N>
513template <
typename CharType>
514const CharType GenericStringRef<CharType>::emptyString[] = {CharType()};
529template <
typename CharType>
549template <
typename CharType>
555#if RAPIDJSON_HAS_STDSTRING
567template <
typename CharType>
578template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
586 typename Void<typename T::EncodingType>
::Type,
587 typename Void<typename T::AllocatorType>
::Type>
588 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>
::Type
605template <
typename ValueType,
typename T>
610template <
typename ValueType>
613 static bool Is(
const ValueType& v) {
return v.IsBool(); }
614 static bool Get(
const ValueType& v) {
return v.GetBool(); }
615 static ValueType&
Set(ValueType& v,
bool data) {
return v.SetBool(data); }
616 static ValueType&
Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&)
618 return v.SetBool(data);
622template <
typename ValueType>
625 static bool Is(
const ValueType& v) {
return v.IsInt(); }
626 static int Get(
const ValueType& v) {
return v.GetInt(); }
627 static ValueType&
Set(ValueType& v,
int data) {
return v.SetInt(data); }
628 static ValueType&
Set(ValueType& v,
int data,
typename ValueType::AllocatorType&)
630 return v.SetInt(data);
634template <
typename ValueType>
637 static bool Is(
const ValueType& v) {
return v.IsUint(); }
638 static unsigned Get(
const ValueType& v) {
return v.GetUint(); }
639 static ValueType&
Set(ValueType& v,
unsigned data) {
return v.SetUint(data); }
640 static ValueType&
Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&)
642 return v.SetUint(data);
648template <
typename ValueType>
649struct TypeHelper<ValueType, long>
651 static bool Is(
const ValueType& v) {
return v.IsInt(); }
652 static long Get(
const ValueType& v) {
return v.GetInt(); }
653 static ValueType&
Set(ValueType& v,
long data) {
return v.SetInt(data); }
654 static ValueType&
Set(ValueType& v,
long data,
typename ValueType::AllocatorType&)
656 return v.SetInt(data);
661template <
typename ValueType>
664 static bool Is(
const ValueType& v) {
return v.IsUint(); }
665 static unsigned long Get(
const ValueType& v) {
return v.GetUint(); }
666 static ValueType&
Set(ValueType& v,
unsigned long data) {
return v.SetUint(data); }
667 static ValueType&
Set(ValueType& v,
unsigned long data,
typename ValueType::AllocatorType&)
669 return v.SetUint(data);
674template <
typename ValueType>
677 static bool Is(
const ValueType& v) {
return v.IsInt64(); }
678 static int64_t Get(
const ValueType& v) {
return v.GetInt64(); }
679 static ValueType&
Set(ValueType& v,
int64_t data) {
return v.SetInt64(data); }
680 static ValueType&
Set(ValueType& v,
int64_t data,
typename ValueType::AllocatorType&)
682 return v.SetInt64(data);
686template <
typename ValueType>
689 static bool Is(
const ValueType& v) {
return v.IsUint64(); }
691 static ValueType&
Set(ValueType& v,
uint64_t data) {
return v.SetUint64(data); }
692 static ValueType&
Set(ValueType& v,
uint64_t data,
typename ValueType::AllocatorType&)
694 return v.SetUint64(data);
698template <
typename ValueType>
701 static bool Is(
const ValueType& v) {
return v.IsDouble(); }
702 static double Get(
const ValueType& v) {
return v.GetDouble(); }
703 static ValueType&
Set(ValueType& v,
double data) {
return v.SetDouble(data); }
704 static ValueType&
Set(ValueType& v,
double data,
typename ValueType::AllocatorType&)
706 return v.SetDouble(data);
710template <
typename ValueType>
713 static bool Is(
const ValueType& v) {
return v.IsFloat(); }
714 static float Get(
const ValueType& v) {
return v.GetFloat(); }
715 static ValueType&
Set(ValueType& v,
float data) {
return v.SetFloat(data); }
716 static ValueType&
Set(ValueType& v,
float data,
typename ValueType::AllocatorType&)
718 return v.SetFloat(data);
722template <
typename ValueType>
726 static bool Is(
const ValueType& v) {
return v.IsString(); }
730 return v.SetString(
typename ValueType::StringRefType(data));
732 static ValueType&
Set(ValueType& v,
const StringType data,
typename ValueType::AllocatorType&
a)
734 return v.SetString(data,
a);
738#if RAPIDJSON_HAS_STDSTRING
739template <
typename ValueType>
740struct TypeHelper<ValueType,
std::basic_string<typename ValueType::Ch>>
742 typedef std::basic_string<typename ValueType::Ch> StringType;
743 static bool Is(
const ValueType& v) {
return v.IsString(); }
744 static StringType Get(
const ValueType& v)
746 return StringType(v.GetString(), v.GetStringLength());
749 Set(ValueType& v,
const StringType& data,
typename ValueType::AllocatorType&
a)
751 return v.SetString(data,
a);
756template <
typename ValueType>
760 static bool Is(
const ValueType& v) {
return v.IsArray(); }
762 static ValueType&
Set(ValueType& v,
ArrayType data) {
return v = data; }
763 static ValueType&
Set(ValueType& v,
ArrayType data,
typename ValueType::AllocatorType&)
769template <
typename ValueType>
773 static bool Is(
const ValueType& v) {
return v.IsArray(); }
777template <
typename ValueType>
781 static bool Is(
const ValueType& v) {
return v.IsObject(); }
784 static ValueType&
Set(ValueType& v,
ObjectType data,
typename ValueType::AllocatorType&)
790template <
typename ValueType>
794 static bool Is(
const ValueType& v) {
return v.IsObject(); }
801template <
bool,
typename>
803template <
bool,
typename>
820template <
typename Encoding,
typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR>
828 typedef typename Encoding::Ch
Ch;
849#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
861#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
863 template <
typename StackAllocator>
867 template <
typename StackAllocator>
887 data_.f.flags = defaultFlags[type];
891 data_.ss.SetLength(0);
902 template <
typename SourceAllocator>
905 bool copyConstStrings =
false)
907 switch(rhs.GetType())
916 new(&le[i])
GenericValue(re[i], allocator, copyConstStrings);
926 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
933 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
944#ifndef RAPIDJSON_DOXYGEN_RUNNING
945 template <
typename T>
946 explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>)))
1013 data_.n.d =
static_cast<double>(f);
1038#if RAPIDJSON_HAS_STDSTRING
1056 a.value_.data_ = Data();
1068 o.value_.data_ = Data();
1079 if(Allocator::kNeedFree ||
1082 switch(
data_.f.flags)
1088 if(Allocator::kNeedFree)
1098 if(Allocator::kNeedFree)
1132#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1160 template <
typename T>
1176 template <
typename SourceAllocator>
1179 bool copyConstStrings =
false)
1181 RAPIDJSON_ASSERT(
static_cast<void*
>(
this) !=
static_cast<void const*
>(&rhs));
1183 new(
this)
GenericValue(rhs, allocator, copyConstStrings);
1197 other.RawAssign(temp);
1214 GenericValue& Move() RAPIDJSON_NOEXCEPT {
return *
this; }
1225 template <
typename SourceAllocator>
1229 if(GetType() != rhs.GetType())
1240 typename RhsType::ConstMemberIterator rhsMemberItr =
1241 rhs.FindMember(lhsMemberItr->name);
1242 if(rhsMemberItr == rhs.MemberEnd() ||
1243 (!(lhsMemberItr->value == rhsMemberItr->value)))
1252 if(!((*
this)[i] == rhs[i]))
1259 if(IsDouble() || rhs.IsDouble())
1261 double a = GetDouble();
1262 double b = rhs.GetDouble();
1263 return a >= b &&
a <= b;
1268 default:
return true;
1275#if RAPIDJSON_HAS_STDSTRING
1279 bool operator==(
const std::basic_string<Ch>& rhs)
const
1289 template <
typename T>
1291 (internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T>>), (
bool))
1297#ifndef __cpp_impl_three_way_comparison
1301 template <
typename SourceAllocator>
1304 return !(*
this == rhs);
1308 bool operator!=(
const Ch* rhs)
const {
return !(*
this == rhs); }
1313 template <
typename T>
1317 return !(*
this == rhs);
1323 template <
typename T>
1333 template <
typename T>
1337 return !(rhs == lhs);
1353 bool IsInt()
const {
return (
data_.f.flags &
kIntFlag) != 0; }
1361 bool IsLosslessDouble()
const
1368 volatile double d =
static_cast<double>(u);
1369 return (d >= 0.0) &&
1370 (d < static_cast<double>((std::numeric_limits<uint64_t>::max)())) &&
1376 volatile double d =
static_cast<double>(i);
1377 return (d >=
static_cast<double>((std::numeric_limits<int64_t>::min)())) &&
1378 (d < static_cast<double>((std::numeric_limits<int64_t>::max)())) &&
1379 (i ==
static_cast<int64_t>(d));
1385 bool IsFloat()
const
1389 double d = GetDouble();
1390 return d >= -3.4028234e38 && d <= 3.4028234e38;
1393 bool IsLosslessFloat()
const
1397 double a = GetDouble();
1398 if(
a <
static_cast<double>(-(std::numeric_limits<float>::max)()) ||
1399 a >
static_cast<double>((std::numeric_limits<float>::max)()))
1401 double b =
static_cast<double>(
static_cast<float>(
a));
1402 return a >= b &&
a <= b;
1422 bool GetBool()
const
1454 return data_.o.size;
1461 return data_.o.capacity;
1465 bool ObjectEmpty()
const
1468 return data_.o.size == 0;
1479 template <
typename T>
1481 (internal::NotExpr<internal::IsSame<
typename internal::RemoveConst<T>::Type,
Ch>>),
1483 operator[](T * name)
1488 template <
typename T>
1490 (internal::NotExpr<internal::IsSame<
typename internal::RemoveConst<T>::Type,
Ch>>),
1492 operator[](T * name)
const
1506 template <
typename SourceAllocator>
1510 if(member != MemberEnd())
1511 return member->value;
1516#if RAPIDJSON_HAS_CXX11
1522#elif defined(_MSC_VER) && _MSC_VER < 1900
1525 __declspec(thread)
static char buffer[
sizeof(
GenericValue)];
1527#elif defined(__GNUC__) || defined(__clang__)
1542 template <
typename SourceAllocator>
1548#if RAPIDJSON_HAS_STDSTRING
1550 GenericValue& operator[](
const std::basic_string<Ch>& name)
1554 const GenericValue& operator[](
const std::basic_string<Ch>& name)
const
1610 bool HasMember(
const Ch* name)
const {
return FindMember(name) != MemberEnd(); }
1612#if RAPIDJSON_HAS_STDSTRING
1621 bool HasMember(
const std::basic_string<Ch>& name)
const
1623 return FindMember(name) != MemberEnd();
1634 template <
typename SourceAllocator>
1637 return FindMember(name) != MemberEnd();
1655 return FindMember(n);
1660 return const_cast<GenericValue&
>(*this).FindMember(name);
1674 template <
typename SourceAllocator>
1681 template <
typename SourceAllocator>
1684 return const_cast<GenericValue&
>(*this).FindMember(name);
1687#if RAPIDJSON_HAS_STDSTRING
1734 return AddMember(name, v, allocator);
1737#if RAPIDJSON_HAS_STDSTRING
1750 return AddMember(name, v, allocator);
1770 template <
typename T>
1772 (internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T>>), (
GenericValue&))
1776 return AddMember(name, v, allocator);
1779#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1782 return AddMember(name,
value, allocator);
1786 return AddMember(name,
value, allocator);
1790 return AddMember(name,
value, allocator);
1795 return AddMember(n,
value, allocator);
1810 return AddMember(n,
value, allocator);
1825 return AddMember(name, v, allocator);
1844 template <
typename T>
1846 (internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T>>), (
GenericValue&))
1850 return AddMember(n,
value, allocator);
1857 void RemoveAllMembers()
1871 bool RemoveMember(
const Ch* name)
1874 return RemoveMember(n);
1877#if RAPIDJSON_HAS_STDSTRING
1878 bool RemoveMember(
const std::basic_string<Ch>& name)
1884 template <
typename SourceAllocator>
1888 if(m != MemberEnd())
1950 bool EraseMember(
const Ch* name)
1953 return EraseMember(n);
1956#if RAPIDJSON_HAS_STDSTRING
1957 bool EraseMember(
const std::basic_string<Ch>& name)
1963 template <
typename SourceAllocator>
1967 if(m != MemberEnd())
2015 return data_.a.size;
2022 return data_.a.capacity;
2029 return data_.a.size == 0;
2091 if(newCapacity >
data_.a.capacity)
2097 data_.a.capacity = newCapacity;
2116 : (
data_.a.capacity + (
data_.a.capacity + 1) / 2),
2122#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2125 return PushBack(
value, allocator);
2139 return (*this).template PushBack<StringRefType>(
value, allocator);
2159 template <
typename T>
2161 (internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T>>), (
GenericValue&))
2162 PushBack(T
value, Allocator& allocator)
2165 return PushBack(v, allocator);
2207 itr->~GenericValue();
2208 std::memmove(
static_cast<void*
>(pos),
2210 static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
2218 return Array(*
this);
2236 unsigned GetUint()
const
2256 double GetDouble()
const
2266 return static_cast<double>(
data_.n.i64);
2268 return static_cast<double>(
data_.n.u64);
2275 float GetFloat()
const {
return static_cast<float>(GetDouble()); }
2319 const Ch* GetString()
const
2369 return SetString(
StringRef(s, length), allocator);
2380 return SetString(
StringRef(s), allocator);
2396#if RAPIDJSON_HAS_STDSTRING
2405 GenericValue& SetString(
const std::basic_string<Ch>& s, Allocator& allocator)
2407 return SetString(
StringRef(s), allocator);
2421 template <
typename T>
2424 return internal::TypeHelper<ValueType, T>::Is(*
this);
2427 template <
typename T>
2430 return internal::TypeHelper<ValueType, T>::Get(*
this);
2433 template <
typename T>
2436 return internal::TypeHelper<ValueType, T>::Get(*
this);
2439 template <
typename T>
2442 return internal::TypeHelper<ValueType, T>::Set(*
this, data);
2445 template <
typename T>
2448 return internal::TypeHelper<ValueType, T>::Set(*
this, data, allocator);
2460 template <
typename Handler>
2461 bool Accept(Handler& handler)
const
2467 case kTrueType:
return handler.Bool(
true);
2475 m->name.IsString());
2477 m->name.GetStringLength(),
2478 (m->name.data_.f.flags &
kCopyFlag) != 0)))
2483 return handler.EndObject(
data_.o.size);
2491 return handler.EndArray(
data_.a.size);
2494 return handler.String(GetString(), GetStringLength(), (
data_.f.flags &
kCopyFlag) != 0);
2499 return handler.Double(
data_.n.d);
2501 return handler.Int(
data_.n.i.i);
2503 return handler.Uint(
data_.n.u.u);
2505 return handler.Int64(
data_.n.i64);
2507 return handler.Uint64(
data_.n.u64);
2512 template <
typename,
typename>
2514 template <
typename,
typename,
typename>
2564#if RAPIDJSON_48BITPOINTER_OPTIMIZATION
2566#elif RAPIDJSON_64BIT
2609#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN
2696#if RAPIDJSON_USE_MEMBERSMAP
2702 bool operator()(
const Data& s1,
const Data& s2)
const
2704 SizeType n1 = DataStringLength(s1), n2 = DataStringLength(s2);
2706 std::memcmp(DataString(s1), DataString(s2),
sizeof(Ch) * (n1 < n2 ? n1 : n2));
2707 return cmp < 0 || (cmp == 0 && n1 < n2);
2710 typedef std::pair<const Data, SizeType> Pair;
2711 typedef std::multimap<Data, SizeType, Less, StdAllocator<Pair, Allocator>> Map;
2712 typedef typename Map::iterator Iterator;
2714 typedef typename MapTraits::Map Map;
2715 typedef typename MapTraits::Less MapLess;
2716 typedef typename MapTraits::Pair MapPair;
2717 typedef typename MapTraits::Iterator MapIterator;
2727 static RAPIDJSON_FORCEINLINE
size_t GetMapLayoutSize(
SizeType capacity)
2733 static RAPIDJSON_FORCEINLINE
SizeType& GetMapCapacity(Map*& map)
2739 static RAPIDJSON_FORCEINLINE
Member* GetMapMembers(Map*& map)
2746 static RAPIDJSON_FORCEINLINE MapIterator* GetMapIterators(Map*& map)
2748 return reinterpret_cast<MapIterator*
>(
2754 static RAPIDJSON_FORCEINLINE Map*& GetMap(
Member* members)
2757 return *
reinterpret_cast<Map**
>(
reinterpret_cast<uintptr_t>(members) -
2763 RAPIDJSON_FORCEINLINE MapIterator DropMapIterator(MapIterator& rhs)
2765#if RAPIDJSON_HAS_CXX11
2766 MapIterator ret = std::move(rhs);
2768 MapIterator ret = rhs;
2774 Map*& DoReallocMap(Map** oldMap,
SizeType newCapacity, Allocator& allocator)
2776 Map** newMap =
static_cast<Map**
>(allocator.Malloc(GetMapLayoutSize(newCapacity)));
2777 GetMapCapacity(*newMap) = newCapacity;
2780 *newMap =
new(allocator.Malloc(
sizeof(Map))) Map(MapLess(), allocator);
2785 size_t count = (*oldMap)->size();
2786 std::memcpy(
static_cast<void*
>(GetMapMembers(*newMap)),
2787 static_cast<void*
>(GetMapMembers(*oldMap)),
2789 MapIterator *oldIt = GetMapIterators(*oldMap), *newIt = GetMapIterators(*newMap);
2792 new(&newIt[count]) MapIterator(DropMapIterator(oldIt[count]));
2794 Allocator::Free(oldMap);
2801 return GetMapMembers(DoReallocMap(0, capacity, allocator));
2807 if(newCapacity > o.capacity)
2810 Map **oldMap = oldMembers ? &GetMap(oldMembers) : 0,
2811 *&newMap = DoReallocMap(oldMap, newCapacity, allocator);
2813 o.capacity = newCapacity;
2817 template <
typename SourceAllocator>
2822 Map*& map = GetMap(members);
2823 MapIterator mit = map->find(
reinterpret_cast<const Data&
>(name.
data_));
2824 if(mit != map->end())
2836 Map*& map = GetMap(members);
2837 MapIterator* mit = GetMapIterators(map);
2840 map->erase(DropMapIterator(mit[i]));
2841 members[i].~Member();
2851 GetMap(members)->~Map();
2854 members[i].~Member();
2856 if(Allocator::kNeedFree)
2858 Map** map = &GetMap(members);
2859 Allocator::Free(*map);
2860 Allocator::Free(map);
2874 ObjectData& o =
data_.o;
2875 if(newCapacity > o.capacity)
2880 o.capacity = newCapacity;
2884 template <
typename SourceAllocator>
2888 for(; member != MemberEnd(); ++member)
2912 ObjectData& o =
data_.o;
2913 if(o.size >= o.capacity)
2918 Member* m = members + o.size;
2921#if RAPIDJSON_USE_MEMBERSMAP
2922 Map*& map = GetMap(members);
2923 MapIterator* mit = GetMapIterators(map);
2924 new(&mit[o.size]) MapIterator(map->insert(MapPair(m->
name.
data_, o.size)));
2931 ObjectData& o =
data_.o;
2933#if RAPIDJSON_USE_MEMBERSMAP
2934 Map*& map = GetMap(members);
2935 MapIterator* mit = GetMapIterators(map);
2937 map->erase(DropMapIterator(mit[mpos]));
2940 if(o.size > 1 && m != last)
2942#if RAPIDJSON_USE_MEMBERSMAP
2943 new(&mit[mpos]) MapIterator(DropMapIterator(mit[&*last - members]));
2944 mit[mpos]->second = mpos;
2958 ObjectData& o =
data_.o;
2959 MemberIterator beg = MemberBegin(), pos = beg + (first - beg), end = MemberEnd();
2960#if RAPIDJSON_USE_MEMBERSMAP
2962 MapIterator* mit = GetMapIterators(map);
2966#if RAPIDJSON_USE_MEMBERSMAP
2967 map->erase(DropMapIterator(mit[itr - beg]));
2971#if RAPIDJSON_USE_MEMBERSMAP
2978 std::memcpy(
static_cast<void*
>(&*itr), &*next,
sizeof(
Member));
2980 new(&mit[mpos]) MapIterator(DropMapIterator(mit[next - beg]));
2981 mit[mpos]->second = mpos;
2986 static_cast<void*
>(&*pos), &*last,
static_cast<size_t>(end - last) *
sizeof(
Member));
2988 o.size -=
static_cast<SizeType>(last - first);
2992 template <
typename SourceAllocator>
2995 bool copyConstStrings)
3004#if RAPIDJSON_USE_MEMBERSMAP
3005 Map*& map = GetMap(lm);
3006 MapIterator* mit = GetMapIterators(map);
3008 for(
SizeType i = 0; i < count; i++)
3012#if RAPIDJSON_USE_MEMBERSMAP
3013 new(&mit[i]) MapIterator(map->insert(MapPair(lm[i].name.data_, i)));
3029 std::memcpy(
static_cast<void*
>(e), values, count *
sizeof(
GenericValue));
3044 std::memcpy(
static_cast<void*
>(m), members, count *
sizeof(
Member));
3045#if RAPIDJSON_USE_MEMBERSMAP
3046 Map*& map = GetMap(m);
3047 MapIterator* mit = GetMapIterators(map);
3048 for(
SizeType i = 0; i < count; i++)
3050 new(&mit[i]) MapIterator(map->insert(MapPair(m[i].name.
data_, i)));
3064 data_.s.length = s.length;
3076 std::memmove(str, s, s.
length *
sizeof(
Ch));
3082 str =
static_cast<Ch*
>(allocator.Malloc((s.
length + 1) *
sizeof(
Ch)));
3084 std::memcpy(str, s, s.
length *
sizeof(
Ch));
3097 template <
typename SourceAllocator>
3103 const SizeType len1 = GetStringLength();
3104 const SizeType len2 = rhs.GetStringLength();
3110 const Ch*
const str1 = GetString();
3111 const Ch*
const str2 = rhs.GetString();
3117 return (std::memcmp(str1, str2,
sizeof(
Ch) * len1) == 0);
3145 typedef typename Encoding::Ch
Ch;
3159 size_t stackCapacity = kDefaultStackCapacity,
3160 StackAllocator* stackAllocator = 0)
3162 allocator_(allocator),
3164 stack_(stackAllocator, stackCapacity),
3178 size_t stackCapacity = kDefaultStackCapacity,
3179 StackAllocator* stackAllocator = 0)
3180 : allocator_(allocator),
3182 stack_(stackAllocator, stackCapacity),
3189#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
3193 std::forward<ValueType>(rhs)),
3194 allocator_(rhs.allocator_),
3195 ownAllocator_(rhs.ownAllocator_),
3196 stack_(std::move(rhs.stack_)),
3197 parseResult_(rhs.parseResult_)
3200 rhs.ownAllocator_ = 0;
3213 ValueType::SetNull();
3218#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
3229 allocator_ = rhs.allocator_;
3230 ownAllocator_ = rhs.ownAllocator_;
3231 stack_ = std::move(rhs.stack_);
3232 parseResult_ = rhs.parseResult_;
3235 rhs.ownAllocator_ = 0;
3250 ValueType::Swap(rhs);
3251 stack_.Swap(rhs.stack_);
3260 using ValueType::Swap;
3281 template <
typename Generator>
3284 ClearStackOnExit scope(*
this);
3290 *stack_.template Pop<ValueType>(1));
3305 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
3309 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
3310 ClearStackOnExit scope(*
this);
3317 *stack_.template Pop<ValueType>(1));
3328 template <
unsigned parseFlags,
typename InputStream>
3339 template <
typename InputStream>
3354 template <
unsigned parseFlags>
3376 template <
unsigned parseFlags,
typename SourceEncoding>
3388 template <
unsigned parseFlags>
3399 template <
unsigned parseFlags,
typename SourceEncoding>
3404 length *
sizeof(
typename SourceEncoding::Ch));
3410 template <
unsigned parseFlags>
3421#if RAPIDJSON_HAS_STDSTRING
3422 template <
unsigned parseFlags,
typename SourceEncoding>
3430 template <
unsigned parseFlags>
3483 struct ClearStackOnExit
3486 ~ClearStackOnExit() { d_.ClearStack(); }
3489 ClearStackOnExit(
const ClearStackOnExit&);
3490 ClearStackOnExit& operator=(
const ClearStackOnExit&);
3496 template <
typename,
typename>
3503 new(stack_.template Push<ValueType>())
ValueType();
3508 new(stack_.template Push<ValueType>())
ValueType(b);
3513 new(stack_.template Push<ValueType>())
ValueType(i);
3518 new(stack_.template Push<ValueType>())
ValueType(i);
3523 new(stack_.template Push<ValueType>())
ValueType(i);
3528 new(stack_.template Push<ValueType>())
ValueType(i);
3533 new(stack_.template Push<ValueType>())
ValueType(d);
3542 new(stack_.template Push<ValueType>())
ValueType(str, length);
3551 new(stack_.template Push<ValueType>())
ValueType(str, length);
3566 stack_.template Pop<typename ValueType::Member>(memberCount);
3567 stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount,
GetAllocator());
3579 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
3580 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount,
GetAllocator());
3592 if(Allocator::kNeedFree)
3595 (stack_.template Pop<ValueType>(1))->~
ValueType();
3603 static const size_t kDefaultStackCapacity = 1024;
3604 Allocator* allocator_;
3605 Allocator* ownAllocator_;
3606 internal::Stack<StackAllocator> stack_;
3607 ParseResult parseResult_;
3619template <
bool Const,
typename ValueT>
3626 typedef typename internal::MaybeAddConst<Const, PlainType>::Type
ValueType;
3632 template <
typename,
typename>
3638 value_ = rhs.value_;
3646 bool Empty()
const {
return value_.Empty(); }
3653 value_.
Reserve(newCapacity, allocator);
3661#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
3664 value_.PushBack(
value, allocator);
3673 template <
typename T>
3679 value_.PushBack(
value, allocator);
3690 return value_.Erase(first, last);
3693#if RAPIDJSON_HAS_CXX11_RANGE_FOR
3710template <
bool Const,
typename ValueT>
3717 typedef typename internal::MaybeAddConst<Const, PlainType>::Type
ValueType;
3719 typename ValueT::EncodingType,
3720 typename ValueT::AllocatorType>
3723 typename ValueT::EncodingType,
3724 typename ValueT::AllocatorType>
3729 typedef typename ValueType::Ch
Ch;
3731 template <
typename,
typename>
3737 value_ = rhs.value_;
3746 template <
typename T>
3749 return value_[name];
3751 template <
typename SourceAllocator>
3754 return value_[name];
3756#if RAPIDJSON_HAS_STDSTRING
3766 bool HasMember(
const Ch* name)
const {
return value_.HasMember(name); }
3767#if RAPIDJSON_HAS_STDSTRING
3768 bool HasMember(
const std::basic_string<Ch>& name)
const {
return value_.HasMember(name); }
3770 template <
typename SourceAllocator>
3773 return value_.HasMember(name);
3776 template <
typename SourceAllocator>
3779 return value_.FindMember(name);
3781#if RAPIDJSON_HAS_STDSTRING
3784 return value_.FindMember(name);
3797#if RAPIDJSON_HAS_STDSTRING
3801 value_.AddMember(name,
value, allocator);
3805 template <
typename T>
3810 value_.AddMember(name,
value, allocator);
3813#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
3816 value_.AddMember(name,
value, allocator);
3845 template <
typename T>
3855#if RAPIDJSON_HAS_STDSTRING
3856 bool RemoveMember(
const std::basic_string<Ch>& name)
const {
return value_.RemoveMember(name); }
3858 template <
typename SourceAllocator>
3861 return value_.RemoveMember(name);
3867 return value_.EraseMember(first, last);
3870#if RAPIDJSON_HAS_STDSTRING
3871 bool EraseMember(
const std::basic_string<Ch>& name)
const
3876 template <
typename SourceAllocator>
3879 return value_.EraseMember(name);
3882#if RAPIDJSON_HAS_CXX11_RANGE_FOR
3896#ifdef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
3897#pragma pop_macro("GetObject")
3898#undef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
T * Malloc(A &a, size_t n=1)
Definition allocators.h:479
T * Realloc(A &a, T *old_p, size_t old_n, size_t new_n)
Definition allocators.h:471
Helper class for accessing Value of array type.
Definition document.h:3621
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(const GenericArray &)) PushBack(T value
const ValueType * ConstValueIterator
Definition document.h:3628
GenericArray PushBack(ValueType &value, AllocatorType &allocator) const
Definition document.h:3656
ValueIterator End() const
Definition document.h:3650
ValueIterator Begin() const
Definition document.h:3649
void Clear() const
Definition document.h:3647
SizeType Size() const
Definition document.h:3644
GenericArray< false, ValueType > Array
Definition document.h:3624
GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const
Definition document.h:3651
GenericArray & operator=(const GenericArray &rhs)
Definition document.h:3636
GenericArray< true, ValueType > ConstArray
Definition document.h:3623
friend class GenericValue
Definition document.h:3633
ValueType::StringRefType StringRefType
Definition document.h:3630
internal::MaybeAddConst< Const, PlainType >::Type ValueType
Definition document.h:3626
~GenericArray()
Definition document.h:3641
GenericArray(const GenericArray &rhs)
Definition document.h:3635
SizeType Capacity() const
Definition document.h:3645
ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const
Definition document.h:3688
GenericArray PushBack(StringRefType value, AllocatorType &allocator) const
Definition document.h:3668
ValueType PlainType
Definition document.h:3625
ValueIterator Erase(ConstValueIterator pos) const
Definition document.h:3687
bool Empty() const
Definition document.h:3646
ValueType::AllocatorType AllocatorType
Definition document.h:3629
ValueType & operator[](SizeType index) const
Definition document.h:3648
ValueType * ValueIterator
Definition document.h:3627
GenericArray PopBack() const
Definition document.h:3682
A document for parsing JSON text as DOM.
Definition document.h:3143
friend void swap(GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
Definition document.h:3271
Allocator & GetAllocator()
Get the allocator of this document.
Definition document.h:3472
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
Definition document.h:3355
bool EndArray(SizeType elementCount)
Definition document.h:3577
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
Definition document.h:3248
Allocator AllocatorType
Allocator type from template parameter.
Definition document.h:3147
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
Definition document.h:3389
GenericDocument(Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Definition document.h:3157
GenericDocument & Parse(const Ch *str, size_t length)
Parse JSON text from a read-only string (with Encoding conversion).
Definition document.h:3411
bool EndObject(SizeType memberCount)
Definition document.h:3563
StackAllocator StackAllocatorType
StackAllocator type from template parameter.
Definition document.h:3148
bool Bool(bool b)
Definition document.h:3506
bool Uint64(uint64_t i)
Definition document.h:3526
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Definition document.h:3448
bool Uint(unsigned i)
Definition document.h:3516
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
Definition document.h:3329
bool Key(const Ch *str, SizeType length, bool copy)
Definition document.h:3561
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Definition document.h:3177
Encoding::Ch Ch
Character type derived from Encoding.
Definition document.h:3145
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags).
Definition document.h:3340
GenericDocument & Parse(const Ch *str, size_t length)
Parse JSON text from a read-only string (with Encoding conversion).
Definition document.h:3416
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion).
Definition document.h:3306
bool Null()
Definition document.h:3501
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition document.h:3146
friend class GenericValue
Definition document.h:3497
bool Int(int i)
Definition document.h:3511
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion).
Definition document.h:3377
bool Int64(int64_t i)
Definition document.h:3521
bool Double(double d)
Definition document.h:3531
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
Definition document.h:3451
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with kParseDefaultFlags).
Definition document.h:3365
size_t GetStackCapacity() const
Get the capacity of stack in bytes.
Definition document.h:3479
~GenericDocument()
Definition document.h:3205
bool StartObject()
Definition document.h:3555
GenericDocument & Populate(Generator &g)
Populate this document by a generator which produces SAX events.
Definition document.h:3282
bool String(const Ch *str, SizeType length, bool copy)
Definition document.h:3546
bool StartArray()
Definition document.h:3571
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
Definition document.h:3454
GenericDocument & Parse(const typename SourceEncoding::Ch *str, size_t length)
Parse JSON text from a read-only string (with Encoding conversion).
Definition document.h:3400
bool RawNumber(const Ch *str, SizeType length, bool copy)
Definition document.h:3537
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags).
Definition document.h:3397
Name-value pair in a JSON object value.
Definition document.h:122
GenericValue< Encoding, Allocator > name
name of member (must be a string)
Definition document.h:124
GenericValue< Encoding, Allocator > value
value of member.
Definition document.h:125
GenericMember & operator=(GenericMember &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition document.h:145
friend void swap(GenericMember &a, GenericMember &b) RAPIDJSON_NOEXCEPT
Definition document.h:156
(Constant) member iterator for a JSON object value
Definition document.h:194
ValueType & reference
Definition document.h:215
bool operator>(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition document.h:327
bool operator<=(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition document.h:312
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
Definition document.h:249
GenericMemberIterator()
Default constructor (singular value).
Definition document.h:231
Iterator & operator=(const NonConstIterator &it)
Pointer to (const) GenericMember.
Definition document.h:250
Iterator operator-(DifferenceType n) const
Definition document.h:285
std::random_access_iterator_tag iterator_category
Definition document.h:217
Iterator & operator++()
Definition document.h:258
Reference operator[](DifferenceType n) const
raw pointer
Definition document.h:346
Iterator operator--(int)
Definition document.h:274
Iterator operator+(DifferenceType n) const
Definition document.h:284
Reference operator*() const
raw pointer
Definition document.h:344
Iterator & operator+=(DifferenceType n)
Definition document.h:287
ValueType value_type
Definition document.h:213
bool operator==(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition document.h:302
ValueType * pointer
Definition document.h:214
reference Reference
Definition document.h:223
Iterator operator++(int)
Definition document.h:268
friend class GenericMemberIterator
Definition document.h:198
Iterator & operator-=(DifferenceType n)
Definition document.h:292
difference_type DifferenceType
Definition document.h:225
bool operator<(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition document.h:322
bool operator>=(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition document.h:317
Pointer operator->() const
raw pointer
Definition document.h:345
pointer Pointer
Definition document.h:221
GenericMemberIterator Iterator
Iterator type itself.
Definition document.h:205
bool operator!=(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition document.h:307
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Definition document.h:209
DifferenceType operator-(ConstIterator that) const
Distance.
Definition document.h:350
Iterator & operator--()
Definition document.h:263
std::ptrdiff_t difference_type
Definition document.h:216
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
Definition document.h:207
Helper class for accessing Value of object type.
Definition document.h:3712
MemberIterator RemoveMember(MemberIterator m) const
Definition document.h:3863
ValueType::AllocatorType AllocatorType
Definition document.h:3726
GenericObject AddMember(StringRefType name, ValueType &value, AllocatorType &allocator) const
Definition document.h:3835
SizeType MemberCapacity() const
Definition document.h:3744
bool HasMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition document.h:3771
GenericObject(const GenericObject &rhs)
Definition document.h:3734
void RemoveAllMembers()
Definition document.h:3853
MemberIterator FindMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition document.h:3777
T value
Definition document.h:3808
SizeType MemberCount() const
Definition document.h:3743
GenericMemberIterator< Const, typename ValueType::EncodingType, typename ValueType::AllocatorType > MemberIterator
Definition document.h:3721
ValueType & operator[](const GenericValue< EncodingType, SourceAllocator > &name) const
Definition document.h:3752
MemberIterator EraseMember(ConstMemberIterator pos) const
Definition document.h:3864
ValueType & operator[](T *name) const
Definition document.h:3747
GenericObject AddMember(ValueType &name, ValueType &value, AllocatorType &allocator) const
Definition document.h:3787
GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType &allocator) const
Definition document.h:3840
ValueType PlainType
Definition document.h:3716
bool EraseMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition document.h:3877
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const
Definition document.h:3865
MemberIterator MemberEnd() const
Definition document.h:3760
friend class GenericValue
Definition document.h:3732
~GenericObject()
Definition document.h:3740
bool RemoveMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition document.h:3859
internal::MaybeAddConst< Const, PlainType >::Type ValueType
Definition document.h:3717
ValueType::EncodingType EncodingType
Definition document.h:3728
MemberIterator FindMember(const Ch *name) const
Definition document.h:3775
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(ValueType &)) AddMember(ValueType &name
GenericObject & operator=(const GenericObject &rhs)
Definition document.h:3735
bool HasMember(const Ch *name) const
Definition document.h:3766
ValueType::StringRefType StringRefType
Definition document.h:3727
bool ObjectEmpty() const
Definition document.h:3745
ValueType::Ch Ch
Definition document.h:3729
GenericObject AddMember(ValueType &name, StringRefType value, AllocatorType &allocator) const
Definition document.h:3792
GenericObject< false, ValueType > Object
Definition document.h:3715
bool RemoveMember(const Ch *name) const
Definition document.h:3854
GenericObject< true, ValueType > ConstObject
Definition document.h:3714
bool EraseMember(const Ch *name) const
Definition document.h:3869
GenericMemberIterator< true, typename ValueType::EncodingType, typename ValueType::AllocatorType > ConstMemberIterator
Definition document.h:3725
MemberIterator MemberBegin() const
Definition document.h:3759
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(GenericObject)) AddMember(StringRefType name
GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocator) const
Definition document.h:3761
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition reader.h:604
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition document.h:822
GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
Constructor for boolean value.
Definition document.h:946
static RAPIDJSON_FORCEINLINE SizeType DataStringLength(const Data &data)
Assignment with move semantics.
Definition document.h:2666
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition document.h:3060
GenericArray< false, ValueType > Array
Definition document.h:838
void DoCopyMembers(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings)
Assignment with move semantics.
Definition document.h:2993
static const SizeType kDefaultArrayCapacity
Assignment with move semantics.
Definition document.h:2559
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
Assignment with move semantics.
Definition document.h:2683
~GenericValue()
Destructor.
Definition document.h:1075
GenericValue(double d) RAPIDJSON_NOEXCEPT
Constructor for double value.
Definition document.h:1004
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
Definition document.h:3037
static const SizeType kDefaultObjectCapacity
Definition document.h:2560
Encoding EncodingType
Encoding type from template parameter.
Definition document.h:826
static RAPIDJSON_FORCEINLINE const Ch * DataString(const Data &data)
Assignment with move semantics.
Definition document.h:2662
GenericValue & operator=(StringRefType str) RAPIDJSON_NOEXCEPT
Assignment of constant string reference (no copy).
Definition document.h:1142
GenericStringRef< Ch > StringRefType
Reference to a constant string.
Definition document.h:829
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
Definition document.h:831
void DoReserveMembers(SizeType newCapacity, Allocator &allocator)
Assignment with move semantics.
Definition document.h:2872
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
Assignment with move semantics.
Definition document.h:2679
GenericValue< Encoding, Allocator > ValueType
Value type of itself.
Definition document.h:837
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
Definition document.h:836
RAPIDJSON_DISABLEIF_RETURN((internal::IsPointer< T >),(GenericValue &)) operator
Assignment with primitive types.
GenericValue(const Ch *s, SizeType length) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string).
Definition document.h:1018
void DoClearMembers()
Assignment with move semantics.
Definition document.h:2894
GenericObject< true, ValueType > ConstObject
Definition document.h:841
MemberIterator DoFindMember(const GenericValue< Encoding, SourceAllocator > &name)
Assignment with move semantics.
Definition document.h:2885
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
Assignment with move semantics.
Definition document.h:2691
MemberIterator DoRemoveMember(MemberIterator m)
Assignment with move semantics.
Definition document.h:2929
void DoAddMember(GenericValue &name, GenericValue &value, Allocator &allocator)
Assignment with move semantics.
Definition document.h:2910
GenericValue(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
Explicit copy constructor (with allocator).
Definition document.h:903
MemberIterator DoEraseMembers(ConstMemberIterator first, ConstMemberIterator last)
Assignment with move semantics.
Definition document.h:2956
Allocator AllocatorType
Allocator type from template parameter.
Definition document.h:827
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition document.h:825
GenericValue(Type type) RAPIDJSON_NOEXCEPT
Constructor with JSON value type.
Definition document.h:877
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
Assignment with move semantics.
Definition document.h:2687
GenericArray< true, ValueType > ConstArray
Definition document.h:839
void SetArrayRaw(GenericValue *values, SizeType count, Allocator &allocator)
Assignment with move semantics.
Definition document.h:3021
GenericValue(Array a) RAPIDJSON_NOEXCEPT
Constructor for Array.
Definition document.h:1054
GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT
Constructor for int64_t value.
Definition document.h:974
GenericValue(unsigned u) RAPIDJSON_NOEXCEPT
Constructor for unsigned value.
Definition document.h:966
GenericValue(const Ch *s, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string).
Definition document.h:1033
GenericValue(Object o) RAPIDJSON_NOEXCEPT
Constructor for Object.
Definition document.h:1066
GenericValue(const Ch *s, SizeType length, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string).
Definition document.h:1027
void DoFreeMembers()
Assignment with move semantics.
Definition document.h:2901
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
Definition document.h:833
Data data_
Definition document.h:3120
GenericValue(int i) RAPIDJSON_NOEXCEPT
Constructor for int value.
Definition document.h:959
GenericValue() RAPIDJSON_NOEXCEPT
Default constructor creates a null value.
Definition document.h:847
friend class GenericDocument
Assignment with move semantics.
Definition document.h:2515
RAPIDJSON_FORCEINLINE const Ch * SetStringPointer(const Ch *str)
Assignment with move semantics.
Definition document.h:2675
GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string).
Definition document.h:1024
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
Definition document.h:3090
GenericValue(float f) RAPIDJSON_NOEXCEPT
Constructor for float value.
Definition document.h:1011
GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT
Constructor for uint64_t value.
Definition document.h:991
void SetStringRaw(StringRefType s, Allocator &allocator)
Initialize this value as copy string with initial data, without calling destructor.
Definition document.h:3068
bool StringEqual(const GenericValue< Encoding, SourceAllocator > &rhs) const
Assignment with move semantics.
Definition document.h:3098
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition document.h:1117
Encoding::Ch Ch
Character type derived from Encoding.
Definition document.h:828
RAPIDJSON_FORCEINLINE Member * DoAllocMembers(SizeType capacity, Allocator &allocator)
Assignment with move semantics.
Definition document.h:2867
GenericValue * ValueIterator
Value iterator for iterating in array.
Definition document.h:834
GenericObject< false, ValueType > Object
Definition document.h:840
@ kCopyStringFlag
Definition document.h:2550
@ kCopyFlag
Definition document.h:2527
@ kNumberDoubleFlag
Definition document.h:2544
@ kConstStringFlag
Definition document.h:2549
@ kFalseFlag
Definition document.h:2535
@ kDoubleFlag
Definition document.h:2525
@ kTrueFlag
Definition document.h:2534
@ kTypeMask
Definition document.h:2556
@ kUintFlag
Definition document.h:2522
@ kInt64Flag
Definition document.h:2523
@ kNullFlag
Definition document.h:2531
@ kNumberFlag
Definition document.h:2520
@ kNumberUint64Flag
Definition document.h:2542
@ kNumberAnyFlag
Definition document.h:2546
@ kObjectFlag
Definition document.h:2553
@ kBoolFlag
Definition document.h:2519
@ kUint64Flag
Definition document.h:2524
@ kShortStringFlag
Definition document.h:2551
@ kNumberIntFlag
Definition document.h:2536
@ kNumberInt64Flag
Definition document.h:2540
@ kIntFlag
Definition document.h:2521
@ kInlineStrFlag
Definition document.h:2528
@ kNumberUintFlag
Definition document.h:2538
@ kStringFlag
Definition document.h:2526
@ kArrayFlag
Definition document.h:2554
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
Assignment with move semantics.
Definition document.h:2671
void Clear()
Definition stack.h:107
void ShrinkToFit()
Definition stack.h:109
size_t GetSize() const
Definition stack.h:206
Concept for allocating, resizing and freeing memory block.
Concept for encoding of Unicode characters.
__device__ void copy(const SrcTensorType &src_tensor, DstTensorType &dst_tensor)
Perform optimized copy between two tensors partitions (threadwise copy). Tensors must have the same s...
Definition copy.hpp:36
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition document.h:3124
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition document.h:530
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition document.h:3611
const CharType GenericStringRef< CharType >::emptyString[]
Definition document.h:514
GenericPointer< Value, CrtAllocator > Pointer
Definition fwd.h:145
#define RAPIDJSON_DEFAULT_ALLOCATOR
Allows to choose default allocator.
Definition document.h:78
#define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
User defined kDefaultArrayCapacity value.
Definition document.h:111
#define RAPIDJSON_DEFAULT_STACK_ALLOCATOR
Allows to choose default stack allocator for Document.
Definition document.h:89
#define RAPIDJSON_NOEXCEPT_ASSERT(x)
Assertion (in non-throwing contexts).
Definition rapidjson.h:717
#define RAPIDJSON_ALIGN(x)
Data alignment of the machine.
Definition rapidjson.h:313
#define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
User defined kDefaultObjectCapacity value.
Definition document.h:100
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition rapidjson.h:518
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition rapidjson.h:531
#define RAPIDJSON_USE_MEMBERSMAP
Enable RapidJSON support for object members handling in a std::multimap.
Definition rapidjson.h:180
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:451
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition rapidjson.h:124
ParseErrorCode
Error code of parsing.
Definition error.h:65
CK_TILE_HOST_DEVICE constexpr bool operator!=(const array< T, Size > &a, const array< T, Size > &b)
Definition tile/core/container/array.hpp:280
@ Set
Definition ck.hpp:278
@ Empty
Definition blkgemmpipe_scheduler.hpp:46
__host__ __device__ constexpr bool operator==(Sequence< Xs... >, Sequence< Ys... >)
Definition utility/sequence.hpp:649
Definition allocators.h:459
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition swap.h:33
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition strfunc.h:32
const GenericPointer< typename T::ValueType > T2 value
Definition pointer.h:1697
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1517
#define RAPIDJSON_SETPOINTER(type, p, x)
Definition rapidjson.h:363
Type
Type of JSON value.
Definition rapidjson.h:760
@ kFalseType
false
Definition rapidjson.h:762
@ kObjectType
object
Definition rapidjson.h:764
@ kTrueType
true
Definition rapidjson.h:763
@ kStringType
string
Definition rapidjson.h:766
@ kNullType
null
Definition rapidjson.h:761
@ kArrayType
array
Definition rapidjson.h:765
@ kNumberType
number
Definition rapidjson.h:767
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition rapidjson.h:746
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.).
Definition rapidjson.h:429
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition rapidjson.h:326
#define RAPIDJSON_GETPOINTER(type, p)
Definition rapidjson.h:364
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition rapidjson.h:742
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition rapidjson.h:500
@ kParseInsituFlag
In-situ(destructive) parsing.
Definition reader.h:152
unsigned short uint16_t
Definition stdint.h:125
_W64 unsigned int uintptr_t
Definition stdint.h:164
signed __int64 int64_t
Definition stdint.h:135
unsigned __int64 uint64_t
Definition stdint.h:136
A read-write string stream.
Definition stream.h:210
Reference to a constant string (not taking a copy).
Definition document.h:417
CharType Ch
character type of the string
Definition document.h:418
const SizeType length
length of the string (excluding the trailing NULL terminator)
Definition document.h:494
GenericStringRef< CharType > StringRef(const CharType *str, size_t length)
Mark a character pointer as constant string.
Definition document.h:550
GenericStringRef(const CharType *str, SizeType len)
Create constant string reference from pointer and length.
Definition document.h:482
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
Definition document.h:471
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition document.h:530
GenericStringRef(const CharType(&str)[N]) RAPIDJSON_NOEXCEPT
Create string reference from const character array.
Definition document.h:446
GenericStringRef(const GenericStringRef &rhs)
Definition document.h:488
const Ch *const s
plain CharType pointer
Definition document.h:493
Read-only string stream.
Definition stream.h:163
Definition document.h:2645
SizeType capacity
Definition document.h:2647
SizeType size
Definition document.h:2646
GenericValue * elements
Definition document.h:2648
Definition document.h:2563
uint16_t flags
Definition document.h:2571
char payload[sizeof(SizeType) *2+sizeof(void *)+2]
Definition document.h:2569
Definition document.h:2611
int i
Definition document.h:2612
char padding[4]
Definition document.h:2613
Definition document.h:2616
unsigned u
Definition document.h:2617
char padding2[4]
Definition document.h:2618
Definition document.h:2638
Member * members
Definition document.h:2641
SizeType capacity
Definition document.h:2640
SizeType size
Definition document.h:2639
Definition document.h:2591
Ch str[MaxChars]
Definition document.h:2598
SizeType GetLength() const
Definition document.h:2602
static bool Usable(SizeType len)
Definition document.h:2600
@ MaxChars
Definition document.h:2594
@ MaxSize
Definition document.h:2595
@ LenPos
Definition document.h:2596
void SetLength(SizeType len)
Definition document.h:2601
Definition document.h:2575
const Ch * str
Definition document.h:2578
SizeType hashcode
reserved
Definition document.h:2577
SizeType length
Definition document.h:2576
Represents an in-memory input byte stream.
Definition memorystream.h:42
Result of parsing (wraps ParseErrorCode).
Definition error.h:108
Definition document.h:595
Definition document.h:580
Definition allocators.h:462
static bool Is(const ValueType &v)
Definition document.h:613
static ValueType & Set(ValueType &v, bool data, typename ValueType::AllocatorType &)
Definition document.h:616
static ValueType & Set(ValueType &v, bool data)
Definition document.h:615
static bool Get(const ValueType &v)
Definition document.h:614
static StringType Get(const ValueType &v)
Definition document.h:727
static ValueType & Set(ValueType &v, const StringType data)
Definition document.h:728
static ValueType & Set(ValueType &v, const StringType data, typename ValueType::AllocatorType &a)
Definition document.h:732
const ValueType::Ch * StringType
Definition document.h:725
static bool Is(const ValueType &v)
Definition document.h:726
static ValueType & Set(ValueType &v, double data, typename ValueType::AllocatorType &)
Definition document.h:704
static bool Is(const ValueType &v)
Definition document.h:701
static ValueType & Set(ValueType &v, double data)
Definition document.h:703
static double Get(const ValueType &v)
Definition document.h:702
static bool Is(const ValueType &v)
Definition document.h:713
static ValueType & Set(ValueType &v, float data)
Definition document.h:715
static float Get(const ValueType &v)
Definition document.h:714
static ValueType & Set(ValueType &v, float data, typename ValueType::AllocatorType &)
Definition document.h:716
static ValueType & Set(ValueType &v, int64_t data, typename ValueType::AllocatorType &)
Definition document.h:680
static ValueType & Set(ValueType &v, int64_t data)
Definition document.h:679
static bool Is(const ValueType &v)
Definition document.h:677
static int64_t Get(const ValueType &v)
Definition document.h:678
static ValueType & Set(ValueType &v, int data, typename ValueType::AllocatorType &)
Definition document.h:628
static ValueType & Set(ValueType &v, int data)
Definition document.h:627
static int Get(const ValueType &v)
Definition document.h:626
static bool Is(const ValueType &v)
Definition document.h:625
static ArrayType Get(ValueType &v)
Definition document.h:761
static bool Is(const ValueType &v)
Definition document.h:760
static ValueType & Set(ValueType &v, ArrayType data)
Definition document.h:762
static ValueType & Set(ValueType &v, ArrayType data, typename ValueType::AllocatorType &)
Definition document.h:763
ValueType::Array ArrayType
Definition document.h:759
static ArrayType Get(const ValueType &v)
Definition document.h:774
static bool Is(const ValueType &v)
Definition document.h:773
ValueType::ConstArray ArrayType
Definition document.h:772
static bool Is(const ValueType &v)
Definition document.h:794
ValueType::ConstObject ObjectType
Definition document.h:793
static ObjectType Get(const ValueType &v)
Definition document.h:795
static ValueType & Set(ValueType &v, ObjectType data)
Definition document.h:783
static bool Is(const ValueType &v)
Definition document.h:781
ValueType::Object ObjectType
Definition document.h:780
static ObjectType Get(ValueType &v)
Definition document.h:782
static ValueType & Set(ValueType &v, ObjectType data, typename ValueType::AllocatorType &)
Definition document.h:784
static uint64_t Get(const ValueType &v)
Definition document.h:690
static bool Is(const ValueType &v)
Definition document.h:689
static ValueType & Set(ValueType &v, uint64_t data, typename ValueType::AllocatorType &)
Definition document.h:692
static ValueType & Set(ValueType &v, uint64_t data)
Definition document.h:691
static ValueType & Set(ValueType &v, unsigned data)
Definition document.h:639
static unsigned Get(const ValueType &v)
Definition document.h:638
static bool Is(const ValueType &v)
Definition document.h:637
static ValueType & Set(ValueType &v, unsigned data, typename ValueType::AllocatorType &)
Definition document.h:640
Definition document.h:607
Definition document.h:2652
Number n
Definition document.h:2655
ShortString ss
Definition document.h:2654
String s
Definition document.h:2653
Flag f
Definition document.h:2658
ArrayData a
Definition document.h:2657
ObjectData o
Definition document.h:2656
Definition document.h:2608
struct GenericValue::Number::I i
uint64_t u64
Definition document.h:2633
struct GenericValue::Number::U u
double d
Definition document.h:2634
int64_t i64
Definition document.h:2632