15#ifndef RAPIDJSON_DOCUMENT_H_
16#define RAPIDJSON_DOCUMENT_H_
30RAPIDJSON_DIAG_OFF(padded)
31RAPIDJSON_DIAG_OFF(
switch-
enum)
32RAPIDJSON_DIAG_OFF(c++98-compat)
33#elif defined(_MSC_VER)
34RAPIDJSON_DIAG_OFF(4127)
35RAPIDJSON_DIAG_OFF(4244)
39RAPIDJSON_DIAG_OFF(effc++)
41RAPIDJSON_DIAG_OFF(terminate)
45#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
49#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
56template <
typename Encoding,
typename Allocator>
59template <
typename Encoding,
typename Allocator,
typename StackAllocator>
68template <
typename Encoding,
typename Allocator>
77#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
98template <
bool Const,
typename Encoding,
typename Allocator>
105 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
204template <
bool Const,
typename Encoding,
typename Allocator>
208template <
typename Encoding,
typename Allocator>
211 typedef GenericMember<Encoding,Allocator>*
Iterator;
214template <
typename Encoding,
typename Allocator>
217 typedef const GenericMember<Encoding,Allocator>*
Iterator;
252template<
typename CharType>
307 :
s(str),
length(NotNullStrLen(str)) {}
324 operator const Ch *()
const {
return s; }
330 SizeType NotNullStrLen(
const CharType* str) {
345template<
typename CharType>
346const CharType GenericStringRef<CharType>::emptyString[] = { CharType() };
360template<
typename CharType>
380template<
typename CharType>
385#if RAPIDJSON_HAS_STDSTRING
398template<
typename CharType>
408template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
413 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>
::Type {};
425template <
typename ValueType,
typename T>
428template<
typename ValueType>
430 static bool Is(
const ValueType& v) {
return v.IsBool(); }
431 static bool Get(
const ValueType& v) {
return v.GetBool(); }
432 static ValueType&
Set(ValueType& v,
bool data) {
return v.SetBool(data); }
433 static ValueType&
Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&) {
return v.SetBool(data); }
436template<
typename ValueType>
438 static bool Is(
const ValueType& v) {
return v.IsInt(); }
439 static int Get(
const ValueType& v) {
return v.GetInt(); }
440 static ValueType&
Set(ValueType& v,
int data) {
return v.SetInt(data); }
441 static ValueType&
Set(ValueType& v,
int data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
444template<
typename ValueType>
446 static bool Is(
const ValueType& v) {
return v.IsUint(); }
447 static unsigned Get(
const ValueType& v) {
return v.GetUint(); }
448 static ValueType&
Set(ValueType& v,
unsigned data) {
return v.SetUint(data); }
449 static ValueType&
Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
454template<
typename ValueType>
455struct TypeHelper<ValueType, long> {
456 static bool Is(
const ValueType& v) {
return v.IsInt(); }
457 static long Get(
const ValueType& v) {
return v.GetInt(); }
458 static ValueType& Set(ValueType& v,
long data) {
return v.SetInt(data); }
459 static ValueType& Set(ValueType& v,
long data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
463template<
typename ValueType>
465 static bool Is(
const ValueType& v) {
return v.IsUint(); }
466 static unsigned long Get(
const ValueType& v) {
return v.GetUint(); }
467 static ValueType& Set(ValueType& v,
unsigned long data) {
return v.SetUint(data); }
468 static ValueType& Set(ValueType& v,
unsigned long data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
472template<
typename ValueType>
474 static bool Is(
const ValueType& v) {
return v.IsInt64(); }
475 static int64_t Get(
const ValueType& v) {
return v.GetInt64(); }
476 static ValueType&
Set(ValueType& v,
int64_t data) {
return v.SetInt64(data); }
477 static ValueType&
Set(ValueType& v,
int64_t data,
typename ValueType::AllocatorType&) {
return v.SetInt64(data); }
480template<
typename ValueType>
482 static bool Is(
const ValueType& v) {
return v.IsUint64(); }
484 static ValueType&
Set(ValueType& v,
uint64_t data) {
return v.SetUint64(data); }
485 static ValueType&
Set(ValueType& v,
uint64_t data,
typename ValueType::AllocatorType&) {
return v.SetUint64(data); }
488template<
typename ValueType>
490 static bool Is(
const ValueType& v) {
return v.IsDouble(); }
491 static double Get(
const ValueType& v) {
return v.GetDouble(); }
492 static ValueType&
Set(ValueType& v,
double data) {
return v.SetDouble(data); }
493 static ValueType&
Set(ValueType& v,
double data,
typename ValueType::AllocatorType&) {
return v.SetDouble(data); }
496template<
typename ValueType>
498 static bool Is(
const ValueType& v) {
return v.IsFloat(); }
499 static float Get(
const ValueType& v) {
return v.GetFloat(); }
500 static ValueType&
Set(ValueType& v,
float data) {
return v.SetFloat(data); }
501 static ValueType&
Set(ValueType& v,
float data,
typename ValueType::AllocatorType&) {
return v.SetFloat(data); }
504template<
typename ValueType>
507 static bool Is(
const ValueType& v) {
return v.IsString(); }
509 static ValueType&
Set(ValueType& v,
const StringType data) {
return v.SetString(
typename ValueType::StringRefType(data)); }
510 static ValueType&
Set(ValueType& v,
const StringType data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data,
a); }
513#if RAPIDJSON_HAS_STDSTRING
514template<
typename ValueType>
515struct TypeHelper<ValueType,
std::basic_string<typename ValueType::Ch> > {
516 typedef std::basic_string<typename ValueType::Ch> StringType;
517 static bool Is(
const ValueType& v) {
return v.IsString(); }
518 static StringType Get(
const ValueType& v) {
return StringType(v.GetString(), v.GetStringLength()); }
519 static ValueType& Set(ValueType& v,
const StringType& data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data,
a); }
523template<
typename ValueType>
526 static bool Is(
const ValueType& v) {
return v.IsArray(); }
528 static ValueType&
Set(ValueType& v,
ArrayType data) {
return v = data; }
529 static ValueType&
Set(ValueType& v,
ArrayType data,
typename ValueType::AllocatorType&) {
return v = data; }
532template<
typename ValueType>
533struct TypeHelper<ValueType, typename ValueType::ConstArray> {
535 static bool Is(
const ValueType& v) {
return v.IsArray(); }
539template<
typename ValueType>
542 static bool Is(
const ValueType& v) {
return v.IsObject(); }
545 static ValueType&
Set(ValueType& v,
ObjectType data,
typename ValueType::AllocatorType&) {
return v = data; }
548template<
typename ValueType>
549struct TypeHelper<ValueType, typename ValueType::ConstObject> {
551 static bool Is(
const ValueType& v) {
return v.IsObject(); }
574template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
581 typedef typename Encoding::Ch
Ch;
599#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
610#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
612 template <
typename StackAllocator>
616 template <
typename StackAllocator>
628 static const uint16_t defaultFlags[7] = {
633 data_.f.flags = defaultFlags[type];
637 data_.ss.SetLength(0);
648 template <
typename SourceAllocator>
650 switch (rhs.GetType()) {
655 for (
SizeType i = 0; i < count; i++) {
668 for (
SizeType i = 0; i < count; i++)
669 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
678 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
685 data_ = *
reinterpret_cast<const Data*
>(&rhs.
data_);
696#ifndef RAPIDJSON_DOXYGEN_RUNNING
697 template <
typename T>
698 explicit GenericValue(
T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT
765#if RAPIDJSON_HAS_STDSTRING
779 a.value_.data_ = Data();
790 o.value_.data_ = Data();
798 if (Allocator::kNeedFree) {
799 switch(
data_.f.flags) {
840#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
843 return *
this = rhs.Move();
869 template <
typename T>
883 template <
typename SourceAllocator>
885 RAPIDJSON_ASSERT(
static_cast<void*
>(
this) !=
static_cast<void const*
>(&rhs));
887 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
900 other.RawAssign(temp);
920 GenericValue& Move() RAPIDJSON_NOEXCEPT {
return *
this; }
930 template <
typename SourceAllocator>
933 if (GetType() != rhs.GetType())
940 for (
ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
941 typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
942 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
951 if ((*
this)[i] != rhs[i])
959 if (IsDouble() || rhs.IsDouble()) {
960 double a = GetDouble();
961 double b = rhs.GetDouble();
962 return a >= b &&
a <= b;
975#if RAPIDJSON_HAS_STDSTRING
990 template <
typename SourceAllocator>
994 bool operator!=(
const Ch* rhs)
const {
return !(*
this == rhs); }
1023 bool IsInt()
const {
return (
data_.f.flags &
kIntFlag) != 0; }
1031 bool IsLosslessDouble()
const {
1032 if (!IsNumber())
return false;
1035 volatile double d =
static_cast<double>(u);
1037 && (d < static_cast<double>((std::numeric_limits<uint64_t>::max)()))
1038 && (u ==
static_cast<uint64_t>(d));
1042 volatile double d =
static_cast<double>(i);
1043 return (d >=
static_cast<double>((std::numeric_limits<int64_t>::min)()))
1044 && (d < static_cast<double>((std::numeric_limits<int64_t>::max)()))
1045 && (i ==
static_cast<int64_t>(d));
1051 bool IsFloat()
const {
1054 double d = GetDouble();
1055 return d >= -3.4028234e38 && d <= 3.4028234e38;
1058 bool IsLosslessFloat()
const {
1059 if (!IsNumber())
return false;
1060 double a = GetDouble();
1061 if (
a <
static_cast<double>(-(std::numeric_limits<float>::max)())
1062 ||
a >
static_cast<double>((std::numeric_limits<float>::max)()))
1064 double b =
static_cast<double>(
static_cast<float>(
a));
1065 return a >= b &&
a <= b;
1112 template <
typename T>
1117 template <
typename T>
1129 template <
typename SourceAllocator>
1132 if (member != MemberEnd())
1133 return member->value;
1146 template <
typename SourceAllocator>
1149#if RAPIDJSON_HAS_STDSTRING
1176 if (newCapacity >
data_.o.capacity) {
1178 data_.o.capacity = newCapacity;
1191 bool HasMember(
const Ch* name)
const {
return FindMember(name) != MemberEnd(); }
1193#if RAPIDJSON_HAS_STDSTRING
1202 bool HasMember(
const std::basic_string<Ch>& name)
const {
return FindMember(name) != MemberEnd(); }
1214 template <
typename SourceAllocator>
1231 return FindMember(n);
1249 template <
typename SourceAllocator>
1254 for ( ; member != MemberEnd(); ++member)
1255 if (
name.StringEqual(member->name))
1261#if RAPIDJSON_HAS_STDSTRING
1288 if (o.size >= o.capacity)
1289 MemberReserve(o.capacity == 0 ?
kDefaultObjectCapacity : (o.capacity + (o.capacity + 1) / 2), allocator);
1291 members[o.size].name.RawAssign(name);
1292 members[o.size].value.RawAssign(
value);
1308 return AddMember(name, v, allocator);
1311#if RAPIDJSON_HAS_STDSTRING
1323 return AddMember(name, v, allocator);
1344 template <
typename T>
1348 return AddMember(name, v, allocator);
1351#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1353 return AddMember(name,
value, allocator);
1356 return AddMember(name,
value, allocator);
1359 return AddMember(name,
value, allocator);
1363 return AddMember(n,
value, allocator);
1380 return AddMember(n,
value, allocator);
1394 return AddMember(name, v, allocator);
1414 template <
typename T>
1418 return AddMember(n,
value, allocator);
1425 void RemoveAllMembers() {
1440 bool RemoveMember(
const Ch* name) {
1442 return RemoveMember(n);
1445#if RAPIDJSON_HAS_STDSTRING
1446 bool RemoveMember(
const std::basic_string<Ch>& name) {
return RemoveMember(
GenericValue(
StringRef(name))); }
1449 template <
typename SourceAllocator>
1452 if (m != MemberEnd()) {
1475 if (
data_.o.size > 1 && m != last)
1493 return EraseMember(pos, pos +1);
1516 std::memmove(&*pos, &*last,
static_cast<size_t>(MemberEnd() - last) *
sizeof(
Member));
1526 bool EraseMember(
const Ch* name) {
1528 return EraseMember(n);
1531#if RAPIDJSON_HAS_STDSTRING
1532 bool EraseMember(
const std::basic_string<Ch>& name) {
return EraseMember(
GenericValue(
StringRef(name))); }
1535 template <
typename SourceAllocator>
1538 if (m != MemberEnd()) {
1612 if (newCapacity >
data_.a.capacity) {
1614 data_.a.capacity = newCapacity;
1637#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1639 return PushBack(
value, allocator);
1653 return (*this).template PushBack<StringRefType>(
value, allocator);
1673 template <
typename T>
1675 PushBack(
T value, Allocator& allocator) {
1677 return PushBack(v, allocator);
1699 return Erase(pos, pos + 1);
1719 itr->~GenericValue();
1720 std::memmove(pos, last,
static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
1741 double GetDouble()
const {
1753 float GetFloat()
const {
1754 return static_cast<float>(GetDouble());
1819#if RAPIDJSON_HAS_STDSTRING
1827 GenericValue& SetString(
const std::basic_string<Ch>& s, Allocator& allocator) {
return SetString(
StringRef(s), allocator); }
1839 template <
typename T>
1840 bool Is()
const {
return internal::TypeHelper<ValueType, T>::Is(*
this); }
1842 template <
typename T>
1843 T Get()
const {
return internal::TypeHelper<ValueType, T>::Get(*
this); }
1845 template <
typename T>
1846 T Get() {
return internal::TypeHelper<ValueType, T>::Get(*
this); }
1848 template<
typename T>
1849 ValueType& Set(
const T& data) {
return internal::TypeHelper<ValueType, T>::Set(*
this, data); }
1851 template<
typename T>
1852 ValueType& Set(
const T& data,
AllocatorType& allocator) {
return internal::TypeHelper<ValueType, T>::Set(*
this, data, allocator); }
1863 template <
typename Handler>
1864 bool Accept(Handler& handler)
const {
1868 case kTrueType:
return handler.Bool(
true);
1880 return handler.EndObject(
data_.o.size);
1888 return handler.EndArray(
data_.a.size);
1891 return handler.String(GetString(), GetStringLength(), (
data_.f.flags &
kCopyFlag) != 0);
1895 if (IsDouble())
return handler.Double(
data_.n.d);
1896 else if (IsInt())
return handler.Int(
data_.n.i.i);
1897 else if (IsUint())
return handler.Uint(
data_.n.u.u);
1898 else if (IsInt64())
return handler.Int64(
data_.n.i64);
1899 else return handler.Uint64(
data_.n.u64);
1904 template <
typename,
typename>
friend class GenericValue;
1942#if RAPIDJSON_48BITPOINTER_OPTIMIZATION
1944#elif RAPIDJSON_64BIT
1977#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN
2036#if defined(__GNUC__) && __GNUC__ >= 8
2037RAPIDJSON_DIAG_OFF(
class-memaccess)
2054#if defined(__GNUC__) && __GNUC__ >= 8
2055RAPIDJSON_DIAG_OFF(
class-memaccess)
2057 std::memcpy(m, members, count *
sizeof(
Member));
2069 data_.s.length = s.length;
2082 str =
static_cast<Ch *
>(allocator.Malloc((s.
length + 1) *
sizeof(
Ch)));
2085 std::memcpy(str, s, s.
length *
sizeof(
Ch));
2096 template <
typename SourceAllocator>
2101 const SizeType len1 = GetStringLength();
2102 const SizeType len2 = rhs.GetStringLength();
2103 if(len1 != len2) {
return false; }
2105 const Ch*
const str1 = GetString();
2106 const Ch*
const str2 = rhs.GetString();
2107 if(str1 == str2) {
return true; }
2109 return (std::memcmp(str1, str2,
sizeof(
Ch) * len1) == 0);
2129template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>,
typename StackAllocator = CrtAllocator>
2132 typedef typename Encoding::Ch
Ch;
2157 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2163#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2166 :
ValueType(std::forward<ValueType>(rhs)),
2167 allocator_(rhs.allocator_),
2168 ownAllocator_(rhs.ownAllocator_),
2169 stack_(std::move(rhs.stack_)),
2170 parseResult_(rhs.parseResult_)
2173 rhs.ownAllocator_ = 0;
2182#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2193 allocator_ = rhs.allocator_;
2194 ownAllocator_ = rhs.ownAllocator_;
2195 stack_ = std::move(rhs.stack_);
2196 parseResult_ = rhs.parseResult_;
2199 rhs.ownAllocator_ = 0;
2213 ValueType::Swap(rhs);
2214 stack_.Swap(rhs.stack_);
2223 using ValueType::Swap;
2244 template <
typename Generator>
2246 ClearStackOnExit scope(*
this);
2264 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
2267 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2268 ClearStackOnExit scope(*
this);
2283 template <
unsigned parseFlags,
typename InputStream>
2293 template <
typename InputStream>
2307 template <
unsigned parseFlags>
2330 template <
unsigned parseFlags,
typename SourceEncoding>
2341 template <
unsigned parseFlags>
2353 template <
unsigned parseFlags,
typename SourceEncoding>
2356 MemoryStream ms(
reinterpret_cast<const char*
>(str), length *
sizeof(
typename SourceEncoding::Ch));
2362 template <
unsigned parseFlags>
2371#if RAPIDJSON_HAS_STDSTRING
2372 template <
unsigned parseFlags,
typename SourceEncoding>
2378 template <
unsigned parseFlags>
2428 struct ClearStackOnExit {
2430 ~ClearStackOnExit() { d_.ClearStack(); }
2432 ClearStackOnExit(
const ClearStackOnExit&);
2433 ClearStackOnExit& operator=(
const ClearStackOnExit&);
2443 bool Null() {
new (stack_.template Push<ValueType>())
ValueType();
return true; }
2444 bool Bool(
bool b) {
new (stack_.template Push<ValueType>())
ValueType(b);
return true; }
2445 bool Int(
int i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2446 bool Uint(
unsigned i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2449 bool Double(
double d) {
new (stack_.template Push<ValueType>())
ValueType(d);
return true; }
2455 new (stack_.template Push<ValueType>())
ValueType(str, length);
2463 new (stack_.template Push<ValueType>())
ValueType(str, length);
2472 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2473 stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount,
GetAllocator());
2480 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2481 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount,
GetAllocator());
2492 if (Allocator::kNeedFree)
2494 (stack_.template Pop<ValueType>(1))->~
ValueType();
2504 static const size_t kDefaultStackCapacity = 1024;
2505 Allocator* allocator_;
2506 Allocator* ownAllocator_;
2507 internal::Stack<StackAllocator> stack_;
2508 ParseResult parseResult_;
2519template <
bool Const,
typename ValueT>
2525 typedef typename internal::MaybeAddConst<Const,PlainType>::Type
ValueType;
2531 template <
typename,
typename>
2540 bool Empty()
const {
return value_.Empty(); }
2547#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2556#if RAPIDJSON_HAS_CXX11_RANGE_FOR
2572template <
bool Const,
typename ValueT>
2578 typedef typename internal::MaybeAddConst<Const,PlainType>::Type
ValueType;
2584 typedef typename ValueType::Ch
Ch;
2586 template <
typename,
typename>
2598#if RAPIDJSON_HAS_STDSTRING
2604 bool HasMember(
const Ch* name)
const {
return value_.HasMember(name); }
2605#if RAPIDJSON_HAS_STDSTRING
2606 bool HasMember(
const std::basic_string<Ch>& name)
const {
return value_.HasMember(name); }
2611#if RAPIDJSON_HAS_STDSTRING
2616#if RAPIDJSON_HAS_STDSTRING
2620#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2631#if RAPIDJSON_HAS_STDSTRING
2632 bool RemoveMember(
const std::basic_string<Ch>& name)
const {
return value_.RemoveMember(name); }
2639#if RAPIDJSON_HAS_STDSTRING
2644#if RAPIDJSON_HAS_CXX11_RANGE_FOR
connection< TProtocol > & operator=(const connection< TProtocol > &obj)
Helper class for accessing Value of array type.
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(const GenericArray &)) PushBack(T value
const ValueType * ConstValueIterator
GenericArray PushBack(ValueType &value, AllocatorType &allocator) const
ValueIterator End() const
ValueIterator Begin() const
GenericArray< false, ValueType > Array
GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const
GenericArray & operator=(const GenericArray &rhs)
GenericArray< true, ValueType > ConstArray
friend class GenericValue
ValueType::StringRefType StringRefType
internal::MaybeAddConst< Const, PlainType >::Type ValueType
GenericArray(const GenericArray &rhs)
SizeType Capacity() const
ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const
GenericArray PushBack(StringRefType value, AllocatorType &allocator) const
ValueIterator Erase(ConstValueIterator pos) const
ValueType::AllocatorType AllocatorType
ValueType & operator[](SizeType index) const
ValueType * ValueIterator
GenericArray PopBack() const
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.
bool EndArray(SizeType elementCount)
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.
GenericDocument & Parse(const Ch *str, size_t length)
bool EndObject(SizeType memberCount)
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
bool Key(const Ch *str, SizeType length, bool copy)
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Encoding::Ch Ch
Character type derived from Encoding.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags).
GenericDocument & Parse(const Ch *str, size_t length)
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion).
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
friend class GenericValue
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.
bool String(const Ch *str, SizeType length, bool copy)
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
GenericDocument & Parse(const typename SourceEncoding::Ch *str, size_t length)
bool RawNumber(const Ch *str, SizeType length, bool copy)
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags).
(Constant) member iterator for a JSON object value
bool operator==(ConstIterator that) const
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
GenericMemberIterator()
Default constructor (singular value).
bool operator!=(ConstIterator that) const
Iterator & operator=(const NonConstIterator &it)
Iterator operator-(DifferenceType n) const
std::random_access_iterator_tag iterator_category
Reference operator[](DifferenceType n) const
Iterator operator+(DifferenceType n) const
Reference operator*() const
bool operator<=(ConstIterator that) const
Iterator & operator+=(DifferenceType n)
bool operator>=(ConstIterator that) const
friend class GenericMemberIterator
Iterator & operator-=(DifferenceType n)
difference_type DifferenceType
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Pointer operator->() const
bool operator<(ConstIterator that) const
GenericMemberIterator Iterator
Iterator type itself.
DifferenceType operator-(ConstIterator that) const
Distance.
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
bool operator>(ConstIterator that) const
std::ptrdiff_t difference_type
Helper class for accessing Value of object type.
MemberIterator RemoveMember(MemberIterator m) const
ValueType::AllocatorType AllocatorType
GenericObject AddMember(StringRefType name, ValueType &value, AllocatorType &allocator) const
SizeType MemberCapacity() const
bool HasMember(const GenericValue< EncodingType, SourceAllocator > &name) const
GenericObject(const GenericObject &rhs)
MemberIterator FindMember(const GenericValue< EncodingType, SourceAllocator > &name) const
SizeType MemberCount() const
GenericMemberIterator< Const, typename ValueType::EncodingType, typename ValueType::AllocatorType > MemberIterator
ValueType & operator[](const GenericValue< EncodingType, SourceAllocator > &name) const
MemberIterator EraseMember(ConstMemberIterator pos) const
ValueType & operator[](T *name) const
GenericObject AddMember(ValueType &name, ValueType &value, AllocatorType &allocator) const
GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType &allocator) const
bool EraseMember(const GenericValue< EncodingType, SourceAllocator > &name) const
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const
MemberIterator MemberEnd() const
friend class GenericValue
bool RemoveMember(const GenericValue< EncodingType, SourceAllocator > &name) const
internal::MaybeAddConst< Const, PlainType >::Type ValueType
ValueType::EncodingType EncodingType
MemberIterator FindMember(const Ch *name) const
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(ValueType &)) AddMember(ValueType &name
GenericObject & operator=(const GenericObject &rhs)
bool HasMember(const Ch *name) const
ValueType::StringRefType StringRefType
GenericObject AddMember(ValueType &name, StringRefType value, AllocatorType &allocator) const
GenericObject< false, ValueType > Object
bool RemoveMember(const Ch *name) const
GenericObject< true, ValueType > ConstObject
bool EraseMember(const Ch *name) const
GenericMemberIterator< true, typename ValueType::EncodingType, typename ValueType::AllocatorType > ConstMemberIterator
MemberIterator MemberBegin() const
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(GenericObject)) AddMember(StringRefType name
GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocator) const
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.
GenericArray< false, ValueType > Array
static const SizeType kDefaultArrayCapacity
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
~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.
static const SizeType kDefaultObjectCapacity
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.
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
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).
GenericObject< true, ValueType > ConstObject
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
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.
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
GenericArray< true, ValueType > ConstArray
void SetArrayRaw(GenericValue *values, SizeType count, Allocator &allocator)
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.
friend class GenericDocument
RAPIDJSON_FORCEINLINE const Ch * SetStringPointer(const Ch *str)
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(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.
bool StringEqual(const GenericValue< Encoding, SourceAllocator > &rhs) const
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.
GenericObject< false, ValueType > Object
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
Concept for allocating, resizing and freeing memory block.
Concept for encoding of Unicode characters.
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.
const CharType GenericStringRef< CharType >::emptyString[]
bool operator==(expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
GenericPointer< Value, CrtAllocator > Pointer
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
#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(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
GTEST_API_ bool IsTrue(bool condition)
const GenericPointer< typename T::ValueType > T2 value
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
#define RAPIDJSON_SETPOINTER(type, p, x)
#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_GETPOINTER(type, p)
#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.
unsigned __int64 uint64_t
A read-write string stream.
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.
Reference to a constant string (not taking a copy).
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(const GenericStringRef &rhs)
const Ch *const s
plain CharType pointer
char payload[sizeof(SizeType) *2+sizeof(void *)+2]
SizeType GetLength() const
static bool Usable(SizeType len)
void SetLength(SizeType len)
SizeType hashcode
reserved
Represents an in-memory input byte stream.
Result of parsing (wraps ParseErrorCode).
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, bool data, typename ValueType::AllocatorType &)
static ValueType & Set(ValueType &v, bool data)
static bool Get(const ValueType &v)
static StringType Get(const ValueType &v)
static ValueType & Set(ValueType &v, const StringType data)
static ValueType & Set(ValueType &v, const StringType data, typename ValueType::AllocatorType &a)
const ValueType::Ch * StringType
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, double data, typename ValueType::AllocatorType &)
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, double data)
static double Get(const ValueType &v)
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, float data)
static float Get(const ValueType &v)
static ValueType & Set(ValueType &v, float data, typename ValueType::AllocatorType &)
static ValueType & Set(ValueType &v, int64_t data, typename ValueType::AllocatorType &)
static ValueType & Set(ValueType &v, int64_t data)
static bool Is(const ValueType &v)
static int64_t Get(const ValueType &v)
static ValueType & Set(ValueType &v, int data, typename ValueType::AllocatorType &)
static ValueType & Set(ValueType &v, int data)
static int Get(const ValueType &v)
static bool Is(const ValueType &v)
static ArrayType Get(ValueType &v)
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, ArrayType data)
static ValueType & Set(ValueType &v, ArrayType data, typename ValueType::AllocatorType &)
ValueType::Array ArrayType
static ArrayType Get(const ValueType &v)
static bool Is(const ValueType &v)
ValueType::ConstArray ArrayType
static bool Is(const ValueType &v)
ValueType::ConstObject ObjectType
static ObjectType Get(const ValueType &v)
static ValueType & Set(ValueType &v, ObjectType data)
static bool Is(const ValueType &v)
ValueType::Object ObjectType
static ObjectType Get(ValueType &v)
static ValueType & Set(ValueType &v, ObjectType data, typename ValueType::AllocatorType &)
static uint64_t Get(const ValueType &v)
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, uint64_t data, typename ValueType::AllocatorType &)
static ValueType & Set(ValueType &v, uint64_t data)
static ValueType & Set(ValueType &v, unsigned data)
static unsigned Get(const ValueType &v)
static bool Is(const ValueType &v)
static ValueType & Set(ValueType &v, unsigned data, typename ValueType::AllocatorType &)
bool operator!=(const ec_scalar &a, const ec_scalar &b)
struct GenericValue::Number::I i
struct GenericValue::Number::U u