Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
GenericValue< Encoding, Allocator > Class Template Reference

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

#include <document.h>

Collaboration diagram for GenericValue< Encoding, Allocator >:

Classes

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

Public Types

typedef GenericMember< Encoding, AllocatorMember
 Name-value pair in an object.
 
typedef Encoding EncodingType
 Encoding type from template parameter.
 
typedef Allocator AllocatorType
 Allocator type from template parameter.
 
typedef Encoding::Ch Ch
 Character type derived from Encoding.
 
typedef GenericStringRef< ChStringRefType
 Reference to a constant string.
 
typedef GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
 Member iterator for iterating in object.
 
typedef GenericMemberIterator< true, Encoding, Allocator >::Iterator ConstMemberIterator
 Constant member iterator for iterating in object.
 
typedef GenericValueValueIterator
 Value iterator for iterating in array.
 
typedef const GenericValueConstValueIterator
 Constant value iterator for iterating in array.
 
typedef GenericValue< Encoding, AllocatorValueType
 Value type of itself.
 
typedef GenericArray< false, ValueTypeArray
 
typedef GenericArray< true, ValueTypeConstArray
 
typedef GenericObject< false, ValueTypeObject
 
typedef GenericObject< true, ValueTypeConstObject
 

Assignment operators

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
}
 
template<typename , typename , typename >
class GenericDocument
 
static const SizeType kDefaultArrayCapacity = 16
 
static const SizeType kDefaultObjectCapacity = 16
 
Data data_
 
GenericValueoperator= (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment with move semantics.
 
GenericValueoperator= (StringRefType str) RAPIDJSON_NOEXCEPT
 Assignment of constant string reference (no copy)
 
template<typename T >
 RAPIDJSON_DISABLEIF_RETURN ((internal::IsPointer< T >),(GenericValue &)) operator
 Assignment with primitive types.
 
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.
 
void SetStringRaw (StringRefType s) RAPIDJSON_NOEXCEPT
 Initialize this value as constant string, without calling destructor.
 
void SetStringRaw (StringRefType s, Allocator &allocator)
 Initialize this value as copy string with initial data, without calling destructor.
 
void RawAssign (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment without calling destructor.
 
template<typename SourceAllocator >
bool StringEqual (const GenericValue< Encoding, SourceAllocator > &rhs) const
 

Constructors and destructor.

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

Detailed Description

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
class GenericValue< Encoding, 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 578 of file document.h.

Member Typedef Documentation

◆ AllocatorType

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

Definition at line 583 of file document.h.

◆ Array

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericArray<false, ValueType> GenericValue< Encoding, Allocator >::Array

Definition at line 591 of file document.h.

◆ Ch

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

Definition at line 584 of file document.h.

◆ ConstArray

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericArray<true, ValueType> GenericValue< Encoding, Allocator >::ConstArray

Definition at line 592 of file document.h.

◆ ConstMemberIterator

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericMemberIterator<true,Encoding,Allocator>::Iterator GenericValue< Encoding, Allocator >::ConstMemberIterator

Definition at line 587 of file document.h.

◆ ConstObject

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericObject<true, ValueType> GenericValue< Encoding, Allocator >::ConstObject

Definition at line 594 of file document.h.

◆ ConstValueIterator

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

Definition at line 589 of file document.h.

◆ EncodingType

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

Definition at line 582 of file document.h.

◆ Member

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericMember<Encoding, Allocator> GenericValue< Encoding, Allocator >::Member

Definition at line 581 of file document.h.

◆ MemberIterator

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericMemberIterator<false,Encoding,Allocator>::Iterator GenericValue< Encoding, Allocator >::MemberIterator

Definition at line 586 of file document.h.

◆ Object

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericObject<false, ValueType> GenericValue< Encoding, Allocator >::Object

Definition at line 593 of file document.h.

◆ StringRefType

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericStringRef<Ch> GenericValue< Encoding, Allocator >::StringRefType

Definition at line 585 of file document.h.

◆ ValueIterator

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

Definition at line 588 of file document.h.

◆ ValueType

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue<Encoding, Allocator> GenericValue< Encoding, Allocator >::ValueType

Definition at line 590 of file document.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
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.
1938
1939 kTypeMask = 0x07
1940 };
@ kFalseType
false
Definition rapidjson.h:646
@ kObjectType
object
Definition rapidjson.h:648
@ kTrueType
true
Definition rapidjson.h:647
@ kStringType
string
Definition rapidjson.h:650
@ kNullType
null
Definition rapidjson.h:645
@ kArrayType
array
Definition rapidjson.h:649
@ kNumberType
number
Definition rapidjson.h:651

Constructor & Destructor Documentation

◆ GenericValue() [1/16]

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

Definition at line 600 of file document.h.

Here is the caller graph for this function:

◆ GenericValue() [2/16]

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

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 };
636 data_.f.flags = defaultFlags[type];
637
638 // Use ShortString to store empty string.
639 if (type == kStringType)
640 data_.ss.SetLength(0);
641 }
#define RAPIDJSON_NOEXCEPT_ASSERT(x)
Assertion (in non-throwing contexts).
Definition rapidjson.h:618
unsigned short uint16_t
Definition stdint.h:125
void SetLength(SizeType len)
Definition document.h:1975
ShortString ss
Definition document.h:2019
yh_object_type type
Definition yubihsm.h:672
Here is the call graph for this function:

◆ GenericValue() [3/16]

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

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 }
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);
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 }
std::string name
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition document.h:578
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Initialize this value as constant string, without calling destructor.
Definition document.h:2060
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
Definition document.h:2029
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
Definition document.h:2028
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition document.h:581
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
Definition document.h:2031
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
Definition document.h:2030
GenericValue() RAPIDJSON_NOEXCEPT
Default constructor creates a null value.
Definition document.h:600
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition document.h:364
int * count
bip::allocator< T, pinnable_mapped_file::segment_manager > allocator
Definition chainbase.hpp:56
#define value
Definition pkcs11.h:157
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition rapidjson.h:384
Definition zm2.cpp:48
Name-value pair in a JSON object value.
Definition document.h:66
Here is the call graph for this function:

◆ GenericValue() [4/16]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename T >
GenericValue< Encoding, Allocator >::GenericValue ( T b,
RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))  )
inlineexplicit
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
707 RAPIDJSON_STATIC_ASSERT((internal::IsSame<bool,T>::Value));
709 }
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition rapidjson.h:445

◆ GenericValue() [5/16]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue< Encoding, Allocator >::GenericValue ( int i)
inlineexplicit

Definition at line 712 of file document.h.

712 : data_() {
713 data_.n.i64 = i;
715 }

◆ GenericValue() [6/16]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue< Encoding, Allocator >::GenericValue ( unsigned u)
inlineexplicit

Definition at line 718 of file document.h.

718 : data_() {
719 data_.n.u64 = u;
720 data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
721 }

◆ GenericValue() [7/16]

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

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)))
731 if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
733 }
734 else if (i64 >= static_cast<int64_t>(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
736 }
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition rapidjson.h:289
signed __int64 int64_t
Definition stdint.h:135
unsigned __int64 uint64_t
Definition stdint.h:136

◆ GenericValue() [8/16]

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

Definition at line 739 of file document.h.

739 : data_() {
740 data_.n.u64 = u64;
742 if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)))
744 if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
746 if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
748 }

◆ GenericValue() [9/16]

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

Definition at line 751 of file document.h.

CK_ULONG d

◆ GenericValue() [10/16]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue< Encoding, Allocator >::GenericValue ( float f)
inlineexplicit

Definition at line 754 of file document.h.

754: data_() { data_.n.d = static_cast<double>(f); data_.f.flags = kNumberDoubleFlag; }

◆ GenericValue() [11/16]

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

Definition at line 757 of file document.h.

757: data_() { SetStringRaw(StringRef(s, length)); }
char * s
Here is the call graph for this function:

◆ GenericValue() [12/16]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue< Encoding, Allocator >::GenericValue ( StringRefType s)
inlineexplicit

Definition at line 760 of file document.h.

760: data_() { SetStringRaw(s); }
Here is the call graph for this function:

◆ GenericValue() [13/16]

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

Definition at line 763 of file document.h.

763: data_() { SetStringRaw(StringRef(s, length), allocator); }
Here is the call graph for this function:

◆ GenericValue() [14/16]

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

Definition at line 766 of file document.h.

766: data_() { SetStringRaw(StringRef(s), allocator); }
Here is the call graph for this function:

◆ GenericValue() [15/16]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue< Encoding, Allocator >::GenericValue ( Array a)
inline
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() [16/16]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue< Encoding, Allocator >::GenericValue ( Object o)
inline
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()

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

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 }
Encoding::Ch Ch
Character type derived from Encoding.
Definition document.h:584
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 call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ GetElementsPointer()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
RAPIDJSON_FORCEINLINE GenericValue * GenericValue< Encoding, Allocator >::GetElementsPointer ( ) const
inline

Definition at line 2028 of file document.h.

#define RAPIDJSON_GETPOINTER(type, p)
Definition rapidjson.h:319
GenericValue * elements
Definition document.h:2014
Here is the caller graph for this function:

◆ GetMembersPointer()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
RAPIDJSON_FORCEINLINE Member * GenericValue< Encoding, Allocator >::GetMembersPointer ( ) const
inline

Definition at line 2030 of file document.h.

Here is the caller graph for this function:

◆ GetStringPointer()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
RAPIDJSON_FORCEINLINE const Ch * GenericValue< Encoding, Allocator >::GetStringPointer ( ) const
inline

Definition at line 2026 of file document.h.

Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue & GenericValue< Encoding, Allocator >::operator= ( GenericValue< Encoding, Allocator > & rhs)
inline
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 }
~GenericValue()
Destructor.
Definition document.h:800
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
GenericValue & GenericValue< Encoding, Allocator >::operator= ( StringRefType str)
inline
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 }

◆ RAPIDJSON_DISABLEIF_RETURN()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename T >
GenericValue< Encoding, Allocator >::RAPIDJSON_DISABLEIF_RETURN ( (internal::IsPointer< T >) ,
(GenericValue< Encoding, Allocator > &)  )
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()

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

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

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void GenericValue< Encoding, Allocator >::SetArrayRaw ( GenericValue< Encoding, Allocator > * values,
SizeType count,
Allocator & allocator )
inline

Definition at line 2034 of file document.h.

2034 {
2036 if (count) {
2037 GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
2039 std::memcpy(static_cast<void*>(e), values, count * sizeof(GenericValue));
2040 }
2041 else
2044 }
Here is the call graph for this function:

◆ SetElementsPointer()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
RAPIDJSON_FORCEINLINE GenericValue * GenericValue< Encoding, Allocator >::SetElementsPointer ( GenericValue< Encoding, Allocator > * elements)
inline

Definition at line 2029 of file document.h.

2029{ return RAPIDJSON_SETPOINTER(GenericValue, data_.a.elements, elements); }
#define RAPIDJSON_SETPOINTER(type, p, x)
Definition rapidjson.h:318
Here is the caller graph for this function:

◆ SetMembersPointer()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
RAPIDJSON_FORCEINLINE Member * GenericValue< Encoding, Allocator >::SetMembersPointer ( Member * members)
inline

Definition at line 2031 of file document.h.

2031{ return RAPIDJSON_SETPOINTER(Member, data_.o.members, members); }
Here is the caller graph for this function:

◆ SetObjectRaw()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void GenericValue< Encoding, Allocator >::SetObjectRaw ( Member * members,
SizeType count,
Allocator & allocator )
inline

Definition at line 2047 of file document.h.

2047 {
2049 if (count) {
2050 Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
2052 std::memcpy(static_cast<void*>(m), members, count * sizeof(Member));
2053 }
2054 else
2057 }
Here is the call graph for this function:

◆ SetStringPointer()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
RAPIDJSON_FORCEINLINE const Ch * GenericValue< Encoding, Allocator >::SetStringPointer ( const Ch * str)
inline

Definition at line 2027 of file document.h.

2027{ return RAPIDJSON_SETPOINTER(Ch, data_.s.str, str); }
Here is the caller graph for this function:

◆ SetStringRaw() [1/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void GenericValue< Encoding, Allocator >::SetStringRaw ( StringRefType s)
inline

Definition at line 2060 of file document.h.

2060 {
2063 data_.s.length = s.length;
2064 }
RAPIDJSON_FORCEINLINE const Ch * SetStringPointer(const Ch *str)
Definition document.h:2027
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetStringRaw() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
void GenericValue< Encoding, Allocator >::SetStringRaw ( StringRefType s,
Allocator & allocator )
inline

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 }
return str
Definition CLI11.hpp:1359
static bool Usable(SizeType len)
Definition document.h:1974
Here is the call graph for this function:

◆ StringEqual()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<typename SourceAllocator >
bool GenericValue< Encoding, Allocator >::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 }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:406

Friends And Related Symbol Documentation

◆ GenericDocument

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

Definition at line 1909 of file document.h.

Member Data Documentation

◆ data_

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

Definition at line 2106 of file document.h.

◆ kDefaultArrayCapacity

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

Definition at line 1942 of file document.h.

◆ kDefaultObjectCapacity

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

Definition at line 1943 of file document.h.


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