Electroneum
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>

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

Classes

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

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 >

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 575 of file document.h.

Member Typedef Documentation

◆ AllocatorType

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

Allocator type from template parameter.

Definition at line 580 of file document.h.

◆ Array

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

Definition at line 588 of file document.h.

◆ Ch

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

Character type derived from Encoding.

Definition at line 581 of file document.h.

◆ ConstArray

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

Definition at line 589 of file document.h.

◆ ConstMemberIterator

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

Constant member iterator for iterating in object.

Definition at line 584 of file document.h.

◆ ConstObject

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

Definition at line 591 of file document.h.

◆ ConstValueIterator

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

Constant value iterator for iterating in array.

Definition at line 586 of file document.h.

◆ EncodingType

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

Encoding type from template parameter.

Definition at line 579 of file document.h.

◆ Member

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

Name-value pair in an object.

Definition at line 578 of file document.h.

◆ MemberIterator

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

Member iterator for iterating in object.

Definition at line 583 of file document.h.

◆ Object

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

Definition at line 590 of file document.h.

◆ StringRefType

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

Reference to a constant string.

Definition at line 582 of file document.h.

◆ ValueIterator

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

Value iterator for iterating in array.

Definition at line 585 of file document.h.

◆ ValueType

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

Value type of itself.

Definition at line 587 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 1907 of file document.h.

1907 {
1908 kBoolFlag = 0x0008,
1909 kNumberFlag = 0x0010,
1910 kIntFlag = 0x0020,
1911 kUintFlag = 0x0040,
1912 kInt64Flag = 0x0080,
1913 kUint64Flag = 0x0100,
1914 kDoubleFlag = 0x0200,
1915 kStringFlag = 0x0400,
1916 kCopyFlag = 0x0800,
1917 kInlineStrFlag = 0x1000,
1918
1919 // Initial flags of different types.
1934
1935 kTypeMask = 0x07
1936 };
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition document.h:575

Constructor & Destructor Documentation

◆ GenericValue() [1/16]

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

Default constructor creates a null value.

Definition at line 597 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

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 627 of file document.h.

627 : data_() {
628 static const uint16_t defaultFlags[7] = {
631 };
633 data_.f.flags = defaultFlags[type];
634
635 // Use ShortString to store empty string.
636 if (type == kStringType)
637 data_.ss.SetLength(0);
638 }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:411

◆ 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

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 649 of file document.h.

649 {
650 switch (rhs.GetType()) {
651 case kObjectType: {
653 Member* lm = reinterpret_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
655 for (SizeType i = 0; i < count; i++) {
658 }
659 data_.f.flags = kObjectFlag;
660 data_.o.size = data_.o.capacity = count;
662 }
663 break;
664 case kArrayType: {
666 GenericValue* le = reinterpret_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
668 for (SizeType i = 0; i < count; i++)
670 data_.f.flags = kArrayFlag;
671 data_.a.size = data_.a.capacity = count;
673 }
674 break;
675 case kStringType:
677 data_.f.flags = rhs.data_.f.flags;
678 data_ = *reinterpret_cast<const Data*>(&rhs.data_);
679 }
680 else
681 SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
682 break;
683 default:
684 data_.f.flags = rhs.data_.f.flags;
685 data_ = *reinterpret_cast<const Data*>(&rhs.data_);
686 break;
687 }
688 }
void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT
Definition document.h:2066
RAPIDJSON_FORCEINLINE GenericValue * SetElementsPointer(GenericValue *elements)
Definition document.h:2025
RAPIDJSON_FORCEINLINE GenericValue * GetElementsPointer() const
Definition document.h:2024
RAPIDJSON_FORCEINLINE Member * SetMembersPointer(Member *members)
Definition document.h:2027
GenericMember< Encoding, Allocator > Member
Definition document.h:578
RAPIDJSON_FORCEINLINE Member * GetMembersPointer() const
Definition document.h:2026
GenericValue() RAPIDJSON_NOEXCEPT
Definition document.h:597
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
Definition document.h:361

◆ 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

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 698 of file document.h.

702 : data_() {
703 // safe-guard against failing SFINAE
705 data_.f.flags = b ? kTrueFlag : kFalseFlag;
706 }
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition rapidjson.h:450

◆ GenericValue() [5/16]

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

Constructor for int value.

Definition at line 709 of file document.h.

709 : data_() {
710 data_.n.i64 = i;
711 data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;
712 }

◆ GenericValue() [6/16]

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

Constructor for unsigned value.

Definition at line 715 of file document.h.

715 : data_() {
716 data_.n.u64 = u;
717 data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);
718 }

◆ GenericValue() [7/16]

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

Constructor for int64_t value.

Definition at line 721 of file document.h.

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

◆ GenericValue() [8/16]

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

Constructor for uint64_t value.

Definition at line 736 of file document.h.

736 : data_() {
737 data_.n.u64 = u64;
738 data_.f.flags = kNumberUint64Flag;
739 if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)))
740 data_.f.flags |= kInt64Flag;
741 if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))
742 data_.f.flags |= kUintFlag;
743 if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))
744 data_.f.flags |= kIntFlag;
745 }

◆ GenericValue() [9/16]

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

Constructor for double value.

Definition at line 748 of file document.h.

748: data_() { data_.n.d = d; data_.f.flags = kNumberDoubleFlag; }

◆ GenericValue() [10/16]

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

Constructor for float value.

Definition at line 751 of file document.h.

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

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

Definition at line 754 of file document.h.

◆ GenericValue() [12/16]

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

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

Definition at line 757 of file document.h.

757: data_() { SetStringRaw(s); }

◆ GenericValue() [13/16]

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

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

Definition at line 760 of file document.h.

◆ GenericValue() [14/16]

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

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

Definition at line 763 of file document.h.

◆ GenericValue() [15/16]

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

778 : data_(a.value_.data_) {
779 a.value_.data_ = Data();
780 a.value_.data_.f.flags = kArrayFlag;
781 }

◆ GenericValue() [16/16]

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

789 : data_(o.value_.data_) {
790 o.value_.data_ = Data();
791 o.value_.data_.f.flags = kObjectFlag;
792 }

◆ ~GenericValue()

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

Destructor.

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

Definition at line 797 of file document.h.

797 {
798 if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
799 switch(data_.f.flags) {
800 case kArrayFlag:
801 {
803 for (GenericValue* v = e; v != e + data_.a.size; ++v)
804 v->~GenericValue();
806 }
807 break;
808
809 case kObjectFlag:
810 for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
811 m->~Member();
813 break;
814
815 case kCopyStringFlag:
816 Allocator::Free(const_cast<Ch*>(GetStringPointer()));
817 break;
818
819 default:
820 break; // Do nothing for other types.
821 }
822 }
823 }
~GenericValue()
Destructor.
Definition document.h:797
GenericMemberIterator< false, Encoding, Allocator >::Iterator MemberIterator
Definition document.h:583
RAPIDJSON_FORCEINLINE const Ch * GetStringPointer() const
Definition document.h:2022
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 2024 of file document.h.

2024{ return RAPIDJSON_GETPOINTER(GenericValue, data_.a.elements); }
#define RAPIDJSON_GETPOINTER(type, p)
Definition rapidjson.h:324
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 2026 of file document.h.

2026{ return RAPIDJSON_GETPOINTER(Member, data_.o.members); }
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 2022 of file document.h.

2022{ return RAPIDJSON_GETPOINTER(Ch, data_.s.str); }
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

Assignment with move semantics.

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

Definition at line 833 of file document.h.

833 {
834 RAPIDJSON_ASSERT(this != &rhs);
835 this->~GenericValue();
836 RawAssign(rhs);
837 return *this;
838 }
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Definition document.h:2090

◆ operator=() [2/2]

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

852 {
854 return *this = s;
855 }

◆ RAPIDJSON_DISABLEIF_RETURN()

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

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

Assignment without calling destructor.

Definition at line 2090 of file document.h.

2090 {
2091 data_ = rhs.data_;
2092 // data_.f.flags = rhs.data_.f.flags;
2094 }
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 2030 of file document.h.

2030 {
2031 data_.f.flags = kArrayFlag;
2032 if (count) {
2033 GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
2036#if defined(__GNUC__) && __GNUC__ >= 8
2037RAPIDJSON_DIAG_OFF(class-memaccess) // ignore complains from gcc that no trivial copy constructor exists.
2038#endif
2039 std::memcpy(e, values, count * sizeof(GenericValue));
2041 }
2042 else
2044 data_.a.size = data_.a.capacity = count;
2045 }

◆ SetElementsPointer()

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

Definition at line 2025 of file document.h.

2025{ return RAPIDJSON_SETPOINTER(GenericValue, data_.a.elements, elements); }
#define RAPIDJSON_SETPOINTER(type, p, x)
Definition rapidjson.h:323
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 2027 of file document.h.

2027{ 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

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

Definition at line 2048 of file document.h.

2048 {
2049 data_.f.flags = kObjectFlag;
2050 if (count) {
2051 Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
2054#if defined(__GNUC__) && __GNUC__ >= 8
2055RAPIDJSON_DIAG_OFF(class-memaccess) // ignore complains from gcc that no trivial copy constructor exists.
2056#endif
2057 std::memcpy(m, members, count * sizeof(Member));
2059 }
2060 else
2062 data_.o.size = data_.o.capacity = count;
2063 }

◆ SetStringPointer()

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

Definition at line 2023 of file document.h.

2023{ 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

Initialize this value as constant string, without calling destructor.

Definition at line 2066 of file document.h.

2066 {
2067 data_.f.flags = kConstStringFlag;
2069 data_.s.length = s.length;
2070 }
RAPIDJSON_FORCEINLINE const Ch * SetStringPointer(const Ch *str)
Definition document.h:2023
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

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

Definition at line 2073 of file document.h.

2073 {
2074 Ch* str = 0;
2075 if (ShortString::Usable(s.length)) {
2076 data_.f.flags = kShortStringFlag;
2077 data_.ss.SetLength(s.length);
2078 str = data_.ss.str;
2079 } else {
2080 data_.f.flags = kCopyStringFlag;
2081 data_.s.length = s.length;
2082 str = static_cast<Ch *>(allocator.Malloc((s.length + 1) * sizeof(Ch)));
2084 }
2085 std::memcpy(str, s, s.length * sizeof(Ch));
2086 str[s.length] = '\0';
2087 }

◆ 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 2097 of file document.h.

2097 {
2099 RAPIDJSON_ASSERT(rhs.IsString());
2100
2101 const SizeType len1 = GetStringLength();
2102 const SizeType len2 = rhs.GetStringLength();
2103 if(len1 != len2) { return false; }
2104
2105 const Ch* const str1 = GetString();
2106 const Ch* const str2 = rhs.GetString();
2107 if(str1 == str2) { return true; } // fast path for constant string
2108
2109 return (std::memcmp(str1, str2, sizeof(Ch) * len1) == 0);
2110 }

◆ GenericDocument

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

Definition at line 1905 of file document.h.

Member Data Documentation

◆ data_

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

Definition at line 2112 of file document.h.

◆ kDefaultArrayCapacity

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

Definition at line 1938 of file document.h.

◆ kDefaultObjectCapacity

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

Definition at line 1939 of file document.h.


The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/external/rapidjson/include/rapidjson/document.h