Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
document.h
Go to the documentation of this file.
1 // Tencent is pleased to support the open source community by making RapidJSON available.
2 //
3 // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4 //
5 // Licensed under the MIT License (the "License"); you may not use this file except
6 // in compliance with the License. You may obtain a copy of the License at
7 //
8 // http://opensource.org/licenses/MIT
9 //
10 // Unless required by applicable law or agreed to in writing, software distributed
11 // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 // specific language governing permissions and limitations under the License.
14 
15 #ifndef RAPIDJSON_DOCUMENT_H_
16 #define RAPIDJSON_DOCUMENT_H_
17 
20 #include "reader.h"
21 #include "internal/meta.h"
22 #include "internal/strfunc.h"
23 #include "memorystream.h"
24 #include "encodedstream.h"
25 #include <new> // placement new
26 #include <limits>
27 #ifdef __cpp_lib_three_way_comparison
28 #include <compare>
29 #endif
30 
31 RAPIDJSON_DIAG_PUSH
32 #ifdef __clang__
33 RAPIDJSON_DIAG_OFF(padded)
34 RAPIDJSON_DIAG_OFF(switch-enum)
35 RAPIDJSON_DIAG_OFF(c++98-compat)
36 #elif defined(_MSC_VER)
37 RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
38 RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible loss of data
39 #endif
40 
41 #ifdef __GNUC__
42 RAPIDJSON_DIAG_OFF(effc++)
43 #endif // __GNUC__
44 
45 #ifdef GetObject
46 // see https://github.com/Tencent/rapidjson/issues/1448
47 // a former included windows.h might have defined a macro called GetObject, which affects
48 // GetObject defined here. This ensures the macro does not get applied
49 #pragma push_macro("GetObject")
50 #define RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
51 #undef GetObject
52 #endif
53 
54 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS
55 #include <iterator> // std::random_access_iterator_tag
56 #endif
57 
58 #if RAPIDJSON_USE_MEMBERSMAP
59 #include <map> // std::multimap
60 #endif
61 
63 
64 // Forward declaration.
65 template <typename Encoding, typename Allocator>
67 
68 template <typename Encoding, typename Allocator, typename StackAllocator>
70 
77 #ifndef RAPIDJSON_DEFAULT_ALLOCATOR
78 #define RAPIDJSON_DEFAULT_ALLOCATOR MemoryPoolAllocator<CrtAllocator>
79 #endif
80 
87 #ifndef RAPIDJSON_DEFAULT_STACK_ALLOCATOR
88 #define RAPIDJSON_DEFAULT_STACK_ALLOCATOR CrtAllocator
89 #endif
90 
97 #ifndef RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
98 // number of objects that rapidjson::Value allocates memory for by default
99 #define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY 16
100 #endif
101 
108 #ifndef RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
109 // number of array elements that rapidjson::Value allocates memory for by default
110 #define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY 16
111 #endif
112 
114 
119 template <typename Encoding, typename Allocator>
121 public:
124 
125 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
126  GenericMember(GenericMember&& rhs) RAPIDJSON_NOEXCEPT
128  : name(std::move(rhs.name)),
129  value(std::move(rhs.value))
130  {
131  }
132 
134  GenericMember& operator=(GenericMember&& rhs) RAPIDJSON_NOEXCEPT {
135  return *this = static_cast<GenericMember&>(rhs);
136  }
137 #endif
138 
140 
142  GenericMember& operator=(GenericMember& rhs) RAPIDJSON_NOEXCEPT {
143  if (RAPIDJSON_LIKELY(this != &rhs)) {
144  name = rhs.name;
145  value = rhs.value;
146  }
147  return *this;
148  }
149 
150  // swap() for std::sort() and other potential use in STL.
151  friend inline void swap(GenericMember& a, GenericMember& b) RAPIDJSON_NOEXCEPT {
152  a.name.Swap(b.name);
153  a.value.Swap(b.value);
154  }
155 
156 private:
158  GenericMember(const GenericMember& rhs);
159 };
160 
162 // GenericMemberIterator
163 
164 #ifndef RAPIDJSON_NOMEMBERITERATORCLASS
165 
167 
185 template <bool Const, typename Encoding, typename Allocator>
187 
189  template <bool, typename, typename> friend class GenericMemberIterator;
190 
192  typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
193 
194 public:
201 
204  typedef ValueType value_type;
205  typedef ValueType * pointer;
206  typedef ValueType & reference;
207  typedef std::ptrdiff_t difference_type;
208  typedef std::random_access_iterator_tag iterator_category;
210 
212  typedef pointer Pointer;
217 
219 
222  GenericMemberIterator() : ptr_() {}
223 
225 
240  GenericMemberIterator(const NonConstIterator & it) : ptr_(it.ptr_) {}
241  Iterator& operator=(const NonConstIterator & it) { ptr_ = it.ptr_; return *this; }
242 
244 
245  Iterator& operator++(){ ++ptr_; return *this; }
246  Iterator& operator--(){ --ptr_; return *this; }
247  Iterator operator++(int){ Iterator old(*this); ++ptr_; return old; }
248  Iterator operator--(int){ Iterator old(*this); --ptr_; return old; }
250 
252 
253  Iterator operator+(DifferenceType n) const { return Iterator(ptr_+n); }
254  Iterator operator-(DifferenceType n) const { return Iterator(ptr_-n); }
255 
256  Iterator& operator+=(DifferenceType n) { ptr_+=n; return *this; }
257  Iterator& operator-=(DifferenceType n) { ptr_-=n; return *this; }
259 
261 
262  template <bool Const_> bool operator==(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ == that.ptr_; }
263  template <bool Const_> bool operator!=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ != that.ptr_; }
264  template <bool Const_> bool operator<=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <= that.ptr_; }
265  template <bool Const_> bool operator>=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ >= that.ptr_; }
266  template <bool Const_> bool operator< (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ < that.ptr_; }
267  template <bool Const_> bool operator> (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ > that.ptr_; }
268 
269 #ifdef __cpp_lib_three_way_comparison
270  template <bool Const_> std::strong_ordering operator<=>(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <=> that.ptr_; }
271 #endif
272 
273 
275 
276  Reference operator*() const { return *ptr_; }
277  Pointer operator->() const { return ptr_; }
278  Reference operator[](DifferenceType n) const { return ptr_[n]; }
280 
282  DifferenceType operator-(ConstIterator that) const { return ptr_-that.ptr_; }
283 
284 private:
286  explicit GenericMemberIterator(Pointer p) : ptr_(p) {}
287 
288  Pointer ptr_;
289 };
290 
291 #else // RAPIDJSON_NOMEMBERITERATORCLASS
292 
293 // class-based member iterator implementation disabled, use plain pointers
294 
295 template <bool Const, typename Encoding, typename Allocator>
297 
299 template <typename Encoding, typename Allocator>
301 public:
304 };
306 template <typename Encoding, typename Allocator>
308 public:
311 };
312 
313 #endif // RAPIDJSON_NOMEMBERITERATORCLASS
314 
316 // GenericStringRef
317 
319 
345 template<typename CharType>
347  typedef CharType Ch;
348 
350 #ifndef __clang__ // -Wdocumentation
351 
373 #endif
374  template<SizeType N>
375  GenericStringRef(const CharType (&str)[N]) RAPIDJSON_NOEXCEPT
376  : s(str), length(N-1) {}
377 
379 #ifndef __clang__ // -Wdocumentation
380 
398 #endif
399  explicit GenericStringRef(const CharType* str)
400  : s(str), length(NotNullStrLen(str)) {}
401 
403 #ifndef __clang__ // -Wdocumentation
404 
410 #endif
411  GenericStringRef(const CharType* str, SizeType len)
412  : s(RAPIDJSON_LIKELY(str) ? str : emptyString), length(len) { RAPIDJSON_ASSERT(str != 0 || len == 0u); }
413 
414  GenericStringRef(const GenericStringRef& rhs) : s(rhs.s), length(rhs.length) {}
415 
417  operator const Ch *() const { return s; }
418 
419  const Ch* const s;
420  const SizeType length;
421 
422 private:
423  SizeType NotNullStrLen(const CharType* str) {
424  RAPIDJSON_ASSERT(str != 0);
425  return internal::StrLen(str);
426  }
427 
429  static const Ch emptyString[];
430 
432  template<SizeType N>
433  GenericStringRef(CharType (&str)[N]) /* = delete */;
435  GenericStringRef& operator=(const GenericStringRef& rhs) /* = delete */;
436 };
437 
438 template<typename CharType>
439 const CharType GenericStringRef<CharType>::emptyString[] = { CharType() };
440 
442 
453 template<typename CharType>
454 inline GenericStringRef<CharType> StringRef(const CharType* str) {
455  return GenericStringRef<CharType>(str);
456 }
457 
459 
473 template<typename CharType>
474 inline GenericStringRef<CharType> StringRef(const CharType* str, size_t length) {
475  return GenericStringRef<CharType>(str, SizeType(length));
476 }
477 
478 #if RAPIDJSON_HAS_STDSTRING
479 
491 template<typename CharType>
492 inline GenericStringRef<CharType> StringRef(const std::basic_string<CharType>& str) {
493  return GenericStringRef<CharType>(str.data(), SizeType(str.size()));
494 }
495 #endif
496 
498 // GenericValue type traits
499 namespace internal {
500 
501 template <typename T, typename Encoding = void, typename Allocator = void>
502 struct IsGenericValueImpl : FalseType {};
503 
504 // select candidates according to nested encoding and allocator types
505 template <typename T> struct IsGenericValueImpl<T, typename Void<typename T::EncodingType>::Type, typename Void<typename T::AllocatorType>::Type>
506  : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>::Type {};
507 
508 // helper to match arbitrary GenericValue instantiations, including derived classes
509 template <typename T> struct IsGenericValue : IsGenericValueImpl<T>::Type {};
510 
511 } // namespace internal
512 
514 // TypeHelper
515 
516 namespace internal {
517 
518 template <typename ValueType, typename T>
519 struct TypeHelper {};
520 
521 template<typename ValueType>
522 struct TypeHelper<ValueType, bool> {
523  static bool Is(const ValueType& v) { return v.IsBool(); }
524  static bool Get(const ValueType& v) { return v.GetBool(); }
525  static ValueType& Set(ValueType& v, bool data) { return v.SetBool(data); }
526  static ValueType& Set(ValueType& v, bool data, typename ValueType::AllocatorType&) { return v.SetBool(data); }
527 };
528 
529 template<typename ValueType>
530 struct TypeHelper<ValueType, int> {
531  static bool Is(const ValueType& v) { return v.IsInt(); }
532  static int Get(const ValueType& v) { return v.GetInt(); }
533  static ValueType& Set(ValueType& v, int data) { return v.SetInt(data); }
534  static ValueType& Set(ValueType& v, int data, typename ValueType::AllocatorType&) { return v.SetInt(data); }
535 };
536 
537 template<typename ValueType>
538 struct TypeHelper<ValueType, unsigned> {
539  static bool Is(const ValueType& v) { return v.IsUint(); }
540  static unsigned Get(const ValueType& v) { return v.GetUint(); }
541  static ValueType& Set(ValueType& v, unsigned data) { return v.SetUint(data); }
542  static ValueType& Set(ValueType& v, unsigned data, typename ValueType::AllocatorType&) { return v.SetUint(data); }
543 };
544 
545 #ifdef _MSC_VER
546 RAPIDJSON_STATIC_ASSERT(sizeof(long) == sizeof(int));
547 template<typename ValueType>
548 struct TypeHelper<ValueType, long> {
549  static bool Is(const ValueType& v) { return v.IsInt(); }
550  static long Get(const ValueType& v) { return v.GetInt(); }
551  static ValueType& Set(ValueType& v, long data) { return v.SetInt(data); }
552  static ValueType& Set(ValueType& v, long data, typename ValueType::AllocatorType&) { return v.SetInt(data); }
553 };
554 
555 RAPIDJSON_STATIC_ASSERT(sizeof(unsigned long) == sizeof(unsigned));
556 template<typename ValueType>
557 struct TypeHelper<ValueType, unsigned long> {
558  static bool Is(const ValueType& v) { return v.IsUint(); }
559  static unsigned long Get(const ValueType& v) { return v.GetUint(); }
560  static ValueType& Set(ValueType& v, unsigned long data) { return v.SetUint(data); }
561  static ValueType& Set(ValueType& v, unsigned long data, typename ValueType::AllocatorType&) { return v.SetUint(data); }
562 };
563 #endif
564 
565 template<typename ValueType>
566 struct TypeHelper<ValueType, int64_t> {
567  static bool Is(const ValueType& v) { return v.IsInt64(); }
568  static int64_t Get(const ValueType& v) { return v.GetInt64(); }
569  static ValueType& Set(ValueType& v, int64_t data) { return v.SetInt64(data); }
570  static ValueType& Set(ValueType& v, int64_t data, typename ValueType::AllocatorType&) { return v.SetInt64(data); }
571 };
572 
573 template<typename ValueType>
574 struct TypeHelper<ValueType, uint64_t> {
575  static bool Is(const ValueType& v) { return v.IsUint64(); }
576  static uint64_t Get(const ValueType& v) { return v.GetUint64(); }
577  static ValueType& Set(ValueType& v, uint64_t data) { return v.SetUint64(data); }
578  static ValueType& Set(ValueType& v, uint64_t data, typename ValueType::AllocatorType&) { return v.SetUint64(data); }
579 };
580 
581 template<typename ValueType>
582 struct TypeHelper<ValueType, double> {
583  static bool Is(const ValueType& v) { return v.IsDouble(); }
584  static double Get(const ValueType& v) { return v.GetDouble(); }
585  static ValueType& Set(ValueType& v, double data) { return v.SetDouble(data); }
586  static ValueType& Set(ValueType& v, double data, typename ValueType::AllocatorType&) { return v.SetDouble(data); }
587 };
588 
589 template<typename ValueType>
590 struct TypeHelper<ValueType, float> {
591  static bool Is(const ValueType& v) { return v.IsFloat(); }
592  static float Get(const ValueType& v) { return v.GetFloat(); }
593  static ValueType& Set(ValueType& v, float data) { return v.SetFloat(data); }
594  static ValueType& Set(ValueType& v, float data, typename ValueType::AllocatorType&) { return v.SetFloat(data); }
595 };
596 
597 template<typename ValueType>
598 struct TypeHelper<ValueType, const typename ValueType::Ch*> {
599  typedef const typename ValueType::Ch* StringType;
600  static bool Is(const ValueType& v) { return v.IsString(); }
601  static StringType Get(const ValueType& v) { return v.GetString(); }
602  static ValueType& Set(ValueType& v, const StringType data) { return v.SetString(typename ValueType::StringRefType(data)); }
603  static ValueType& Set(ValueType& v, const StringType data, typename ValueType::AllocatorType& a) { return v.SetString(data, a); }
604 };
605 
606 #if RAPIDJSON_HAS_STDSTRING
607 template<typename ValueType>
608 struct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch> > {
609  typedef std::basic_string<typename ValueType::Ch> StringType;
610  static bool Is(const ValueType& v) { return v.IsString(); }
611  static StringType Get(const ValueType& v) { return StringType(v.GetString(), v.GetStringLength()); }
612  static ValueType& Set(ValueType& v, const StringType& data, typename ValueType::AllocatorType& a) { return v.SetString(data, a); }
613 };
614 #endif
615 
616 template<typename ValueType>
617 struct TypeHelper<ValueType, typename ValueType::Array> {
618  typedef typename ValueType::Array ArrayType;
619  static bool Is(const ValueType& v) { return v.IsArray(); }
620  static ArrayType Get(ValueType& v) { return v.GetArray(); }
621  static ValueType& Set(ValueType& v, ArrayType data) { return v = data; }
622  static ValueType& Set(ValueType& v, ArrayType data, typename ValueType::AllocatorType&) { return v = data; }
623 };
624 
625 template<typename ValueType>
626 struct TypeHelper<ValueType, typename ValueType::ConstArray> {
627  typedef typename ValueType::ConstArray ArrayType;
628  static bool Is(const ValueType& v) { return v.IsArray(); }
629  static ArrayType Get(const ValueType& v) { return v.GetArray(); }
630 };
631 
632 template<typename ValueType>
633 struct TypeHelper<ValueType, typename ValueType::Object> {
634  typedef typename ValueType::Object ObjectType;
635  static bool Is(const ValueType& v) { return v.IsObject(); }
636  static ObjectType Get(ValueType& v) { return v.GetObject(); }
637  static ValueType& Set(ValueType& v, ObjectType data) { return v = data; }
638  static ValueType& Set(ValueType& v, ObjectType data, typename ValueType::AllocatorType&) { return v = data; }
639 };
640 
641 template<typename ValueType>
642 struct TypeHelper<ValueType, typename ValueType::ConstObject> {
643  typedef typename ValueType::ConstObject ObjectType;
644  static bool Is(const ValueType& v) { return v.IsObject(); }
645  static ObjectType Get(const ValueType& v) { return v.GetObject(); }
646 };
647 
648 } // namespace internal
649 
650 // Forward declarations
651 template <bool, typename> class GenericArray;
652 template <bool, typename> class GenericObject;
653 
655 // GenericValue
656 
658 
667 template <typename Encoding, typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR >
668 class GenericValue {
669 public:
674  typedef typename Encoding::Ch Ch;
685 
687 
688 
690  GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; }
691 
692 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
693  GenericValue(GenericValue&& rhs) RAPIDJSON_NOEXCEPT : data_(rhs.data_) {
695  rhs.data_.f.flags = kNullFlag; // give up contents
696  }
697 #endif
698 
699 private:
701  GenericValue(const GenericValue& rhs);
702 
703 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
704  template <typename StackAllocator>
707 
709  template <typename StackAllocator>
711 #endif
712 
713 public:
714 
716 
720  explicit GenericValue(Type type) RAPIDJSON_NOEXCEPT : data_() {
721  static const uint16_t defaultFlags[] = {
724  };
725  RAPIDJSON_NOEXCEPT_ASSERT(type >= kNullType && type <= kNumberType);
726  data_.f.flags = defaultFlags[type];
727 
728  // Use ShortString to store empty string.
729  if (type == kStringType)
730  data_.ss.SetLength(0);
731  }
732 
734 
741  template <typename SourceAllocator>
742  GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator, bool copyConstStrings = false) {
743  switch (rhs.GetType()) {
744  case kObjectType:
745  DoCopyMembers(rhs, allocator, copyConstStrings);
746  break;
747  case kArrayType: {
748  SizeType count = rhs.data_.a.size;
749  GenericValue* le = reinterpret_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
751  for (SizeType i = 0; i < count; i++)
752  new (&le[i]) GenericValue(re[i], allocator, copyConstStrings);
754  data_.a.size = data_.a.capacity = count;
755  SetElementsPointer(le);
756  }
757  break;
758  case kStringType:
759  if (rhs.data_.f.flags == kConstStringFlag && !copyConstStrings) {
760  data_.f.flags = rhs.data_.f.flags;
761  data_ = *reinterpret_cast<const Data*>(&rhs.data_);
762  }
763  else
764  SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
765  break;
766  default:
767  data_.f.flags = rhs.data_.f.flags;
768  data_ = *reinterpret_cast<const Data*>(&rhs.data_);
769  break;
770  }
771  }
772 
774 
779 #ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen
780  template <typename T>
781  explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT // See #472
782 #else
783  explicit GenericValue(bool b) RAPIDJSON_NOEXCEPT
784 #endif
785  : data_() {
786  // safe-guard against failing SFINAE
788  data_.f.flags = b ? kTrueFlag : kFalseFlag;
789  }
790 
792  explicit GenericValue(int i) RAPIDJSON_NOEXCEPT : data_() {
793  data_.n.i64 = i;
795  }
796 
798  explicit GenericValue(unsigned u) RAPIDJSON_NOEXCEPT : data_() {
799  data_.n.u64 = u;
800  data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
801  }
802 
804  explicit GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT : data_() {
805  data_.n.i64 = i64;
807  if (i64 >= 0) {
809  if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
810  data_.f.flags |= kUintFlag;
811  if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
812  data_.f.flags |= kIntFlag;
813  }
814  else if (i64 >= static_cast<int64_t>(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
815  data_.f.flags |= kIntFlag;
816  }
817 
819  explicit GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT : data_() {
820  data_.n.u64 = u64;
822  if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)))
823  data_.f.flags |= kInt64Flag;
824  if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
825  data_.f.flags |= kUintFlag;
826  if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
827  data_.f.flags |= kIntFlag;
828  }
829 
831  explicit GenericValue(double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d = d; data_.f.flags = kNumberDoubleFlag; }
832 
834  explicit GenericValue(float f) RAPIDJSON_NOEXCEPT : data_() { data_.n.d = static_cast<double>(f); data_.f.flags = kNumberDoubleFlag; }
835 
837  GenericValue(const Ch* s, SizeType length) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(StringRef(s, length)); }
838 
840  explicit GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(s); }
841 
843  GenericValue(const Ch* s, SizeType length, Allocator& allocator) : data_() { SetStringRaw(StringRef(s, length), allocator); }
844 
847 
848 #if RAPIDJSON_HAS_STDSTRING
849 
852  GenericValue(const std::basic_string<Ch>& s, Allocator& allocator) : data_() { SetStringRaw(StringRef(s), allocator); }
853 #endif
854 
856 
861  GenericValue(Array a) RAPIDJSON_NOEXCEPT : data_(a.value_.data_) {
862  a.value_.data_ = Data();
863  a.value_.data_.f.flags = kArrayFlag;
864  }
865 
867 
872  GenericValue(Object o) RAPIDJSON_NOEXCEPT : data_(o.value_.data_) {
873  o.value_.data_ = Data();
874  o.value_.data_.f.flags = kObjectFlag;
875  }
876 
878 
881  // With RAPIDJSON_USE_MEMBERSMAP, the maps need to be destroyed to release
882  // their Allocator if it's refcounted (e.g. MemoryPoolAllocator).
883  if (Allocator::kNeedFree || (RAPIDJSON_USE_MEMBERSMAP+0 &&
885  switch(data_.f.flags) {
886  case kArrayFlag:
887  {
889  for (GenericValue* v = e; v != e + data_.a.size; ++v)
890  v->~GenericValue();
891  if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
892  Allocator::Free(e);
893  }
894  }
895  break;
896 
897  case kObjectFlag:
898  DoFreeMembers();
899  break;
900 
901  case kCopyStringFlag:
902  if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
903  Allocator::Free(const_cast<Ch*>(GetStringPointer()));
904  }
905  break;
906 
907  default:
908  break; // Do nothing for other types.
909  }
910  }
911  }
912 
914 
916 
917 
919 
921  GenericValue& operator=(GenericValue& rhs) RAPIDJSON_NOEXCEPT {
922  if (RAPIDJSON_LIKELY(this != &rhs)) {
923  // Can't destroy "this" before assigning "rhs", otherwise "rhs"
924  // could be used after free if it's an sub-Value of "this",
925  // hence the temporary danse.
926  GenericValue temp;
927  temp.RawAssign(rhs);
928  this->~GenericValue();
929  RawAssign(temp);
930  }
931  return *this;
932  }
933 
934 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
935  GenericValue& operator=(GenericValue&& rhs) RAPIDJSON_NOEXCEPT {
937  return *this = rhs.Move();
938  }
939 #endif
940 
942 
946  GenericValue& operator=(StringRefType str) RAPIDJSON_NOEXCEPT {
947  GenericValue s(str);
948  return *this = s;
949  }
950 
952 
963  template <typename T>
964  RAPIDJSON_DISABLEIF_RETURN((internal::IsPointer<T>), (GenericValue&))
965  operator=(T value) {
966  GenericValue v(value);
967  return *this = v;
968  }
969 
971 
977  template <typename SourceAllocator>
978  GenericValue& CopyFrom(const GenericValue<Encoding, SourceAllocator>& rhs, Allocator& allocator, bool copyConstStrings = false) {
979  RAPIDJSON_ASSERT(static_cast<void*>(this) != static_cast<void const*>(&rhs));
980  this->~GenericValue();
981  new (this) GenericValue(rhs, allocator, copyConstStrings);
982  return *this;
983  }
984 
986 
990  GenericValue& Swap(GenericValue& other) RAPIDJSON_NOEXCEPT {
991  GenericValue temp;
992  temp.RawAssign(*this);
993  RawAssign(other);
994  other.RawAssign(temp);
995  return *this;
996  }
997 
999 
1010  friend inline void swap(GenericValue& a, GenericValue& b) RAPIDJSON_NOEXCEPT { a.Swap(b); }
1011 
1013 
1014  GenericValue& Move() RAPIDJSON_NOEXCEPT { return *this; }
1016 
1018 
1019 
1024  template <typename SourceAllocator>
1025  bool operator==(const GenericValue<Encoding, SourceAllocator>& rhs) const {
1027  if (GetType() != rhs.GetType())
1028  return false;
1029 
1030  switch (GetType()) {
1031  case kObjectType: // Warning: O(n^2) inner-loop
1032  if (data_.o.size != rhs.data_.o.size)
1033  return false;
1034  for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
1035  typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
1036  if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
1037  return false;
1038  }
1039  return true;
1040 
1041  case kArrayType:
1042  if (data_.a.size != rhs.data_.a.size)
1043  return false;
1044  for (SizeType i = 0; i < data_.a.size; i++)
1045  if ((*this)[i] != rhs[i])
1046  return false;
1047  return true;
1048 
1049  case kStringType:
1050  return StringEqual(rhs);
1051 
1052  case kNumberType:
1053  if (IsDouble() || rhs.IsDouble()) {
1054  double a = GetDouble(); // May convert from integer to double.
1055  double b = rhs.GetDouble(); // Ditto
1056  return a >= b && a <= b; // Prevent -Wfloat-equal
1057  }
1058  else
1059  return data_.n.u64 == rhs.data_.n.u64;
1060 
1061  default:
1062  return true;
1063  }
1064  }
1065 
1067  bool operator==(const Ch* rhs) const { return *this == GenericValue(StringRef(rhs)); }
1068 
1069 #if RAPIDJSON_HAS_STDSTRING
1070 
1073  bool operator==(const std::basic_string<Ch>& rhs) const { return *this == GenericValue(StringRef(rhs)); }
1074 #endif
1075 
1077 
1079  template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,internal::IsGenericValue<T> >), (bool)) operator==(const T& rhs) const { return *this == GenericValue(rhs); }
1080 
1082 
1084  template <typename SourceAllocator>
1085  bool operator!=(const GenericValue<Encoding, SourceAllocator>& rhs) const { return !(*this == rhs); }
1086 
1088  bool operator!=(const Ch* rhs) const { return !(*this == rhs); }
1089 
1091 
1093  template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& rhs) const { return !(*this == rhs); }
1094 
1095 #ifndef __cpp_lib_three_way_comparison
1096 
1099  template <typename T> friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator==(const T& lhs, const GenericValue& rhs) { return rhs == lhs; }
1100 
1102 
1104  template <typename T> friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& lhs, const GenericValue& rhs) { return !(rhs == lhs); }
1106 #endif
1107 
1109 
1110 
1111  Type GetType() const { return static_cast<Type>(data_.f.flags & kTypeMask); }
1112  bool IsNull() const { return data_.f.flags == kNullFlag; }
1113  bool IsFalse() const { return data_.f.flags == kFalseFlag; }
1114  bool IsTrue() const { return data_.f.flags == kTrueFlag; }
1115  bool IsBool() const { return (data_.f.flags & kBoolFlag) != 0; }
1116  bool IsObject() const { return data_.f.flags == kObjectFlag; }
1117  bool IsArray() const { return data_.f.flags == kArrayFlag; }
1118  bool IsNumber() const { return (data_.f.flags & kNumberFlag) != 0; }
1119  bool IsInt() const { return (data_.f.flags & kIntFlag) != 0; }
1120  bool IsUint() const { return (data_.f.flags & kUintFlag) != 0; }
1121  bool IsInt64() const { return (data_.f.flags & kInt64Flag) != 0; }
1122  bool IsUint64() const { return (data_.f.flags & kUint64Flag) != 0; }
1123  bool IsDouble() const { return (data_.f.flags & kDoubleFlag) != 0; }
1124  bool IsString() const { return (data_.f.flags & kStringFlag) != 0; }
1125 
1126  // Checks whether a number can be losslessly converted to a double.
1127  bool IsLosslessDouble() const {
1128  if (!IsNumber()) return false;
1129  if (IsUint64()) {
1130  uint64_t u = GetUint64();
1131  volatile double d = static_cast<double>(u);
1132  return (d >= 0.0)
1133  && (d < static_cast<double>((std::numeric_limits<uint64_t>::max)()))
1134  && (u == static_cast<uint64_t>(d));
1135  }
1136  if (IsInt64()) {
1137  int64_t i = GetInt64();
1138  volatile double d = static_cast<double>(i);
1139  return (d >= static_cast<double>((std::numeric_limits<int64_t>::min)()))
1140  && (d < static_cast<double>((std::numeric_limits<int64_t>::max)()))
1141  && (i == static_cast<int64_t>(d));
1142  }
1143  return true; // double, int, uint are always lossless
1144  }
1145 
1146  // Checks whether a number is a float (possible lossy).
1147  bool IsFloat() const {
1148  if ((data_.f.flags & kDoubleFlag) == 0)
1149  return false;
1150  double d = GetDouble();
1151  return d >= -3.4028234e38 && d <= 3.4028234e38;
1152  }
1153  // Checks whether a number can be losslessly converted to a float.
1154  bool IsLosslessFloat() const {
1155  if (!IsNumber()) return false;
1156  double a = GetDouble();
1157  if (a < static_cast<double>(-(std::numeric_limits<float>::max)())
1158  || a > static_cast<double>((std::numeric_limits<float>::max)()))
1159  return false;
1160  double b = static_cast<double>(static_cast<float>(a));
1161  return a >= b && a <= b; // Prevent -Wfloat-equal
1162  }
1163 
1165 
1167 
1168 
1169  GenericValue& SetNull() { this->~GenericValue(); new (this) GenericValue(); return *this; }
1170 
1172 
1174 
1175 
1176  bool GetBool() const { RAPIDJSON_ASSERT(IsBool()); return data_.f.flags == kTrueFlag; }
1178 
1179  GenericValue& SetBool(bool b) { this->~GenericValue(); new (this) GenericValue(b); return *this; }
1180 
1182 
1184 
1185 
1187 
1188  GenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; }
1189 
1191  SizeType MemberCount() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.size; }
1192 
1194  SizeType MemberCapacity() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.capacity; }
1195 
1197  bool ObjectEmpty() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.size == 0; }
1198 
1200 
1208  template <typename T>
1209  RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >),(GenericValue&)) operator[](T* name) {
1211  return (*this)[n];
1212  }
1213  template <typename T>
1214  RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >),(const GenericValue&)) operator[](T* name) const { return const_cast<GenericValue&>(*this)[name]; }
1215 
1217 
1225  template <typename SourceAllocator>
1227  MemberIterator member = FindMember(name);
1228  if (member != MemberEnd())
1229  return member->value;
1230  else {
1231  RAPIDJSON_ASSERT(false); // see above note
1232 
1233  // This will generate -Wexit-time-destructors in clang
1234  // static GenericValue NullValue;
1235  // return NullValue;
1236 
1237  // Use static buffer and placement-new to prevent destruction
1238  static char buffer[sizeof(GenericValue)];
1239  return *new (buffer) GenericValue();
1240  }
1241  }
1242  template <typename SourceAllocator>
1243  const GenericValue& operator[](const GenericValue<Encoding, SourceAllocator>& name) const { return const_cast<GenericValue&>(*this)[name]; }
1244 
1245 #if RAPIDJSON_HAS_STDSTRING
1246  GenericValue& operator[](const std::basic_string<Ch>& name) { return (*this)[GenericValue(StringRef(name))]; }
1248  const GenericValue& operator[](const std::basic_string<Ch>& name) const { return (*this)[GenericValue(StringRef(name))]; }
1249 #endif
1250 
1252 
1253  ConstMemberIterator MemberBegin() const { RAPIDJSON_ASSERT(IsObject()); return ConstMemberIterator(GetMembersPointer()); }
1255 
1256  ConstMemberIterator MemberEnd() const { RAPIDJSON_ASSERT(IsObject()); return ConstMemberIterator(GetMembersPointer() + data_.o.size); }
1258 
1259  MemberIterator MemberBegin() { RAPIDJSON_ASSERT(IsObject()); return MemberIterator(GetMembersPointer()); }
1261 
1262  MemberIterator MemberEnd() { RAPIDJSON_ASSERT(IsObject()); return MemberIterator(GetMembersPointer() + data_.o.size); }
1263 
1265 
1270  GenericValue& MemberReserve(SizeType newCapacity, Allocator &allocator) {
1271  RAPIDJSON_ASSERT(IsObject());
1272  DoReserveMembers(newCapacity, allocator);
1273  return *this;
1274  }
1275 
1277 
1284  bool HasMember(const Ch* name) const { return FindMember(name) != MemberEnd(); }
1285 
1286 #if RAPIDJSON_HAS_STDSTRING
1287 
1295  bool HasMember(const std::basic_string<Ch>& name) const { return FindMember(name) != MemberEnd(); }
1296 #endif
1297 
1299 
1307  template <typename SourceAllocator>
1308  bool HasMember(const GenericValue<Encoding, SourceAllocator>& name) const { return FindMember(name) != MemberEnd(); }
1309 
1311 
1322  MemberIterator FindMember(const Ch* name) {
1324  return FindMember(n);
1325  }
1326 
1327  ConstMemberIterator FindMember(const Ch* name) const { return const_cast<GenericValue&>(*this).FindMember(name); }
1328 
1330 
1342  template <typename SourceAllocator>
1344  RAPIDJSON_ASSERT(IsObject());
1345  RAPIDJSON_ASSERT(name.IsString());
1346  return DoFindMember(name);
1347  }
1348  template <typename SourceAllocator> ConstMemberIterator FindMember(const GenericValue<Encoding, SourceAllocator>& name) const { return const_cast<GenericValue&>(*this).FindMember(name); }
1349 
1350 #if RAPIDJSON_HAS_STDSTRING
1351 
1358  MemberIterator FindMember(const std::basic_string<Ch>& name) { return FindMember(GenericValue(StringRef(name))); }
1359  ConstMemberIterator FindMember(const std::basic_string<Ch>& name) const { return FindMember(GenericValue(StringRef(name))); }
1360 #endif
1361 
1363 
1373  RAPIDJSON_ASSERT(IsObject());
1374  RAPIDJSON_ASSERT(name.IsString());
1376  return *this;
1377  }
1378 
1380 
1389  GenericValue v(value);
1390  return AddMember(name, v, allocator);
1391  }
1392 
1393 #if RAPIDJSON_HAS_STDSTRING
1394 
1403  GenericValue& AddMember(GenericValue& name, std::basic_string<Ch>& value, Allocator& allocator) {
1405  return AddMember(name, v, allocator);
1406  }
1407 #endif
1408 
1410 
1426  template <typename T>
1427  RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))
1428  AddMember(GenericValue& name, T value, Allocator& allocator) {
1429  GenericValue v(value);
1430  return AddMember(name, v, allocator);
1431  }
1432 
1433 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1435  return AddMember(name, value, allocator);
1436  }
1438  return AddMember(name, value, allocator);
1439  }
1441  return AddMember(name, value, allocator);
1442  }
1444  GenericValue n(name);
1445  return AddMember(n, value, allocator);
1446  }
1447 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
1448 
1449 
1451 
1461  GenericValue n(name);
1462  return AddMember(n, value, allocator);
1463  }
1464 
1466 
1475  GenericValue v(value);
1476  return AddMember(name, v, allocator);
1477  }
1478 
1480 
1496  template <typename T>
1497  RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))
1498  AddMember(StringRefType name, T value, Allocator& allocator) {
1499  GenericValue n(name);
1500  return AddMember(n, value, allocator);
1501  }
1502 
1504 
1507  void RemoveAllMembers() {
1508  RAPIDJSON_ASSERT(IsObject());
1509  DoClearMembers();
1510  }
1511 
1513 
1520  bool RemoveMember(const Ch* name) {
1522  return RemoveMember(n);
1523  }
1524 
1525 #if RAPIDJSON_HAS_STDSTRING
1526  bool RemoveMember(const std::basic_string<Ch>& name) { return RemoveMember(GenericValue(StringRef(name))); }
1527 #endif
1528 
1529  template <typename SourceAllocator>
1530  bool RemoveMember(const GenericValue<Encoding, SourceAllocator>& name) {
1531  MemberIterator m = FindMember(name);
1532  if (m != MemberEnd()) {
1533  RemoveMember(m);
1534  return true;
1535  }
1536  else
1537  return false;
1538  }
1539 
1541 
1548  MemberIterator RemoveMember(MemberIterator m) {
1549  RAPIDJSON_ASSERT(IsObject());
1552  RAPIDJSON_ASSERT(m >= MemberBegin() && m < MemberEnd());
1553  return DoRemoveMember(m);
1554  }
1555 
1557 
1565  MemberIterator EraseMember(ConstMemberIterator pos) {
1566  return EraseMember(pos, pos +1);
1567  }
1568 
1570 
1578  MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) {
1579  RAPIDJSON_ASSERT(IsObject());
1582  RAPIDJSON_ASSERT(first >= MemberBegin());
1583  RAPIDJSON_ASSERT(first <= last);
1584  RAPIDJSON_ASSERT(last <= MemberEnd());
1585  return DoEraseMembers(first, last);
1586  }
1587 
1589 
1593  bool EraseMember(const Ch* name) {
1595  return EraseMember(n);
1596  }
1597 
1598 #if RAPIDJSON_HAS_STDSTRING
1599  bool EraseMember(const std::basic_string<Ch>& name) { return EraseMember(GenericValue(StringRef(name))); }
1600 #endif
1601 
1602  template <typename SourceAllocator>
1603  bool EraseMember(const GenericValue<Encoding, SourceAllocator>& name) {
1604  MemberIterator m = FindMember(name);
1605  if (m != MemberEnd()) {
1606  EraseMember(m);
1607  return true;
1608  }
1609  else
1610  return false;
1611  }
1612 
1613  Object GetObject() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
1614  Object GetObj() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
1615  ConstObject GetObject() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }
1616  ConstObject GetObj() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }
1617 
1619 
1621 
1622 
1624 
1625  GenericValue& SetArray() { this->~GenericValue(); new (this) GenericValue(kArrayType); return *this; }
1626 
1628  SizeType Size() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size; }
1629 
1631  SizeType Capacity() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.capacity; }
1632 
1634  bool Empty() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size == 0; }
1635 
1637 
1640  void Clear() {
1641  RAPIDJSON_ASSERT(IsArray());
1643  for (GenericValue* v = e; v != e + data_.a.size; ++v)
1644  v->~GenericValue();
1645  data_.a.size = 0;
1646  }
1647 
1649 
1653  GenericValue& operator[](SizeType index) {
1654  RAPIDJSON_ASSERT(IsArray());
1655  RAPIDJSON_ASSERT(index < data_.a.size);
1656  return GetElementsPointer()[index];
1657  }
1658  const GenericValue& operator[](SizeType index) const { return const_cast<GenericValue&>(*this)[index]; }
1659 
1661 
1662  ValueIterator Begin() { RAPIDJSON_ASSERT(IsArray()); return GetElementsPointer(); }
1664 
1665  ValueIterator End() { RAPIDJSON_ASSERT(IsArray()); return GetElementsPointer() + data_.a.size; }
1667 
1668  ConstValueIterator Begin() const { return const_cast<GenericValue&>(*this).Begin(); }
1670 
1671  ConstValueIterator End() const { return const_cast<GenericValue&>(*this).End(); }
1672 
1674 
1679  GenericValue& Reserve(SizeType newCapacity, Allocator &allocator) {
1680  RAPIDJSON_ASSERT(IsArray());
1681  if (newCapacity > data_.a.capacity) {
1682  SetElementsPointer(reinterpret_cast<GenericValue*>(allocator.Realloc(GetElementsPointer(), data_.a.capacity * sizeof(GenericValue), newCapacity * sizeof(GenericValue))));
1683  data_.a.capacity = newCapacity;
1684  }
1685  return *this;
1686  }
1687 
1689 
1699  RAPIDJSON_ASSERT(IsArray());
1700  if (data_.a.size >= data_.a.capacity)
1701  Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2), allocator);
1703  return *this;
1704  }
1705 
1706 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1708  return PushBack(value, allocator);
1709  }
1710 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
1711 
1713 
1722  return (*this).template PushBack<StringRefType>(value, allocator);
1723  }
1724 
1726 
1742  template <typename T>
1743  RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))
1744  PushBack(T value, Allocator& allocator) {
1745  GenericValue v(value);
1746  return PushBack(v, allocator);
1747  }
1748 
1750 
1753  GenericValue& PopBack() {
1754  RAPIDJSON_ASSERT(IsArray());
1755  RAPIDJSON_ASSERT(!Empty());
1757  return *this;
1758  }
1759 
1761 
1767  ValueIterator Erase(ConstValueIterator pos) {
1768  return Erase(pos, pos + 1);
1769  }
1770 
1772 
1780  RAPIDJSON_ASSERT(IsArray());
1783  RAPIDJSON_ASSERT(first >= Begin());
1784  RAPIDJSON_ASSERT(first <= last);
1785  RAPIDJSON_ASSERT(last <= End());
1786  ValueIterator pos = Begin() + (first - Begin());
1787  for (ValueIterator itr = pos; itr != last; ++itr)
1788  itr->~GenericValue();
1789  std::memmove(static_cast<void*>(pos), last, static_cast<size_t>(End() - last) * sizeof(GenericValue));
1790  data_.a.size -= static_cast<SizeType>(last - first);
1791  return pos;
1792  }
1793 
1794  Array GetArray() { RAPIDJSON_ASSERT(IsArray()); return Array(*this); }
1795  ConstArray GetArray() const { RAPIDJSON_ASSERT(IsArray()); return ConstArray(*this); }
1796 
1798 
1800 
1801 
1802  int GetInt() const { RAPIDJSON_ASSERT(data_.f.flags & kIntFlag); return data_.n.i.i; }
1803  unsigned GetUint() const { RAPIDJSON_ASSERT(data_.f.flags & kUintFlag); return data_.n.u.u; }
1804  int64_t GetInt64() const { RAPIDJSON_ASSERT(data_.f.flags & kInt64Flag); return data_.n.i64; }
1805  uint64_t GetUint64() const { RAPIDJSON_ASSERT(data_.f.flags & kUint64Flag); return data_.n.u64; }
1806 
1808 
1810  double GetDouble() const {
1811  RAPIDJSON_ASSERT(IsNumber());
1812  if ((data_.f.flags & kDoubleFlag) != 0) return data_.n.d; // exact type, no conversion.
1813  if ((data_.f.flags & kIntFlag) != 0) return data_.n.i.i; // int -> double
1814  if ((data_.f.flags & kUintFlag) != 0) return data_.n.u.u; // unsigned -> double
1815  if ((data_.f.flags & kInt64Flag) != 0) return static_cast<double>(data_.n.i64); // int64_t -> double (may lose precision)
1816  RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0); return static_cast<double>(data_.n.u64); // uint64_t -> double (may lose precision)
1817  }
1818 
1820 
1822  float GetFloat() const {
1823  return static_cast<float>(GetDouble());
1824  }
1825 
1826  GenericValue& SetInt(int i) { this->~GenericValue(); new (this) GenericValue(i); return *this; }
1827  GenericValue& SetUint(unsigned u) { this->~GenericValue(); new (this) GenericValue(u); return *this; }
1828  GenericValue& SetInt64(int64_t i64) { this->~GenericValue(); new (this) GenericValue(i64); return *this; }
1829  GenericValue& SetUint64(uint64_t u64) { this->~GenericValue(); new (this) GenericValue(u64); return *this; }
1830  GenericValue& SetDouble(double d) { this->~GenericValue(); new (this) GenericValue(d); return *this; }
1831  GenericValue& SetFloat(float f) { this->~GenericValue(); new (this) GenericValue(static_cast<double>(f)); return *this; }
1832 
1834 
1836 
1837 
1838  const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return DataString(data_); }
1839 
1841 
1843  SizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return DataStringLength(data_); }
1844 
1846 
1853  GenericValue& SetString(const Ch* s, SizeType length) { return SetString(StringRef(s, length)); }
1854 
1856 
1860  GenericValue& SetString(StringRefType s) { this->~GenericValue(); SetStringRaw(s); return *this; }
1861 
1863 
1870  GenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { return SetString(StringRef(s, length), allocator); }
1871 
1873 
1878  GenericValue& SetString(const Ch* s, Allocator& allocator) { return SetString(StringRef(s), allocator); }
1879 
1881 
1886  GenericValue& SetString(StringRefType s, Allocator& allocator) { this->~GenericValue(); SetStringRaw(s, allocator); return *this; }
1887 
1888 #if RAPIDJSON_HAS_STDSTRING
1889 
1896  GenericValue& SetString(const std::basic_string<Ch>& s, Allocator& allocator) { return SetString(StringRef(s), allocator); }
1897 #endif
1898 
1900 
1902 
1903 
1905 
1908  template <typename T>
1909  bool Is() const { return internal::TypeHelper<ValueType, T>::Is(*this); }
1910 
1911  template <typename T>
1912  T Get() const { return internal::TypeHelper<ValueType, T>::Get(*this); }
1913 
1914  template <typename T>
1915  T Get() { return internal::TypeHelper<ValueType, T>::Get(*this); }
1916 
1917  template<typename T>
1918  ValueType& Set(const T& data) { return internal::TypeHelper<ValueType, T>::Set(*this, data); }
1919 
1920  template<typename T>
1921  ValueType& Set(const T& data, AllocatorType& allocator) { return internal::TypeHelper<ValueType, T>::Set(*this, data, allocator); }
1922 
1924 
1926 
1932  template <typename Handler>
1933  bool Accept(Handler& handler) const {
1934  switch(GetType()) {
1935  case kNullType: return handler.Null();
1936  case kFalseType: return handler.Bool(false);
1937  case kTrueType: return handler.Bool(true);
1938 
1939  case kObjectType:
1940  if (RAPIDJSON_UNLIKELY(!handler.StartObject()))
1941  return false;
1942  for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m) {
1943  RAPIDJSON_ASSERT(m->name.IsString()); // User may change the type of name by MemberIterator.
1944  if (RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0)))
1945  return false;
1946  if (RAPIDJSON_UNLIKELY(!m->value.Accept(handler)))
1947  return false;
1948  }
1949  return handler.EndObject(data_.o.size);
1950 
1951  case kArrayType:
1952  if (RAPIDJSON_UNLIKELY(!handler.StartArray()))
1953  return false;
1954  for (ConstValueIterator v = Begin(); v != End(); ++v)
1955  if (RAPIDJSON_UNLIKELY(!v->Accept(handler)))
1956  return false;
1957  return handler.EndArray(data_.a.size);
1958 
1959  case kStringType:
1960  return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0);
1961 
1962  default:
1963  RAPIDJSON_ASSERT(GetType() == kNumberType);
1964  if (IsDouble()) return handler.Double(data_.n.d);
1965  else if (IsInt()) return handler.Int(data_.n.i.i);
1966  else if (IsUint()) return handler.Uint(data_.n.u.u);
1967  else if (IsInt64()) return handler.Int64(data_.n.i64);
1968  else return handler.Uint64(data_.n.u64);
1969  }
1970  }
1971 
1972 private:
1973  template <typename, typename> friend class GenericValue;
1974  template <typename, typename, typename> friend class GenericDocument;
1975 
1976  enum {
1977  kBoolFlag = 0x0008,
1978  kNumberFlag = 0x0010,
1979  kIntFlag = 0x0020,
1980  kUintFlag = 0x0040,
1981  kInt64Flag = 0x0080,
1982  kUint64Flag = 0x0100,
1983  kDoubleFlag = 0x0200,
1984  kStringFlag = 0x0400,
1985  kCopyFlag = 0x0800,
1986  kInlineStrFlag = 0x1000,
1987 
1988  // Initial flags of different types.
1990  // These casts are added to suppress the warning on MSVC about bitwise operations between enums of different types.
1991  kTrueFlag = static_cast<int>(kTrueType) | static_cast<int>(kBoolFlag),
1992  kFalseFlag = static_cast<int>(kFalseType) | static_cast<int>(kBoolFlag),
1993  kNumberIntFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kIntFlag | kInt64Flag),
1994  kNumberUintFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag),
1995  kNumberInt64Flag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kInt64Flag),
1996  kNumberUint64Flag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kUint64Flag),
1997  kNumberDoubleFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kDoubleFlag),
1998  kNumberAnyFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag),
1999  kConstStringFlag = static_cast<int>(kStringType) | static_cast<int>(kStringFlag),
2000  kCopyStringFlag = static_cast<int>(kStringType) | static_cast<int>(kStringFlag | kCopyFlag),
2001  kShortStringFlag = static_cast<int>(kStringType) | static_cast<int>(kStringFlag | kCopyFlag | kInlineStrFlag),
2004 
2005  kTypeMask = 0x07
2006  };
2007 
2010 
2011  struct Flag {
2012 #if RAPIDJSON_48BITPOINTER_OPTIMIZATION
2013  char payload[sizeof(SizeType) * 2 + 6]; // 2 x SizeType + lower 48-bit pointer
2014 #elif RAPIDJSON_64BIT
2015  char payload[sizeof(SizeType) * 2 + sizeof(void*) + 6]; // 6 padding bytes
2016 #else
2017  char payload[sizeof(SizeType) * 2 + sizeof(void*) + 2]; // 2 padding bytes
2018 #endif
2020  };
2021 
2022  struct String {
2025  const Ch* str;
2026  }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode
2027 
2028  // implementation detail: ShortString can represent zero-terminated strings up to MaxSize chars
2029  // (excluding the terminating zero) and store a value to determine the length of the contained
2030  // string in the last character str[LenPos] by storing "MaxSize - length" there. If the string
2031  // to store has the maximal length of MaxSize then str[LenPos] will be 0 and therefore act as
2032  // the string terminator as well. For getting the string length back from that value just use
2033  // "MaxSize - str[LenPos]".
2034  // This allows to store 13-chars strings in 32-bit mode, 21-chars strings in 64-bit mode,
2035  // 13-chars strings for RAPIDJSON_48BITPOINTER_OPTIMIZATION=1 inline (for `UTF8`-encoded strings).
2036  struct ShortString {
2037  enum { MaxChars = sizeof(static_cast<Flag*>(0)->payload) / sizeof(Ch), MaxSize = MaxChars - 1, LenPos = MaxSize };
2039 
2040  inline static bool Usable(SizeType len) { return (MaxSize >= len); }
2041  inline void SetLength(SizeType len) { str[LenPos] = static_cast<Ch>(MaxSize - len); }
2042  inline SizeType GetLength() const { return static_cast<SizeType>(MaxSize - str[LenPos]); }
2043  }; // at most as many bytes as "String" above => 12 bytes in 32-bit mode, 16 bytes in 64-bit mode
2044 
2045  // By using proper binary layout, retrieval of different integer types do not need conversions.
2046  union Number {
2047 #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN
2048  struct I {
2049  int i;
2050  char padding[4];
2051  }i;
2052  struct U {
2053  unsigned u;
2054  char padding2[4];
2055  }u;
2056 #else
2057  struct I {
2058  char padding[4];
2059  int i;
2060  }i;
2061  struct U {
2062  char padding2[4];
2063  unsigned u;
2064  }u;
2065 #endif
2068  double d;
2069  }; // 8 bytes
2070 
2071  struct ObjectData {
2075  }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode
2076 
2077  struct ArrayData {
2081  }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode
2082 
2083  union Data {
2090  }; // 16 bytes in 32-bit mode, 24 bytes in 64-bit mode, 16 bytes in 64-bit with RAPIDJSON_48BITPOINTER_OPTIMIZATION
2091 
2092  static RAPIDJSON_FORCEINLINE const Ch* DataString(const Data& data) {
2093  return (data.f.flags & kInlineStrFlag) ? data.ss.str : RAPIDJSON_GETPOINTER(Ch, data.s.str);
2094  }
2095  static RAPIDJSON_FORCEINLINE SizeType DataStringLength(const Data& data) {
2096  return (data.f.flags & kInlineStrFlag) ? data.ss.GetLength() : data.s.length;
2097  }
2098 
2099  RAPIDJSON_FORCEINLINE const Ch* GetStringPointer() const { return RAPIDJSON_GETPOINTER(Ch, data_.s.str); }
2100  RAPIDJSON_FORCEINLINE const Ch* SetStringPointer(const Ch* str) { return RAPIDJSON_SETPOINTER(Ch, data_.s.str, str); }
2101  RAPIDJSON_FORCEINLINE GenericValue* GetElementsPointer() const { return RAPIDJSON_GETPOINTER(GenericValue, data_.a.elements); }
2102  RAPIDJSON_FORCEINLINE GenericValue* SetElementsPointer(GenericValue* elements) { return RAPIDJSON_SETPOINTER(GenericValue, data_.a.elements, elements); }
2103  RAPIDJSON_FORCEINLINE Member* GetMembersPointer() const { return RAPIDJSON_GETPOINTER(Member, data_.o.members); }
2104  RAPIDJSON_FORCEINLINE Member* SetMembersPointer(Member* members) { return RAPIDJSON_SETPOINTER(Member, data_.o.members, members); }
2105 
2106 #if RAPIDJSON_USE_MEMBERSMAP
2107 
2108  struct MapTraits {
2109  struct Less {
2110  bool operator()(const Data& s1, const Data& s2) const {
2111  SizeType n1 = DataStringLength(s1), n2 = DataStringLength(s2);
2112  int cmp = std::memcmp(DataString(s1), DataString(s2), sizeof(Ch) * (n1 < n2 ? n1 : n2));
2113  return cmp < 0 || (cmp == 0 && n1 < n2);
2114  }
2115  };
2116  typedef std::pair<const Data, SizeType> Pair;
2117  typedef std::multimap<Data, SizeType, Less, StdAllocator<Pair, Allocator> > Map;
2118  typedef typename Map::iterator Iterator;
2119  };
2120  typedef typename MapTraits::Map Map;
2121  typedef typename MapTraits::Less MapLess;
2122  typedef typename MapTraits::Pair MapPair;
2123  typedef typename MapTraits::Iterator MapIterator;
2124 
2125  //
2126  // Layout of the members' map/array, re(al)located according to the needed capacity:
2127  //
2128  // {Map*}<>{capacity}<>{Member[capacity]}<>{MapIterator[capacity]}
2129  //
2130  // (where <> stands for the RAPIDJSON_ALIGN-ment, if needed)
2131  //
2132 
2133  static RAPIDJSON_FORCEINLINE size_t GetMapLayoutSize(SizeType capacity) {
2134  return RAPIDJSON_ALIGN(sizeof(Map*)) +
2135  RAPIDJSON_ALIGN(sizeof(SizeType)) +
2136  RAPIDJSON_ALIGN(capacity * sizeof(Member)) +
2137  capacity * sizeof(MapIterator);
2138  }
2139 
2140  static RAPIDJSON_FORCEINLINE SizeType &GetMapCapacity(Map* &map) {
2141  return *reinterpret_cast<SizeType*>(reinterpret_cast<uintptr_t>(&map) +
2142  RAPIDJSON_ALIGN(sizeof(Map*)));
2143  }
2144 
2145  static RAPIDJSON_FORCEINLINE Member* GetMapMembers(Map* &map) {
2146  return reinterpret_cast<Member*>(reinterpret_cast<uintptr_t>(&map) +
2147  RAPIDJSON_ALIGN(sizeof(Map*)) +
2148  RAPIDJSON_ALIGN(sizeof(SizeType)));
2149  }
2150 
2151  static RAPIDJSON_FORCEINLINE MapIterator* GetMapIterators(Map* &map) {
2152  return reinterpret_cast<MapIterator*>(reinterpret_cast<uintptr_t>(&map) +
2153  RAPIDJSON_ALIGN(sizeof(Map*)) +
2154  RAPIDJSON_ALIGN(sizeof(SizeType)) +
2155  RAPIDJSON_ALIGN(GetMapCapacity(map) * sizeof(Member)));
2156  }
2157 
2158  static RAPIDJSON_FORCEINLINE Map* &GetMap(Member* members) {
2159  RAPIDJSON_ASSERT(members != 0);
2160  return *reinterpret_cast<Map**>(reinterpret_cast<uintptr_t>(members) -
2161  RAPIDJSON_ALIGN(sizeof(SizeType)) -
2162  RAPIDJSON_ALIGN(sizeof(Map*)));
2163  }
2164 
2165  // Some compilers' debug mechanisms want all iterators to be destroyed, for their accounting..
2166  RAPIDJSON_FORCEINLINE MapIterator DropMapIterator(MapIterator& rhs) {
2167 #if RAPIDJSON_HAS_CXX11
2168  MapIterator ret = std::move(rhs);
2169 #else
2170  MapIterator ret = rhs;
2171 #endif
2172  rhs.~MapIterator();
2173  return ret;
2174  }
2175 
2176  Map* &DoReallocMap(Map** oldMap, SizeType newCapacity, Allocator& allocator) {
2177  Map **newMap = static_cast<Map**>(allocator.Malloc(GetMapLayoutSize(newCapacity)));
2178  GetMapCapacity(*newMap) = newCapacity;
2179  if (!oldMap) {
2180  *newMap = new (allocator.Malloc(sizeof(Map))) Map(MapLess(), allocator);
2181  }
2182  else {
2183  *newMap = *oldMap;
2184  size_t count = (*oldMap)->size();
2185  std::memcpy(static_cast<void*>(GetMapMembers(*newMap)),
2186  static_cast<void*>(GetMapMembers(*oldMap)),
2187  count * sizeof(Member));
2188  MapIterator *oldIt = GetMapIterators(*oldMap),
2189  *newIt = GetMapIterators(*newMap);
2190  while (count--) {
2191  new (&newIt[count]) MapIterator(DropMapIterator(oldIt[count]));
2192  }
2193  Allocator::Free(oldMap);
2194  }
2195  return *newMap;
2196  }
2197 
2198  RAPIDJSON_FORCEINLINE Member* DoAllocMembers(SizeType capacity, Allocator& allocator) {
2199  return GetMapMembers(DoReallocMap(0, capacity, allocator));
2200  }
2201 
2202  void DoReserveMembers(SizeType newCapacity, Allocator& allocator) {
2203  ObjectData& o = data_.o;
2204  if (newCapacity > o.capacity) {
2205  Member* oldMembers = GetMembersPointer();
2206  Map **oldMap = oldMembers ? &GetMap(oldMembers) : 0,
2207  *&newMap = DoReallocMap(oldMap, newCapacity, allocator);
2208  RAPIDJSON_SETPOINTER(Member, o.members, GetMapMembers(newMap));
2209  o.capacity = newCapacity;
2210  }
2211  }
2212 
2213  template <typename SourceAllocator>
2215  if (Member* members = GetMembersPointer()) {
2216  Map* &map = GetMap(members);
2217  MapIterator mit = map->find(reinterpret_cast<const Data&>(name.data_));
2218  if (mit != map->end()) {
2219  return MemberIterator(&members[mit->second]);
2220  }
2221  }
2222  return MemberEnd();
2223  }
2224 
2225  void DoClearMembers() {
2226  if (Member* members = GetMembersPointer()) {
2227  Map* &map = GetMap(members);
2228  MapIterator* mit = GetMapIterators(map);
2229  for (SizeType i = 0; i < data_.o.size; i++) {
2230  map->erase(DropMapIterator(mit[i]));
2231  members[i].~Member();
2232  }
2233  data_.o.size = 0;
2234  }
2235  }
2236 
2237  void DoFreeMembers() {
2238  if (Member* members = GetMembersPointer()) {
2239  GetMap(members)->~Map();
2240  for (SizeType i = 0; i < data_.o.size; i++) {
2241  members[i].~Member();
2242  }
2243  if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
2244  Map** map = &GetMap(members);
2245  Allocator::Free(*map);
2246  Allocator::Free(map);
2247  }
2248  }
2249  }
2250 
2251 #else // !RAPIDJSON_USE_MEMBERSMAP
2252 
2253  RAPIDJSON_FORCEINLINE Member* DoAllocMembers(SizeType capacity, Allocator& allocator) {
2254  return Malloc<Member>(allocator, capacity);
2255  }
2256 
2258  ObjectData& o = data_.o;
2259  if (newCapacity > o.capacity) {
2260  Member* newMembers = Realloc<Member>(allocator, GetMembersPointer(), o.capacity, newCapacity);
2261  RAPIDJSON_SETPOINTER(Member, o.members, newMembers);
2262  o.capacity = newCapacity;
2263  }
2264  }
2265 
2266  template <typename SourceAllocator>
2268  MemberIterator member = MemberBegin();
2269  for ( ; member != MemberEnd(); ++member)
2270  if (name.StringEqual(member->name))
2271  break;
2272  return member;
2273  }
2274 
2276  for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
2277  m->~Member();
2278  data_.o.size = 0;
2279  }
2280 
2281  void DoFreeMembers() {
2282  for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
2283  m->~Member();
2285  }
2286 
2287 #endif // !RAPIDJSON_USE_MEMBERSMAP
2288 
2290  ObjectData& o = data_.o;
2291  if (o.size >= o.capacity)
2292  DoReserveMembers(o.capacity ? (o.capacity + (o.capacity + 1) / 2) : kDefaultObjectCapacity, allocator);
2293  Member* members = GetMembersPointer();
2294  Member* m = members + o.size;
2295  m->name.RawAssign(name);
2296  m->value.RawAssign(value);
2297 #if RAPIDJSON_USE_MEMBERSMAP
2298  Map* &map = GetMap(members);
2299  MapIterator* mit = GetMapIterators(map);
2300  new (&mit[o.size]) MapIterator(map->insert(MapPair(m->name.data_, o.size)));
2301 #endif
2302  ++o.size;
2303  }
2304 
2306  ObjectData& o = data_.o;
2307  Member* members = GetMembersPointer();
2308 #if RAPIDJSON_USE_MEMBERSMAP
2309  Map* &map = GetMap(members);
2310  MapIterator* mit = GetMapIterators(map);
2311  SizeType mpos = static_cast<SizeType>(&*m - members);
2312  map->erase(DropMapIterator(mit[mpos]));
2313 #endif
2314  MemberIterator last(members + (o.size - 1));
2315  if (o.size > 1 && m != last) {
2316 #if RAPIDJSON_USE_MEMBERSMAP
2317  new (&mit[mpos]) MapIterator(DropMapIterator(mit[&*last - members]));
2318  mit[mpos]->second = mpos;
2319 #endif
2320  *m = *last; // Move the last one to this place
2321  }
2322  else {
2323  m->~Member(); // Only one left, just destroy
2324  }
2325  --o.size;
2326  return m;
2327  }
2328 
2330  ObjectData& o = data_.o;
2331  MemberIterator beg = MemberBegin(),
2332  pos = beg + (first - beg),
2333  end = MemberEnd();
2334 #if RAPIDJSON_USE_MEMBERSMAP
2335  Map* &map = GetMap(GetMembersPointer());
2336  MapIterator* mit = GetMapIterators(map);
2337 #endif
2338  for (MemberIterator itr = pos; itr != last; ++itr) {
2339 #if RAPIDJSON_USE_MEMBERSMAP
2340  map->erase(DropMapIterator(mit[itr - beg]));
2341 #endif
2342  itr->~Member();
2343  }
2344 #if RAPIDJSON_USE_MEMBERSMAP
2345  if (first != last) {
2346  // Move remaining members/iterators
2347  MemberIterator next = pos + (last - first);
2348  for (MemberIterator itr = pos; next != end; ++itr, ++next) {
2349  std::memcpy(static_cast<void*>(&*itr), &*next, sizeof(Member));
2350  SizeType mpos = static_cast<SizeType>(itr - beg);
2351  new (&mit[mpos]) MapIterator(DropMapIterator(mit[next - beg]));
2352  mit[mpos]->second = mpos;
2353  }
2354  }
2355 #else
2356  std::memmove(static_cast<void*>(&*pos), &*last,
2357  static_cast<size_t>(end - last) * sizeof(Member));
2358 #endif
2359  o.size -= static_cast<SizeType>(last - first);
2360  return pos;
2361  }
2362 
2363  template <typename SourceAllocator>
2364  void DoCopyMembers(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator, bool copyConstStrings) {
2365  RAPIDJSON_ASSERT(rhs.GetType() == kObjectType);
2366 
2368  SizeType count = rhs.data_.o.size;
2369  Member* lm = DoAllocMembers(count, allocator);
2371 #if RAPIDJSON_USE_MEMBERSMAP
2372  Map* &map = GetMap(lm);
2373  MapIterator* mit = GetMapIterators(map);
2374 #endif
2375  for (SizeType i = 0; i < count; i++) {
2376  new (&lm[i].name) GenericValue(rm[i].name, allocator, copyConstStrings);
2377  new (&lm[i].value) GenericValue(rm[i].value, allocator, copyConstStrings);
2378 #if RAPIDJSON_USE_MEMBERSMAP
2379  new (&mit[i]) MapIterator(map->insert(MapPair(lm[i].name.data_, i)));
2380 #endif
2381  }
2382  data_.o.size = data_.o.capacity = count;
2383  SetMembersPointer(lm);
2384  }
2385 
2386  // Initialize this value as array with initial data, without calling destructor.
2388  data_.f.flags = kArrayFlag;
2389  if (count) {
2390  GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
2391  SetElementsPointer(e);
2392  std::memcpy(static_cast<void*>(e), values, count * sizeof(GenericValue));
2393  }
2394  else
2395  SetElementsPointer(0);
2396  data_.a.size = data_.a.capacity = count;
2397  }
2398 
2400  void SetObjectRaw(Member* members, SizeType count, Allocator& allocator) {
2402  if (count) {
2403  Member* m = DoAllocMembers(count, allocator);
2404  SetMembersPointer(m);
2405  std::memcpy(static_cast<void*>(m), members, count * sizeof(Member));
2406 #if RAPIDJSON_USE_MEMBERSMAP
2407  Map* &map = GetMap(m);
2408  MapIterator* mit = GetMapIterators(map);
2409  for (SizeType i = 0; i < count; i++) {
2410  new (&mit[i]) MapIterator(map->insert(MapPair(m[i].name.data_, i)));
2411  }
2412 #endif
2413  }
2414  else
2415  SetMembersPointer(0);
2416  data_.o.size = data_.o.capacity = count;
2417  }
2418 
2420  void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT {
2422  SetStringPointer(s);
2423  data_.s.length = s.length;
2424  }
2425 
2428  Ch* str = 0;
2429  if (ShortString::Usable(s.length)) {
2431  data_.ss.SetLength(s.length);
2432  str = data_.ss.str;
2433  } else {
2435  data_.s.length = s.length;
2436  str = static_cast<Ch *>(allocator.Malloc((s.length + 1) * sizeof(Ch)));
2437  SetStringPointer(str);
2438  }
2439  std::memcpy(str, s, s.length * sizeof(Ch));
2440  str[s.length] = '\0';
2441  }
2442 
2444  void RawAssign(GenericValue& rhs) RAPIDJSON_NOEXCEPT {
2445  data_ = rhs.data_;
2446  // data_.f.flags = rhs.data_.f.flags;
2447  rhs.data_.f.flags = kNullFlag;
2448  }
2449 
2450  template <typename SourceAllocator>
2452  RAPIDJSON_ASSERT(IsString());
2453  RAPIDJSON_ASSERT(rhs.IsString());
2454 
2455  const SizeType len1 = GetStringLength();
2456  const SizeType len2 = rhs.GetStringLength();
2457  if(len1 != len2) { return false; }
2458 
2459  const Ch* const str1 = GetString();
2460  const Ch* const str2 = rhs.GetString();
2461  if(str1 == str2) { return true; } // fast path for constant string
2462 
2463  return (std::memcmp(str1, str2, sizeof(Ch) * len1) == 0);
2464  }
2465 
2466  Data data_;
2467 };
2468 
2471 
2473 // GenericDocument
2474 
2476 
2483 template <typename Encoding, typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR, typename StackAllocator = RAPIDJSON_DEFAULT_STACK_ALLOCATOR >
2484 class GenericDocument : public GenericValue<Encoding, Allocator> {
2485 public:
2486  typedef typename Encoding::Ch Ch;
2489 
2491 
2497  explicit GenericDocument(Type type, Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2498  GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2499  {
2500  if (!allocator_)
2501  ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2502  }
2503 
2505 
2510  GenericDocument(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
2511  allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2512  {
2513  if (!allocator_)
2514  ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2515  }
2516 
2517 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2518  GenericDocument(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT
2520  : ValueType(std::forward<ValueType>(rhs)), // explicit cast to avoid prohibited move from Document
2521  allocator_(rhs.allocator_),
2522  ownAllocator_(rhs.ownAllocator_),
2523  stack_(std::move(rhs.stack_)),
2524  parseResult_(rhs.parseResult_)
2525  {
2526  rhs.allocator_ = 0;
2527  rhs.ownAllocator_ = 0;
2528  rhs.parseResult_ = ParseResult();
2529  }
2530 #endif
2531 
2533  // Clear the ::ValueType before ownAllocator is destroyed, ~ValueType()
2534  // runs last and may access its elements or members which would be freed
2535  // with an allocator like MemoryPoolAllocator (CrtAllocator does not
2536  // free its data when destroyed, but MemoryPoolAllocator does).
2537  if (ownAllocator_) {
2538  ValueType::SetNull();
2539  }
2540  Destroy();
2541  }
2542 
2543 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2544  GenericDocument& operator=(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT
2546  {
2547  // The cast to ValueType is necessary here, because otherwise it would
2548  // attempt to call GenericValue's templated assignment operator.
2549  ValueType::operator=(std::forward<ValueType>(rhs));
2550 
2551  // Calling the destructor here would prematurely call stack_'s destructor
2552  Destroy();
2553 
2554  allocator_ = rhs.allocator_;
2555  ownAllocator_ = rhs.ownAllocator_;
2556  stack_ = std::move(rhs.stack_);
2557  parseResult_ = rhs.parseResult_;
2558 
2559  rhs.allocator_ = 0;
2560  rhs.ownAllocator_ = 0;
2561  rhs.parseResult_ = ParseResult();
2562 
2563  return *this;
2564  }
2565 #endif
2566 
2568 
2573  GenericDocument& Swap(GenericDocument& rhs) RAPIDJSON_NOEXCEPT {
2574  ValueType::Swap(rhs);
2575  stack_.Swap(rhs.stack_);
2576  internal::Swap(allocator_, rhs.allocator_);
2577  internal::Swap(ownAllocator_, rhs.ownAllocator_);
2578  internal::Swap(parseResult_, rhs.parseResult_);
2579  return *this;
2580  }
2581 
2582  // Allow Swap with ValueType.
2583  // Refer to Effective C++ 3rd Edition/Item 33: Avoid hiding inherited names.
2584  using ValueType::Swap;
2585 
2587 
2598  friend inline void swap(GenericDocument& a, GenericDocument& b) RAPIDJSON_NOEXCEPT { a.Swap(b); }
2599 
2601 
2605  template <typename Generator>
2606  GenericDocument& Populate(Generator& g) {
2607  ClearStackOnExit scope(*this);
2608  if (g(*this)) {
2609  RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2610  ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2611  }
2612  return *this;
2613  }
2614 
2617 
2619 
2625  template <unsigned parseFlags, typename SourceEncoding, typename InputStream>
2626  GenericDocument& ParseStream(InputStream& is) {
2628  stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2629  ClearStackOnExit scope(*this);
2630  parseResult_ = reader.template Parse<parseFlags>(is, *this);
2631  if (parseResult_) {
2632  RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2633  ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2634  }
2635  return *this;
2636  }
2637 
2639 
2644  template <unsigned parseFlags, typename InputStream>
2645  GenericDocument& ParseStream(InputStream& is) {
2646  return ParseStream<parseFlags, Encoding, InputStream>(is);
2647  }
2648 
2650 
2654  template <typename InputStream>
2655  GenericDocument& ParseStream(InputStream& is) {
2656  return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2657  }
2659 
2662 
2664 
2668  template <unsigned parseFlags>
2671  return ParseStream<parseFlags | kParseInsituFlag>(s);
2672  }
2673 
2675 
2679  return ParseInsitu<kParseDefaultFlags>(str);
2680  }
2682 
2685 
2687 
2691  template <unsigned parseFlags, typename SourceEncoding>
2692  GenericDocument& Parse(const typename SourceEncoding::Ch* str) {
2693  RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2695  return ParseStream<parseFlags, SourceEncoding>(s);
2696  }
2697 
2699 
2702  template <unsigned parseFlags>
2703  GenericDocument& Parse(const Ch* str) {
2704  return Parse<parseFlags, Encoding>(str);
2705  }
2706 
2708 
2710  GenericDocument& Parse(const Ch* str) {
2711  return Parse<kParseDefaultFlags>(str);
2712  }
2713 
2714  template <unsigned parseFlags, typename SourceEncoding>
2715  GenericDocument& Parse(const typename SourceEncoding::Ch* str, size_t length) {
2716  RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2717  MemoryStream ms(reinterpret_cast<const char*>(str), length * sizeof(typename SourceEncoding::Ch));
2719  ParseStream<parseFlags, SourceEncoding>(is);
2720  return *this;
2721  }
2722 
2723  template <unsigned parseFlags>
2724  GenericDocument& Parse(const Ch* str, size_t length) {
2725  return Parse<parseFlags, Encoding>(str, length);
2726  }
2727 
2728  GenericDocument& Parse(const Ch* str, size_t length) {
2729  return Parse<kParseDefaultFlags>(str, length);
2730  }
2731 
2732 #if RAPIDJSON_HAS_STDSTRING
2733  template <unsigned parseFlags, typename SourceEncoding>
2734  GenericDocument& Parse(const std::basic_string<typename SourceEncoding::Ch>& str) {
2735  // c_str() is constant complexity according to standard. Should be faster than Parse(const char*, size_t)
2736  return Parse<parseFlags, SourceEncoding>(str.c_str());
2737  }
2738 
2739  template <unsigned parseFlags>
2740  GenericDocument& Parse(const std::basic_string<Ch>& str) {
2741  return Parse<parseFlags, Encoding>(str.c_str());
2742  }
2743 
2744  GenericDocument& Parse(const std::basic_string<Ch>& str) {
2745  return Parse<kParseDefaultFlags>(str);
2746  }
2747 #endif // RAPIDJSON_HAS_STDSTRING
2748 
2750 
2753 
2755  bool HasParseError() const { return parseResult_.IsError(); }
2756 
2758  ParseErrorCode GetParseError() const { return parseResult_.Code(); }
2759 
2761  size_t GetErrorOffset() const { return parseResult_.Offset(); }
2762 
2764 #ifndef __clang // -Wdocumentation
2765 
2774 #endif
2775  operator ParseResult() const { return parseResult_; }
2777 
2780  RAPIDJSON_ASSERT(allocator_);
2781  return *allocator_;
2782  }
2783 
2785  size_t GetStackCapacity() const { return stack_.GetCapacity(); }
2786 
2787 private:
2788  // clear stack on any exit from ParseStream, e.g. due to exception
2789  struct ClearStackOnExit {
2790  explicit ClearStackOnExit(GenericDocument& d) : d_(d) {}
2791  ~ClearStackOnExit() { d_.ClearStack(); }
2792  private:
2793  ClearStackOnExit(const ClearStackOnExit&);
2794  ClearStackOnExit& operator=(const ClearStackOnExit&);
2795  GenericDocument& d_;
2796  };
2797 
2798  // callers of the following private Handler functions
2799  // template <typename,typename,typename> friend class GenericReader; // for parsing
2800  template <typename, typename> friend class GenericValue; // for deep copying
2801 
2802 public:
2803  // Implementation of Handler
2804  bool Null() { new (stack_.template Push<ValueType>()) ValueType(); return true; }
2805  bool Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b); return true; }
2806  bool Int(int i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
2807  bool Uint(unsigned i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
2808  bool Int64(int64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
2809  bool Uint64(uint64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
2810  bool Double(double d) { new (stack_.template Push<ValueType>()) ValueType(d); return true; }
2811 
2812  bool RawNumber(const Ch* str, SizeType length, bool copy) {
2813  if (copy)
2814  new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2815  else
2816  new (stack_.template Push<ValueType>()) ValueType(str, length);
2817  return true;
2818  }
2819 
2820  bool String(const Ch* str, SizeType length, bool copy) {
2821  if (copy)
2822  new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2823  else
2824  new (stack_.template Push<ValueType>()) ValueType(str, length);
2825  return true;
2826  }
2827 
2828  bool StartObject() { new (stack_.template Push<ValueType>()) ValueType(kObjectType); return true; }
2829 
2830  bool Key(const Ch* str, SizeType length, bool copy) { return String(str, length, copy); }
2831 
2832  bool EndObject(SizeType memberCount) {
2833  typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2834  stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount, GetAllocator());
2835  return true;
2836  }
2837 
2838  bool StartArray() { new (stack_.template Push<ValueType>()) ValueType(kArrayType); return true; }
2839 
2840  bool EndArray(SizeType elementCount) {
2841  ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2842  stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());
2843  return true;
2844  }
2845 
2846 private:
2851 
2852  void ClearStack() {
2853  if (Allocator::kNeedFree)
2854  while (stack_.GetSize() > 0) // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects)
2855  (stack_.template Pop<ValueType>(1))->~ValueType();
2856  else
2857  stack_.Clear();
2858  stack_.ShrinkToFit();
2859  }
2860 
2861  void Destroy() {
2862  RAPIDJSON_DELETE(ownAllocator_);
2863  }
2864 
2865  static const size_t kDefaultStackCapacity = 1024;
2866  Allocator* allocator_;
2867  Allocator* ownAllocator_;
2869  ParseResult parseResult_;
2870 };
2871 
2874 
2875 
2877 
2881 template <bool Const, typename ValueT>
2882 class GenericArray {
2883 public:
2886  typedef ValueT PlainType;
2888  typedef ValueType* ValueIterator; // This may be const or non-const iterator
2889  typedef const ValueT* ConstValueIterator;
2890  typedef typename ValueType::AllocatorType AllocatorType;
2891  typedef typename ValueType::StringRefType StringRefType;
2892 
2893  template <typename, typename>
2894  friend class GenericValue;
2895 
2896  GenericArray(const GenericArray& rhs) : value_(rhs.value_) {}
2897  GenericArray& operator=(const GenericArray& rhs) { value_ = rhs.value_; return *this; }
2899 
2900  operator ValueType&() const { return value_; }
2901  SizeType Size() const { return value_.Size(); }
2902  SizeType Capacity() const { return value_.Capacity(); }
2903  bool Empty() const { return value_.Empty(); }
2904  void Clear() const { value_.Clear(); }
2905  ValueType& operator[](SizeType index) const { return value_[index]; }
2906  ValueIterator Begin() const { return value_.Begin(); }
2907  ValueIterator End() const { return value_.End(); }
2908  GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const { value_.Reserve(newCapacity, allocator); return *this; }
2909  GenericArray PushBack(ValueType& value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; }
2910 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2911  GenericArray PushBack(ValueType&& value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; }
2912 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
2913  GenericArray PushBack(StringRefType value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; }
2914  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; }
2915  GenericArray PopBack() const { value_.PopBack(); return *this; }
2916  ValueIterator Erase(ConstValueIterator pos) const { return value_.Erase(pos); }
2917  ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const { return value_.Erase(first, last); }
2918 
2919 #if RAPIDJSON_HAS_CXX11_RANGE_FOR
2920  ValueIterator begin() const { return value_.Begin(); }
2921  ValueIterator end() const { return value_.End(); }
2922 #endif
2923 
2924 private:
2925  GenericArray();
2926  GenericArray(ValueType& value) : value_(value) {}
2927  ValueType& value_;
2928 };
2929 
2931 
2935 template <bool Const, typename ValueT>
2936 class GenericObject {
2937 public:
2940  typedef ValueT PlainType;
2944  typedef typename ValueType::AllocatorType AllocatorType;
2945  typedef typename ValueType::StringRefType StringRefType;
2946  typedef typename ValueType::EncodingType EncodingType;
2947  typedef typename ValueType::Ch Ch;
2948 
2949  template <typename, typename>
2950  friend class GenericValue;
2951 
2952  GenericObject(const GenericObject& rhs) : value_(rhs.value_) {}
2953  GenericObject& operator=(const GenericObject& rhs) { value_ = rhs.value_; return *this; }
2955 
2956  operator ValueType&() const { return value_; }
2957  SizeType MemberCount() const { return value_.MemberCount(); }
2958  SizeType MemberCapacity() const { return value_.MemberCapacity(); }
2959  bool ObjectEmpty() const { return value_.ObjectEmpty(); }
2960  template <typename T> ValueType& operator[](T* name) const { return value_[name]; }
2961  template <typename SourceAllocator> ValueType& operator[](const GenericValue<EncodingType, SourceAllocator>& name) const { return value_[name]; }
2962 #if RAPIDJSON_HAS_STDSTRING
2963  ValueType& operator[](const std::basic_string<Ch>& name) const { return value_[name]; }
2964 #endif
2965  MemberIterator MemberBegin() const { return value_.MemberBegin(); }
2966  MemberIterator MemberEnd() const { return value_.MemberEnd(); }
2967  GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocator) const { value_.MemberReserve(newCapacity, allocator); return *this; }
2968  bool HasMember(const Ch* name) const { return value_.HasMember(name); }
2969 #if RAPIDJSON_HAS_STDSTRING
2970  bool HasMember(const std::basic_string<Ch>& name) const { return value_.HasMember(name); }
2971 #endif
2972  template <typename SourceAllocator> bool HasMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.HasMember(name); }
2973  MemberIterator FindMember(const Ch* name) const { return value_.FindMember(name); }
2974  template <typename SourceAllocator> MemberIterator FindMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.FindMember(name); }
2975 #if RAPIDJSON_HAS_STDSTRING
2976  MemberIterator FindMember(const std::basic_string<Ch>& name) const { return value_.FindMember(name); }
2977 #endif
2978  GenericObject AddMember(ValueType& name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }
2980 #if RAPIDJSON_HAS_STDSTRING
2981  GenericObject AddMember(ValueType& name, std::basic_string<Ch>& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }
2982 #endif
2983  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; }
2984 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
2985  GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }
2986  GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }
2987  GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }
2988  GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }
2989 #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
2992  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; }
2993  void RemoveAllMembers() { value_.RemoveAllMembers(); }
2994  bool RemoveMember(const Ch* name) const { return value_.RemoveMember(name); }
2995 #if RAPIDJSON_HAS_STDSTRING
2996  bool RemoveMember(const std::basic_string<Ch>& name) const { return value_.RemoveMember(name); }
2997 #endif
2998  template <typename SourceAllocator> bool RemoveMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.RemoveMember(name); }
2999  MemberIterator RemoveMember(MemberIterator m) const { return value_.RemoveMember(m); }
3000  MemberIterator EraseMember(ConstMemberIterator pos) const { return value_.EraseMember(pos); }
3001  MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const { return value_.EraseMember(first, last); }
3002  bool EraseMember(const Ch* name) const { return value_.EraseMember(name); }
3003 #if RAPIDJSON_HAS_STDSTRING
3004  bool EraseMember(const std::basic_string<Ch>& name) const { return EraseMember(ValueType(StringRef(name))); }
3005 #endif
3006  template <typename SourceAllocator> bool EraseMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.EraseMember(name); }
3007 
3008 #if RAPIDJSON_HAS_CXX11_RANGE_FOR
3009  MemberIterator begin() const { return value_.MemberBegin(); }
3010  MemberIterator end() const { return value_.MemberEnd(); }
3011 #endif
3012 
3013 private:
3014  GenericObject();
3015  GenericObject(ValueType& value) : value_(value) {}
3016  ValueType& value_;
3017 };
3018 
3020 RAPIDJSON_DIAG_POP
3021 
3022 #ifdef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
3023 #pragma pop_macro("GetObject")
3024 #undef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
3025 #endif
3026 
3027 #endif // RAPIDJSON_DOCUMENT_H_
GenericValue::MemberIterator
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
Definition: document.h:676
GenericValue::DoFindMember
MemberIterator DoFindMember(const GenericValue< Encoding, SourceAllocator > &name)
Definition: document.h:2267
GenericValue::kNumberUintFlag
@ kNumberUintFlag
Definition: document.h:1994
GenericObject::FindMember
MemberIterator FindMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition: document.h:2974
GenericObject::EncodingType
ValueType::EncodingType EncodingType
Definition: document.h:2946
GenericDocument::ParseStream
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
Definition: document.h:2626
GenericStringRef::Ch
CharType Ch
character type of the string
Definition: document.h:347
GenericObject::MemberReserve
GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocator) const
Definition: document.h:2967
GenericMemberIterator::Pointer
pointer Pointer
Pointer to (const) GenericMember.
Definition: document.h:212
GenericObject::AddMember
GenericObject AddMember(StringRefType name, ValueType &value, AllocatorType &allocator) const
Definition: document.h:2990
GenericObject::ConstMemberIterator
GenericMemberIterator< true, typename ValueT::EncodingType, typename ValueT::AllocatorType > ConstMemberIterator
Definition: document.h:2943
GenericPointer
Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.
Definition: fwd.h:126
GenericMemberIterator::operator+=
Iterator & operator+=(DifferenceType n)
Definition: document.h:256
GenericValue::StringEqual
bool StringEqual(const GenericValue< Encoding, SourceAllocator > &rhs) const
Definition: document.h:2451
internal::TypeHelper
Definition: document.h:519
RAPIDJSON_NAMESPACE_END
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
GenericObject::GenericObject
GenericObject(const GenericObject &rhs)
Definition: document.h:2952
GenericMemberIterator::difference_type
std::ptrdiff_t difference_type
Definition: document.h:207
GenericMemberIterator::DifferenceType
difference_type DifferenceType
Signed integer type (e.g. ptrdiff_t)
Definition: document.h:216
GenericArray::allocator
AllocatorType &const allocator
Definition: document.h:2914
GenericObject::AddMember
GenericObject AddMember(ValueType &name, StringRefType value, AllocatorType &allocator) const
Definition: document.h:2979
GenericValue::Flag
Definition: document.h:2011
GenericValue::ConstObject
GenericObject< true, ValueType > ConstObject
Definition: document.h:684
GenericValue::kStringFlag
@ kStringFlag
Definition: document.h:1984
internal::TypeHelper< ValueType, typename ValueType::ConstArray >::ArrayType
ValueType::ConstArray ArrayType
Definition: document.h:627
kNullType
@ kNullType
null
Definition: rapidjson.h:730
RAPIDJSON_NAMESPACE_BEGIN
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
GenericValue::ObjectData::members
Member * members
Definition: document.h:2074
GenericValue::ShortString::MaxChars
@ MaxChars
Definition: document.h:2037
internal::IsGenericValue
Definition: document.h:509
GenericArray::Reserve
GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const
Definition: document.h:2908
GenericValue::kBoolFlag
@ kBoolFlag
Definition: document.h:1977
GenericDocument
A document for parsing JSON text as DOM.
Definition: document.h:69
GenericStringRef::GenericStringRef
GenericStringRef(const GenericStringRef &rhs)
Definition: document.h:414
GenericValue::String
Definition: document.h:2022
GenericObject::HasMember
bool HasMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition: document.h:2972
GenericDocument::GetParseError
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
Definition: document.h:2758
GenericObject::Ch
ValueType::Ch Ch
Definition: document.h:2947
kFalseType
@ kFalseType
false
Definition: rapidjson.h:731
GenericStringRef::GenericStringRef
GenericStringRef(const CharType *str, SizeType len)
Create constant string reference from pointer and length.
Definition: document.h:411
GenericValue::kNumberIntFlag
@ kNumberIntFlag
Definition: document.h:1993
GenericValue::SetElementsPointer
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
Definition: document.h:2102
GenericValue::ShortString::GetLength
SizeType GetLength() const
Definition: document.h:2042
Allocator
Concept for allocating, resizing and freeing memory block.
GenericDocument::StartObject
bool StartObject()
Definition: document.h:2828
Document
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:2873
internal::Stack::GetCapacity
size_t GetCapacity() const
Definition: stack.h:179
kArrayType
@ kArrayType
array
Definition: rapidjson.h:734
GenericValue::ConstValueIterator
const typedef GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
Definition: document.h:679
GenericValue::Number
Definition: document.h:2046
internal::TypeHelper< ValueType, int >::Set
static ValueType & Set(ValueType &v, int data, typename ValueType::AllocatorType &)
Definition: document.h:534
GenericValue::kNumberDoubleFlag
@ kNumberDoubleFlag
Definition: document.h:1997
GenericValue::ArrayData::capacity
SizeType capacity
Definition: document.h:2079
GenericValue::ArrayData::elements
GenericValue * elements
Definition: document.h:2080
internal::TypeHelper< ValueType, float >::Set
static ValueType & Set(ValueType &v, float data, typename ValueType::AllocatorType &)
Definition: document.h:594
GenericDocument::Int64
bool Int64(int64_t i)
Definition: document.h:2808
GenericArray::ConstValueIterator
const typedef ValueT * ConstValueIterator
Definition: document.h:2889
GenericValue::kDefaultArrayCapacity
static const SizeType kDefaultArrayCapacity
Definition: document.h:2008
GenericStringRef::GenericStringRef
GenericStringRef(const CharType *str)
Explicitly create string reference from const character pointer.
Definition: document.h:399
GenericDocument::Bool
bool Bool(bool b)
Definition: document.h:2805
GenericDocument::ParseStream
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream.
Definition: document.h:2645
GenericValue::kObjectFlag
@ kObjectFlag
Definition: document.h:2002
Type
Type
Type of JSON value.
Definition: rapidjson.h:729
GenericValue::Number::i
struct GenericValue::Number::I i
GenericMemberIterator::operator<=
bool operator<=(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition: document.h:264
internal::Stack::Clear
void Clear()
Definition: stack.h:99
GenericValue::kNumberAnyFlag
@ kNumberAnyFlag
Definition: document.h:1998
GenericObject::ValueType
internal::MaybeAddConst< Const, PlainType >::Type ValueType
Definition: document.h:2941
GenericObject::FindMember
MemberIterator FindMember(const Ch *name) const
Definition: document.h:2973
GenericDocument::Parse
GenericDocument & Parse(const typename SourceEncoding::Ch *str, size_t length)
Definition: document.h:2715
GenericDocument::ParseInsitu
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
Definition: document.h:2669
internal::TypeHelper< ValueType, typename ValueType::ConstObject >::Get
static ObjectType Get(const ValueType &v)
Definition: document.h:645
GenericStringRef::s
const Ch *const s
plain CharType pointer
Definition: document.h:419
internal::TypeHelper< ValueType, uint64_t >::Get
static uint64_t Get(const ValueType &v)
Definition: document.h:576
GenericMemberIterator::operator>
bool operator>(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition: document.h:267
GenericValue::kNumberFlag
@ kNumberFlag
Definition: document.h:1978
GenericDocument::Parse
GenericDocument & Parse(const Ch *str, size_t length)
Definition: document.h:2728
GenericArray::Erase
ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const
Definition: document.h:2917
internal::IsGenericValueImpl
Definition: document.h:502
GenericArray::ConstArray
GenericArray< true, ValueT > ConstArray
Definition: document.h:2884
internal::TypeHelper< ValueType, typename ValueType::Object >::Is
static bool Is(const ValueType &v)
Definition: document.h:635
GenericValue::kArrayFlag
@ kArrayFlag
Definition: document.h:2003
GenericObject::EraseMember
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const
Definition: document.h:3001
GenericStringRef::length
const SizeType length
length of the string (excluding the trailing NULL terminator)
Definition: document.h:420
GenericValue::String::str
const Ch * str
Definition: document.h:2025
GenericMemberIterator::operator*
Reference operator*() const
Definition: document.h:276
GenericMemberIterator::value_type
ValueType value_type
Definition: document.h:204
GenericValue::kIntFlag
@ kIntFlag
Definition: document.h:1979
GenericValue::StringRefType
GenericStringRef< Ch > StringRefType
Reference to a constant string.
Definition: document.h:675
internal::TypeHelper< ValueType, uint64_t >::Set
static ValueType & Set(ValueType &v, uint64_t data, typename ValueType::AllocatorType &)
Definition: document.h:578
GenericArray::RAPIDJSON_DISABLEIF_RETURN
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(const GenericArray &)) PushBack(T value
kObjectType
@ kObjectType
object
Definition: rapidjson.h:733
GenericValue::DoAllocMembers
RAPIDJSON_FORCEINLINE Member * DoAllocMembers(SizeType capacity, Allocator &allocator)
Definition: document.h:2253
GenericValue::GenericValue
GenericValue(Object o) RAPIDJSON_NOEXCEPT
Constructor for Object.
Definition: document.h:872
GenericMemberIterator::operator=
Iterator & operator=(const NonConstIterator &it)
Definition: document.h:241
GenericArray
Helper class for accessing Value of array type.
Definition: document.h:651
copy
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting changing font or adding deleting some characters in from glyph table PL means Public License Copyright Holder means whoever is named in the copyright or copyrights for the Font You means the or person redistributing or modifying the Font Freely Available means that you have the freedom to copy or modify the Font as well as redistribute copies of the Font under the same conditions you not price If you you can charge for this service Copying &Distribution You may copy and distribute verbatim copies of this Font in any without provided that you retain this license including modifying reordering converting changing font or adding deleting some characters in from glyph and copy and distribute such modifications under the terms of Section provided that the following conditions are such as by offering access to copy the modifications from a designated or distributing the modifications on a medium customarily used for software interchange c If the modified fonts normally reads commands interactively when you must cause when started running for such interactive use in the most ordinary to print or display an announcement including an appropriate copyright notice and a notice that there is no and telling the user how to view a copy of this License These requirements apply to the modified work as a whole If identifiable sections of that work are not derived from the and can be reasonably considered independent and separate works in then this License and its do not apply to those sections when you distribute them as separate works mere aggregation of another work not based on the Font with the Font on a volume of a storage or distribution medium does not bring the other work under the scope of this License Condition Subsequent You may not copy
Definition: ARPHICPL.TXT:41
GenericValue::ConstMemberIterator
GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
Constant member iterator for iterating in object.
Definition: document.h:677
GenericValue::SetStringPointer
const RAPIDJSON_FORCEINLINE Ch * SetStringPointer(const Ch *str)
Definition: document.h:2100
GenericObject::AddMember
GenericObject AddMember(ValueType &name, ValueType &value, AllocatorType &allocator) const
Definition: document.h:2978
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
GenericDocument::GetErrorOffset
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
Definition: document.h:2761
GenericArray::Capacity
SizeType Capacity() const
Definition: document.h:2902
internal::TypeHelper< ValueType, float >::Set
static ValueType & Set(ValueType &v, float data)
Definition: document.h:593
GenericArray::PlainType
ValueT PlainType
Definition: document.h:2886
internal::TypeHelper< ValueType, typename ValueType::ConstObject >::Is
static bool Is(const ValueType &v)
Definition: document.h:644
GenericMember::swap
friend void swap(GenericMember &a, GenericMember &b) RAPIDJSON_NOEXCEPT
Definition: document.h:151
internal::TypeHelper< ValueType, int64_t >::Set
static ValueType & Set(ValueType &v, int64_t data, typename ValueType::AllocatorType &)
Definition: document.h:570
GenericMemberIterator::operator--
Iterator operator--(int)
Definition: document.h:248
ParseResult::Offset
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition: error.h:118
GenericArray::Erase
ValueIterator Erase(ConstValueIterator pos) const
Definition: document.h:2916
internal::TypeHelper< ValueType, int64_t >::Is
static bool Is(const ValueType &v)
Definition: document.h:567
GenericValue::DoFreeMembers
void DoFreeMembers()
Definition: document.h:2281
MemoryStream
Represents an in-memory input byte stream.
Definition: memorystream.h:40
GenericMemberIterator::operator<
bool operator<(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition: document.h:266
GenericObject::AllocatorType
ValueType::AllocatorType AllocatorType
Definition: document.h:2944
GenericObject::ObjectEmpty
bool ObjectEmpty() const
Definition: document.h:2959
GenericValue::String::length
SizeType length
Definition: document.h:2023
GenericValue::DoRemoveMember
MemberIterator DoRemoveMember(MemberIterator m)
Definition: document.h:2305
GenericObject::RemoveMember
bool RemoveMember(const Ch *name) const
Definition: document.h:2994
GenericInsituStringStream
A read-write string stream.
Definition: fwd.h:52
internal::TypeHelper< ValueType, const typename ValueType::Ch * >::Is
static bool Is(const ValueType &v)
Definition: document.h:600
GenericValue::Number::U::padding2
char padding2[4]
Definition: document.h:2054
GenericValue::kNumberInt64Flag
@ kNumberInt64Flag
Definition: document.h:1995
SizeType
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:415
GenericArray::ValueIterator
ValueType * ValueIterator
Definition: document.h:2888
GenericObject::ConstObject
GenericObject< true, ValueT > ConstObject
Definition: document.h:2938
GenericValue::ShortString::LenPos
@ LenPos
Definition: document.h:2037
internal::TypeHelper< ValueType, unsigned >::Set
static ValueType & Set(ValueType &v, unsigned data)
Definition: document.h:541
internal::TypeHelper< ValueType, const typename ValueType::Ch * >::Get
static StringType Get(const ValueType &v)
Definition: document.h:601
internal::TypeHelper< ValueType, typename ValueType::Array >::Set
static ValueType & Set(ValueType &v, ArrayType data, typename ValueType::AllocatorType &)
Definition: document.h:622
ParseResult::IsError
bool IsError() const
Whether the result is an error.
Definition: error.h:123
GenericArray::Empty
bool Empty() const
Definition: document.h:2903
GenericValue::DoClearMembers
void DoClearMembers()
Definition: document.h:2275
GenericValue::Data::o
ObjectData o
Definition: document.h:2087
GenericValue::GenericValue
GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT
Constructor for int64_t value.
Definition: document.h:804
GenericValue::operator=
GenericValue & operator=(StringRefType str) RAPIDJSON_NOEXCEPT
Assignment of constant string reference (no copy)
Definition: document.h:946
GenericValue::Ch
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:674
StringRef
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:454
GenericMember::value
GenericValue< Encoding, Allocator > value
value of member.
Definition: document.h:123
GenericValue::kInt64Flag
@ kInt64Flag
Definition: document.h:1981
internal::TypeHelper< ValueType, typename ValueType::ConstObject >::ObjectType
ValueType::ConstObject ObjectType
Definition: document.h:643
GenericDocument::EndArray
bool EndArray(SizeType elementCount)
Definition: document.h:2840
GenericValue::kUintFlag
@ kUintFlag
Definition: document.h:1980
allocator
Blam::LinearAllocator allocator
– TO BE FILLED IN BY VERTIGO –
Definition: main.cpp:76
GenericMemberIterator::GenericMemberIterator
friend class GenericMemberIterator
Definition: document.h:189
GenericValue::GenericValue
GenericValue(const Ch *s, SizeType length) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
Definition: document.h:837
kParseInsituFlag
@ kParseInsituFlag
In-situ(destructive) parsing.
Definition: reader.h:148
GenericDocument::Key
bool Key(const Ch *str, SizeType length, bool copy)
Definition: document.h:2830
kStringType
@ kStringType
string
Definition: rapidjson.h:735
GenericObject::MemberCount
SizeType MemberCount() const
Definition: document.h:2957
memorystream.h
GenericValue::SetArrayRaw
void SetArrayRaw(GenericValue *values, SizeType count, Allocator &allocator)
Definition: document.h:2387
GenericObject::RemoveMember
MemberIterator RemoveMember(MemberIterator m) const
Definition: document.h:2999
uint64_t
unsigned long long uint64_t
Definition: stdint.h:18
internal::TypeHelper< ValueType, double >::Is
static bool Is(const ValueType &v)
Definition: document.h:583
GenericObject::MemberBegin
MemberIterator MemberBegin() const
Definition: document.h:2965
GenericDocument::Null
bool Null()
Definition: document.h:2804
GenericStringStream
Read-only string stream.
Definition: fwd.h:47
GenericValue::operator=
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:921
GenericValue::Flag::flags
uint16_t flags
Definition: document.h:2019
GenericMemberIterator::operator-=
Iterator & operator-=(DifferenceType n)
Definition: document.h:257
GenericValue::GenericValue
GenericValue(const Ch *s, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
Definition: document.h:846
GenericDocument::GenericDocument
GenericDocument(Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Definition: document.h:2510
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
internal::TypeHelper< ValueType, const typename ValueType::Ch * >::Set
static ValueType & Set(ValueType &v, const StringType data)
Definition: document.h:602
GenericValue::kTrueFlag
@ kTrueFlag
Definition: document.h:1991
GenericDocument::GetAllocator
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:2779
internal::TypeHelper< ValueType, const typename ValueType::Ch * >::StringType
const typedef ValueType::Ch * StringType
Definition: document.h:599
RAPIDJSON_ASSERT
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:437
that
b output the Images to a print format other than for collateral and the you may copy and distribute your animations and renderings incorporating the Images All other rights with respect to the Images and their use are reserved to Company The Images are protected by United States copyright international treaty and other laws TERM You may use the Images for incorporation in a single product or or for visualization purposes within a single project of duration not more than three years INFRINGEMENT WARRANTY NVIDIA warrants to you that
Definition: TextureUsageAgreement.txt:16
internal::TypeHelper< ValueType, bool >::Is
static bool Is(const ValueType &v)
Definition: document.h:523
GenericValue::Number::U
Definition: document.h:2052
internal::TypeHelper< ValueType, unsigned >::Get
static unsigned Get(const ValueType &v)
Definition: document.h:540
meta.h
internal::TypeHelper< ValueType, typename ValueType::Object >::Set
static ValueType & Set(ValueType &v, ObjectType data)
Definition: document.h:637
GenericValue::DataString
static const RAPIDJSON_FORCEINLINE Ch * DataString(const Data &data)
Definition: document.h:2092
GenericValue::ArrayData
Definition: document.h:2077
internal::TypeHelper< ValueType, double >::Set
static ValueType & Set(ValueType &v, double data)
Definition: document.h:585
internal::TypeHelper< ValueType, typename ValueType::ConstArray >::Is
static bool Is(const ValueType &v)
Definition: document.h:628
GenericValue::kConstStringFlag
@ kConstStringFlag
Definition: document.h:1999
GenericStringRef::StringRef
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:454
GenericMember::name
GenericValue< Encoding, Allocator > name
name of member (must be a string)
Definition: document.h:122
GenericValue::kDefaultObjectCapacity
static const SizeType kDefaultObjectCapacity
Definition: document.h:2009
GenericValue::Number::U::u
unsigned u
Definition: document.h:2053
GenericValue::GenericValue
GenericValue(unsigned u) RAPIDJSON_NOEXCEPT
Constructor for unsigned value.
Definition: document.h:798
ParseErrorCode
ParseErrorCode
Error code of parsing.
Definition: error.h:64
GenericDocument::EndObject
bool EndObject(SizeType memberCount)
Definition: document.h:2832
internal::TypeHelper< ValueType, typename ValueType::ConstArray >::Get
static ArrayType Get(const ValueType &v)
Definition: document.h:629
GenericValue::kTypeMask
@ kTypeMask
Definition: document.h:2005
internal::TypeHelper< ValueType, int64_t >::Get
static int64_t Get(const ValueType &v)
Definition: document.h:568
internal::TypeHelper< ValueType, bool >::Set
static ValueType & Set(ValueType &v, bool data, typename ValueType::AllocatorType &)
Definition: document.h:526
GenericDocument::StartArray
bool StartArray()
Definition: document.h:2838
GenericValue::DoEraseMembers
MemberIterator DoEraseMembers(ConstMemberIterator first, ConstMemberIterator last)
Definition: document.h:2329
GenericDocument::Populate
GenericDocument & Populate(Generator &g)
Populate this document by a generator which produces SAX events.
Definition: document.h:2606
a
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1249
GenericDocument::RawNumber
bool RawNumber(const Ch *str, SizeType length, bool copy)
Definition: document.h:2812
GenericDocument::ParseInsitu
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string (with kParseDefaultFlags)
Definition: document.h:2678
kNumberType
@ kNumberType
number
Definition: rapidjson.h:736
GenericObject::RAPIDJSON_DISABLEIF_RETURN
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr< internal::IsPointer< T >, internal::IsGenericValue< T > >),(ValueType &)) AddMember(ValueType &name
internal::TypeHelper< ValueType, unsigned >::Set
static ValueType & Set(ValueType &v, unsigned data, typename ValueType::AllocatorType &)
Definition: document.h:542
GenericMember::operator=
GenericMember & operator=(GenericMember &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:142
GenericObject::operator[]
ValueType & operator[](T *name) const
Definition: document.h:2960
GenericDocument::swap
friend void swap(GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
Definition: document.h:2598
GenericObject::PlainType
ValueT PlainType
Definition: document.h:2940
GenericValue::Data::n
Number n
Definition: document.h:2086
GenericDocument::GetStackCapacity
size_t GetStackCapacity() const
Get the capacity of stack in bytes.
Definition: document.h:2785
GenericValue::RAPIDJSON_DISABLEIF_RETURN
RAPIDJSON_DISABLEIF_RETURN((internal::IsPointer< T >),(GenericValue &)) operator
Assignment with primitive types.
GenericMemberIterator::GenericMemberIterator
GenericMemberIterator()
Default constructor (singular value)
Definition: document.h:222
internal::TypeHelper< ValueType, bool >::Set
static ValueType & Set(ValueType &v, bool data)
Definition: document.h:525
GenericDocument::HasParseError
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Definition: document.h:2755
GenericValue::ObjectData::size
SizeType size
Definition: document.h:2072
GenericMemberIterator::Reference
reference Reference
Reference to (const) GenericMember.
Definition: document.h:214
GenericMemberIterator::operator-
DifferenceType operator-(ConstIterator that) const
Distance.
Definition: document.h:282
ParseResult
Result of parsing (wraps ParseErrorCode)
Definition: error.h:106
GenericValue::DoCopyMembers
void DoCopyMembers(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings)
Definition: document.h:2364
GenericValue::ConstArray
GenericArray< true, ValueType > ConstArray
Definition: document.h:682
reader.h
int64_t
long long int64_t
Definition: stdint.h:14
internal::Stack::GetSize
size_t GetSize() const
Definition: stack.h:178
GenericValue::EncodingType
Encoding EncodingType
Encoding type from template parameter.
Definition: document.h:672
GenericValue::ObjectData
Definition: document.h:2071
GenericObject::operator[]
ValueType & operator[](const GenericValue< EncodingType, SourceAllocator > &name) const
Definition: document.h:2961
GenericMemberIterator::NonConstIterator
GenericMemberIterator< false, Encoding, Allocator > NonConstIterator
Non-constant iterator type.
Definition: document.h:200
GenericObject::EraseMember
bool EraseMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition: document.h:3006
GenericMemberIterator::reference
ValueType & reference
Definition: document.h:206
GenericValue::GenericValue
GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
Constructor for boolean value.
Definition: document.h:781
GenericDocument::ParseStream
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with kParseDefaultFlags)
Definition: document.h:2655
GenericMemberIterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: document.h:208
GenericValue::DoReserveMembers
void DoReserveMembers(SizeType newCapacity, Allocator &allocator)
Definition: document.h:2257
RAPIDJSON_GETPOINTER
#define RAPIDJSON_GETPOINTER(type, p)
Definition: rapidjson.h:350
GenericValue::ObjectData::capacity
SizeType capacity
Definition: document.h:2073
RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
#define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
User defined kDefaultArrayCapacity value.
Definition: document.h:110
GenericArray::StringRefType
ValueType::StringRefType StringRefType
Definition: document.h:2891
Value
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2470
GenericArray::~GenericArray
~GenericArray()
Definition: document.h:2898
GenericValue::Number::d
double d
Definition: document.h:2068
it
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting changing font or adding deleting some characters in from glyph table PL means Public License Copyright Holder means whoever is named in the copyright or copyrights for the Font You means the or person redistributing or modifying the Font Freely Available means that you have the freedom to copy or modify the Font as well as redistribute copies of the Font under the same conditions you not price If you you can charge for this service Copying &Distribution You may copy and distribute verbatim copies of this Font in any without provided that you retain this license including modifying reordering converting changing font or adding deleting some characters in from glyph and copy and distribute such modifications under the terms of Section provided that the following conditions are such as by offering access to copy the modifications from a designated or distributing the modifications on a medium customarily used for software interchange c If the modified fonts normally reads commands interactively when you must cause it
Definition: ARPHICPL.TXT:36
GenericValue::Data
Definition: document.h:2083
Blam::Globals::Object
@ Object
Unknown. Referenced within the hs_doc from Halo 2 Sapien.
Definition: globals.h:47
internal::TypeHelper< ValueType, typename ValueType::Object >::Set
static ValueType & Set(ValueType &v, ObjectType data, typename ValueType::AllocatorType &)
Definition: document.h:638
GenericObject::allocator
T AllocatorType &const allocator
Definition: document.h:2983
GenericArray::End
ValueIterator End() const
Definition: document.h:2907
GenericMemberIterator::operator==
bool operator==(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition: document.h:262
strfunc.h
internal::Stack::GetAllocator
Allocator & GetAllocator()
Definition: stack.h:172
GenericObject::~GenericObject
~GenericObject()
Definition: document.h:2954
GenericMemberIterator::operator>=
bool operator>=(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition: document.h:265
GenericMemberIterator::ConstIterator
GenericMemberIterator< true, Encoding, Allocator > ConstIterator
Constant iterator type.
Definition: document.h:198
GenericValue::kCopyFlag
@ kCopyFlag
Definition: document.h:1985
internal::Stack::HasAllocator
bool HasAllocator() const
Definition: stack.h:168
Free
void Free(A &a, T *p, size_t n=1)
Definition: allocators.h:447
RAPIDJSON_NEW
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition: rapidjson.h:712
GenericArray::Begin
ValueIterator Begin() const
Definition: document.h:2906
RAPIDJSON_DELETE
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition: rapidjson.h:716
GenericObject::AddMember
GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType &allocator) const
Definition: document.h:2991
internal::TypeHelper< ValueType, uint64_t >::Set
static ValueType & Set(ValueType &v, uint64_t data)
Definition: document.h:577
GenericReader
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition: fwd.h:88
GenericValue::GenericValue
GenericValue(const Ch *s, SizeType length, Allocator &allocator)
Constructor for copy-string (i.e. do make a copy of string)
Definition: document.h:843
internal::TypeHelper< ValueType, typename ValueType::Array >::Get
static ArrayType Get(ValueType &v)
Definition: document.h:620
GenericValue::ShortString::Usable
static bool Usable(SizeType len)
Definition: document.h:2040
internal::Stack< StackAllocator >
GenericMemberIterator::operator->
Pointer operator->() const
Definition: document.h:277
encodedstream.h
GenericValue
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:66
GenericMember
Name-value pair in a JSON object value.
Definition: document.h:120
GenericValue::RawAssign
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
Definition: document.h:2444
internal::TypeHelper< ValueType, typename ValueType::Object >::Get
static ObjectType Get(ValueType &v)
Definition: document.h:636
EncodedInputStream
Input byte stream wrapper with a statically bound encoding.
Definition: encodedstream.h:39
internal::TypeHelper< ValueType, const typename ValueType::Ch * >::Set
static ValueType & Set(ValueType &v, const StringType data, typename ValueType::AllocatorType &a)
Definition: document.h:603
internal::TypeHelper< ValueType, float >::Get
static float Get(const ValueType &v)
Definition: document.h:592
GenericValue::GenericValue
GenericValue(float f) RAPIDJSON_NOEXCEPT
Constructor for float value.
Definition: document.h:834
GenericDocument::Uint
bool Uint(unsigned i)
Definition: document.h:2807
GenericValue::kShortStringFlag
@ kShortStringFlag
Definition: document.h:2001
internal::TypeHelper< ValueType, typename ValueType::Array >::Is
static bool Is(const ValueType &v)
Definition: document.h:619
GenericValue::GenericValue
GenericValue() RAPIDJSON_NOEXCEPT
Default constructor creates a null value.
Definition: document.h:690
ParseResult::Code
ParseErrorCode Code() const
Get the error code.
Definition: error.h:116
GenericArray::ValueType
internal::MaybeAddConst< Const, PlainType >::Type ValueType
Definition: document.h:2887
internal::TypeHelper< ValueType, unsigned >::Is
static bool Is(const ValueType &v)
Definition: document.h:539
GenericValue::kNumberUint64Flag
@ kNumberUint64Flag
Definition: document.h:1996
GenericArray::AllocatorType
ValueType::AllocatorType AllocatorType
Definition: document.h:2890
GenericValue::Number::i64
int64_t i64
Definition: document.h:2066
internal::TypeHelper< ValueType, typename ValueType::Array >::Set
static ValueType & Set(ValueType &v, ArrayType data)
Definition: document.h:621
GenericObject::MemberEnd
MemberIterator MemberEnd() const
Definition: document.h:2966
kTrueType
@ kTrueType
true
Definition: rapidjson.h:732
internal::TypeHelper< ValueType, uint64_t >::Is
static bool Is(const ValueType &v)
Definition: document.h:575
internal::IsRefCounted
Definition: allocators.h:424
GenericDocument::Double
bool Double(double d)
Definition: document.h:2810
value
Offset font vertically by altering the io Font DisplayOffset value
Definition: README.txt:67
GenericValue::kInlineStrFlag
@ kInlineStrFlag
Definition: document.h:1986
internal::Swap
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition: swap.h:33
GenericDocument::Uint64
bool Uint64(uint64_t i)
Definition: document.h:2809
GenericDocument::GenericDocument
GenericDocument(Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
Constructor.
Definition: document.h:2497
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint.h:52
GenericObject::operator=
GenericObject & operator=(const GenericObject &rhs)
Definition: document.h:2953
GenericValue::Number::I::i
int i
Definition: document.h:2049
GenericValue::ShortString::str
Ch str[MaxChars]
Definition: document.h:2038
GenericValue::ShortString
Definition: document.h:2036
GenericValue::ArrayData::size
SizeType size
Definition: document.h:2078
GenericArray::PopBack
GenericArray PopBack() const
Definition: document.h:2915
internal::TypeHelper< ValueType, double >::Get
static double Get(const ValueType &v)
Definition: document.h:584
GenericValue::~GenericValue
~GenericValue()
Destructor.
Definition: document.h:880
GenericStringRef
Reference to a constant string (not taking a copy)
Definition: document.h:346
GenericValue::GenericValue
GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT
Constructor for constant string (i.e. do not make a copy of string)
Definition: document.h:840
RAPIDJSON_NOEXCEPT_ASSERT
#define RAPIDJSON_NOEXCEPT_ASSERT(x)
Assertion (in non-throwing contexts).
Definition: rapidjson.h:687
GenericValue::kNullFlag
@ kNullFlag
Definition: document.h:1989
GenericValue::Member
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:671
GenericArray::GenericArray
GenericArray(const GenericArray &rhs)
Definition: document.h:2896
GenericValue::Array
GenericArray< false, ValueType > Array
Definition: document.h:681
GenericDocument::Ch
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:2486
GenericValue::ValueType
GenericValue< Encoding, Allocator > ValueType
Value type of itself.
Definition: document.h:680
GenericValue::kUint64Flag
@ kUint64Flag
Definition: document.h:1982
GenericObject::EraseMember
MemberIterator EraseMember(ConstMemberIterator pos) const
Definition: document.h:3000
internal::TypeHelper< ValueType, int64_t >::Set
static ValueType & Set(ValueType &v, int64_t data)
Definition: document.h:569
internal::Stack::Swap
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT
Definition: stack.h:90
internal::TypeHelper< ValueType, int >::Is
static bool Is(const ValueType &v)
Definition: document.h:531
GenericValue::AllocatorType
Allocator AllocatorType
Allocator type from template parameter.
Definition: document.h:673
GenericObject::MemberCapacity
SizeType MemberCapacity() const
Definition: document.h:2958
GenericObject::StringRefType
ValueType::StringRefType StringRefType
Definition: document.h:2945
GenericArray::Array
GenericArray< false, ValueT > Array
Definition: document.h:2885
RAPIDJSON_ALIGN
#define RAPIDJSON_ALIGN(x)
Data alignment of the machine.
Definition: rapidjson.h:307
GenericObject
Helper class for accessing Value of object type.
Definition: document.h:652
GenericValue::kCopyStringFlag
@ kCopyStringFlag
Definition: document.h:2000
GenericValue::GetElementsPointer
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
Definition: document.h:2101
GenericDocument::Parse
GenericDocument & Parse(const Ch *str, size_t length)
Definition: document.h:2724
GenericArray::Clear
void Clear() const
Definition: document.h:2904
GenericDocument::Parse
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
Definition: document.h:2703
GenericMemberIterator::operator++
Iterator operator++(int)
Definition: document.h:247
GenericObject::RemoveMember
bool RemoveMember(const GenericValue< EncodingType, SourceAllocator > &name) const
Definition: document.h:2998
GenericDocument::Parse
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition: document.h:2692
GenericMemberIterator::pointer
ValueType * pointer
Definition: document.h:205
GenericValue::Number::u64
uint64_t u64
Definition: document.h:2067
GenericMemberIterator
(Constant) member iterator for a JSON object value
Definition: document.h:186
GenericValue::GetMembersPointer
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
Definition: document.h:2103
internal::TypeHelper< ValueType, int >::Set
static ValueType & Set(ValueType &v, int data)
Definition: document.h:533
GenericValue::ValueIterator
GenericValue * ValueIterator
Value iterator for iterating in array.
Definition: document.h:678
GenericMemberIterator::operator+
Iterator operator+(DifferenceType n) const
Definition: document.h:253
GenericArray::PushBack
GenericArray PushBack(ValueType &value, AllocatorType &allocator) const
Definition: document.h:2909
GenericValue::GenericValue
GenericValue(int i) RAPIDJSON_NOEXCEPT
Constructor for int value.
Definition: document.h:792
GenericValue::Number::u
struct GenericValue::Number::U u
GenericArray::PushBack
GenericArray PushBack(StringRefType value, AllocatorType &allocator) const
Definition: document.h:2913
RAPIDJSON_LIKELY
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:494
internal
Definition: allocators.h:422
GenericValue::SetMembersPointer
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
Definition: document.h:2104
GenericValue::GetStringPointer
const RAPIDJSON_FORCEINLINE Ch * GetStringPointer() const
Definition: document.h:2099
GenericValue::Data::ss
ShortString ss
Definition: document.h:2085
GenericObject::value
T value
Definition: document.h:2983
GenericValue::DataStringLength
static RAPIDJSON_FORCEINLINE SizeType DataStringLength(const Data &data)
Definition: document.h:2095
GenericValue::String::hashcode
SizeType hashcode
reserved
Definition: document.h:2024
GenericValue::Data::s
String s
Definition: document.h:2084
GenericObject::HasMember
bool HasMember(const Ch *name) const
Definition: document.h:2968
GenericArray::operator=
GenericArray & operator=(const GenericArray &rhs)
Definition: document.h:2897
GenericValue::GenericValue
GenericValue(const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
Explicit copy constructor (with allocator)
Definition: document.h:742
RAPIDJSON_SETPOINTER
#define RAPIDJSON_SETPOINTER(type, p, x)
Definition: rapidjson.h:349
RAPIDJSON_USE_MEMBERSMAP
#define RAPIDJSON_USE_MEMBERSMAP
Enable RapidJSON support for object members handling in a std::multimap.
Definition: rapidjson.h:180
GenericMemberIterator::operator!=
bool operator!=(const GenericMemberIterator< Const_, Encoding, Allocator > &that) const
Definition: document.h:263
internal::TypeHelper< ValueType, typename ValueType::Array >::ArrayType
ValueType::Array ArrayType
Definition: document.h:618
GenericValue::SetObjectRaw
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
Definition: document.h:2400
GenericArray::Size
SizeType Size() const
Definition: document.h:2901
GenericValue::ShortString::SetLength
void SetLength(SizeType len)
Definition: document.h:2041
internal::TypeHelper< ValueType, typename ValueType::Object >::ObjectType
ValueType::Object ObjectType
Definition: document.h:634
GenericValue::ShortString::MaxSize
@ MaxSize
Definition: document.h:2037
GenericValue::Number::I::padding
char padding[4]
Definition: document.h:2050
GenericValue::Object
GenericObject< false, ValueType > Object
Definition: document.h:683
internal::TypeHelper< ValueType, double >::Set
static ValueType & Set(ValueType &v, double data, typename ValueType::AllocatorType &)
Definition: document.h:586
GenericValue::Data::a
ArrayData a
Definition: document.h:2088
GenericArray::operator[]
ValueType & operator[](SizeType index) const
Definition: document.h:2905
GenericMemberIterator::operator[]
Reference operator[](DifferenceType n) const
Definition: document.h:278
GenericValue::GenericValue
GenericValue(Array a) RAPIDJSON_NOEXCEPT
Constructor for Array.
Definition: document.h:861
GenericValue::GenericValue
GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT
Constructor for uint64_t value.
Definition: document.h:819
GenericValue::GenericValue
GenericValue(Type type) RAPIDJSON_NOEXCEPT
Constructor with JSON value type.
Definition: document.h:720
RAPIDJSON_UNLIKELY
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:507
uint16_t
unsigned short uint16_t
Definition: stdint.h:16
GenericObject::Object
GenericObject< false, ValueT > Object
Definition: document.h:2939
GenericMemberIterator::operator-
Iterator operator-(DifferenceType n) const
Definition: document.h:254
GenericStringRef::GenericStringRef
GenericStringRef(const CharType(&str)[N]) RAPIDJSON_NOEXCEPT
Create string reference from const character array.
Definition: document.h:375
GenericDocument::String
bool String(const Ch *str, SizeType length, bool copy)
Definition: document.h:2820
GenericValue::DoAddMember
void DoAddMember(GenericValue &name, GenericValue &value, Allocator &allocator)
Definition: document.h:2289
GenericObject::RemoveAllMembers
void RemoveAllMembers()
Definition: document.h:2993
GenericDocument::AllocatorType
Allocator AllocatorType
Allocator type from template parameter.
Definition: document.h:2488
internal::TypeHelper< ValueType, float >::Is
static bool Is(const ValueType &v)
Definition: document.h:591
GenericObject::MemberIterator
GenericMemberIterator< Const, typename ValueT::EncodingType, typename ValueT::AllocatorType > MemberIterator
Definition: document.h:2942
GenericDocument::~GenericDocument
~GenericDocument()
Definition: document.h:2532
GenericValue::SetStringRaw
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition: document.h:2420
Encoding
Concept for encoding of Unicode characters.
GenericMemberIterator::Iterator
GenericMemberIterator Iterator
Iterator type itself.
Definition: document.h:196
GenericValue::data_
Data data_
Definition: document.h:2466
internal::Stack::ShrinkToFit
void ShrinkToFit()
Definition: stack.h:101
GenericValue::kDoubleFlag
@ kDoubleFlag
Definition: document.h:1983
name
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting changing font name
Definition: ARPHICPL.TXT:16
RAPIDJSON_UINT64_C2
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:320
GenericValue::GenericValue
GenericValue(double d) RAPIDJSON_NOEXCEPT
Constructor for double value.
Definition: document.h:831
GenericMemberIterator::GenericMemberIterator
GenericMemberIterator(const NonConstIterator &it)
Iterator conversions to more const.
Definition: document.h:240
GenericMemberIterator::operator--
Iterator & operator--()
Definition: document.h:246
internal::TypeHelper< ValueType, int >::Get
static int Get(const ValueType &v)
Definition: document.h:532
internal::StrLen
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:31
GenericDocument::Swap
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
Definition: document.h:2573
internal::TypeHelper< ValueType, bool >::Get
static bool Get(const ValueType &v)
Definition: document.h:524
GenericDocument::Int
bool Int(int i)
Definition: document.h:2806
GenericMemberIterator::operator++
Iterator & operator++()
Definition: document.h:245
RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
#define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
User defined kDefaultObjectCapacity value.
Definition: document.h:99
GenericValue::SetStringRaw
void SetStringRaw(StringRefType s, Allocator &allocator)
Initialize this value as copy string with initial data, without calling destructor.
Definition: document.h:2427
GenericDocument::ValueType
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2487
GenericDocument::Parse
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string (with kParseDefaultFlags)
Definition: document.h:2710
GenericValue::Data::f
Flag f
Definition: document.h:2089
Handler
Concept for receiving events from GenericReader upon parsing. The functions return true if no error o...
GenericObject::EraseMember
bool EraseMember(const Ch *name) const
Definition: document.h:3002
GenericValue::Flag::payload
char payload[sizeof(SizeType) *2+sizeof(void *)+2]
Definition: document.h:2017
GenericValue::kFalseFlag
@ kFalseFlag
Definition: document.h:1992
GenericValue::Number::I
Definition: document.h:2048
RAPIDJSON_STATIC_ASSERT
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition: rapidjson.h:476