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 
535  {
536  kBool_Flag = 0x100,
537  kNumberFlag = 0x200,
538  kIntFlag = 0x400,
539  kUintFlag = 0x800,
540  kInt64Flag = 0x1000,
541  kUint64Flag = 0x2000,
542  kDoubleFlag = 0x4000,
543  kStringFlag = 0x100000,
544  kCopyFlag = 0x200000,
545 
546  // Initial flags of different types.
559 
560  kTypeMask = 0xFF // bitwise-and with mask of 0xFF can be optimized by compiler
561  };
@ kStringFlag
Definition: document.h:543
@ kTrueFlag
Definition: document.h:548
@ kNumberDoubleFlag
Definition: document.h:554
@ kNumberUint64Flag
Definition: document.h:553
@ kFalseFlag
Definition: document.h:549
@ kDoubleFlag
Definition: document.h:542
@ kBool_Flag
Definition: document.h:536
@ kArrayFlag
Definition: document.h:558
@ kConstStringFlag
Definition: document.h:555
@ kTypeMask
Definition: document.h:560
@ kIntFlag
Definition: document.h:538
@ kObjectFlag
Definition: document.h:557
@ kCopyFlag
Definition: document.h:544
@ kNumberUintFlag
Definition: document.h:551
@ kUint64Flag
Definition: document.h:541
@ kNumberInt64Flag
Definition: document.h:552
@ kNull_Flag
Definition: document.h:547
@ kCopyStringFlag
Definition: document.h:556
@ kNumberIntFlag
Definition: document.h:550
@ kUintFlag
Definition: document.h:539
@ kNumberFlag
Definition: document.h:537
@ kInt64Flag
Definition: document.h:540
@ kArrayType
array
Definition: rapidjson.h:518
@ kNull_Type
null
Definition: rapidjson.h:514
@ kTrueType
true
Definition: rapidjson.h:516
@ kFalseType
false
Definition: rapidjson.h:515
@ kNumberType
number
Definition: rapidjson.h:520
@ kObjectType
object
Definition: rapidjson.h:517
@ kStringType
string
Definition: rapidjson.h:519

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.
63  {
64  static const unsigned defaultFlags[7] = {
67  };
69  flags_ = defaultFlags[type];
70  memset(&data_, 0, sizeof(data_));
71  }
Data data_
Definition: document.h:673
type
Definition: compute_granudrum_aor.py:141
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:80

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, RAPIDJSON_ASSERT, and compute_granudrum_aor::type.

◆ GenericValue() [4/13]

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

Constructor for boolean value.

74 : flags_(b ? kTrueFlag : kFalseFlag) {}
Scalar * b
Definition: benchVecAdd.cpp:17

◆ 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)

void SetStringRaw(const Ch *s, SizeType length)
Initialize this value as constant string, without calling destructor.
Definition: document.h:650
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:14

References s, 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)

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

References s, and 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)

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

References s, 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.

138  {
139  if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
140  switch(flags_) {
141  case kArrayFlag:
142  for (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
143  v->~GenericValue();
144  Allocator::Free(data_.a.elements);
145  break;
146 
147  case kObjectFlag:
148  for (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) {
149  m->name.~GenericValue();
150  m->value.~GenericValue();
151  }
152  Allocator::Free(data_.o.members);
153  break;
154 
155  case kCopyStringFlag:
156  Allocator::Free(const_cast<Ch*>(data_.s.str));
157  break;
158  }
159  }
160  }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
GenericValue()
Default constructor creates a null value.
Definition: document.h:50
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:40
int * m
Definition: level2_cplx_impl.h:294
SizeType size
Definition: document.h:606
GenericValue< Encoding, Allocator > * elements
Definition: document.h:605
SizeType size
Definition: document.h:600
Member * members
Definition: document.h:599
Array a
Definition: document.h:614
Object o
Definition: document.h:613

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, m, 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, rapidjson::GenericValue< Encoding, Allocator >::String::str, and v.

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.
494  {
495  switch(GetType()) {
496  case kNull_Type: handler.Null_(); break;
497  case kFalseType: handler.Bool_(false); break;
498  case kTrueType: handler.Bool_(true); break;
499 
500  case kObjectType:
501  handler.StartObject();
502  for (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) {
503  handler.String(m->name.data_.s.str, m->name.data_.s.length, false);
504  m->value.Accept(handler);
505  }
506  handler.EndObject(data_.o.size);
507  break;
508 
509  case kArrayType:
510  handler.StartArray();
511  for (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
512  v->Accept(handler);
513  handler.EndArray(data_.a.size);
514  break;
515 
516  case kStringType:
517  handler.String(data_.s.str, data_.s.length, false);
518  break;
519 
520  case kNumberType:
521  if (IsInt()) handler.Int(data_.n.i.i);
522  else if (IsUint()) handler.Uint(data_.n.u.u);
523  else if (IsInt64()) handler.Int64(data_.n.i64);
524  else if (IsUint64()) handler.Uint64(data_.n.u64);
525  else handler.Double(data_.n.d);
526  break;
527  }
528  return *this;
529  }
bool IsUint64() const
Definition: document.h:204
bool IsInt() const
Definition: document.h:201
Type GetType() const
Definition: document.h:193
bool IsUint() const
Definition: document.h:202
bool IsInt64() const
Definition: document.h:203
int i
Definition: document.h:576
unsigned u
Definition: document.h:580
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, m, 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, rapidjson::GenericValue< Encoding, Allocator >::Number::u64, and v.

◆ 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
279  {
280  GenericValue n(name, internal::StrLen(name), nameAllocator);
281  return AddMember(n, value, allocator);
282  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
GenericValue & AddMember(GenericValue &name, GenericValue &value, Allocator &allocator)
Add a member (name-value pair) to the object.
Definition: document.h:258
squared absolute value
Definition: GlobalFunctions.h:87
string name
Definition: plotDoE.py:33

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

◆ 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,
T  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.
258  {
260  RAPIDJSON_ASSERT(name.IsString());
261  Object& o = data_.o;
262  if (o.size >= o.capacity) {
263  if (o.capacity == 0) {
265  o.members = (Member*)allocator.Malloc(o.capacity * sizeof(Member));
266  }
267  else {
268  SizeType oldCapacity = o.capacity;
269  o.capacity *= 2;
270  o.members = (Member*)allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member));
271  }
272  }
273  o.members[o.size].name.RawAssign(name);
274  o.members[o.size].value.RawAssign(value);
275  o.size++;
276  return *this;
277  }
bool IsObject() const
Definition: document.h:198
static const SizeType kDefaultObjectCapacity
Definition: document.h:564
unsigned SizeType
Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.
Definition: rapidjson.h:67
SizeType capacity
Definition: document.h:601

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, plotDoE::name, rapidjson::GenericValue< Encoding, Allocator >::Member::name, rapidjson::GenericValue< Encoding, Allocator >::Data::o, RAPIDJSON_ASSERT, rapidjson::GenericValue< Encoding, Allocator >::Object::size, rapidjson::GenericValue< Encoding, Allocator >::Member::value, and Eigen::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
372 { 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
373 { 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
631 { return const_cast<GenericValue&>(*this).FindMember(name); }

References rapidjson::GenericValue< Encoding, Allocator >::FindMember(), and plotDoE::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
427  {
429  if ((flags_ & kDoubleFlag) != 0) return data_.n.d; // exact type, no conversion.
430  if ((flags_ & kIntFlag) != 0) return data_.n.i.i; // int -> double
431  if ((flags_ & kUintFlag) != 0) return data_.n.u.u; // unsigned -> double
432  if ((flags_ & kInt64Flag) != 0) return (double)data_.n.i64; // int64_t -> double (may lose precision)
433  RAPIDJSON_ASSERT((flags_ & kUint64Flag) != 0); return (double)data_.n.u64; // uint64_t -> double (may lose precision)
434  }
bool IsNumber() const
Definition: document.h:200

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().

452 { 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.

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

References rapidjson::GenericValue< Encoding, Allocator >::FindMember(), and plotDoE::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.
170  {
171  RAPIDJSON_ASSERT(this != &rhs);
172  this->~GenericValue();
173  memcpy(this, &rhs, sizeof(GenericValue));
174  rhs.flags_ = kNull_Flag;
175  return *this;
176  }
~GenericValue()
Destructor.
Definition: document.h:138

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= ( T  value)
inline

Assignment with primitive types.

Template Parameters
TEither Type, int, unsigned, int64_t, uint64_t, const Ch*
Parameters
valueThe value to be assigned.
183  {
184  this->~GenericValue();
185  new (this) GenericValue(value);
186  return *this;
187  }

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.

232  {
233  if (Member* member = FindMember(name))
234  return member->value;
235  else {
236  static GenericValue Null_Value;
237  return Null_Value;
238  }
239  }

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

◆ operator[]() [2/4]

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

References plotDoE::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.
Scalar * y
Definition: level1_cplx_impl.h:128
const Scalar * a
Definition: level2_cplx_impl.h:32
list x
Definition: plotDoE.py:28
GenericValue< UTF8<> > Value
Value with UTF8 encoding.
Definition: document.h:679
362  {
364  RAPIDJSON_ASSERT(index < data_.a.size);
365  return data_.a.elements[index];
366  }

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
367 { 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.
396  {
398  if (data_.a.size >= data_.a.capacity)
399  Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : data_.a.capacity * 2, allocator);
400  data_.a.elements[data_.a.size++].RawAssign(value);
401  return *this;
402  }
GenericValue & Reserve(SizeType newCapacity, Allocator &allocator)
Request the array to have enough capacity to store elements.
Definition: document.h:380
static const SizeType kDefaultArrayCapacity
Definition: document.h:563

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(), rapidjson::GenericValue< Encoding, Allocator >::Array::size, and Eigen::value.

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 ( T  value,
Allocator allocator 
)
inline
405  {
407  return PushBack(v, allocator);
408  }
GenericValue & PushBack(GenericValue &value, Allocator &allocator)
Append a value at the end of the array.
Definition: document.h:396

References rapidjson::GenericValue< Encoding, Allocator >::PushBack(), v, and Eigen::value.

◆ RawAssign()

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

Assignment without calling destructor.

668  {
669  memcpy(this, &rhs, sizeof(GenericValue));
670  rhs.flags_ = kNull_Flag;
671  }

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.
301  {
303  if (Member* m = FindMember(name)) {
306 
307  Member* last = data_.o.members + (data_.o.size - 1);
308  if (data_.o.size > 1 && m != last) {
309  // Move the last one to this place
310  m->name = last->name;
311  m->value = last->value;
312  }
313  else {
314  // Only one left, just destroy
315  m->name.~GenericValue();
316  m->value.~GenericValue();
317  }
318  --data_.o.size;
319  return true;
320  }
321  return false;
322  }
static constexpr const last_t last
Definition: IndexedViewHelper.h:48

References rapidjson::GenericValue< Encoding, Allocator >::data_, rapidjson::GenericValue< Encoding, Allocator >::FindMember(), rapidjson::GenericValue< Encoding, Allocator >::IsObject(), Eigen::placeholders::last, m, rapidjson::GenericValue< Encoding, Allocator >::Object::members, plotDoE::name, rapidjson::GenericValue< Encoding, Allocator >::Data::o, RAPIDJSON_ASSERT, and rapidjson::GenericValue< Encoding, Allocator >::Object::size.

◆ 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.
380  {
382  if (newCapacity > data_.a.capacity) {
383  data_.a.elements = (GenericValue*)allocator.Realloc(data_.a.elements, data_.a.capacity * sizeof(GenericValue), newCapacity * sizeof(GenericValue));
384  data_.a.capacity = newCapacity;
385  }
386  return *this;
387  }

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.
466 { 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:460

References s, 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.
482 { SetString(s, internal::StrLen(s), allocator); return *this; }

References s, 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.
460 { 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.
475 { 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.

658  {
659  RAPIDJSON_ASSERT(s != NULL);
661  data_.s.str = (Ch *)allocator.Malloc((length + 1) * sizeof(Ch));
662  data_.s.length = length;
663  memcpy(const_cast<Ch*>(data_.s.str), s, length * sizeof(Ch));
664  const_cast<Ch*>(data_.s.str)[length] = '\0';
665  }

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, 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: