rapidjson::GenericValue< Encoding, Allocator > Class Template Reference

Represents a JSON value. Use Value for UTF8 encoding and default allocator. More...

#include <document.h>

Classes

struct  Array
 
union  Data
 
struct  Member
 Name-value pair in an object. More...
 
union  Number
 
struct  Object
 
struct  String
 

Public Types

typedef Encoding EncodingType
 Encoding type from template parameter. More...
 
typedef Allocator AllocatorType
 Allocator type from template parameter. More...
 
typedef Encoding::Ch Ch
 Character type derived from Encoding. More...
 
typedef MemberMemberIterator
 Member iterator for iterating in object. More...
 
typedef const MemberConstMemberIterator
 Constant member iterator for iterating in object. More...
 
typedef GenericValueValueIterator
 Value iterator for iterating in array. More...
 
typedef const GenericValueConstValueIterator
 Constant value iterator for iterating in array. More...
 

Public Member Functions

Assignment operators
GenericValueoperator= (GenericValue &rhs)
 Assignment with move semantics. More...
 
template<typename T >
GenericValueoperator= (T value)
 Assignment with primitive types. More...
 
Type
Type GetType () const
 
bool IsNull_ () const
 
bool IsFalse () const
 
bool IsTrue () const
 
bool IsBool_ () const
 
bool IsObject () const
 
bool IsArray () const
 
bool IsNumber () const
 
bool IsInt () const
 
bool IsUint () const
 
bool IsInt64 () const
 
bool IsUint64 () const
 
bool IsDouble () const
 
bool IsString () const
 
Null_
GenericValueSetNull_ ()
 
Bool_
bool GetBool_ () const
 
GenericValueSetBool_ (bool b)
 
Object
GenericValueSetObject ()
 Set this value as an empty object. More...
 
GenericValueoperator[] (const Ch *name)
 Get the value associated with the object's name. More...
 
const GenericValueoperator[] (const Ch *name) const
 
ConstMemberIterator MemberBegin () const
 Member iterators. More...
 
ConstMemberIterator MemberEnd () const
 
MemberIterator MemberBegin ()
 
MemberIterator MemberEnd ()
 
bool HasMember (const Ch *name) const
 Check whether a member exists in the object. More...
 
GenericValueAddMember (GenericValue &name, GenericValue &value, Allocator &allocator)
 Add a member (name-value pair) to the object. More...
 
GenericValueAddMember (const Ch *name, Allocator &nameAllocator, GenericValue &value, Allocator &allocator)
 
GenericValueAddMember (const Ch *name, GenericValue &value, Allocator &allocator)
 
template<typename T >
GenericValueAddMember (const Ch *name, T value, Allocator &allocator)
 
bool RemoveMember (const Ch *name)
 Remove a member in object by its name. More...
 
Array
GenericValueSetArray ()
 Set this value as an empty array. More...
 
SizeType Size () const
 Get the number of elements in array. More...
 
SizeType Capacity () const
 Get the capacity of array. More...
 
bool Empty () const
 Check whether the array is empty. More...
 
void Clear ()
 Remove all elements in the array. More...
 
GenericValueoperator[] (SizeType index)
 Get an element from array by index. More...
 
const GenericValueoperator[] (SizeType index) const
 
ValueIterator Begin ()
 Element iterator. More...
 
ValueIterator End ()
 
ConstValueIterator Begin () const
 
ConstValueIterator End () const
 
GenericValueReserve (SizeType newCapacity, Allocator &allocator)
 Request the array to have enough capacity to store elements. More...
 
GenericValuePushBack (GenericValue &value, Allocator &allocator)
 Append a value at the end of the array. More...
 
template<typename T >
GenericValuePushBack (T value, Allocator &allocator)
 
GenericValuePopBack ()
 Remove the last element in the array. More...
 
Number
int GetInt () const
 
unsigned GetUint () const
 
int64_t GetInt64 () const
 
uint64_t GetUint64 () const
 
double GetDouble () const
 
GenericValueSetInt (int i)
 
GenericValueSetUint (unsigned u)
 
GenericValueSetInt64 (int64_t i64)
 
GenericValueSetUint64 (uint64_t u64)
 
GenericValueSetDouble (double d)
 

String

enum  {
  kBool_Flag = 0x100 , kNumberFlag = 0x200 , kIntFlag = 0x400 , kUintFlag = 0x800 ,
  kInt64Flag = 0x1000 , kUint64Flag = 0x2000 , kDoubleFlag = 0x4000 , kStringFlag = 0x100000 ,
  kCopyFlag = 0x200000 , kNull_Flag = kNull_Type , kTrueFlag = kTrueType | kBool_Flag , kFalseFlag = kFalseType | kBool_Flag ,
  kNumberIntFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag , kNumberUintFlag = kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag , kNumberInt64Flag = kNumberType | kNumberFlag | kInt64Flag , kNumberUint64Flag = kNumberType | kNumberFlag | kUint64Flag ,
  kNumberDoubleFlag = kNumberType | kNumberFlag | kDoubleFlag , kConstStringFlag = kStringType | kStringFlag , kCopyStringFlag = kStringType | kStringFlag | kCopyFlag , kObjectFlag = kObjectType ,
  kArrayFlag = kArrayType , kTypeMask = 0xFF
}
 
template<typename , typename >
class GenericDocument
 
static const SizeType kDefaultArrayCapacity = 16
 
static const SizeType kDefaultObjectCapacity = 16
 
Data data_
 
unsigned flags_
 
const ChGetString () const
 
SizeType GetStringLength () const
 Get the length of string. More...
 
GenericValueSetString (const Ch *s, SizeType length)
 Set this value as a string without copying source string. More...
 
GenericValueSetString (const Ch *s)
 Set this value as a string without copying source string. More...
 
GenericValueSetString (const Ch *s, SizeType length, Allocator &allocator)
 Set this value as a string by copying from source string. More...
 
GenericValueSetString (const Ch *s, Allocator &allocator)
 Set this value as a string by copying from source string. More...
 
template<typename Handler >
const GenericValueAccept (Handler &handler) const
 Generate events of this value to a Handler. More...
 
MemberFindMember (const Ch *name)
 Find member by name. More...
 
const MemberFindMember (const Ch *name) const
 
void SetArrayRaw (GenericValue *values, SizeType count, Allocator &alloctaor)
 
void SetObjectRaw (Member *members, SizeType count, Allocator &alloctaor)
 Initialize this value as object with initial data, without calling destructor. More...
 
void SetStringRaw (const Ch *s, SizeType length)
 Initialize this value as constant string, without calling destructor. More...
 
void SetStringRaw (const Ch *s, SizeType length, Allocator &allocator)
 Initialize this value as copy string with initial data, without calling destructor. More...
 
void RawAssign (GenericValue &rhs)
 Assignment without calling destructor. More...
 

Constructors and destructor.

 GenericValue ()
 Default constructor creates a null value. More...
 
 GenericValue (Type type)
 Constructor with JSON value type. More...
 
 GenericValue (bool b)
 Constructor for boolean value. More...
 
 GenericValue (int i)
 Constructor for int value. More...
 
 GenericValue (unsigned u)
 Constructor for unsigned value. More...
 
 GenericValue (int64_t i64)
 Constructor for int64_t value. More...
 
 GenericValue (uint64_t u64)
 Constructor for uint64_t value. More...
 
 GenericValue (double d)
 Constructor for double value. More...
 
 GenericValue (const Ch *s, SizeType length)
 Constructor for constant string (i.e. do not make a copy of string) More...
 
 GenericValue (const Ch *s)
 Constructor for constant string (i.e. do not make a copy of string) More...
 
 GenericValue (const Ch *s, SizeType length, Allocator &allocator)
 Constructor for copy-string (i.e. do make a copy of string) More...
 
 GenericValue (const Ch *s, Allocator &allocator)
 Constructor for copy-string (i.e. do make a copy of string) More...
 
 ~GenericValue ()
 Destructor. More...
 
 GenericValue (const GenericValue &rhs)
 Copy constructor is not permitted. More...
 

Detailed Description

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
class rapidjson::GenericValue< Encoding, Allocator >

Represents a JSON value. Use Value for UTF8 encoding and default allocator.

A JSON value can be one of 7 types. This class is a variant type supporting these types.

Use the Value if UTF8 and default allocator

Template Parameters
EncodingEncoding of the value. (Even non-string values need to have the same encoding in a document)
AllocatorAllocator type for allocating memory of object, array and string.

Member Typedef Documentation

◆ AllocatorType

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
typedef Allocator rapidjson::GenericValue< Encoding, Allocator >::AllocatorType

Allocator type from template parameter.

◆ Ch

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
typedef Encoding::Ch rapidjson::GenericValue< Encoding, Allocator >::Ch

Character type derived from Encoding.

◆ ConstMemberIterator

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
typedef const Member* rapidjson::GenericValue< Encoding, Allocator >::ConstMemberIterator

Constant member iterator for iterating in object.

◆ ConstValueIterator

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
typedef const GenericValue* rapidjson::GenericValue< Encoding, Allocator >::ConstValueIterator

Constant value iterator for iterating in array.

◆ EncodingType

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
typedef Encoding rapidjson::GenericValue< Encoding, Allocator >::EncodingType

Encoding type from template parameter.

◆ MemberIterator

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
typedef Member* rapidjson::GenericValue< Encoding, Allocator >::MemberIterator

Member iterator for iterating in object.

◆ ValueIterator

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
typedef GenericValue* rapidjson::GenericValue< Encoding, Allocator >::ValueIterator

Value iterator for iterating in array.

Member Enumeration Documentation

◆ anonymous enum

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
anonymous enum
private
Enumerator
kBool_Flag 
kNumberFlag 
kIntFlag 
kUintFlag 
kInt64Flag 
kUint64Flag 
kDoubleFlag 
kStringFlag 
kCopyFlag 
kNull_Flag 
kTrueFlag 
kFalseFlag 
kNumberIntFlag 
kNumberUintFlag 
kNumberInt64Flag 
kNumberUint64Flag 
kNumberDoubleFlag 
kConstStringFlag 
kCopyStringFlag 
kObjectFlag 
kArrayFlag 
kTypeMask 
560  {
561  kBool_Flag = 0x100,
562  kNumberFlag = 0x200,
563  kIntFlag = 0x400,
564  kUintFlag = 0x800,
565  kInt64Flag = 0x1000,
566  kUint64Flag = 0x2000,
567  kDoubleFlag = 0x4000,
568  kStringFlag = 0x100000,
569  kCopyFlag = 0x200000,
570 
571  // Initial flags of different types.
584 
585  kTypeMask = 0xFF // bitwise-and with mask of 0xFF can be optimized by compiler
586  };
@ kStringFlag
Definition: document.h:568
@ kTrueFlag
Definition: document.h:573
@ kNumberDoubleFlag
Definition: document.h:579
@ kNumberUint64Flag
Definition: document.h:578
@ kFalseFlag
Definition: document.h:574
@ kDoubleFlag
Definition: document.h:567
@ kBool_Flag
Definition: document.h:561
@ kArrayFlag
Definition: document.h:583
@ kConstStringFlag
Definition: document.h:580
@ kTypeMask
Definition: document.h:585
@ kIntFlag
Definition: document.h:563
@ kObjectFlag
Definition: document.h:582
@ kCopyFlag
Definition: document.h:569
@ kNumberUintFlag
Definition: document.h:576
@ kUint64Flag
Definition: document.h:566
@ kNumberInt64Flag
Definition: document.h:577
@ kNull_Flag
Definition: document.h:572
@ kCopyStringFlag
Definition: document.h:581
@ kNumberIntFlag
Definition: document.h:575
@ kUintFlag
Definition: document.h:564
@ kNumberFlag
Definition: document.h:562
@ kInt64Flag
Definition: document.h:565
@ kArrayType
array
Definition: rapidjson.h:543
@ kNull_Type
null
Definition: rapidjson.h:539
@ kTrueType
true
Definition: rapidjson.h:541
@ kFalseType
false
Definition: rapidjson.h:540
@ kNumberType
number
Definition: rapidjson.h:545
@ kObjectType
object
Definition: rapidjson.h:542
@ kStringType
string
Definition: rapidjson.h:544

Constructor & Destructor Documentation

◆ GenericValue() [1/13]

◆ GenericValue() [2/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( const GenericValue< Encoding, Allocator > &  rhs)
private

Copy constructor is not permitted.

◆ GenericValue() [3/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( Type  type)
inline

Constructor with JSON value type.

This creates a Value of specified type with default content.

Parameters
typeType of the value.
Note
Default content for number is zero.
88  {
89  static const unsigned defaultFlags[7] = {
92  };
94  flags_ = defaultFlags[type];
95  memset(&data_, 0, sizeof(data_));
96  }
Data data_
Definition: document.h:698
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:105

References rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::flags_, rapidjson::GenericValue< Encoding, Allocator >::kArrayFlag, rapidjson::GenericValue< Encoding, Allocator >::kConstStringFlag, rapidjson::GenericValue< Encoding, Allocator >::kDoubleFlag, rapidjson::GenericValue< Encoding, Allocator >::kFalseFlag, rapidjson::GenericValue< Encoding, Allocator >::kInt64Flag, rapidjson::GenericValue< Encoding, Allocator >::kIntFlag, rapidjson::GenericValue< Encoding, Allocator >::kNull_Flag, rapidjson::GenericValue< Encoding, Allocator >::kNumberFlag, rapidjson::kNumberType, rapidjson::GenericValue< Encoding, Allocator >::kObjectFlag, rapidjson::GenericValue< Encoding, Allocator >::kTrueFlag, rapidjson::GenericValue< Encoding, Allocator >::kUint64Flag, rapidjson::GenericValue< Encoding, Allocator >::kUintFlag, and RAPIDJSON_ASSERT.

◆ GenericValue() [4/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( bool  b)
inline

Constructor for boolean value.

99 : flags_(b ? kTrueFlag : kFalseFlag) {}

◆ GenericValue() [5/13]

◆ GenericValue() [6/13]

◆ GenericValue() [7/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( int64_t  i64)
inline

◆ GenericValue() [8/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( uint64_t  u64)
inline

◆ GenericValue() [9/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( double  d)
inline

◆ GenericValue() [10/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( const Ch s,
SizeType  length 
)
inline

◆ GenericValue() [11/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( const Ch s)
inline

Constructor for constant string (i.e. do not make a copy of string)

152 { SetStringRaw(s, internal::StrLen(s)); }
void SetStringRaw(const Ch *s, SizeType length)
Initialize this value as constant string, without calling destructor.
Definition: document.h:675
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:39

References rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw(), and rapidjson::internal::StrLen().

◆ GenericValue() [12/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( const Ch s,
SizeType  length,
Allocator allocator 
)
inline

Constructor for copy-string (i.e. do make a copy of string)

155 { SetStringRaw(s, length, allocator); }

References rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw().

◆ GenericValue() [13/13]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( const Ch s,
Allocator allocator 
)
inline

Constructor for copy-string (i.e. do make a copy of string)

158 { SetStringRaw(s, internal::StrLen(s), allocator); }

References rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw(), and rapidjson::internal::StrLen().

◆ ~GenericValue()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericValue< Encoding, Allocator >::~GenericValue ( )
inline

Destructor.

Need to destruct elements of array, members of object, or copy-string.

163  {
164  if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
165  switch(flags_) {
166  case kArrayFlag:
167  for (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
168  v->~GenericValue();
169  Allocator::Free(data_.a.elements);
170  break;
171 
172  case kObjectFlag:
173  for (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) {
174  m->name.~GenericValue();
175  m->value.~GenericValue();
176  }
177  Allocator::Free(data_.o.members);
178  break;
179 
180  case kCopyStringFlag:
181  Allocator::Free(const_cast<Ch*>(data_.s.str));
182  break;
183  }
184  }
185  }
GenericValue()
Default constructor creates a null value.
Definition: document.h:75
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:65
SizeType size
Definition: document.h:631
GenericValue< Encoding, Allocator > * elements
Definition: document.h:630
SizeType size
Definition: document.h:625
Member * members
Definition: document.h:624
Array a
Definition: document.h:639
Object o
Definition: document.h:638

References rapidjson::GenericValue< Encoding, Allocator >::Data::a, rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::Array::elements, rapidjson::GenericValue< Encoding, Allocator >::flags_, rapidjson::GenericValue< Encoding, Allocator >::kArrayFlag, rapidjson::GenericValue< Encoding, Allocator >::kCopyStringFlag, rapidjson::GenericValue< Encoding, Allocator >::kObjectFlag, rapidjson::GenericValue< Encoding, Allocator >::Object::members, rapidjson::GenericValue< Encoding, Allocator >::Data::o, rapidjson::GenericValue< Encoding, Allocator >::Data::s, rapidjson::GenericValue< Encoding, Allocator >::Object::size, rapidjson::GenericValue< Encoding, Allocator >::Array::size, and rapidjson::GenericValue< Encoding, Allocator >::String::str.

Referenced by rapidjson::GenericValue< Encoding, Allocator >::operator=(), rapidjson::GenericValue< Encoding, Allocator >::SetArray(), rapidjson::GenericValue< Encoding, Allocator >::SetBool_(), rapidjson::GenericValue< Encoding, Allocator >::SetDouble(), rapidjson::GenericValue< Encoding, Allocator >::SetInt(), rapidjson::GenericValue< Encoding, Allocator >::SetInt64(), rapidjson::GenericValue< Encoding, Allocator >::SetNull_(), rapidjson::GenericValue< Encoding, Allocator >::SetObject(), rapidjson::GenericValue< Encoding, Allocator >::SetString(), rapidjson::GenericValue< Encoding, Allocator >::SetUint(), and rapidjson::GenericValue< Encoding, Allocator >::SetUint64().

Member Function Documentation

◆ Accept()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename Handler >
const GenericValue& rapidjson::GenericValue< Encoding, Allocator >::Accept ( Handler handler) const
inline

Generate events of this value to a Handler.

This function adopts the GoF visitor pattern. Typical usage is to output this JSON value as JSON text via Writer, which is a Handler. It can also be used to deep clone this value via GenericDocument, which is also a Handler.

Template Parameters
Handlertype of handler.
Parameters
handlerAn object implementing concept Handler.
519  {
520  switch(GetType()) {
521  case kNull_Type: handler.Null_(); break;
522  case kFalseType: handler.Bool_(false); break;
523  case kTrueType: handler.Bool_(true); break;
524 
525  case kObjectType:
526  handler.StartObject();
527  for (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) {
528  handler.String(m->name.data_.s.str, m->name.data_.s.length, false);
529  m->value.Accept(handler);
530  }
531  handler.EndObject(data_.o.size);
532  break;
533 
534  case kArrayType:
535  handler.StartArray();
536  for (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
537  v->Accept(handler);
538  handler.EndArray(data_.a.size);
539  break;
540 
541  case kStringType:
542  handler.String(data_.s.str, data_.s.length, false);
543  break;
544 
545  case kNumberType:
546  if (IsInt()) handler.Int(data_.n.i.i);
547  else if (IsUint()) handler.Uint(data_.n.u.u);
548  else if (IsInt64()) handler.Int64(data_.n.i64);
549  else if (IsUint64()) handler.Uint64(data_.n.u64);
550  else handler.Double(data_.n.d);
551  break;
552  }
553  return *this;
554  }
bool IsUint64() const
Definition: document.h:229
bool IsInt() const
Definition: document.h:226
Type GetType() const
Definition: document.h:218
bool IsUint() const
Definition: document.h:227
bool IsInt64() const
Definition: document.h:228
int i
Definition: document.h:601
unsigned u
Definition: document.h:605
struct rapidjson::GenericValue::Number::I i
struct rapidjson::GenericValue::Number::U u

References rapidjson::GenericValue< Encoding, Allocator >::Data::a, rapidjson::GenericValue< Encoding, Allocator >::Number::d, rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::Array::elements, rapidjson::GenericValue< Encoding, Allocator >::GetType(), rapidjson::GenericValue< Encoding, Allocator >::Number::I::i, rapidjson::GenericValue< Encoding, Allocator >::Number::i, rapidjson::GenericValue< Encoding, Allocator >::Number::i64, rapidjson::GenericValue< Encoding, Allocator >::IsInt(), rapidjson::GenericValue< Encoding, Allocator >::IsInt64(), rapidjson::GenericValue< Encoding, Allocator >::IsUint(), rapidjson::GenericValue< Encoding, Allocator >::IsUint64(), rapidjson::kArrayType, rapidjson::kFalseType, rapidjson::kNull_Type, rapidjson::kNumberType, rapidjson::kObjectType, rapidjson::kStringType, rapidjson::kTrueType, rapidjson::GenericValue< Encoding, Allocator >::String::length, rapidjson::GenericValue< Encoding, Allocator >::Object::members, rapidjson::GenericValue< Encoding, Allocator >::Data::n, rapidjson::GenericValue< Encoding, Allocator >::Data::o, rapidjson::GenericValue< Encoding, Allocator >::Data::s, rapidjson::GenericValue< Encoding, Allocator >::Object::size, rapidjson::GenericValue< Encoding, Allocator >::Array::size, rapidjson::GenericValue< Encoding, Allocator >::String::str, rapidjson::GenericValue< Encoding, Allocator >::Number::U::u, rapidjson::GenericValue< Encoding, Allocator >::Number::u, and rapidjson::GenericValue< Encoding, Allocator >::Number::u64.

◆ AddMember() [1/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( const Ch name,
Allocator nameAllocator,
GenericValue< Encoding, Allocator > &  value,
Allocator allocator 
)
inline
304  {
305  GenericValue n(name, internal::StrLen(name), nameAllocator);
306  return AddMember(n, value, allocator);
307  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
GenericValue & AddMember(GenericValue &name, GenericValue &value, Allocator &allocator)
Add a member (name-value pair) to the object.
Definition: document.h:283
std::string name
Definition: MercuryProb.h:48

References rapidjson::GenericValue< Encoding, Allocator >::AddMember(), n, units::name, and rapidjson::internal::StrLen().

◆ AddMember() [2/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( const Ch name,
GenericValue< Encoding, Allocator > &  value,
Allocator allocator 
)
inline

◆ AddMember() [3/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( const Ch name,
value,
Allocator allocator 
)
inline

◆ AddMember() [4/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( GenericValue< Encoding, Allocator > &  name,
GenericValue< Encoding, Allocator > &  value,
Allocator allocator 
)
inline

Add a member (name-value pair) to the object.

Parameters
nameA string value as name of member.
valueValue of any type.
allocatorAllocator for reallocating memory.
Returns
The value itself for fluent API.
Note
The ownership of name and value will be transfered to this object if success.
283  {
285  RAPIDJSON_ASSERT(name.IsString());
286  Object& o = data_.o;
287  if (o.size >= o.capacity) {
288  if (o.capacity == 0) {
290  o.members = (Member*)allocator.Malloc(o.capacity * sizeof(Member));
291  }
292  else {
293  SizeType oldCapacity = o.capacity;
294  o.capacity *= 2;
295  o.members = (Member*)allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member));
296  }
297  }
298  o.members[o.size].name.RawAssign(name);
299  o.members[o.size].value.RawAssign(value);
300  o.size++;
301  return *this;
302  }
bool IsObject() const
Definition: document.h:223
static const SizeType kDefaultObjectCapacity
Definition: document.h:589
unsigned SizeType
Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.
Definition: rapidjson.h:92
SizeType capacity
Definition: document.h:626

References rapidjson::GenericValue< Encoding, Allocator >::Object::capacity, rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::IsObject(), rapidjson::GenericValue< Encoding, Allocator >::kDefaultObjectCapacity, rapidjson::GenericValue< Encoding, Allocator >::Object::members, rapidjson::GenericValue< Encoding, Allocator >::Member::name, units::name, rapidjson::GenericValue< Encoding, Allocator >::Data::o, RAPIDJSON_ASSERT, rapidjson::GenericValue< Encoding, Allocator >::Object::size, and rapidjson::GenericValue< Encoding, Allocator >::Member::value.

Referenced by rapidjson::GenericValue< Encoding, Allocator >::AddMember().

◆ Begin() [1/2]

◆ Begin() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
ConstValueIterator rapidjson::GenericValue< Encoding, Allocator >::Begin ( ) const
inline
397 { return const_cast<GenericValue&>(*this).Begin(); }

References rapidjson::GenericValue< Encoding, Allocator >::Begin().

◆ Capacity()

◆ Clear()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void rapidjson::GenericValue< Encoding, Allocator >::Clear ( )
inline

◆ Empty()

◆ End() [1/2]

◆ End() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
ConstValueIterator rapidjson::GenericValue< Encoding, Allocator >::End ( ) const
inline
398 { return const_cast<GenericValue&>(*this).End(); }

References rapidjson::GenericValue< Encoding, Allocator >::End().

◆ FindMember() [1/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
Member* rapidjson::GenericValue< Encoding, Allocator >::FindMember ( const Ch name)
inlineprivate

◆ FindMember() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
const Member* rapidjson::GenericValue< Encoding, Allocator >::FindMember ( const Ch name) const
inlineprivate
656 { return const_cast<GenericValue&>(*this).FindMember(name); }

References rapidjson::GenericValue< Encoding, Allocator >::FindMember(), and units::name.

◆ GetBool_()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::GetBool_ ( ) const
inline

◆ GetDouble()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
double rapidjson::GenericValue< Encoding, Allocator >::GetDouble ( ) const
inline
452  {
454  if ((flags_ & kDoubleFlag) != 0) return data_.n.d; // exact type, no conversion.
455  if ((flags_ & kIntFlag) != 0) return data_.n.i.i; // int -> double
456  if ((flags_ & kUintFlag) != 0) return data_.n.u.u; // unsigned -> double
457  if ((flags_ & kInt64Flag) != 0) return (double)data_.n.i64; // int64_t -> double (may lose precision)
458  RAPIDJSON_ASSERT((flags_ & kUint64Flag) != 0); return (double)data_.n.u64; // uint64_t -> double (may lose precision)
459  }
bool IsNumber() const
Definition: document.h:225

References rapidjson::GenericValue< Encoding, Allocator >::Number::d, rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::flags_, rapidjson::GenericValue< Encoding, Allocator >::Number::I::i, rapidjson::GenericValue< Encoding, Allocator >::Number::i, rapidjson::GenericValue< Encoding, Allocator >::Number::i64, rapidjson::GenericValue< Encoding, Allocator >::IsNumber(), rapidjson::GenericValue< Encoding, Allocator >::kDoubleFlag, rapidjson::GenericValue< Encoding, Allocator >::kInt64Flag, rapidjson::GenericValue< Encoding, Allocator >::kIntFlag, rapidjson::GenericValue< Encoding, Allocator >::kUint64Flag, rapidjson::GenericValue< Encoding, Allocator >::kUintFlag, rapidjson::GenericValue< Encoding, Allocator >::Data::n, RAPIDJSON_ASSERT, rapidjson::GenericValue< Encoding, Allocator >::Number::U::u, rapidjson::GenericValue< Encoding, Allocator >::Number::u, and rapidjson::GenericValue< Encoding, Allocator >::Number::u64.

◆ GetInt()

◆ GetInt64()

◆ GetString()

◆ GetStringLength()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
SizeType rapidjson::GenericValue< Encoding, Allocator >::GetStringLength ( ) const
inline

Get the length of string.

Since rapidjson permits "\u0000" in the json string, strlen(v.GetString()) may not equal to v.GetStringLength().

477 { RAPIDJSON_ASSERT(IsString()); return data_.s.length; }

References rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::IsString(), rapidjson::GenericValue< Encoding, Allocator >::String::length, RAPIDJSON_ASSERT, and rapidjson::GenericValue< Encoding, Allocator >::Data::s.

◆ GetType()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
Type rapidjson::GenericValue< Encoding, Allocator >::GetType ( ) const
inline

◆ GetUint()

◆ GetUint64()

◆ HasMember()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::HasMember ( const Ch name) const
inline

Check whether a member exists in the object.

274 { return FindMember(name) != 0; }
Member * FindMember(const Ch *name)
Find member by name.
Definition: document.h:643

References rapidjson::GenericValue< Encoding, Allocator >::FindMember(), and units::name.

◆ IsArray()

◆ IsBool_()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsBool_ ( ) const
inline

◆ IsDouble()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsDouble ( ) const
inline

◆ IsFalse()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsFalse ( ) const
inline

◆ IsInt()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsInt ( ) const
inline

◆ IsInt64()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsInt64 ( ) const
inline

◆ IsNull_()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsNull_ ( ) const
inline

◆ IsNumber()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsNumber ( ) const
inline

◆ IsObject()

◆ IsString()

◆ IsTrue()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsTrue ( ) const
inline

◆ IsUint()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsUint ( ) const
inline

◆ IsUint64()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::IsUint64 ( ) const
inline

◆ MemberBegin() [1/2]

◆ MemberBegin() [2/2]

◆ MemberEnd() [1/2]

◆ MemberEnd() [2/2]

◆ operator=() [1/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator= ( GenericValue< Encoding, Allocator > &  rhs)
inline

Assignment with move semantics.

Parameters
rhsSource of the assignment. It will become a null value after assignment.
195  {
196  RAPIDJSON_ASSERT(this != &rhs);
197  this->~GenericValue();
198  memcpy(this, &rhs, sizeof(GenericValue));
199  rhs.flags_ = kNull_Flag;
200  return *this;
201  }
~GenericValue()
Destructor.
Definition: document.h:163

References rapidjson::GenericValue< Encoding, Allocator >::flags_, rapidjson::GenericValue< Encoding, Allocator >::kNull_Flag, RAPIDJSON_ASSERT, and rapidjson::GenericValue< Encoding, Allocator >::~GenericValue().

◆ operator=() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator= ( value)
inline

Assignment with primitive types.

Template Parameters
TEither Type, int, unsigned, int64_t, uint64_t, const Ch*
Parameters
valueThe value to be assigned.
208  {
209  this->~GenericValue();
210  new (this) GenericValue(value);
211  return *this;
212  }

References rapidjson::GenericValue< Encoding, Allocator >::GenericValue(), and rapidjson::GenericValue< Encoding, Allocator >::~GenericValue().

◆ operator[]() [1/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator[] ( const Ch name)
inline

Get the value associated with the object's name.

257  {
258  if (Member* member = FindMember(name))
259  return member->value;
260  else {
261  static GenericValue Null_Value;
262  return Null_Value;
263  }
264  }

References rapidjson::GenericValue< Encoding, Allocator >::FindMember(), and units::name.

◆ operator[]() [2/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
const GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator[] ( const Ch name) const
inline
265 { return const_cast<GenericValue&>(*this)[name]; }

References units::name.

◆ operator[]() [3/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator[] ( SizeType  index)
inline

Get an element from array by index.

Parameters
indexZero-based index of element.
Note
a.PushBack(123);
int x = a[0].GetInt(); // Error: operator[ is ambiguous, as 0 also mean a null pointer of const char* type.
int y = a[SizeType(0)].GetInt(); // Cast to SizeType will work.
int z = a[0u].GetInt(); // This works too.
GenericValue< UTF8<> > Value
Value with UTF8 encoding.
Definition: document.h:704
387  {
389  RAPIDJSON_ASSERT(index < data_.a.size);
390  return data_.a.elements[index];
391  }

References rapidjson::GenericValue< Encoding, Allocator >::Data::a, rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::Array::elements, rapidjson::GenericValue< Encoding, Allocator >::IsArray(), RAPIDJSON_ASSERT, and rapidjson::GenericValue< Encoding, Allocator >::Array::size.

◆ operator[]() [4/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
const GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator[] ( SizeType  index) const
inline
392 { return const_cast<GenericValue&>(*this)[index]; }

◆ PopBack()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::PopBack ( )
inline

◆ PushBack() [1/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::PushBack ( GenericValue< Encoding, Allocator > &  value,
Allocator allocator 
)
inline

Append a value at the end of the array.

Parameters
valueThe value to be appended.
allocatorThe allocator for allocating memory. It must be the same one use previously.
Returns
The value itself for fluent API.
Note
The ownership of the value will be transfered to this object if success.
If the number of elements to be appended is known, calls Reserve() once first may be more efficient.
421  {
423  if (data_.a.size >= data_.a.capacity)
424  Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : data_.a.capacity * 2, allocator);
425  data_.a.elements[data_.a.size++].RawAssign(value);
426  return *this;
427  }
GenericValue & Reserve(SizeType newCapacity, Allocator &allocator)
Request the array to have enough capacity to store elements.
Definition: document.h:405
static const SizeType kDefaultArrayCapacity
Definition: document.h:588

References rapidjson::GenericValue< Encoding, Allocator >::Data::a, rapidjson::GenericValue< Encoding, Allocator >::Array::capacity, rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::Array::elements, rapidjson::GenericValue< Encoding, Allocator >::IsArray(), rapidjson::GenericValue< Encoding, Allocator >::kDefaultArrayCapacity, RAPIDJSON_ASSERT, rapidjson::GenericValue< Encoding, Allocator >::Reserve(), and rapidjson::GenericValue< Encoding, Allocator >::Array::size.

Referenced by rapidjson::GenericValue< Encoding, Allocator >::PushBack().

◆ PushBack() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::PushBack ( value,
Allocator allocator 
)
inline
430  {
431  GenericValue v(value);
432  return PushBack(v, allocator);
433  }
GenericValue & PushBack(GenericValue &value, Allocator &allocator)
Append a value at the end of the array.
Definition: document.h:421

References rapidjson::GenericValue< Encoding, Allocator >::PushBack().

◆ RawAssign()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void rapidjson::GenericValue< Encoding, Allocator >::RawAssign ( GenericValue< Encoding, Allocator > &  rhs)
inlineprivate

Assignment without calling destructor.

693  {
694  memcpy(this, &rhs, sizeof(GenericValue));
695  rhs.flags_ = kNull_Flag;
696  }

References rapidjson::GenericValue< Encoding, Allocator >::flags_, and rapidjson::GenericValue< Encoding, Allocator >::kNull_Flag.

◆ RemoveMember()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
bool rapidjson::GenericValue< Encoding, Allocator >::RemoveMember ( const Ch name)
inline

Remove a member in object by its name.

Parameters
nameName of member to be removed.
Returns
Whether the member existed.
Note
Removing member is implemented by moving the last member. So the ordering of members is changed.
326  {
328  if (Member* m = FindMember(name)) {
331 
332  Member* last = data_.o.members + (data_.o.size - 1);
333  if (data_.o.size > 1 && m != last) {
334  // Move the last one to this place
335  m->name = last->name;
336  m->value = last->value;
337  }
338  else {
339  // Only one left, just destroy
340  m->name.~GenericValue();
341  m->value.~GenericValue();
342  }
343  --data_.o.size;
344  return true;
345  }
346  return false;
347  }
GenericValue< Encoding, Allocator > name
name of member (must be a string)
Definition: document.h:59

References rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::FindMember(), rapidjson::GenericValue< Encoding, Allocator >::IsObject(), rapidjson::GenericValue< Encoding, Allocator >::Object::members, rapidjson::GenericValue< Encoding, Allocator >::Member::name, units::name, rapidjson::GenericValue< Encoding, Allocator >::Data::o, RAPIDJSON_ASSERT, rapidjson::GenericValue< Encoding, Allocator >::Object::size, and rapidjson::GenericValue< Encoding, Allocator >::Member::value.

◆ Reserve()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::Reserve ( SizeType  newCapacity,
Allocator allocator 
)
inline

Request the array to have enough capacity to store elements.

Parameters
newCapacityThe capacity that the array at least need to have.
allocatorThe allocator for allocating memory. It must be the same one use previously.
Returns
The value itself for fluent API.
405  {
407  if (newCapacity > data_.a.capacity) {
408  data_.a.elements = (GenericValue*)allocator.Realloc(data_.a.elements, data_.a.capacity * sizeof(GenericValue), newCapacity * sizeof(GenericValue));
409  data_.a.capacity = newCapacity;
410  }
411  return *this;
412  }

References rapidjson::GenericValue< Encoding, Allocator >::Data::a, rapidjson::GenericValue< Encoding, Allocator >::Array::capacity, rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::Array::elements, rapidjson::GenericValue< Encoding, Allocator >::GenericValue(), rapidjson::GenericValue< Encoding, Allocator >::IsArray(), and RAPIDJSON_ASSERT.

Referenced by rapidjson::GenericValue< Encoding, Allocator >::PushBack().

◆ SetArray()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetArray ( )
inline

◆ SetArrayRaw()

◆ SetBool_()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetBool_ ( bool  b)
inline

◆ SetDouble()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetDouble ( double  d)
inline

◆ SetInt()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetInt ( int  i)
inline

◆ SetInt64()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetInt64 ( int64_t  i64)
inline

◆ SetNull_()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetNull_ ( )
inline

◆ SetObject()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetObject ( )
inline

◆ SetObjectRaw()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void rapidjson::GenericValue< Encoding, Allocator >::SetObjectRaw ( Member members,
SizeType  count,
Allocator alloctaor 
)
inlineprivate

◆ SetString() [1/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetString ( const Ch s)
inline

Set this value as a string without copying source string.

Parameters
ssource string pointer.
Returns
The value itself for fluent API.
491 { return SetString(s, internal::StrLen(s)); }
GenericValue & SetString(const Ch *s, SizeType length)
Set this value as a string without copying source string.
Definition: document.h:485

References rapidjson::GenericValue< Encoding, Allocator >::SetString(), and rapidjson::internal::StrLen().

Referenced by rapidjson::GenericValue< Encoding, Allocator >::SetString().

◆ SetString() [2/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetString ( const Ch s,
Allocator allocator 
)
inline

Set this value as a string by copying from source string.

Parameters
ssource string.
allocatorAllocator for allocating copied buffer. Commonly use document.GetAllocator().
Returns
The value itself for fluent API.
507 { SetString(s, internal::StrLen(s), allocator); return *this; }

References rapidjson::GenericValue< Encoding, Allocator >::SetString(), and rapidjson::internal::StrLen().

Referenced by rapidjson::GenericValue< Encoding, Allocator >::SetString().

◆ SetString() [3/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetString ( const Ch s,
SizeType  length 
)
inline

Set this value as a string without copying source string.

This version has better performance with supplied length, and also support string containing null character.

Parameters
ssource string pointer.
lengthThe length of source string, excluding the trailing null terminator.
Returns
The value itself for fluent API.
485 { this->~GenericValue(); SetStringRaw(s, length); return *this; }

References rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw(), and rapidjson::GenericValue< Encoding, Allocator >::~GenericValue().

◆ SetString() [4/4]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetString ( const Ch s,
SizeType  length,
Allocator allocator 
)
inline

Set this value as a string by copying from source string.

This version has better performance with supplied length, and also support string containing null character.

Parameters
ssource string.
lengthThe length of source string, excluding the trailing null terminator.
allocatorAllocator for allocating copied buffer. Commonly use document.GetAllocator().
Returns
The value itself for fluent API.
500 { this->~GenericValue(); SetStringRaw(s, length, allocator); return *this; }

References rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw(), and rapidjson::GenericValue< Encoding, Allocator >::~GenericValue().

◆ SetStringRaw() [1/2]

◆ SetStringRaw() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw ( const Ch s,
SizeType  length,
Allocator allocator 
)
inlineprivate

Initialize this value as copy string with initial data, without calling destructor.

683  {
684  RAPIDJSON_ASSERT(s != NULL);
686  data_.s.str = (Ch *)allocator.Malloc((length + 1) * sizeof(Ch));
687  data_.s.length = length;
688  memcpy(const_cast<Ch*>(data_.s.str), s, length * sizeof(Ch));
689  const_cast<Ch*>(data_.s.str)[length] = '\0';
690  }

References rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::flags_, rapidjson::GenericValue< Encoding, Allocator >::kCopyStringFlag, rapidjson::GenericValue< Encoding, Allocator >::String::length, RAPIDJSON_ASSERT, rapidjson::GenericValue< Encoding, Allocator >::Data::s, and rapidjson::GenericValue< Encoding, Allocator >::String::str.

◆ SetUint()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetUint ( unsigned  u)
inline

◆ SetUint64()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetUint64 ( uint64_t  u64)
inline

◆ Size()

Friends And Related Function Documentation

◆ GenericDocument

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename , typename >
friend class GenericDocument
friend

Member Data Documentation

◆ data_

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
Data rapidjson::GenericValue< Encoding, Allocator >::data_
private

Referenced by rapidjson::GenericValue< Encoding, Allocator >::Accept(), rapidjson::GenericValue< Encoding, Allocator >::AddMember(), rapidjson::GenericValue< Encoding, Allocator >::Begin(), rapidjson::GenericValue< Encoding, Allocator >::Capacity(), rapidjson::GenericValue< Encoding, Allocator >::Clear(), rapidjson::GenericValue< Encoding, Allocator >::Empty(), rapidjson::GenericValue< Encoding, Allocator >::End(), rapidjson::GenericValue< Encoding, Allocator >::FindMember(), rapidjson::GenericValue< Encoding, Allocator >::GenericValue(), rapidjson::GenericValue< Encoding, Allocator >::GetDouble(), rapidjson::GenericValue< Encoding, Allocator >::GetInt(), rapidjson::GenericValue< Encoding, Allocator >::GetInt64(), rapidjson::GenericValue< Encoding, Allocator >::GetString(), rapidjson::GenericValue< Encoding, Allocator >::GetStringLength(), rapidjson::GenericValue< Encoding, Allocator >::GetUint(), rapidjson::GenericValue< Encoding, Allocator >::GetUint64(), rapidjson::GenericValue< Encoding, Allocator >::MemberBegin(), rapidjson::GenericValue< Encoding, Allocator >::MemberEnd(), rapidjson::GenericValue< Encoding, Allocator >::operator[](), rapidjson::GenericValue< Encoding, Allocator >::PopBack(), rapidjson::GenericValue< Encoding, Allocator >::PushBack(), rapidjson::GenericValue< Encoding, Allocator >::RemoveMember(), rapidjson::GenericValue< Encoding, Allocator >::Reserve(), rapidjson::GenericValue< Encoding, Allocator >::SetArrayRaw(), rapidjson::GenericValue< Encoding, Allocator >::SetObjectRaw(), rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw(), rapidjson::GenericValue< Encoding, Allocator >::Size(), and rapidjson::GenericValue< Encoding, Allocator >::~GenericValue().

◆ flags_

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
unsigned rapidjson::GenericValue< Encoding, Allocator >::flags_
private

Referenced by rapidjson::GenericValue< Encoding, Allocator >::GenericValue(), rapidjson::GenericValue< Encoding, Allocator >::GetBool_(), rapidjson::GenericValue< Encoding, Allocator >::GetDouble(), rapidjson::GenericValue< Encoding, Allocator >::GetInt(), rapidjson::GenericValue< Encoding, Allocator >::GetInt64(), rapidjson::GenericValue< Encoding, Allocator >::GetType(), rapidjson::GenericValue< Encoding, Allocator >::GetUint(), rapidjson::GenericValue< Encoding, Allocator >::GetUint64(), rapidjson::GenericValue< Encoding, Allocator >::IsArray(), rapidjson::GenericValue< Encoding, Allocator >::IsBool_(), rapidjson::GenericValue< Encoding, Allocator >::IsDouble(), rapidjson::GenericValue< Encoding, Allocator >::IsFalse(), rapidjson::GenericValue< Encoding, Allocator >::IsInt(), rapidjson::GenericValue< Encoding, Allocator >::IsInt64(), rapidjson::GenericValue< Encoding, Allocator >::IsNull_(), rapidjson::GenericValue< Encoding, Allocator >::IsNumber(), rapidjson::GenericValue< Encoding, Allocator >::IsObject(), rapidjson::GenericValue< Encoding, Allocator >::IsString(), rapidjson::GenericValue< Encoding, Allocator >::IsTrue(), rapidjson::GenericValue< Encoding, Allocator >::IsUint(), rapidjson::GenericValue< Encoding, Allocator >::IsUint64(), rapidjson::GenericValue< Encoding, Allocator >::operator=(), rapidjson::GenericValue< Encoding, Allocator >::RawAssign(), rapidjson::GenericValue< Encoding, Allocator >::SetArrayRaw(), rapidjson::GenericValue< Encoding, Allocator >::SetObjectRaw(), rapidjson::GenericValue< Encoding, Allocator >::SetStringRaw(), and rapidjson::GenericValue< Encoding, Allocator >::~GenericValue().

◆ kDefaultArrayCapacity

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
const SizeType rapidjson::GenericValue< Encoding, Allocator >::kDefaultArrayCapacity = 16
staticprivate

◆ kDefaultObjectCapacity

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
const SizeType rapidjson::GenericValue< Encoding, Allocator >::kDefaultObjectCapacity = 16
staticprivate

The documentation for this class was generated from the following file: