16#ifndef RAPIDJSON_DOCUMENT_H_
17#define RAPIDJSON_DOCUMENT_H_
22#include "internal/meta.h"
23#include "internal/strfunc.h"
24#include "memorystream.h"
25#include "encodedstream.h"
31RAPIDJSON_DIAG_OFF(padded)
32RAPIDJSON_DIAG_OFF(
switch-
enum)
33RAPIDJSON_DIAG_OFF(c++98-compat)
34#elif defined(_MSC_VER)
35RAPIDJSON_DIAG_OFF(4127)
36RAPIDJSON_DIAG_OFF(4244)
40RAPIDJSON_DIAG_OFF(effc++)
43#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
47#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
54template <
typename Encoding,
typename Allocator>
57template <
typename Encoding,
typename Allocator,
typename StackAllocator>
66template <
typename Encoding,
typename Allocator>
72#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
75 :
name(std::move(rhs.name)),
76 value(std::move(rhs.value))
100 a.value.Swap(b.value);
111#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
132template <
bool Const,
typename Encoding,
typename Allocator>
139 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
151 typedef ValueType value_type;
152 typedef ValueType * pointer;
153 typedef ValueType & reference;
154 typedef std::ptrdiff_t difference_type;
155 typedef std::random_access_iterator_tag iterator_category;
238template <
bool Const,
typename Encoding,
typename Allocator>
242template <
typename Encoding,
typename Allocator>
248template <
typename Encoding,
typename Allocator>
286template<
typename CharType>
341 :
s(str),
length(NotNullStrLen(str)) {}
358 operator const Ch *()
const {
return s; }
364 SizeType NotNullStrLen(
const CharType* str) {
366 return internal::StrLen(str);
379template<
typename CharType>
394template<
typename CharType>
414template<
typename CharType>
419#if RAPIDJSON_HAS_STDSTRING
432template<
typename CharType>
442template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
447 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>
::Type {};
459template <
typename ValueType,
typename T>
462template<
typename ValueType>
464 static bool Is(
const ValueType& v) {
return v.IsBool(); }
465 static bool Get(
const ValueType& v) {
return v.GetBool(); }
466 static ValueType& Set(ValueType& v,
bool data) {
return v.SetBool(data); }
467 static ValueType& Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&) {
return v.SetBool(data); }
470template<
typename ValueType>
472 static bool Is(
const ValueType& v) {
return v.IsInt(); }
473 static int Get(
const ValueType& v) {
return v.GetInt(); }
474 static ValueType& Set(ValueType& v,
int data) {
return v.SetInt(data); }
475 static ValueType& Set(ValueType& v,
int data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
478template<
typename ValueType>
480 static bool Is(
const ValueType& v) {
return v.IsUint(); }
481 static unsigned Get(
const ValueType& v) {
return v.GetUint(); }
482 static ValueType& Set(ValueType& v,
unsigned data) {
return v.SetUint(data); }
483 static ValueType& Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
488template<
typename ValueType>
490 static bool Is(
const ValueType& v) {
return v.IsInt(); }
491 static long Get(
const ValueType& v) {
return v.GetInt(); }
492 static ValueType& Set(ValueType& v,
long data) {
return v.SetInt(data); }
493 static ValueType& Set(ValueType& v,
long data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
497template<
typename ValueType>
498struct TypeHelper<ValueType, unsigned long> {
499 static bool Is(
const ValueType& v) {
return v.IsUint(); }
500 static unsigned long Get(
const ValueType& v) {
return v.GetUint(); }
501 static ValueType& Set(ValueType& v,
unsigned long data) {
return v.SetUint(data); }
502 static ValueType& Set(ValueType& v,
unsigned long data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
506template<
typename ValueType>
508 static bool Is(
const ValueType& v) {
return v.IsInt64(); }
509 static int64_t Get(
const ValueType& v) {
return v.GetInt64(); }
510 static ValueType& Set(ValueType& v, int64_t data) {
return v.SetInt64(data); }
511 static ValueType& Set(ValueType& v, int64_t data,
typename ValueType::AllocatorType&) {
return v.SetInt64(data); }
514template<
typename ValueType>
516 static bool Is(
const ValueType& v) {
return v.IsUint64(); }
517 static uint64_t Get(
const ValueType& v) {
return v.GetUint64(); }
518 static ValueType& Set(ValueType& v,
uint64_t data) {
return v.SetUint64(data); }
519 static ValueType& Set(ValueType& v,
uint64_t data,
typename ValueType::AllocatorType&) {
return v.SetUint64(data); }
522template<
typename ValueType>
524 static bool Is(
const ValueType& v) {
return v.IsDouble(); }
525 static double Get(
const ValueType& v) {
return v.GetDouble(); }
526 static ValueType& Set(ValueType& v,
double data) {
return v.SetDouble(data); }
527 static ValueType& Set(ValueType& v,
double data,
typename ValueType::AllocatorType&) {
return v.SetDouble(data); }
530template<
typename ValueType>
532 static bool Is(
const ValueType& v) {
return v.IsFloat(); }
533 static float Get(
const ValueType& v) {
return v.GetFloat(); }
534 static ValueType& Set(ValueType& v,
float data) {
return v.SetFloat(data); }
535 static ValueType& Set(ValueType& v,
float data,
typename ValueType::AllocatorType&) {
return v.SetFloat(data); }
538template<
typename ValueType>
540 typedef const typename ValueType::Ch* StringType;
541 static bool Is(
const ValueType& v) {
return v.IsString(); }
542 static StringType Get(
const ValueType& v) {
return v.GetString(); }
543 static ValueType& Set(ValueType& v,
const StringType data) {
return v.SetString(
typename ValueType::StringRefType(data)); }
544 static ValueType& Set(ValueType& v,
const StringType data,
typename ValueType::AllocatorType& a) {
return v.SetString(data, a); }
547#if RAPIDJSON_HAS_STDSTRING
548template<
typename ValueType>
549struct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch> > {
550 typedef std::basic_string<typename ValueType::Ch> StringType;
551 static bool Is(
const ValueType& v) {
return v.IsString(); }
552 static StringType Get(
const ValueType& v) {
return StringType(v.GetString(), v.GetStringLength()); }
553 static ValueType& Set(ValueType& v,
const StringType& data,
typename ValueType::AllocatorType& a) {
return v.SetString(data, a); }
557template<
typename ValueType>
559 typedef typename ValueType::Array ArrayType;
560 static bool Is(
const ValueType& v) {
return v.IsArray(); }
561 static ArrayType Get(ValueType& v) {
return v.GetArray(); }
562 static ValueType& Set(ValueType& v, ArrayType data) {
return v = data; }
563 static ValueType& Set(ValueType& v, ArrayType data,
typename ValueType::AllocatorType&) {
return v = data; }
566template<
typename ValueType>
567struct TypeHelper<ValueType, typename ValueType::ConstArray> {
568 typedef typename ValueType::ConstArray ArrayType;
569 static bool Is(
const ValueType& v) {
return v.IsArray(); }
570 static ArrayType Get(
const ValueType& v) {
return v.GetArray(); }
573template<
typename ValueType>
575 typedef typename ValueType::Object ObjectType;
576 static bool Is(
const ValueType& v) {
return v.IsObject(); }
577 static ObjectType Get(ValueType& v) {
return v.GetObject(); }
578 static ValueType& Set(ValueType& v, ObjectType data) {
return v = data; }
579 static ValueType& Set(ValueType& v, ObjectType data,
typename ValueType::AllocatorType&) {
return v = data; }
582template<
typename ValueType>
583struct TypeHelper<ValueType, typename ValueType::ConstObject> {
584 typedef typename ValueType::ConstObject ObjectType;
585 static bool Is(
const ValueType& v) {
return v.IsObject(); }
586 static ObjectType Get(
const ValueType& v) {
return v.GetObject(); }
608template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
615 typedef typename Encoding::Ch
Ch;
631 GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; }
633#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
636 rhs.data_.f.flags = kNullFlag;
644#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
646 template <
typename StackAllocator>
650 template <
typename StackAllocator>
662 static const uint16_t defaultFlags[] = {
663 kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kShortStringFlag,
667 data_.f.flags = defaultFlags[type];
671 data_.ss.SetLength(0);
682 template <
typename SourceAllocator>
684 switch (rhs.GetType()) {
689 for (
SizeType i = 0; i < count; i++) {
693 data_.f.flags = kObjectFlag;
694 data_.o.size = data_.o.capacity = count;
695 SetMembersPointer(lm);
702 for (
SizeType i = 0; i < count; i++)
703 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
704 data_.f.flags = kArrayFlag;
705 data_.a.size = data_.a.capacity = count;
706 SetElementsPointer(le);
710 if (rhs.data_.f.flags == kConstStringFlag && !copyConstStrings) {
711 data_.f.flags = rhs.data_.f.flags;
712 data_ = *
reinterpret_cast<const Data*
>(&rhs.data_);
718 data_.f.flags = rhs.data_.f.flags;
719 data_ = *
reinterpret_cast<const Data*
>(&rhs.data_);
730#ifndef RAPIDJSON_DOXYGEN_RUNNING
731 template <
typename T>
732 explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT
739 data_.f.flags = b ? kTrueFlag : kFalseFlag;
745 data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;
751 data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
757 data_.f.flags = kNumberInt64Flag;
759 data_.f.flags |= kNumberUint64Flag;
761 data_.f.flags |= kUintFlag;
763 data_.f.flags |= kIntFlag;
766 data_.f.flags |= kIntFlag;
772 data_.f.flags = kNumberUint64Flag;
774 data_.f.flags |= kInt64Flag;
776 data_.f.flags |= kUintFlag;
778 data_.f.flags |= kIntFlag;
782 explicit GenericValue(
double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d = d; data_.f.flags = kNumberDoubleFlag; }
785 explicit GenericValue(
float f) RAPIDJSON_NOEXCEPT : data_() { data_.n.d =
static_cast<double>(f); data_.f.flags = kNumberDoubleFlag; }
799#if RAPIDJSON_HAS_STDSTRING
813 a.value_.data_ =
Data();
814 a.value_.data_.f.flags = kArrayFlag;
824 o.value_.data_ =
Data();
825 o.value_.data_.f.flags = kObjectFlag;
832 if (Allocator::kNeedFree) {
833 switch(data_.f.flags) {
846 Allocator::Free(GetMembersPointer());
849 case kCopyStringFlag:
850 Allocator::Free(
const_cast<Ch*
>(GetStringPointer()));
875#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
878 return *
this = rhs.Move();
904 template <
typename T>
918 template <
typename SourceAllocator>
920 RAPIDJSON_ASSERT(
static_cast<void*
>(
this) !=
static_cast<void const*
>(&rhs));
922 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
935 other.RawAssign(temp);
955 GenericValue& Move() RAPIDJSON_NOEXCEPT {
return *
this; }
965 template <
typename SourceAllocator>
968 if (GetType() != rhs.GetType())
973 if (data_.o.size != rhs.data_.o.size)
975 for (
ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
976 typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
977 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
983 if (data_.a.size != rhs.data_.a.size)
985 for (
SizeType i = 0; i < data_.a.size; i++)
986 if ((*
this)[i] != rhs[i])
991 return StringEqual(rhs);
994 if (IsDouble() || rhs.IsDouble()) {
995 double a = GetDouble();
996 double b = rhs.GetDouble();
997 return a >= b && a <= b;
1000 return data_.n.u64 == rhs.data_.n.u64;
1010#if RAPIDJSON_HAS_STDSTRING
1014 bool operator==(
const std::basic_string<Ch>& rhs)
const {
return *
this ==
GenericValue(
StringRef(rhs)); }
1025 template <
typename SourceAllocator>
1029 bool operator!=(
const Ch* rhs)
const {
return !(*
this == rhs); }
1050 Type GetType()
const {
return static_cast<Type>(data_.f.flags & kTypeMask); }
1051 bool IsNull()
const {
return data_.f.flags == kNullFlag; }
1052 bool IsFalse()
const {
return data_.f.flags == kFalseFlag; }
1053 bool IsTrue()
const {
return data_.f.flags == kTrueFlag; }
1054 bool IsBool()
const {
return (data_.f.flags & kBoolFlag) != 0; }
1055 bool IsObject()
const {
return data_.f.flags == kObjectFlag; }
1056 bool IsArray()
const {
return data_.f.flags == kArrayFlag; }
1057 bool IsNumber()
const {
return (data_.f.flags & kNumberFlag) != 0; }
1058 bool IsInt()
const {
return (data_.f.flags & kIntFlag) != 0; }
1059 bool IsUint()
const {
return (data_.f.flags & kUintFlag) != 0; }
1060 bool IsInt64()
const {
return (data_.f.flags & kInt64Flag) != 0; }
1061 bool IsUint64()
const {
return (data_.f.flags & kUint64Flag) != 0; }
1062 bool IsDouble()
const {
return (data_.f.flags & kDoubleFlag) != 0; }
1063 bool IsString()
const {
return (data_.f.flags & kStringFlag) != 0; }
1066 bool IsLosslessDouble()
const {
1067 if (!IsNumber())
return false;
1070 volatile double d =
static_cast<double>(u);
1072 && (d < static_cast<double>((std::numeric_limits<uint64_t>::max)()))
1073 && (u ==
static_cast<uint64_t>(d));
1076 int64_t i = GetInt64();
1077 volatile double d =
static_cast<double>(i);
1078 return (d >=
static_cast<double>((std::numeric_limits<int64_t>::min)()))
1079 && (d <
static_cast<double>((std::numeric_limits<int64_t>::max)()))
1080 && (i ==
static_cast<int64_t
>(d));
1086 bool IsFloat()
const {
1087 if ((data_.f.flags & kDoubleFlag) == 0)
1089 double d = GetDouble();
1090 return d >= -3.4028234e38 && d <= 3.4028234e38;
1093 bool IsLosslessFloat()
const {
1094 if (!IsNumber())
return false;
1095 double a = GetDouble();
1096 if (a <
static_cast<double>(-(std::numeric_limits<float>::max)())
1097 || a >
static_cast<double>((std::numeric_limits<float>::max)()))
1099 double b =
static_cast<double>(
static_cast<float>(a));
1100 return a >= b && a <= b;
1115 bool GetBool()
const {
RAPIDJSON_ASSERT(IsBool());
return data_.f.flags == kTrueFlag; }
1136 bool ObjectEmpty()
const {
RAPIDJSON_ASSERT(IsObject());
return data_.o.size == 0; }
1147 template <
typename T>
1152 template <
typename T>
1164 template <
typename SourceAllocator>
1167 if (member != MemberEnd())
1168 return member->value;
1181 template <
typename SourceAllocator>
1184#if RAPIDJSON_HAS_STDSTRING
1211 if (newCapacity > data_.o.capacity) {
1212 SetMembersPointer(
reinterpret_cast<Member*
>(allocator.Realloc(GetMembersPointer(), data_.o.capacity *
sizeof(
Member), newCapacity *
sizeof(
Member))));
1213 data_.o.capacity = newCapacity;
1226 bool HasMember(
const Ch* name)
const {
return FindMember(name) != MemberEnd(); }
1228#if RAPIDJSON_HAS_STDSTRING
1237 bool HasMember(
const std::basic_string<Ch>& name)
const {
return FindMember(name) != MemberEnd(); }
1249 template <
typename SourceAllocator>
1266 return FindMember(n);
1284 template <
typename SourceAllocator>
1289 for ( ; member != MemberEnd(); ++member)
1290 if (name.StringEqual(member->name))
1296#if RAPIDJSON_HAS_STDSTRING
1322 ObjectData& o = data_.o;
1323 if (o.size >= o.capacity)
1324 MemberReserve(o.capacity == 0 ? kDefaultObjectCapacity : (o.capacity + (o.capacity + 1) / 2), allocator);
1325 Member* members = GetMembersPointer();
1326 members[o.size].name.RawAssign(name);
1327 members[o.size].value.RawAssign(value);
1343 return AddMember(name, v, allocator);
1346#if RAPIDJSON_HAS_STDSTRING
1358 return AddMember(name, v, allocator);
1379 template <
typename T>
1383 return AddMember(name, v, allocator);
1386#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1388 return AddMember(name, value, allocator);
1391 return AddMember(name, value, allocator);
1394 return AddMember(name, value, allocator);
1398 return AddMember(n, value, allocator);
1415 return AddMember(n, value, allocator);
1429 return AddMember(name, v, allocator);
1449 template <
typename T>
1453 return AddMember(n, value, allocator);
1460 void RemoveAllMembers() {
1475 bool RemoveMember(
const Ch* name) {
1477 return RemoveMember(n);
1480#if RAPIDJSON_HAS_STDSTRING
1481 bool RemoveMember(
const std::basic_string<Ch>& name) {
return RemoveMember(
GenericValue(
StringRef(name))); }
1484 template <
typename SourceAllocator>
1487 if (m != MemberEnd()) {
1510 if (data_.o.size > 1 && m != last)
1528 return EraseMember(pos, pos +1);
1551 std::memmove(
static_cast<void*
>(&*pos), &*last,
static_cast<size_t>(MemberEnd() - last) *
sizeof(
Member));
1552 data_.o.size -=
static_cast<SizeType>(last - first);
1561 bool EraseMember(
const Ch* name) {
1563 return EraseMember(n);
1566#if RAPIDJSON_HAS_STDSTRING
1567 bool EraseMember(
const std::basic_string<Ch>& name) {
return EraseMember(
GenericValue(
StringRef(name))); }
1570 template <
typename SourceAllocator>
1573 if (m != MemberEnd()) {
1582 ConstObject GetObject()
const {
RAPIDJSON_ASSERT(IsObject());
return ConstObject(*
this); }
1600 bool Empty()
const {
RAPIDJSON_ASSERT(IsArray());
return data_.a.size == 0; }
1622 return GetElementsPointer()[index];
1647 if (newCapacity > data_.a.capacity) {
1649 data_.a.capacity = newCapacity;
1666 if (data_.a.size >= data_.a.capacity)
1667 Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2), allocator);
1668 GetElementsPointer()[data_.a.size++].
RawAssign(value);
1672#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1674 return PushBack(value, allocator);
1688 return (*this).template PushBack<StringRefType>(value, allocator);
1708 template <
typename T>
1710 PushBack(T value,
Allocator& allocator) {
1712 return PushBack(v, allocator);
1734 return Erase(pos, pos + 1);
1755 std::memmove(
static_cast<void*
>(pos), last,
static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
1756 data_.a.size -=
static_cast<SizeType>(last - first);
1761 ConstArray GetArray()
const {
RAPIDJSON_ASSERT(IsArray());
return ConstArray(*
this); }
1768 int GetInt()
const {
RAPIDJSON_ASSERT(data_.f.flags & kIntFlag);
return data_.n.i.i; }
1769 unsigned GetUint()
const {
RAPIDJSON_ASSERT(data_.f.flags & kUintFlag);
return data_.n.u.u; }
1770 int64_t GetInt64()
const {
RAPIDJSON_ASSERT(data_.f.flags & kInt64Flag);
return data_.n.i64; }
1776 double GetDouble()
const {
1778 if ((data_.f.flags & kDoubleFlag) != 0)
return data_.n.d;
1779 if ((data_.f.flags & kIntFlag) != 0)
return data_.n.i.i;
1780 if ((data_.f.flags & kUintFlag) != 0)
return data_.n.u.u;
1781 if ((data_.f.flags & kInt64Flag) != 0)
return static_cast<double>(data_.n.i64);
1782 RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0);
return static_cast<double>(data_.n.u64);
1788 float GetFloat()
const {
1789 return static_cast<float>(GetDouble());
1804 const Ch* GetString()
const {
RAPIDJSON_ASSERT(IsString());
return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer(); }
1809 SizeType GetStringLength()
const {
RAPIDJSON_ASSERT(IsString());
return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength()) : data_.s.length); }
1854#if RAPIDJSON_HAS_STDSTRING
1874 template <
typename T>
1877 template <
typename T>
1880 template <
typename T>
1883 template<
typename T>
1886 template<
typename T>
1898 template <
typename Handler>
1899 bool Accept(
Handler& handler)
const {
1903 case kTrueType:
return handler.Bool(
true);
1910 if (
RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0)))
1915 return handler.EndObject(data_.o.size);
1923 return handler.EndArray(data_.a.size);
1926 return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0);
1930 if (IsDouble())
return handler.Double(data_.n.d);
1931 else if (IsInt())
return handler.Int(data_.n.i.i);
1932 else if (IsUint())
return handler.Uint(data_.n.u.u);
1933 else if (IsInt64())
return handler.Int64(data_.n.i64);
1934 else return handler.Uint64(data_.n.u64);
1939 template <
typename,
typename>
friend class GenericValue;
1944 kNumberFlag = 0x0010,
1947 kInt64Flag = 0x0080,
1948 kUint64Flag = 0x0100,
1949 kDoubleFlag = 0x0200,
1950 kStringFlag = 0x0400,
1952 kInlineStrFlag = 0x1000,
1958 kNumberIntFlag =
kNumberType | kNumberFlag | kIntFlag | kInt64Flag,
1959 kNumberUintFlag =
kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag,
1960 kNumberInt64Flag =
kNumberType | kNumberFlag | kInt64Flag,
1961 kNumberUint64Flag =
kNumberType | kNumberFlag | kUint64Flag,
1962 kNumberDoubleFlag =
kNumberType | kNumberFlag | kDoubleFlag,
1963 kNumberAnyFlag =
kNumberType | kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag,
1965 kCopyStringFlag =
kStringType | kStringFlag | kCopyFlag,
1966 kShortStringFlag =
kStringType | kStringFlag | kCopyFlag | kInlineStrFlag,
1973 static const SizeType kDefaultArrayCapacity = 16;
1974 static const SizeType kDefaultObjectCapacity = 16;
1977#if RAPIDJSON_48BITPOINTER_OPTIMIZATION
1978 char payload[
sizeof(
SizeType) * 2 + 6];
1979#elif RAPIDJSON_64BIT
1980 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 6];
1982 char payload[
sizeof(
SizeType) * 2 +
sizeof(
void*) + 2];
2002 enum { MaxChars =
sizeof(
static_cast<Flag*
>(0)->payload) /
sizeof(
Ch), MaxSize = MaxChars - 1, LenPos = MaxSize };
2005 inline static bool Usable(
SizeType len) {
return (MaxSize >= len); }
2006 inline void SetLength(
SizeType len) { str[LenPos] =
static_cast<Ch>(MaxSize - len); }
2007 inline SizeType GetLength()
const {
return static_cast<SizeType>(MaxSize - str[LenPos]); }
2012#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN
2057 RAPIDJSON_FORCEINLINE
const Ch* GetStringPointer()
const {
return RAPIDJSON_GETPOINTER(
Ch, data_.s.str); }
2058 RAPIDJSON_FORCEINLINE
const Ch* SetStringPointer(
const Ch* str) {
return RAPIDJSON_SETPOINTER(
Ch, data_.s.str, str); }
2059 RAPIDJSON_FORCEINLINE
GenericValue* GetElementsPointer()
const {
return RAPIDJSON_GETPOINTER(
GenericValue, data_.a.elements); }
2061 RAPIDJSON_FORCEINLINE
Member* GetMembersPointer()
const {
return RAPIDJSON_GETPOINTER(
Member, data_.o.members); }
2062 RAPIDJSON_FORCEINLINE
Member* SetMembersPointer(
Member* members) {
return RAPIDJSON_SETPOINTER(
Member, data_.o.members, members); }
2066 data_.f.flags = kArrayFlag;
2069 SetElementsPointer(e);
2070 std::memcpy(
static_cast<void*
>(e), values, count *
sizeof(
GenericValue));
2073 SetElementsPointer(0);
2074 data_.a.size = data_.a.capacity = count;
2079 data_.f.flags = kObjectFlag;
2082 SetMembersPointer(m);
2083 std::memcpy(
static_cast<void*
>(m), members, count *
sizeof(
Member));
2086 SetMembersPointer(0);
2087 data_.o.size = data_.o.capacity = count;
2092 data_.f.flags = kConstStringFlag;
2093 SetStringPointer(s);
2094 data_.s.length = s.length;
2100 if (ShortString::Usable(s.
length)) {
2101 data_.f.flags = kShortStringFlag;
2102 data_.ss.SetLength(s.
length);
2105 data_.f.flags = kCopyStringFlag;
2106 data_.s.length = s.
length;
2107 str =
static_cast<Ch *
>(allocator.Malloc((s.
length + 1) *
sizeof(
Ch)));
2108 SetStringPointer(str);
2110 std::memcpy(str, s, s.
length *
sizeof(
Ch));
2118 rhs.data_.f.flags = kNullFlag;
2121 template <
typename SourceAllocator>
2126 const SizeType len1 = GetStringLength();
2127 const SizeType len2 = rhs.GetStringLength();
2128 if(len1 != len2) {
return false; }
2130 const Ch*
const str1 = GetString();
2131 const Ch*
const str2 = rhs.GetString();
2132 if(str1 == str2) {
return true; }
2134 return (std::memcmp(str1, str2,
sizeof(
Ch) * len1) == 0);
2154template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>,
typename StackAllocator = CrtAllocator>
2157 typedef typename Encoding::Ch
Ch;
2182 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2188#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2191 :
ValueType(std::forward<ValueType>(rhs)),
2192 allocator_(rhs.allocator_),
2193 ownAllocator_(rhs.ownAllocator_),
2194 stack_(std::move(rhs.stack_)),
2195 parseResult_(rhs.parseResult_)
2198 rhs.ownAllocator_ = 0;
2207#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2218 allocator_ = rhs.allocator_;
2219 ownAllocator_ = rhs.ownAllocator_;
2220 stack_ = std::move(rhs.stack_);
2221 parseResult_ = rhs.parseResult_;
2224 rhs.ownAllocator_ = 0;
2238 ValueType::Swap(rhs);
2239 stack_.Swap(rhs.stack_);
2240 internal::Swap(allocator_, rhs.allocator_);
2241 internal::Swap(ownAllocator_, rhs.ownAllocator_);
2242 internal::Swap(parseResult_, rhs.parseResult_);
2248 using ValueType::Swap;
2269 template <
typename Generator>
2289 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
2292 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2294 parseResult_ = reader.template Parse<parseFlags>(is, *
this);
2308 template <
unsigned parseFlags,
typename InputStream>
2310 return ParseStream<parseFlags, Encoding, InputStream>(is);
2318 template <
typename InputStream>
2320 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2332 template <
unsigned parseFlags>
2335 return ParseStream<parseFlags | kParseInsituFlag>(s);
2343 return ParseInsitu<kParseDefaultFlags>(str);
2355 template <
unsigned parseFlags,
typename SourceEncoding>
2359 return ParseStream<parseFlags, SourceEncoding>(s);
2366 template <
unsigned parseFlags>
2368 return Parse<parseFlags, Encoding>(str);
2375 return Parse<kParseDefaultFlags>(str);
2378 template <
unsigned parseFlags,
typename SourceEncoding>
2381 MemoryStream ms(
reinterpret_cast<const char*
>(str), length *
sizeof(
typename SourceEncoding::Ch));
2383 ParseStream<parseFlags, SourceEncoding>(is);
2387 template <
unsigned parseFlags>
2389 return Parse<parseFlags, Encoding>(str, length);
2393 return Parse<kParseDefaultFlags>(str, length);
2396#if RAPIDJSON_HAS_STDSTRING
2397 template <
unsigned parseFlags,
typename SourceEncoding>
2400 return Parse<parseFlags, SourceEncoding>(str.c_str());
2403 template <
unsigned parseFlags>
2405 return Parse<parseFlags, Encoding>(str.c_str());
2409 return Parse<kParseDefaultFlags>(str);
2464 template <
typename,
typename>
friend class GenericValue;
2468 bool Null() {
new (stack_.template Push<ValueType>())
ValueType();
return true; }
2469 bool Bool(
bool b) {
new (stack_.template Push<ValueType>())
ValueType(b);
return true; }
2470 bool Int(
int i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2471 bool Uint(
unsigned i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2472 bool Int64(int64_t i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2473 bool Uint64(
uint64_t i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2474 bool Double(
double d) {
new (stack_.template Push<ValueType>())
ValueType(d);
return true; }
2476 bool RawNumber(
const Ch* str,
SizeType length,
bool copy) {
2480 new (stack_.template Push<ValueType>())
ValueType(str, length);
2484 bool String(
const Ch* str,
SizeType length,
bool copy) {
2488 new (stack_.template Push<ValueType>())
ValueType(str, length);
2492 bool StartObject() {
new (stack_.template Push<ValueType>())
ValueType(
kObjectType);
return true; }
2494 bool Key(
const Ch* str,
SizeType length,
bool copy) {
return String(str, length, copy); }
2496 bool EndObject(
SizeType memberCount) {
2497 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2498 stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount,
GetAllocator());
2502 bool StartArray() {
new (stack_.template Push<ValueType>())
ValueType(
kArrayType);
return true; }
2504 bool EndArray(
SizeType elementCount) {
2505 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2506 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount,
GetAllocator());
2517 if (Allocator::kNeedFree)
2518 while (stack_.GetSize() > 0)
2519 (stack_.template Pop<ValueType>(1))->~
ValueType();
2522 stack_.ShrinkToFit();
2529 static const size_t kDefaultStackCapacity = 1024;
2544template <
bool Const,
typename ValueT>
2549 typedef ValueT PlainType;
2550 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
2551 typedef ValueType* ValueIterator;
2552 typedef const ValueT* ConstValueIterator;
2553 typedef typename ValueType::AllocatorType AllocatorType;
2554 typedef typename ValueType::StringRefType StringRefType;
2556 template <
typename,
typename>
2563 SizeType Size()
const {
return value_.Size(); }
2564 SizeType Capacity()
const {
return value_.Capacity(); }
2565 bool Empty()
const {
return value_.Empty(); }
2566 void Clear()
const { value_.Clear(); }
2567 ValueType& operator[](
SizeType index)
const {
return value_[index]; }
2568 ValueIterator Begin()
const {
return value_.Begin(); }
2569 ValueIterator End()
const {
return value_.End(); }
2570 GenericArray Reserve(
SizeType newCapacity, AllocatorType &allocator)
const { value_.Reserve(newCapacity, allocator);
return *
this; }
2571 GenericArray PushBack(ValueType& value, AllocatorType& allocator)
const { value_.PushBack(value, allocator);
return *
this; }
2572#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2573 GenericArray PushBack(ValueType&& value, AllocatorType& allocator)
const { value_.PushBack(value, allocator);
return *
this; }
2575 GenericArray PushBack(StringRefType value, AllocatorType& allocator)
const { value_.PushBack(value, allocator);
return *
this; }
2576 template <
typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,
internal::IsGenericValue<T> >), (
const GenericArray&)) PushBack(T value, AllocatorType& allocator)
const { value_.PushBack(value, allocator);
return *
this; }
2577 GenericArray PopBack()
const { value_.PopBack();
return *
this; }
2578 ValueIterator Erase(ConstValueIterator pos)
const {
return value_.Erase(pos); }
2579 ValueIterator Erase(ConstValueIterator first, ConstValueIterator last)
const {
return value_.Erase(first, last); }
2581#if RAPIDJSON_HAS_CXX11_RANGE_FOR
2582 ValueIterator begin()
const {
return value_.Begin(); }
2583 ValueIterator end()
const {
return value_.End(); }
2597template <
bool Const,
typename ValueT>
2602 typedef ValueT PlainType;
2603 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
2606 typedef typename ValueType::AllocatorType AllocatorType;
2607 typedef typename ValueType::StringRefType StringRefType;
2608 typedef typename ValueType::EncodingType EncodingType;
2609 typedef typename ValueType::Ch Ch;
2611 template <
typename,
typename>
2618 SizeType MemberCount()
const {
return value_.MemberCount(); }
2619 SizeType MemberCapacity()
const {
return value_.MemberCapacity(); }
2620 bool ObjectEmpty()
const {
return value_.ObjectEmpty(); }
2621 template <
typename T> ValueType& operator[](T* name)
const {
return value_[name]; }
2623#if RAPIDJSON_HAS_STDSTRING
2624 ValueType& operator[](
const std::basic_string<Ch>& name)
const {
return value_[name]; }
2626 MemberIterator MemberBegin()
const {
return value_.MemberBegin(); }
2628 GenericObject MemberReserve(
SizeType newCapacity, AllocatorType &allocator)
const { value_.MemberReserve(newCapacity, allocator);
return *
this; }
2629 bool HasMember(
const Ch* name)
const {
return value_.HasMember(name); }
2630#if RAPIDJSON_HAS_STDSTRING
2631 bool HasMember(
const std::basic_string<Ch>& name)
const {
return value_.HasMember(name); }
2634 MemberIterator FindMember(
const Ch* name)
const {
return value_.FindMember(name); }
2636#if RAPIDJSON_HAS_STDSTRING
2637 MemberIterator FindMember(
const std::basic_string<Ch>& name)
const {
return value_.FindMember(name); }
2639 GenericObject AddMember(ValueType& name, ValueType& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2640 GenericObject AddMember(ValueType& name, StringRefType value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2641#if RAPIDJSON_HAS_STDSTRING
2642 GenericObject AddMember(ValueType& name, std::basic_string<Ch>& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2644 template <
typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,
internal::IsGenericValue<T> >), (ValueType&)) AddMember(ValueType& name, T value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2645#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2646 GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2647 GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2648 GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2649 GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2651 GenericObject AddMember(StringRefType name, ValueType& value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2652 GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2653 template <
typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,
internal::IsGenericValue<T> >), (
GenericObject)) AddMember(StringRefType name, T value, AllocatorType& allocator)
const { value_.AddMember(name, value, allocator);
return *
this; }
2654 void RemoveAllMembers() { value_.RemoveAllMembers(); }
2655 bool RemoveMember(
const Ch* name)
const {
return value_.RemoveMember(name); }
2656#if RAPIDJSON_HAS_STDSTRING
2657 bool RemoveMember(
const std::basic_string<Ch>& name)
const {
return value_.RemoveMember(name); }
2663 bool EraseMember(
const Ch* name)
const {
return value_.EraseMember(name); }
2664#if RAPIDJSON_HAS_STDSTRING
2665 bool EraseMember(
const std::basic_string<Ch>& name)
const {
return EraseMember(ValueType(
StringRef(name))); }
2669#if RAPIDJSON_HAS_CXX11_RANGE_FOR
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Helper class for accessing Value of array type.
A document for parsing JSON text as DOM.
friend void swap(GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
Allocator & GetAllocator()
Get the allocator of this document.
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
Allocator AllocatorType
Allocator type from template parameter.
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
GenericDocument(Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
GenericDocument(const GenericDocument &)
Prohibit copying.
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Encoding::Ch Ch
Character type derived from Encoding.
GenericDocument & operator=(const GenericDocument &)
Prohibit assignment.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags)
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with kParseDefaultFlags)
size_t GetStackCapacity() const
Get the capacity of stack in bytes.
GenericDocument & Populate(Generator &g)
Populate this document by a generator which produces SAX events.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags)
(Constant) member iterator for a JSON object value
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
GenericMemberIterator()
Default constructor (singular value)
GenericMemberIterator(Pointer p)
Internal constructor from plain pointer.
reference Reference
Reference to (const) GenericMember.
difference_type DifferenceType
Signed integer type (e.g. ptrdiff_t)
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
pointer Pointer
Pointer to (const) GenericMember.
GenericMemberIterator Iterator
Iterator type itself.
DifferenceType operator-(ConstIterator that) const
Distance.
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
Name-value pair in a JSON object value.
GenericValue< Encoding, Allocator > name
name of member (must be a string)
GenericValue< Encoding, Allocator > value
value of member.
GenericMember(const GenericMember &rhs)
Copy constructor is not permitted.
GenericMember & operator=(GenericMember &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Helper class for accessing Value of object type.
Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
Constructor for boolean value.
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
~GenericValue()
Destructor.
GenericValue(double d) RAPIDJSON_NOEXCEPT
Constructor for double value.
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
Encoding EncodingType
Encoding type from template parameter.
GenericValue & operator=(StringRefType str) RAPIDJSON_NOEXCEPT
Assignment of constant string reference (no copy)
GenericStringRef< Ch > StringRefType
Reference to a constant string.
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
GenericValue< Encoding, Allocator > ValueType
Value type of itself.
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
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)
GenericValue(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
Explicit copy constructor (with allocator)
Allocator AllocatorType
Allocator type from template parameter.
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
GenericValue(Type type) RAPIDJSON_NOEXCEPT
Constructor with JSON value type.
GenericValue(Array a) RAPIDJSON_NOEXCEPT
Constructor for Array.
GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT
Constructor for int64_t value.
GenericValue(unsigned u) RAPIDJSON_NOEXCEPT
Constructor for unsigned value.
GenericValue(const Ch *s, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
GenericValue(Object o) RAPIDJSON_NOEXCEPT
Constructor for Object.
GenericValue(const Ch *s, SizeType length, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
GenericValue(int i) RAPIDJSON_NOEXCEPT
Constructor for int value.
GenericValue() RAPIDJSON_NOEXCEPT
Default constructor creates a null value.
GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
GenericValue(const GenericValue &rhs)
Copy constructor is not permitted.
GenericValue(float f) RAPIDJSON_NOEXCEPT
Constructor for float value.
GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT
Constructor for uint64_t value.
void SetStringRaw(StringRefType s, Allocator &allocator)
Initialize this value as copy string with initial data, without calling destructor.
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Encoding::Ch Ch
Character type derived from Encoding.
GenericValue * ValueIterator
Value iterator for iterating in array.
A type-unsafe stack for storing different types of data.
Concept for allocating, resizing and freeing memory block.
Concept for encoding of Unicode characters.
Concept for receiving events from GenericReader upon parsing. The functions return true if no error o...
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
#define RAPIDJSON_NOEXCEPT_ASSERT(x)
Assertion (in non-throwing contexts).
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
ParseErrorCode
Error code of parsing.
void swap(UniqueArray< T > &v1, UniqueArray< T > &v2)
Échange les valeurs de v1 et v2.
#define RAPIDJSON_DELETE(x)
! customization point for global delete
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
@ kParseInsituFlag
In-situ(destructive) parsing.
A read-write string stream.
Reference to a constant string (not taking a copy)
GenericStringRef & operator=(const GenericStringRef &rhs)
Copy assignment operator not permitted - immutable type.
CharType Ch
character type of the string
const SizeType length
length of the string (excluding the trailing NULL terminator)
GenericStringRef< CharType > StringRef(const CharType *str, size_t length)
Mark a character pointer as constant string.
GenericStringRef(const CharType *str, SizeType len)
Create constant string reference from pointer and length.
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
GenericStringRef(const CharType(&str)[N]) RAPIDJSON_NOEXCEPT
Create string reference from const character array.
GenericStringRef(CharType(&str)[N])
Disallow construction from non-const array.
const Ch *const s
plain CharType pointer
static const Ch emptyString[]
Empty string - used when passing in a NULL pointer.
SizeType hashcode
reserved
Represents an in-memory input byte stream.
Result of parsing (wraps ParseErrorCode)
ParseErrorCode Code() const
Get the error code.
bool IsError() const
Whether the result is an error.
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.