IN2OSM  1.0.1
GenericValue< Encoding, Allocator >

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

#include <document.h>

Inheritance diagram for GenericValue< Encoding, Allocator >:
Inheritance graph
Collaboration diagram for GenericValue< Encoding, Allocator >:
Collaboration graph

Classes

struct  ArrayData
 
union  Data
 
struct  Flag
 
union  Number
 
struct  ObjectData
 
struct  ShortString
 
struct  String
 

Public Types

enum  {
  kBoolFlag = 0x0008, kNumberFlag = 0x0010, kIntFlag = 0x0020, kUintFlag = 0x0040,
  kInt64Flag = 0x0080, kUint64Flag = 0x0100, kDoubleFlag = 0x0200, kStringFlag = 0x0400,
  kCopyFlag = 0x0800, kInlineStrFlag = 0x1000, kNullFlag = kNullType, kTrueFlag = kTrueType | kBoolFlag,
  kFalseFlag = kFalseType | kBoolFlag, kNumberIntFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag, kNumberUintFlag = kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag, kNumberInt64Flag = kNumberType | kNumberFlag | kInt64Flag,
  kNumberUint64Flag = kNumberType | kNumberFlag | kUint64Flag, kNumberDoubleFlag = kNumberType | kNumberFlag | kDoubleFlag, kNumberAnyFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag, kConstStringFlag = kStringType | kStringFlag,
  kCopyStringFlag = kStringType | kStringFlag | kCopyFlag, kShortStringFlag = kStringType | kStringFlag | kCopyFlag | kInlineStrFlag, kObjectFlag = kObjectType, kArrayFlag = kArrayType,
  kTypeMask = 0x07
}
 
typedef GenericMember< Encoding, Allocator > Member
 Name-value pair in an object. More...
 
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 GenericStringRef< ChStringRefType
 Reference to a constant string. More...
 
typedef GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
 Member iterator for iterating in object. More...
 
typedef GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
 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...
 
typedef GenericValue< Encoding, Allocator > ValueType
 Value type of itself. More...
 
typedef GenericArray< false, ValueTypeArray
 
typedef GenericArray< true, ValueTypeConstArray
 
typedef GenericObject< false, ValueTypeObject
 
typedef GenericObject< true, ValueTypeConstObject
 

Public Member Functions

template<typename T >
 RAPIDJSON_DISABLEIF_RETURN ((internal::IsPointer< T >),(GenericValue &)) operator
 Assignment with primitive types. More...
 
RAPIDJSON_FORCEINLINE const ChGetStringPointer () const
 
RAPIDJSON_FORCEINLINE const ChSetStringPointer (const Ch *str)
 
RAPIDJSON_FORCEINLINE GenericValueGetElementsPointer () const
 
RAPIDJSON_FORCEINLINE GenericValueSetElementsPointer (GenericValue *elements)
 
RAPIDJSON_FORCEINLINE MemberGetMembersPointer () const
 
RAPIDJSON_FORCEINLINE MemberSetMembersPointer (Member *members)
 
void SetArrayRaw (GenericValue *values, SizeType count, Allocator &allocator)
 
void SetObjectRaw (Member *members, SizeType count, Allocator &allocator)
 Initialize this value as object with initial data, without calling destructor. More...
 
void SetStringRaw (StringRefType s) RAPIDJSON_NOEXCEPT
 Initialize this value as constant string, without calling destructor. More...
 
void SetStringRaw (StringRefType s, Allocator &allocator)
 Initialize this value as copy string with initial data, without calling destructor. More...
 
void RawAssign (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment without calling destructor. More...
 
template<typename SourceAllocator >
bool StringEqual (const GenericValue< Encoding, SourceAllocator > &rhs) const
 
Assignment operators
GenericValueoperator= (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment with move semantics. More...
 
GenericValueoperator= (StringRefType str) RAPIDJSON_NOEXCEPT
 Assignment of constant string reference (no copy) More...
 

Public Attributes

Data data_
 

Static Public Attributes

static const SizeType kDefaultArrayCapacity = 16
 
static const SizeType kDefaultObjectCapacity = 16
 

Friends

template<typename , typename , typename >
class GenericDocument
 

Constructors and destructor.

 GenericValue () RAPIDJSON_NOEXCEPT
 Default constructor creates a null value. More...
 
 GenericValue (Type type) RAPIDJSON_NOEXCEPT
 Constructor with JSON value type. More...
 
template<typename SourceAllocator >
 GenericValue (const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
 Explicit copy constructor (with allocator) More...
 
template<typename T >
 GenericValue (T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT
 Constructor for boolean value. More...
 
 GenericValue (int i) RAPIDJSON_NOEXCEPT
 Constructor for int value. More...
 
 GenericValue (unsigned u) RAPIDJSON_NOEXCEPT
 Constructor for unsigned value. More...
 
 GenericValue (int64_t i64) RAPIDJSON_NOEXCEPT
 Constructor for int64_t value. More...
 
 GenericValue (uint64_t u64) RAPIDJSON_NOEXCEPT
 Constructor for uint64_t value. More...
 
 GenericValue (double d) RAPIDJSON_NOEXCEPT
 Constructor for double value. More...
 
 GenericValue (float f) RAPIDJSON_NOEXCEPT
 Constructor for float value. More...
 
 GenericValue (const Ch *s, SizeType length) RAPIDJSON_NOEXCEPT
 Constructor for constant string (i.e. do not make a copy of string) More...
 
 GenericValue (StringRefType s) RAPIDJSON_NOEXCEPT
 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 (Array a) RAPIDJSON_NOEXCEPT
 Constructor for Array. More...
 
 GenericValue (Object o) RAPIDJSON_NOEXCEPT
 Constructor for Object. More...
 
 ~GenericValue ()
 Destructor. More...
 
 GenericValue (const GenericValue &rhs)
 Copy constructor is not permitted. More...
 

Detailed Description

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
class 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.

Definition at line 54 of file document.h.

Member Typedef Documentation

◆ AllocatorType

typedef Allocator AllocatorType

Allocator type from template parameter.

Definition at line 583 of file document.h.

◆ Array

typedef GenericArray<false, ValueType> Array

Definition at line 591 of file document.h.

◆ Ch

typedef Encoding::Ch Ch

Character type derived from Encoding.

Definition at line 584 of file document.h.

◆ ConstArray

Definition at line 592 of file document.h.

◆ ConstMemberIterator

typedef GenericMemberIterator<true,Encoding,Allocator>::Iterator ConstMemberIterator

Constant member iterator for iterating in object.

Definition at line 587 of file document.h.

◆ ConstObject

Definition at line 594 of file document.h.

◆ ConstValueIterator

Constant value iterator for iterating in array.

Definition at line 589 of file document.h.

◆ EncodingType

typedef Encoding EncodingType

Encoding type from template parameter.

Definition at line 582 of file document.h.

◆ Member

typedef GenericMember<Encoding, Allocator> Member

Name-value pair in an object.

Definition at line 581 of file document.h.

◆ MemberIterator

typedef GenericMemberIterator<false,Encoding,Allocator>::Iterator MemberIterator

Member iterator for iterating in object.

Definition at line 586 of file document.h.

◆ Object

typedef GenericObject<false, ValueType> Object

Definition at line 593 of file document.h.

◆ StringRefType

Reference to a constant string.

Definition at line 585 of file document.h.

◆ ValueIterator

Value iterator for iterating in array.

Definition at line 588 of file document.h.

◆ ValueType

typedef GenericValue<Encoding, Allocator> ValueType

Value type of itself.

Definition at line 590 of file document.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kBoolFlag 
kNumberFlag 
kIntFlag 
kUintFlag 
kInt64Flag 
kUint64Flag 
kDoubleFlag 
kStringFlag 
kCopyFlag 
kInlineStrFlag 
kNullFlag 
kTrueFlag 
kFalseFlag 
kNumberIntFlag 
kNumberUintFlag 
kNumberInt64Flag 
kNumberUint64Flag 
kNumberDoubleFlag 
kNumberAnyFlag 
kConstStringFlag 
kCopyStringFlag 
kShortStringFlag 
kObjectFlag 
kArrayFlag 
kTypeMask 

Definition at line 1911 of file document.h.

1911  {
1912  kBoolFlag = 0x0008,
1913  kNumberFlag = 0x0010,
1914  kIntFlag = 0x0020,
1915  kUintFlag = 0x0040,
1916  kInt64Flag = 0x0080,
1917  kUint64Flag = 0x0100,
1918  kDoubleFlag = 0x0200,
1919  kStringFlag = 0x0400,
1920  kCopyFlag = 0x0800,
1921  kInlineStrFlag = 0x1000,
1922 
1923  // Initial flags of different types.
1924  kNullFlag = kNullType,
1938 
1939  kTypeMask = 0x07
1940  };
object
Definition: rapidjson.h:646
array
Definition: rapidjson.h:647
false
Definition: rapidjson.h:644
string
Definition: rapidjson.h:648
number
Definition: rapidjson.h:649
true
Definition: rapidjson.h:645
null
Definition: rapidjson.h:643

Constructor & Destructor Documentation

◆ GenericValue() [1/17]

GenericValue ( )
inline

Default constructor creates a null value.

Definition at line 600 of file document.h.

◆ GenericValue() [2/17]

GenericValue ( const GenericValue< Encoding, Allocator > &  rhs)
private

Copy constructor is not permitted.

◆ GenericValue() [3/17]

GenericValue ( Type  type)
inlineexplicit

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.

Definition at line 630 of file document.h.

630  : data_() {
631  static const uint16_t defaultFlags[] = {
634  };
635  RAPIDJSON_NOEXCEPT_ASSERT(type >= kNullType && type <= kNumberType);
636  data_.f.flags = defaultFlags[type];
637 
638  // Use ShortString to store empty string.
639  if (type == kStringType)
640  data_.ss.SetLength(0);
641  }
void SetLength(SizeType len)
Definition: document.h:1975
unsigned short uint16_t
Definition: stdint.h:125
#define RAPIDJSON_NOEXCEPT_ASSERT(x)
Assertion (in non-throwing contexts).
Definition: rapidjson.h:617
string
Definition: rapidjson.h:648
number
Definition: rapidjson.h:649
ShortString ss
Definition: document.h:2019
null
Definition: rapidjson.h:643

◆ GenericValue() [4/17]

GenericValue ( const GenericValue< Encoding, SourceAllocator > &  rhs,
Allocator &  allocator,
bool  copyConstStrings = false 
)
inline

Explicit copy constructor (with allocator)

Creates a copy of a Value by using the given Allocator

Template Parameters
SourceAllocatorallocator of rhs
Parameters
rhsValue to copy from (read-only)
allocatorAllocator for allocating copied elements and buffers. Commonly use GenericDocument::GetAllocator().
copyConstStringsForce copying of constant strings (e.g. referencing an in-situ buffer)
See also
CopyFrom()

Definition at line 652 of file document.h.

652  {
653  switch (rhs.GetType()) {
654  case kObjectType: {
655  SizeType count = rhs.data_.o.size;
656  Member* lm = reinterpret_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
658  for (SizeType i = 0; i < count; i++) {
659  new (&lm[i].name) GenericValue(rm[i].name, allocator, copyConstStrings);
660  new (&lm[i].value) GenericValue(rm[i].value, allocator, copyConstStrings);
661  }
663  data_.o.size = data_.o.capacity = count;
664  SetMembersPointer(lm);
665  }
666  break;
667  case kArrayType: {
668  SizeType count = rhs.data_.a.size;
669  GenericValue* le = reinterpret_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
671  for (SizeType i = 0; i < count; i++)
672  new (&le[i]) GenericValue(re[i], allocator, copyConstStrings);
674  data_.a.size = data_.a.capacity = count;
675  SetElementsPointer(le);
676  }
677  break;
678  case kStringType:
679  if (rhs.data_.f.flags == kConstStringFlag && !copyConstStrings) {
680  data_.f.flags = rhs.data_.f.flags;
681  data_ = *reinterpret_cast<const Data*>(&rhs.data_);
682  }
683  else
684  SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
685  break;
686  default:
687  data_.f.flags = rhs.data_.f.flags;
688  data_ = *reinterpret_cast<const Data*>(&rhs.data_);
689  break;
690  }
691  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
object
Definition: rapidjson.h:646
array
Definition: rapidjson.h:647
Name-value pair in a JSON object value.
Definition: document.h:66
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
Definition: document.h:2030
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:54
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
Definition: document.h:2029
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
Definition: document.h:2031
string
Definition: rapidjson.h:648
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition: document.h:2060
ObjectData o
Definition: document.h:2021
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
Definition: document.h:2028
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:364
GenericValue() RAPIDJSON_NOEXCEPT
Default constructor creates a null value.
Definition: document.h:600
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1282
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:581

◆ GenericValue() [5/17]

GenericValue ( b,
RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))   
)
inlineexplicit

Constructor for boolean value.

Parameters
bBoolean value
Note
This constructor is limited to real boolean values and rejects implicitly converted types like arbitrary pointers. Use an explicit cast to bool, if you want to construct a boolean JSON value in such cases.

Definition at line 701 of file document.h.

705  : data_() {
706  // safe-guard against failing SFINAE
708  data_.f.flags = b ? kTrueFlag : kFalseFlag;
709  }
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition: rapidjson.h:445
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2110

◆ GenericValue() [6/17]

GenericValue ( int  i)
inlineexplicit

Constructor for int value.

Definition at line 712 of file document.h.

◆ GenericValue() [7/17]

GenericValue ( unsigned  u)
inlineexplicit

Constructor for unsigned value.

Definition at line 718 of file document.h.

◆ GenericValue() [8/17]

GenericValue ( int64_t  i64)
inlineexplicit

Constructor for int64_t value.

Definition at line 724 of file document.h.

724  : data_() {
725  data_.n.i64 = i64;
727  if (i64 >= 0) {
729  if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
730  data_.f.flags |= kUintFlag;
731  if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
732  data_.f.flags |= kIntFlag;
733  }
734  else if (i64 >= static_cast<int64_t>(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
735  data_.f.flags |= kIntFlag;
736  }
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:289

◆ GenericValue() [9/17]

GenericValue ( uint64_t  u64)
inlineexplicit

Constructor for uint64_t value.

Definition at line 739 of file document.h.

739  : data_() {
740  data_.n.u64 = u64;
742  if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)))
743  data_.f.flags |= kInt64Flag;
744  if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
745  data_.f.flags |= kUintFlag;
746  if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
747  data_.f.flags |= kIntFlag;
748  }
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:289

◆ GenericValue() [10/17]

GenericValue ( double  d)
inlineexplicit

Constructor for double value.

Definition at line 751 of file document.h.

◆ GenericValue() [11/17]

GenericValue ( float  f)
inlineexplicit

Constructor for float value.

Definition at line 754 of file document.h.

◆ GenericValue() [12/17]

GenericValue ( const Ch s,
SizeType  length 
)
inline

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

Definition at line 757 of file document.h.

757 : data_() { SetStringRaw(StringRef(s, length)); }
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition: document.h:2060
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:364

◆ GenericValue() [13/17]

GenericValue ( StringRefType  s)
inlineexplicit

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

Definition at line 760 of file document.h.

760 : data_() { SetStringRaw(s); }
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition: document.h:2060

◆ GenericValue() [14/17]

GenericValue ( const Ch s,
SizeType  length,
Allocator &  allocator 
)
inline

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

Definition at line 763 of file document.h.

763 : data_() { SetStringRaw(StringRef(s, length), allocator); }
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition: document.h:2060
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:364

◆ GenericValue() [15/17]

GenericValue ( const Ch s,
Allocator &  allocator 
)
inline

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

Definition at line 766 of file document.h.

766 : data_() { SetStringRaw(StringRef(s), allocator); }
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition: document.h:2060
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition: document.h:364

◆ GenericValue() [16/17]

GenericValue ( Array  a)
inline

Constructor for Array.

Parameters
aAn array obtained by GetArray().
Note
Array is always pass-by-value.
the source array is moved into this value and the sourec array becomes empty.

Definition at line 781 of file document.h.

781  : data_(a.value_.data_) {
782  a.value_.data_ = Data();
783  a.value_.data_.f.flags = kArrayFlag;
784  }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1181

◆ GenericValue() [17/17]

GenericValue ( Object  o)
inline

Constructor for Object.

Parameters
oAn object obtained by GetObject().
Note
Object is always pass-by-value.
the source object is moved into this value and the sourec object becomes empty.

Definition at line 792 of file document.h.

792  : data_(o.value_.data_) {
793  o.value_.data_ = Data();
794  o.value_.data_.f.flags = kObjectFlag;
795  }

◆ ~GenericValue()

~GenericValue ( )
inline

Destructor.

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

Definition at line 800 of file document.h.

800  {
801  if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
802  switch(data_.f.flags) {
803  case kArrayFlag:
804  {
806  for (GenericValue* v = e; v != e + data_.a.size; ++v)
807  v->~GenericValue();
808  Allocator::Free(e);
809  }
810  break;
811 
812  case kObjectFlag:
813  for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
814  m->~Member();
815  Allocator::Free(GetMembersPointer());
816  break;
817 
818  case kCopyStringFlag:
819  Allocator::Free(const_cast<Ch*>(GetStringPointer()));
820  break;
821 
822  default:
823  break; // Do nothing for other types.
824  }
825  }
826  }
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
Definition: document.h:2030
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:54
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
Definition: document.h:2028
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Member iterator for iterating in object.
Definition: document.h:586
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
Definition: document.h:2026
Here is the caller graph for this function:

Member Function Documentation

◆ GetElementsPointer()

RAPIDJSON_FORCEINLINE GenericValue* GetElementsPointer ( ) const
inline

Definition at line 2028 of file document.h.

Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:54
GenericValue * elements
Definition: document.h:2014
#define RAPIDJSON_GETPOINTER(type, p)
Definition: rapidjson.h:319
Here is the caller graph for this function:

◆ GetMembersPointer()

RAPIDJSON_FORCEINLINE Member* GetMembersPointer ( ) const
inline

Definition at line 2030 of file document.h.

ObjectData o
Definition: document.h:2021
#define RAPIDJSON_GETPOINTER(type, p)
Definition: rapidjson.h:319
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:581
Here is the caller graph for this function:

◆ GetStringPointer()

RAPIDJSON_FORCEINLINE const Ch* GetStringPointer ( ) const
inline

Definition at line 2026 of file document.h.

2026 { return RAPIDJSON_GETPOINTER(Ch, data_.s.str); }
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:584
#define RAPIDJSON_GETPOINTER(type, p)
Definition: rapidjson.h:319

◆ operator=() [1/2]

GenericValue& operator= ( GenericValue< Encoding, Allocator > &  rhs)
inline

Assignment with move semantics.

Parameters
rhsSource of the assignment. It will become a null value after assignment.

Definition at line 836 of file document.h.

836  {
837  if (RAPIDJSON_LIKELY(this != &rhs)) {
838  this->~GenericValue();
839  RawAssign(rhs);
840  }
841  return *this;
842  }
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
Definition: document.h:2084
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
~GenericValue()
Destructor.
Definition: document.h:800
Here is the caller graph for this function:

◆ operator=() [2/2]

GenericValue& operator= ( StringRefType  str)
inline

Assignment of constant string reference (no copy)

Parameters
strConstant string reference to be assigned
Note
This overload is needed to avoid clashes with the generic primitive type assignment overload below.
See also
GenericStringRef, operator=(T)

Definition at line 856 of file document.h.

856  {
857  GenericValue s(str);
858  return *this = s;
859  }
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:54

◆ RAPIDJSON_DISABLEIF_RETURN()

RAPIDJSON_DISABLEIF_RETURN ( (internal::IsPointer< T >)  ,
(GenericValue< Encoding, Allocator > &)   
)

Assignment with primitive types.

Template Parameters
TEither Type, int, unsigned, int64_t, uint64_t
Parameters
valueThe value to be assigned.
Note
The source type T explicitly disallows all pointer types, especially (const) Ch*. This helps avoiding implicitly referencing character strings with insufficient lifetime, use SetString(const Ch*, Allocator&) (for copying) or StringRef() (to explicitly mark the pointer as constant) instead. All other pointer types would implicitly convert to bool, use SetBool() instead.Set boolean value

◆ RawAssign()

void RawAssign ( GenericValue< Encoding, Allocator > &  rhs)
inline

Assignment without calling destructor.

Definition at line 2084 of file document.h.

2084  {
2085  data_ = rhs.data_;
2086  // data_.f.flags = rhs.data_.f.flags;
2087  rhs.data_.f.flags = kNullFlag;
2088  }
Here is the caller graph for this function:

◆ SetArrayRaw()

void SetArrayRaw ( GenericValue< Encoding, Allocator > *  values,
SizeType  count,
Allocator &  allocator 
)
inline

Definition at line 2034 of file document.h.

2034  {
2035  data_.f.flags = kArrayFlag;
2036  if (count) {
2037  GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
2038  SetElementsPointer(e);
2039  std::memcpy(static_cast<void*>(e), values, count * sizeof(GenericValue));
2040  }
2041  else
2042  SetElementsPointer(0);
2043  data_.a.size = data_.a.capacity = count;
2044  }
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:54
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
Definition: document.h:2029
Here is the caller graph for this function:

◆ SetElementsPointer()

RAPIDJSON_FORCEINLINE GenericValue* SetElementsPointer ( GenericValue< Encoding, Allocator > *  elements)
inline

Definition at line 2029 of file document.h.

2029 { return RAPIDJSON_SETPOINTER(GenericValue, data_.a.elements, elements); }
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:54
GenericValue * elements
Definition: document.h:2014
#define RAPIDJSON_SETPOINTER(type, p, x)
Definition: rapidjson.h:318

◆ SetMembersPointer()

RAPIDJSON_FORCEINLINE Member* SetMembersPointer ( Member members)
inline

Definition at line 2031 of file document.h.

2031 { return RAPIDJSON_SETPOINTER(Member, data_.o.members, members); }
ObjectData o
Definition: document.h:2021
#define RAPIDJSON_SETPOINTER(type, p, x)
Definition: rapidjson.h:318
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:581

◆ SetObjectRaw()

void SetObjectRaw ( Member members,
SizeType  count,
Allocator &  allocator 
)
inline

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

Definition at line 2047 of file document.h.

2047  {
2049  if (count) {
2050  Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
2051  SetMembersPointer(m);
2052  std::memcpy(static_cast<void*>(m), members, count * sizeof(Member));
2053  }
2054  else
2055  SetMembersPointer(0);
2056  data_.o.size = data_.o.capacity = count;
2057  }
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
Definition: document.h:2031
ObjectData o
Definition: document.h:2021
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:581
Here is the caller graph for this function:

◆ SetStringPointer()

RAPIDJSON_FORCEINLINE const Ch* SetStringPointer ( const Ch str)
inline

Definition at line 2027 of file document.h.

2027 { return RAPIDJSON_SETPOINTER(Ch, data_.s.str, str); }
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:584
#define RAPIDJSON_SETPOINTER(type, p, x)
Definition: rapidjson.h:318

◆ SetStringRaw() [1/2]

void SetStringRaw ( StringRefType  s)
inline

Initialize this value as constant string, without calling destructor.

Definition at line 2060 of file document.h.

2060  {
2062  SetStringPointer(s);
2063  data_.s.length = s.length;
2064  }
RAPIDJSON_FORCEINLINE const Ch * SetStringPointer(const Ch *str)
Definition: document.h:2027

◆ SetStringRaw() [2/2]

void SetStringRaw ( StringRefType  s,
Allocator &  allocator 
)
inline

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

Definition at line 2067 of file document.h.

2067  {
2068  Ch* str = 0;
2069  if (ShortString::Usable(s.length)) {
2071  data_.ss.SetLength(s.length);
2072  str = data_.ss.str;
2073  } else {
2075  data_.s.length = s.length;
2076  str = static_cast<Ch *>(allocator.Malloc((s.length + 1) * sizeof(Ch)));
2077  SetStringPointer(str);
2078  }
2079  std::memcpy(str, s, s.length * sizeof(Ch));
2080  str[s.length] = '\0';
2081  }
void SetLength(SizeType len)
Definition: document.h:1975
RAPIDJSON_FORCEINLINE const Ch * SetStringPointer(const Ch *str)
Definition: document.h:2027
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:584
ShortString ss
Definition: document.h:2019
static bool Usable(SizeType len)
Definition: document.h:1974

◆ StringEqual()

bool StringEqual ( const GenericValue< Encoding, SourceAllocator > &  rhs) const
inline

Definition at line 2091 of file document.h.

2091  {
2092  RAPIDJSON_ASSERT(IsString());
2093  RAPIDJSON_ASSERT(rhs.IsString());
2094 
2095  const SizeType len1 = GetStringLength();
2096  const SizeType len2 = rhs.GetStringLength();
2097  if(len1 != len2) { return false; }
2098 
2099  const Ch* const str1 = GetString();
2100  const Ch* const str2 = rhs.GetString();
2101  if(str1 == str2) { return true; } // fast path for constant string
2102 
2103  return (std::memcmp(str1, str2, sizeof(Ch) * len1) == 0);
2104  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
Encoding::Ch Ch
Character type derived from Encoding.
Definition: document.h:584
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ GenericDocument

friend class GenericDocument
friend

Definition at line 1909 of file document.h.

Member Data Documentation

◆ data_

Data data_

Definition at line 2106 of file document.h.

◆ kDefaultArrayCapacity

const SizeType kDefaultArrayCapacity = 16
static

Definition at line 1942 of file document.h.

◆ kDefaultObjectCapacity

const SizeType kDefaultObjectCapacity = 16
static

Definition at line 1943 of file document.h.


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