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++)
42#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
46#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
53template <
typename Encoding,
typename Allocator>
56template <
typename Encoding,
typename Allocator,
typename StackAllocator>
65template <
typename Encoding,
typename Allocator>
73 a.value.Swap(b.value);
80#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
101template <
bool Const,
typename Encoding,
typename Allocator>
108 typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
207template <
bool Const,
typename Encoding,
typename Allocator>
211template <
typename Encoding,
typename Allocator>
217template <
typename Encoding,
typename Allocator>
255template<
typename CharType>
310 :
s(str), length(NotNullStrLen(str)) {}
327 operator const Ch *()
const {
return s; }
333 SizeType NotNullStrLen(
const CharType* str) {
339 static const Ch emptyString[];
348template<
typename CharType>
363template<
typename CharType>
383template<
typename CharType>
388#if RAPIDJSON_HAS_STDSTRING
401template<
typename CharType>
411template <
typename T,
typename Encoding =
void,
typename Allocator =
void>
416 : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>
::Type {};
428template <
typename ValueType,
typename T>
431template<
typename ValueType>
433 static bool Is(
const ValueType& v) {
return v.IsBool(); }
434 static bool Get(
const ValueType& v) {
return v.GetBool(); }
435 static ValueType&
Set(ValueType& v,
bool data) {
return v.SetBool(data); }
436 static ValueType&
Set(ValueType& v,
bool data,
typename ValueType::AllocatorType&) {
return v.SetBool(data); }
439template<
typename ValueType>
441 static bool Is(
const ValueType& v) {
return v.IsInt(); }
442 static int Get(
const ValueType& v) {
return v.GetInt(); }
443 static ValueType&
Set(ValueType& v,
int data) {
return v.SetInt(data); }
444 static ValueType&
Set(ValueType& v,
int data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
447template<
typename ValueType>
449 static bool Is(
const ValueType& v) {
return v.IsUint(); }
450 static unsigned Get(
const ValueType& v) {
return v.GetUint(); }
451 static ValueType&
Set(ValueType& v,
unsigned data) {
return v.SetUint(data); }
452 static ValueType&
Set(ValueType& v,
unsigned data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
457template<
typename ValueType>
458struct TypeHelper<ValueType, long> {
459 static bool Is(
const ValueType& v) {
return v.IsInt(); }
460 static long Get(
const ValueType& v) {
return v.GetInt(); }
461 static ValueType& Set(ValueType& v,
long data) {
return v.SetInt(data); }
462 static ValueType& Set(ValueType& v,
long data,
typename ValueType::AllocatorType&) {
return v.SetInt(data); }
466template<
typename ValueType>
467struct TypeHelper<
ValueType, unsigned long> {
468 static bool Is(
const ValueType& v) {
return v.IsUint(); }
469 static unsigned long Get(
const ValueType& v) {
return v.GetUint(); }
470 static ValueType& Set(ValueType& v,
unsigned long data) {
return v.SetUint(data); }
471 static ValueType& Set(ValueType& v,
unsigned long data,
typename ValueType::AllocatorType&) {
return v.SetUint(data); }
475template<
typename ValueType>
477 static bool Is(
const ValueType& v) {
return v.IsInt64(); }
478 static int64_t Get(
const ValueType& v) {
return v.GetInt64(); }
479 static ValueType&
Set(ValueType& v,
int64_t data) {
return v.SetInt64(data); }
480 static ValueType&
Set(ValueType& v,
int64_t data,
typename ValueType::AllocatorType&) {
return v.SetInt64(data); }
483template<
typename ValueType>
485 static bool Is(
const ValueType& v) {
return v.IsUint64(); }
487 static ValueType&
Set(ValueType& v,
uint64_t data) {
return v.SetUint64(data); }
488 static ValueType&
Set(ValueType& v,
uint64_t data,
typename ValueType::AllocatorType&) {
return v.SetUint64(data); }
491template<
typename ValueType>
493 static bool Is(
const ValueType& v) {
return v.IsDouble(); }
494 static double Get(
const ValueType& v) {
return v.GetDouble(); }
495 static ValueType&
Set(ValueType& v,
double data) {
return v.SetDouble(data); }
496 static ValueType&
Set(ValueType& v,
double data,
typename ValueType::AllocatorType&) {
return v.SetDouble(data); }
499template<
typename ValueType>
501 static bool Is(
const ValueType& v) {
return v.IsFloat(); }
502 static float Get(
const ValueType& v) {
return v.GetFloat(); }
503 static ValueType&
Set(ValueType& v,
float data) {
return v.SetFloat(data); }
504 static ValueType&
Set(ValueType& v,
float data,
typename ValueType::AllocatorType&) {
return v.SetFloat(data); }
507template<
typename ValueType>
510 static bool Is(
const ValueType& v) {
return v.IsString(); }
512 static ValueType&
Set(ValueType& v,
const StringType data) {
return v.SetString(
typename ValueType::StringRefType(data)); }
513 static ValueType&
Set(ValueType& v,
const StringType data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data,
a); }
516#if RAPIDJSON_HAS_STDSTRING
517template<
typename ValueType>
518struct TypeHelper<ValueType,
std::basic_string<typename ValueType::Ch> > {
519 typedef std::basic_string<typename ValueType::Ch> StringType;
520 static bool Is(
const ValueType& v) {
return v.IsString(); }
521 static StringType Get(
const ValueType& v) {
return StringType(v.GetString(), v.GetStringLength()); }
522 static ValueType& Set(ValueType& v,
const StringType& data,
typename ValueType::AllocatorType&
a) {
return v.SetString(data,
a); }
526template<
typename ValueType>
529 static bool Is(
const ValueType& v) {
return v.IsArray(); }
531 static ValueType&
Set(ValueType& v,
ArrayType data) {
return v = data; }
532 static ValueType&
Set(ValueType& v,
ArrayType data,
typename ValueType::AllocatorType&) {
return v = data; }
535template<
typename ValueType>
536struct TypeHelper<ValueType, typename ValueType::ConstArray> {
538 static bool Is(
const ValueType& v) {
return v.IsArray(); }
542template<
typename ValueType>
545 static bool Is(
const ValueType& v) {
return v.IsObject(); }
548 static ValueType&
Set(ValueType& v,
ObjectType data,
typename ValueType::AllocatorType&) {
return v = data; }
551template<
typename ValueType>
552struct TypeHelper<ValueType, typename ValueType::ConstObject> {
554 static bool Is(
const ValueType& v) {
return v.IsObject(); }
577template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<> >
584 typedef typename Encoding::Ch
Ch;
602#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
613#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
615 template <
typename StackAllocator>
619 template <
typename StackAllocator>
631 static const uint16_t defaultFlags[] = {
651 template <
typename SourceAllocator>
653 switch (rhs.GetType()) {
672 new (&le[i])
GenericValue(re[i], allocator, copyConstStrings);
699#ifndef RAPIDJSON_DOXYGEN_RUNNING
700 template <
typename T>
701 explicit GenericValue(
T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT
768#if RAPIDJSON_HAS_STDSTRING
782 a.value_.data_ =
Data();
793 o.value_.data_ =
Data();
801 if (Allocator::kNeedFree) {
844#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
847 return *
this = rhs.Move();
873 template <
typename T>
887 template <
typename SourceAllocator>
889 RAPIDJSON_ASSERT(
static_cast<void*
>(
this) !=
static_cast<void const*
>(&rhs));
891 new (
this)
GenericValue(rhs, allocator, copyConstStrings);
904 other.RawAssign(temp);
924 GenericValue& Move() RAPIDJSON_NOEXCEPT {
return *
this; }
934 template <
typename SourceAllocator>
937 if (GetType() != rhs.GetType())
944 for (
ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
945 typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
946 if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
955 if ((*
this)[i] != rhs[i])
963 if (IsDouble() || rhs.IsDouble()) {
964 double a = GetDouble();
965 double b = rhs.GetDouble();
966 return a >= b &&
a <= b;
979#if RAPIDJSON_HAS_STDSTRING
994 template <
typename SourceAllocator>
998 bool operator!=(
const Ch* rhs)
const {
return !(*
this == rhs); }
1035 bool IsLosslessDouble()
const {
1036 if (!IsNumber())
return false;
1039 volatile double d =
static_cast<double>(u);
1041 && (d < static_cast<double>((std::numeric_limits<uint64_t>::max)()))
1042 && (u ==
static_cast<uint64_t>(d));
1046 volatile double d =
static_cast<double>(i);
1047 return (d >=
static_cast<double>((std::numeric_limits<int64_t>::min)()))
1048 && (d < static_cast<double>((std::numeric_limits<int64_t>::max)()))
1049 && (i ==
static_cast<int64_t>(d));
1055 bool IsFloat()
const {
1058 double d = GetDouble();
1059 return d >= -3.4028234e38 &&
d <= 3.4028234e38;
1062 bool IsLosslessFloat()
const {
1063 if (!IsNumber())
return false;
1064 double a = GetDouble();
1065 if (
a <
static_cast<double>(-(std::numeric_limits<float>::max)())
1066 ||
a >
static_cast<double>((std::numeric_limits<float>::max)()))
1068 double b =
static_cast<double>(
static_cast<float>(
a));
1069 return a >= b &&
a <= b;
1116 template <
typename T>
1121 template <
typename T>
1133 template <
typename SourceAllocator>
1136 if (member != MemberEnd())
1137 return member->value;
1150 template <
typename SourceAllocator>
1153#if RAPIDJSON_HAS_STDSTRING
1195 bool HasMember(
const Ch*
name)
const {
return FindMember(
name) != MemberEnd(); }
1197#if RAPIDJSON_HAS_STDSTRING
1206 bool HasMember(
const std::basic_string<Ch>&
name)
const {
return FindMember(
name) != MemberEnd(); }
1218 template <
typename SourceAllocator>
1235 return FindMember(n);
1253 template <
typename SourceAllocator>
1258 for ( ; member != MemberEnd(); ++member)
1259 if (
name.StringEqual(member->name))
1265#if RAPIDJSON_HAS_STDSTRING
1292 if (o.size >= o.capacity)
1293 MemberReserve(o.capacity == 0 ?
kDefaultObjectCapacity : (o.capacity + (o.capacity + 1) / 2), allocator);
1295 members[o.size].name.RawAssign(
name);
1296 members[o.size].value.RawAssign(
value);
1312 return AddMember(
name, v, allocator);
1315#if RAPIDJSON_HAS_STDSTRING
1327 return AddMember(
name, v, allocator);
1348 template <
typename T>
1352 return AddMember(
name, v, allocator);
1355#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1357 return AddMember(
name,
value, allocator);
1360 return AddMember(
name,
value, allocator);
1363 return AddMember(
name,
value, allocator);
1367 return AddMember(n,
value, allocator);
1384 return AddMember(n,
value, allocator);
1398 return AddMember(
name, v, allocator);
1418 template <
typename T>
1422 return AddMember(n,
value, allocator);
1429 void RemoveAllMembers() {
1444 bool RemoveMember(
const Ch*
name) {
1446 return RemoveMember(n);
1449#if RAPIDJSON_HAS_STDSTRING
1453 template <
typename SourceAllocator>
1456 if (m != MemberEnd()) {
1497 return EraseMember(pos, pos +1);
1520 std::memmove(
static_cast<void*
>(&*pos), &*last,
static_cast<size_t>(MemberEnd() - last) *
sizeof(
Member));
1530 bool EraseMember(
const Ch*
name) {
1532 return EraseMember(n);
1535#if RAPIDJSON_HAS_STDSTRING
1539 template <
typename SourceAllocator>
1542 if (m != MemberEnd()) {
1641#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1643 return PushBack(
value, allocator);
1657 return (*this).template PushBack<StringRefType>(
value, allocator);
1677 template <
typename T>
1681 return PushBack(v, allocator);
1703 return Erase(pos, pos + 1);
1724 std::memmove(
static_cast<void*
>(pos), last,
static_cast<size_t>(End() - last) *
sizeof(
GenericValue));
1745 double GetDouble()
const {
1757 float GetFloat()
const {
1758 return static_cast<float>(GetDouble());
1823#if RAPIDJSON_HAS_STDSTRING
1843 template <
typename T>
1846 template <
typename T>
1849 template <
typename T>
1852 template<
typename T>
1855 template<
typename T>
1867 template <
typename Handler>
1868 bool Accept(
Handler& handler)
const {
1872 case kTrueType:
return handler.Bool(
true);
1899 if (IsDouble())
return handler.Double(
data_.
n.
d);
1900 else if (IsInt())
return handler.Int(
data_.
n.
i.i);
1901 else if (IsUint())
return handler.Uint(
data_.
n.
u.u);
1902 else if (IsInt64())
return handler.Int64(
data_.
n.
i64);
1903 else return handler.Uint64(
data_.
n.
u64);
1908 template <
typename,
typename>
friend class GenericValue;
1946#if RAPIDJSON_48BITPOINTER_OPTIMIZATION
1948#elif RAPIDJSON_64BIT
1981#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN
2052 std::memcpy(
static_cast<void*
>(m), members,
count *
sizeof(
Member));
2076 str =
static_cast<Ch *
>(allocator.Malloc((
s.length + 1) *
sizeof(
Ch)));
2079 std::memcpy(str,
s,
s.length *
sizeof(
Ch));
2080 str[
s.length] =
'\0';
2090 template <
typename SourceAllocator>
2095 const SizeType len1 = GetStringLength();
2096 const SizeType len2 = rhs.GetStringLength();
2097 if(len1 != len2) {
return false; }
2099 const Ch*
const str1 = GetString();
2100 const Ch*
const str2 = rhs.GetString();
2101 if(str1 == str2) {
return true; }
2103 return (std::memcmp(str1, str2,
sizeof(
Ch) * len1) == 0);
2123template <
typename Encoding,
typename Allocator = MemoryPoolAllocator<>,
typename StackAllocator = CrtAllocator>
2126 typedef typename Encoding::Ch
Ch;
2151 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2157#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2160 :
ValueType(std::forward<ValueType>(rhs)),
2161 allocator_(rhs.allocator_),
2162 ownAllocator_(rhs.ownAllocator_),
2163 stack_(std::move(rhs.stack_)),
2164 parseResult_(rhs.parseResult_)
2167 rhs.ownAllocator_ = 0;
2176#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2187 allocator_ = rhs.allocator_;
2188 ownAllocator_ = rhs.ownAllocator_;
2189 stack_ = std::move(rhs.stack_);
2190 parseResult_ = rhs.parseResult_;
2193 rhs.ownAllocator_ = 0;
2207 ValueType::Swap(rhs);
2208 stack_.
Swap(rhs.stack_);
2217 using ValueType::Swap;
2238 template <
typename Generator>
2240 ClearStackOnExit scope(*
this);
2258 template <
unsigned parseFlags,
typename SourceEncoding,
typename InputStream>
2262 ClearStackOnExit scope(*
this);
2277 template <
unsigned parseFlags,
typename InputStream>
2287 template <
typename InputStream>
2301 template <
unsigned parseFlags>
2324 template <
unsigned parseFlags,
typename SourceEncoding>
2335 template <
unsigned parseFlags>
2347 template <
unsigned parseFlags,
typename SourceEncoding>
2350 MemoryStream ms(
reinterpret_cast<const char*
>(str), length *
sizeof(
typename SourceEncoding::Ch));
2356 template <
unsigned parseFlags>
2365#if RAPIDJSON_HAS_STDSTRING
2366 template <
unsigned parseFlags,
typename SourceEncoding>
2372 template <
unsigned parseFlags>
2422 struct ClearStackOnExit {
2424 ~ClearStackOnExit() { d_.ClearStack(); }
2426 ClearStackOnExit(
const ClearStackOnExit&);
2427 ClearStackOnExit& operator=(
const ClearStackOnExit&);
2437 bool Null() {
new (stack_.template Push<ValueType>())
ValueType();
return true; }
2438 bool Bool(
bool b) {
new (stack_.template Push<ValueType>())
ValueType(b);
return true; }
2439 bool Int(
int i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2440 bool Uint(
unsigned i) {
new (stack_.template Push<ValueType>())
ValueType(i);
return true; }
2449 new (stack_.template Push<ValueType>())
ValueType(str, length);
2457 new (stack_.template Push<ValueType>())
ValueType(str, length);
2466 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2467 stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount,
GetAllocator());
2474 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2475 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount,
GetAllocator());
2486 if (Allocator::kNeedFree)
2488 (stack_.template Pop<ValueType>(1))->~
ValueType();
2498 static const size_t kDefaultStackCapacity = 1024;
2513template <
bool Const,
typename ValueT>
2519 typedef typename internal::MaybeAddConst<Const,PlainType>::Type
ValueType;
2525 template <
typename,
typename>
2534 bool Empty()
const {
return value_.Empty(); }
2541#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2550#if RAPIDJSON_HAS_CXX11_RANGE_FOR
2566template <
bool Const,
typename ValueT>
2572 typedef typename internal::MaybeAddConst<Const,PlainType>::Type
ValueType;
2578 typedef typename ValueType::Ch
Ch;
2580 template <
typename,
typename>
2592#if RAPIDJSON_HAS_STDSTRING
2599#if RAPIDJSON_HAS_STDSTRING
2600 bool HasMember(
const std::basic_string<Ch>&
name)
const {
return value_.HasMember(
name); }
2605#if RAPIDJSON_HAS_STDSTRING
2610#if RAPIDJSON_HAS_STDSTRING
2614#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2625#if RAPIDJSON_HAS_STDSTRING
2626 bool RemoveMember(
const std::basic_string<Ch>&
name)
const {
return value_.RemoveMember(
name); }
2633#if RAPIDJSON_HAS_STDSTRING
2638#if RAPIDJSON_HAS_CXX11_RANGE_FOR
Helper class for accessing Value of array type.
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(const GenericArray &)) PushBack(T value
GenericArray PushBack(ValueType &value, AllocatorType &allocator) const
ValueIterator End() const
ValueIterator Begin() const
ValueType::StringRefType StringRefType
internal::MaybeAddConst< Const, PlainType >::Type ValueType
GenericArray< false, ValueT > Array
GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const
GenericArray & operator=(const GenericArray &rhs)
GenericArray< true, ValueT > ConstArray
ValueType * ValueIterator
GenericArray(const GenericArray &rhs)
SizeType Capacity() const
ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const
GenericArray PushBack(StringRefType value, AllocatorType &allocator) const
ValueType::AllocatorType AllocatorType
ValueIterator Erase(ConstValueIterator pos) const
const ValueT * ConstValueIterator
ValueType & operator[](SizeType index) const
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)
Encoding::Ch Ch
Character type derived from Encoding.
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
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.
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)
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)
Allocator AllocatorType
Allocator type from template parameter.
bool RawNumber(const Ch *str, SizeType length, bool copy)
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags)
(Constant) member iterator for a JSON object value
difference_type DifferenceType
Signed integer type (e.g. ptrdiff_t)
bool operator==(ConstIterator that) const
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
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
Reference operator[](DifferenceType n) const
Iterator operator+(DifferenceType n) const
GenericMemberIterator Iterator
Iterator type itself.
Reference operator*() const
bool operator<=(ConstIterator that) const
Iterator & operator+=(DifferenceType n)
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
bool operator>=(ConstIterator that) const
std::random_access_iterator_tag iterator_category
std::ptrdiff_t difference_type
reference Reference
Reference to (const) GenericMember.
friend class GenericMemberIterator
Iterator & operator-=(DifferenceType n)
Pointer operator->() const
bool operator<(ConstIterator that) const
DifferenceType operator-(ConstIterator that) const
Distance.
bool operator>(ConstIterator that) const
pointer Pointer
Pointer to (const) GenericMember.
Helper class for accessing Value of object type.
MemberIterator RemoveMember(MemberIterator m) const
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
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
ValueType::EncodingType EncodingType
internal::MaybeAddConst< Const, PlainType >::Type ValueType
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const
MemberIterator MemberEnd() const
bool RemoveMember(const GenericValue< EncodingType, SourceAllocator > &name) const
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
GenericMemberIterator< Const, typename ValueT::EncodingType, typename ValueT::AllocatorType > MemberIterator
GenericMemberIterator< true, typename ValueT::EncodingType, typename ValueT::AllocatorType > ConstMemberIterator
ValueType::AllocatorType AllocatorType
GenericObject< false, ValueT > Object
GenericObject< true, ValueT > ConstObject
ValueType::StringRefType StringRefType
GenericObject AddMember(ValueType &name, StringRefType value, AllocatorType &allocator) const
bool RemoveMember(const Ch *name) const
bool EraseMember(const Ch *name) const
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
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.
GenericArray< false, ValueType > Array
Encoding EncodingType
Encoding type from template parameter.
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.
static const SizeType kDefaultArrayCapacity
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
~GenericValue()
Destructor.
GenericArray< true, ValueType > ConstArray
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
GenericValue & operator=(StringRefType str) RAPIDJSON_NOEXCEPT
Assignment of constant string reference (no copy)
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Encoding::Ch Ch
Character type derived from Encoding.
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 * ValueIterator
Value iterator for iterating in array.
GenericStringRef< Ch > StringRefType
Reference to a constant string.
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
GenericObject< true, ValueType > ConstObject
GenericValue(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
Explicit copy constructor (with allocator)
Allocator AllocatorType
Allocator type from template parameter.
GenericValue(Type type) RAPIDJSON_NOEXCEPT
Constructor with JSON value type.
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
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< false, Encoding, Allocator >::Iterator MemberIterator
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.
GenericValue< Encoding, Allocator > ValueType
Value type of itself.
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
GenericObject< false, ValueType > Object
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
A type-unsafe stack for storing different types of data.
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT
bool HasAllocator() const
size_t GetCapacity() const
Allocator & GetAllocator()
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.
bool operator!=(const environment &other)
bool operator==(const environment &other)
#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.
bip::allocator< T, pinnable_mapped_file::segment_manager > allocator
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.
void swap(picojson::value &x, picojson::value &y)
GTEST_API_ bool IsTrue(bool condition)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
#define T(meth, val, expected)
#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.
friend void swap(GenericMember &a, GenericMember &b) RAPIDJSON_NOEXCEPT
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)
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.
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)
ValueType::Array ArrayType
static ValueType & Set(ValueType &v, ArrayType data, typename ValueType::AllocatorType &)
ValueType::ConstArray ArrayType
static ArrayType Get(const ValueType &v)
static bool Is(const ValueType &v)
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)
static ObjectType Get(ValueType &v)
ValueType::Object ObjectType
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 &)
struct GenericValue::Number::I i
struct GenericValue::Number::U u