全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
rapidjson::GenericValue< Encoding, Allocator > 模板类 参考

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

#include <document.h>

类 rapidjson::GenericValue< Encoding, Allocator > 继承关系图:
rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >

Public 类型

typedef GenericMember
< Encoding, Allocator
Member
 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,
Allocator
ValueType
 Value type of itself.
 

Public 成员函数

template<typename Handler >
bool Accept (Handler &handler) const
 Generate events of this value to a Handler. 更多...
 
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
 Set boolean value.
 
GenericValueSetBool (bool b)
 
Object
GenericValueSetObject ()
 Set this value as an empty object. 更多...
 
SizeType MemberCount () const
 Get the number of members in the object.
 
bool ObjectEmpty () const
 Check whether the object is empty.
 
template<typename T >
GenericValueoperator[] (T *name)
 Get a value from an object associated with the name. 更多...
 
template<typename T >
const GenericValueoperator[] (T *name) const
 
template<typename SourceAllocator >
GenericValueoperator[] (const GenericValue< Encoding, SourceAllocator > &name)
 Get a value from an object associated with the name. 更多...
 
template<typename SourceAllocator >
const GenericValueoperator[] (const GenericValue< Encoding, SourceAllocator > &name) const
 
GenericValueoperator[] (const std::basic_string< Ch > &name)
 Get a value from an object associated with name (string object).
 
const GenericValueoperator[] (const std::basic_string< Ch > &name) const
 
ConstMemberIterator MemberBegin () const
 Const member iterator. 更多...
 
ConstMemberIterator MemberEnd () const
 Const past-the-end member iterator. 更多...
 
MemberIterator MemberBegin ()
 Member iterator. 更多...
 
MemberIterator MemberEnd ()
 Past-the-end member iterator 更多...
 
bool HasMember (const Ch *name) const
 Check whether a member exists in the object. 更多...
 
bool HasMember (const std::basic_string< Ch > &name) const
 Check whether a member exists in the object with string object. 更多...
 
template<typename SourceAllocator >
bool HasMember (const GenericValue< Encoding, SourceAllocator > &name) const
 Check whether a member exists in the object with GenericValue name. 更多...
 
MemberIterator FindMember (const Ch *name)
 Find member by name. 更多...
 
ConstMemberIterator FindMember (const Ch *name) const
 
template<typename SourceAllocator >
MemberIterator FindMember (const GenericValue< Encoding, SourceAllocator > &name)
 Find member by name. 更多...
 
template<typename SourceAllocator >
ConstMemberIterator FindMember (const GenericValue< Encoding, SourceAllocator > &name) const
 
MemberIterator FindMember (const std::basic_string< Ch > &name)
 Find member by string object name. 更多...
 
ConstMemberIterator FindMember (const std::basic_string< Ch > &name) const
 
GenericValueAddMember (GenericValue &name, GenericValue &value, Allocator &allocator)
 Add a member (name-value pair) to the object. 更多...
 
GenericValueAddMember (GenericValue &name, StringRefType value, Allocator &allocator)
 Add a constant string value as member (name-value pair) to the object. 更多...
 
GenericValueAddMember (GenericValue &name, std::basic_string< Ch > &value, Allocator &allocator)
 Add a string object as member (name-value pair) to the object. 更多...
 
template<typename T >
GenericValueAddMember (GenericValue &name, T value, Allocator &allocator)
 Add any primitive value as member (name-value pair) to the object. 更多...
 
GenericValueAddMember (StringRefType name, GenericValue &value, Allocator &allocator)
 Add a member (name-value pair) to the object. 更多...
 
GenericValueAddMember (StringRefType name, StringRefType value, Allocator &allocator)
 Add a constant string value as member (name-value pair) to the object. 更多...
 
template<typename T >
GenericValueAddMember (StringRefType name, T value, Allocator &allocator)
 Add any primitive value as member (name-value pair) to the object. 更多...
 
void RemoveAllMembers ()
 Remove all members in the object. 更多...
 
bool RemoveMember (const Ch *name)
 Remove a member in object by its name. 更多...
 
bool RemoveMember (const std::basic_string< Ch > &name)
 
template<typename SourceAllocator >
bool RemoveMember (const GenericValue< Encoding, SourceAllocator > &name)
 
MemberIterator RemoveMember (MemberIterator m)
 Remove a member in object by iterator. 更多...
 
MemberIterator EraseMember (ConstMemberIterator pos)
 Remove a member from an object by iterator. 更多...
 
MemberIterator EraseMember (ConstMemberIterator first, ConstMemberIterator last)
 Remove members in the range [first, last) from an object. 更多...
 
bool EraseMember (const Ch *name)
 Erase a member in object by its name. 更多...
 
bool EraseMember (const std::basic_string< Ch > &name)
 
template<typename SourceAllocator >
bool EraseMember (const GenericValue< Encoding, SourceAllocator > &name)
 
Array
GenericValueSetArray ()
 Set this value as an empty array. 更多...
 
SizeType Size () const
 Get the number of elements in array.
 
SizeType Capacity () const
 Get the capacity of array.
 
bool Empty () const
 Check whether the array is empty.
 
void Clear ()
 Remove all elements in the array. 更多...
 
GenericValueoperator[] (SizeType index)
 Get an element from array by index. 更多...
 
const GenericValueoperator[] (SizeType index) const
 
ValueIterator Begin ()
 Element iterator. 更多...
 
ValueIterator End ()
 Past-the-end element iterator 更多...
 
ConstValueIterator Begin () const
 Constant element iterator. 更多...
 
ConstValueIterator End () const
 Constant past-the-end element iterator. 更多...
 
GenericValueReserve (SizeType newCapacity, Allocator &allocator)
 Request the array to have enough capacity to store elements. 更多...
 
GenericValuePushBack (GenericValue &value, Allocator &allocator)
 Append a GenericValue at the end of the array. 更多...
 
GenericValuePushBack (StringRefType value, Allocator &allocator)
 Append a constant string reference at the end of the array. 更多...
 
template<typename T >
GenericValuePushBack (T value, Allocator &allocator)
 Append a primitive value at the end of the array. 更多...
 
GenericValuePopBack ()
 Remove the last element in the array. 更多...
 
ValueIterator Erase (ConstValueIterator pos)
 Remove an element of array by iterator. 更多...
 
ValueIterator Erase (ConstValueIterator first, ConstValueIterator last)
 Remove elements in the range [first, last) of the array. 更多...
 
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
const ChGetString () const
 
SizeType GetStringLength () const
 Get the length of string. 更多...
 
GenericValueSetString (const Ch *s, SizeType length)
 Set this value as a string without copying source string. 更多...
 
GenericValueSetString (StringRefType s)
 Set this value as a string without copying source string. 更多...
 
GenericValueSetString (const Ch *s, SizeType length, Allocator &allocator)
 Set this value as a string by copying from source string. 更多...
 
GenericValueSetString (const Ch *s, Allocator &allocator)
 Set this value as a string by copying from source string. 更多...
 
GenericValueSetString (const std::basic_string< Ch > &s, Allocator &allocator)
 Set this value as a string by copying from source string. 更多...
 

友元

template<typename , typename >
class GenericValue
 
template<typename , typename , typename >
class GenericDocument
 

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)
 Explicit copy constructor (with allocator) 更多...
 
 GenericValue (bool b) 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 (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 (const std::basic_string< Ch > &s, Allocator &allocator)
 Constructor for copy-string from a string object (i.e. do make a copy of string) 更多...
 
 ~GenericValue ()
 Destructor. 更多...
 

Assignment operators

void swap (GenericValue &a, GenericValue &b) RAPIDJSON_NOEXCEPT
 free-standing swap function helper 更多...
 
GenericValueoperator= (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment with move semantics. 更多...
 
GenericValueoperator= (StringRefType str) RAPIDJSON_NOEXCEPT
 Assignment of constant string reference (no copy) 更多...
 
template<typename T >
GenericValueoperator= (T value)
 Assignment with primitive types. 更多...
 
template<typename SourceAllocator >
GenericValueCopyFrom (const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator)
 Deep-copy assignment from Value. 更多...
 
GenericValueSwap (GenericValue &other) RAPIDJSON_NOEXCEPT
 Exchange the contents of this value with those of other. 更多...
 
GenericValueMove () RAPIDJSON_NOEXCEPT
 Prepare Value for move semantics. 更多...
 

Equal-to and not-equal-to operators

template<typename T >
bool operator== (const T &lhs, const GenericValue &rhs)
 Equal-to operator with arbitrary types (symmetric version) 更多...
 
template<typename T >
bool operator!= (const T &lhs, const GenericValue &rhs)
 Not-Equal-to operator with arbitrary types (symmetric version) 更多...
 
template<typename SourceAllocator >
bool operator== (const GenericValue< Encoding, SourceAllocator > &rhs) const
 Equal-to operator. 更多...
 
bool operator== (const Ch *rhs) const
 Equal-to operator with const C-string pointer.
 
bool operator== (const std::basic_string< Ch > &rhs) const
 Equal-to operator with string object. 更多...
 
template<typename T >
bool operator== (const T &rhs) const
 Equal-to operator with primitive types. 更多...
 
template<typename SourceAllocator >
bool operator!= (const GenericValue< Encoding, SourceAllocator > &rhs) const
 Not-equal-to operator. 更多...
 
bool operator!= (const Ch *rhs) const
 Not-equal-to operator with const C-string pointer.
 
template<typename T >
bool operator!= (const T &rhs) const
 Not-equal-to operator with arbitrary types. 更多...
 

详细描述

template<typename Encoding, typename Allocator>
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

模板参数
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.

构造及析构函数说明

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

Constructor with JSON value type.

This creates a Value of specified type with default content.

参数
typeType of the value.
注解
Default content for number is zero.
template<typename Encoding, typename Allocator>
template<typename SourceAllocator >
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( const GenericValue< Encoding, SourceAllocator > &  rhs,
Allocator allocator 
)
inline

Explicit copy constructor (with allocator)

Creates a copy of a Value by using the given Allocator

模板参数
SourceAllocatorallocator of rhs
参数
rhsValue to copy from (read-only)
allocatorAllocator for allocating copied elements and buffers. Commonly use GenericDocument::GetAllocator().
参见
CopyFrom()
template<typename Encoding, typename Allocator>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( bool  b)
inlineexplicit

Constructor for boolean value.

参数
bBoolean value
注解
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.
template<typename Encoding, typename Allocator>
rapidjson::GenericValue< Encoding, Allocator >::GenericValue ( const std::basic_string< Ch > &  s,
Allocator allocator 
)
inline

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

注解
Requires the definition of the preprocessor symbol RAPIDJSON_HAS_STDSTRING.
template<typename Encoding, typename Allocator>
rapidjson::GenericValue< Encoding, Allocator >::~GenericValue ( )
inline

Destructor.

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

成员函数说明

template<typename Encoding, typename Allocator>
template<typename Handler >
bool 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.

模板参数
Handlertype of handler.
参数
handlerAn object implementing concept Handler.
template<typename Encoding, typename Allocator>
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.

参数
nameA string value as name of member.
valueValue of any type.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
注解
The ownership of name and value will be transferred to this object on success.
前置条件
IsObject() && name.IsString()
后置条件
name.IsNull() && value.IsNull()
注解
Amortized Constant time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( GenericValue< Encoding, Allocator > &  name,
StringRefType  value,
Allocator allocator 
)
inline

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

参数
nameA string value as name of member.
valueconstant string reference as value of member.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
前置条件
IsObject()
注解
This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below.
Amortized Constant time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( GenericValue< Encoding, Allocator > &  name,
std::basic_string< Ch > &  value,
Allocator allocator 
)
inline

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

参数
nameA string value as name of member.
valueconstant string reference as value of member.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
前置条件
IsObject()
注解
This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below.
Amortized Constant time complexity.
template<typename Encoding, typename Allocator>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( GenericValue< Encoding, Allocator > &  name,
value,
Allocator allocator 
)
inline

Add any primitive value as member (name-value pair) to the object.

模板参数
TEither Type, int, unsigned, int64_t, uint64_t
参数
nameA string value as name of member.
valueValue of primitive type T as value of member
allocatorAllocator for reallocating memory. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
前置条件
IsObject()
注解
The source type T explicitly disallows all pointer types, especially (const) Ch*. This helps avoiding implicitly referencing character strings with insufficient lifetime, use AddMember(StringRefType, GenericValue&, Allocator&) or AddMember(StringRefType, StringRefType, Allocator&). All other pointer types would implicitly convert to bool, use an explicit cast instead, if needed.
Amortized Constant time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( StringRefType  name,
GenericValue< Encoding, Allocator > &  value,
Allocator allocator 
)
inline

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

参数
nameA constant string reference as name of member.
valueValue of any type.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
注解
The ownership of value will be transferred to this object on success.
前置条件
IsObject()
后置条件
value.IsNull()
注解
Amortized Constant time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( StringRefType  name,
StringRefType  value,
Allocator allocator 
)
inline

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

参数
nameA constant string reference as name of member.
valueconstant string reference as value of member.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
前置条件
IsObject()
注解
This overload is needed to avoid clashes with the generic primitive type AddMember(StringRefType,T,Allocator&) overload below.
Amortized Constant time complexity.
template<typename Encoding, typename Allocator>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::AddMember ( StringRefType  name,
value,
Allocator allocator 
)
inline

Add any primitive value as member (name-value pair) to the object.

模板参数
TEither Type, int, unsigned, int64_t, uint64_t
参数
nameA constant string reference as name of member.
valueValue of primitive type T as value of member
allocatorAllocator for reallocating memory. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
前置条件
IsObject()
注解
The source type T explicitly disallows all pointer types, especially (const) Ch*. This helps avoiding implicitly referencing character strings with insufficient lifetime, use AddMember(StringRefType, GenericValue&, Allocator&) or AddMember(StringRefType, StringRefType, Allocator&). All other pointer types would implicitly convert to bool, use an explicit cast instead, if needed.
Amortized Constant time complexity.
template<typename Encoding, typename Allocator>
ValueIterator rapidjson::GenericValue< Encoding, Allocator >::Begin ( )
inline

Element iterator.

前置条件
IsArray() == true
template<typename Encoding, typename Allocator>
ConstValueIterator rapidjson::GenericValue< Encoding, Allocator >::Begin ( ) const
inline

Constant element iterator.

前置条件
IsArray() == true
template<typename Encoding, typename Allocator>
void rapidjson::GenericValue< Encoding, Allocator >::Clear ( )
inline

Remove all elements in the array.

This function do not deallocate memory in the array, i.e. the capacity is unchanged.

注解
Linear time complexity.
template<typename Encoding, typename Allocator>
template<typename SourceAllocator >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::CopyFrom ( const GenericValue< Encoding, SourceAllocator > &  rhs,
Allocator allocator 
)
inline

Deep-copy assignment from Value.

Assigns a copy of the Value to the current Value object

模板参数
SourceAllocatorAllocator type of rhs
参数
rhsValue to copy from (read-only)
allocatorAllocator to use for copying
template<typename Encoding, typename Allocator>
ValueIterator rapidjson::GenericValue< Encoding, Allocator >::End ( )
inline

Past-the-end element iterator

前置条件
IsArray() == true
template<typename Encoding, typename Allocator>
ConstValueIterator rapidjson::GenericValue< Encoding, Allocator >::End ( ) const
inline

Constant past-the-end element iterator.

前置条件
IsArray() == true
template<typename Encoding, typename Allocator>
ValueIterator rapidjson::GenericValue< Encoding, Allocator >::Erase ( ConstValueIterator  pos)
inline

Remove an element of array by iterator.

参数
positerator to the element to remove
前置条件
IsArray() == true && Begin() <= pos < End()
返回
Iterator following the removed element. If the iterator pos refers to the last element, the End() iterator is returned.
注解
Linear time complexity.
template<typename Encoding, typename Allocator>
ValueIterator rapidjson::GenericValue< Encoding, Allocator >::Erase ( ConstValueIterator  first,
ConstValueIterator  last 
)
inline

Remove elements in the range [first, last) of the array.

参数
firstiterator to the first element to remove
lastiterator following the last element to remove
前置条件
IsArray() == true && Begin() <= first <= last <= End()
返回
Iterator following the last removed element.
注解
Linear time complexity.
template<typename Encoding, typename Allocator>
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::EraseMember ( ConstMemberIterator  pos)
inline

Remove a member from an object by iterator.

参数
positerator to the member to remove
前置条件
IsObject() == true && MemberBegin() <= pos < MemberEnd()
返回
Iterator following the removed element. If the iterator pos refers to the last element, the MemberEnd() iterator is returned.
注解
This function preserves the relative order of the remaining object members. If you do not need this, use the more efficient RemoveMember(MemberIterator).
Linear time complexity.
template<typename Encoding, typename Allocator>
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::EraseMember ( ConstMemberIterator  first,
ConstMemberIterator  last 
)
inline

Remove members in the range [first, last) from an object.

参数
firstiterator to the first member to remove
lastiterator following the last member to remove
前置条件
IsObject() == true && MemberBegin() <= first <= last <= MemberEnd()
返回
Iterator following the last removed element.
注解
This function preserves the relative order of the remaining object members.
Linear time complexity.
template<typename Encoding, typename Allocator>
bool rapidjson::GenericValue< Encoding, Allocator >::EraseMember ( const Ch name)
inline

Erase a member in object by its name.

参数
nameName of member to be removed.
返回
Whether the member existed.
注解
Linear time complexity.
template<typename Encoding, typename Allocator>
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::FindMember ( const Ch name)
inline

Find member by name.

参数
nameMember name to be searched.
前置条件
IsObject() == true
返回
Iterator to member, if it exists. Otherwise returns MemberEnd().
注解
Earlier versions of Rapidjson returned a NULL pointer, in case the requested member doesn't exist. For consistency with e.g. std::map, this has been changed to MemberEnd() now.
Linear time complexity.
template<typename Encoding, typename Allocator>
template<typename SourceAllocator >
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::FindMember ( const GenericValue< Encoding, SourceAllocator > &  name)
inline

Find member by name.

This version is faster because it does not need a StrLen(). It can also handle string with null character.

参数
nameMember name to be searched.
前置条件
IsObject() == true
返回
Iterator to member, if it exists. Otherwise returns MemberEnd().
注解
Earlier versions of Rapidjson returned a NULL pointer, in case the requested member doesn't exist. For consistency with e.g. std::map, this has been changed to MemberEnd() now.
Linear time complexity.
template<typename Encoding, typename Allocator>
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::FindMember ( const std::basic_string< Ch > &  name)
inline

Find member by string object name.

参数
nameMember name to be searched.
前置条件
IsObject() == true
返回
Iterator to member, if it exists. Otherwise returns MemberEnd().
template<typename Encoding, typename Allocator>
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().

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

Check whether a member exists in the object.

参数
nameMember name to be searched.
前置条件
IsObject() == true
返回
Whether a member with that name exists.
注解
It is better to use FindMember() directly if you need the obtain the value as well.
Linear time complexity.
template<typename Encoding, typename Allocator>
bool rapidjson::GenericValue< Encoding, Allocator >::HasMember ( const std::basic_string< Ch > &  name) const
inline

Check whether a member exists in the object with string object.

参数
nameMember name to be searched.
前置条件
IsObject() == true
返回
Whether a member with that name exists.
注解
It is better to use FindMember() directly if you need the obtain the value as well.
Linear time complexity.
template<typename Encoding, typename Allocator>
template<typename SourceAllocator >
bool rapidjson::GenericValue< Encoding, Allocator >::HasMember ( const GenericValue< Encoding, SourceAllocator > &  name) const
inline

Check whether a member exists in the object with GenericValue name.

This version is faster because it does not need a StrLen(). It can also handle string with null character.

参数
nameMember name to be searched.
前置条件
IsObject() == true
返回
Whether a member with that name exists.
注解
It is better to use FindMember() directly if you need the obtain the value as well.
Linear time complexity.
template<typename Encoding, typename Allocator>
ConstMemberIterator rapidjson::GenericValue< Encoding, Allocator >::MemberBegin ( ) const
inline

Const member iterator.

前置条件
IsObject() == true
template<typename Encoding, typename Allocator>
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::MemberBegin ( )
inline

Member iterator.

前置条件
IsObject() == true
template<typename Encoding, typename Allocator>
ConstMemberIterator rapidjson::GenericValue< Encoding, Allocator >::MemberEnd ( ) const
inline

Const past-the-end member iterator.

前置条件
IsObject() == true
template<typename Encoding, typename Allocator>
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::MemberEnd ( )
inline

Past-the-end member iterator

前置条件
IsObject() == true
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::Move ( )
inline

Prepare Value for move semantics.

返回
*this
template<typename Encoding, typename Allocator>
template<typename SourceAllocator >
bool rapidjson::GenericValue< Encoding, Allocator >::operator!= ( const GenericValue< Encoding, SourceAllocator > &  rhs) const
inline

Not-equal-to operator.

返回
!(*this == rhs)
template<typename Encoding, typename Allocator>
template<typename T >
bool rapidjson::GenericValue< Encoding, Allocator >::operator!= ( const T &  rhs) const
inline

Not-equal-to operator with arbitrary types.

返回
!(*this == rhs)
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator= ( GenericValue< Encoding, Allocator > &  rhs)
inline

Assignment with move semantics.

参数
rhsSource of the assignment. It will become a null value after assignment.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator= ( StringRefType  str)
inline

Assignment of constant string reference (no copy)

参数
strConstant string reference to be assigned
注解
This overload is needed to avoid clashes with the generic primitive type assignment overload below.
参见
GenericStringRef, operator=(T)
template<typename Encoding, typename Allocator>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator= ( value)
inline

Assignment with primitive types.

模板参数
TEither Type, int, unsigned, int64_t, uint64_t
参数
valueThe value to be assigned.
注解
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.
template<typename Encoding, typename Allocator>
template<typename SourceAllocator >
bool rapidjson::GenericValue< Encoding, Allocator >::operator== ( const GenericValue< Encoding, SourceAllocator > &  rhs) const
inline

Equal-to operator.

注解
If an object contains duplicated named member, comparing equality with any object is always false.
Linear time complexity (number of all values in the subtree and total lengths of all strings).
template<typename Encoding, typename Allocator>
bool rapidjson::GenericValue< Encoding, Allocator >::operator== ( const std::basic_string< Ch > &  rhs) const
inline

Equal-to operator with string object.

注解
Requires the definition of the preprocessor symbol RAPIDJSON_HAS_STDSTRING.
template<typename Encoding, typename Allocator>
template<typename T >
bool rapidjson::GenericValue< Encoding, Allocator >::operator== ( const T &  rhs) const
inline

Equal-to operator with primitive types.

模板参数
TEither Type, int, unsigned, int64_t, uint64_t, double, true, false
template<typename Encoding, typename Allocator>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator[] ( T *  name)
inline

Get a value from an object associated with the name.

前置条件
IsObject() == true
模板参数
TEither Ch or const Ch (template used for disambiguation with operator[](SizeType))
注解
In version 0.1x, if the member is not found, this function returns a null value. This makes issue 7. Since 0.2, if the name is not correct, it will assert. If user is unsure whether a member exists, user should use HasMember() first. A better approach is to use FindMember().
Linear time complexity.
template<typename Encoding, typename Allocator>
template<typename SourceAllocator >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator[] ( const GenericValue< Encoding, SourceAllocator > &  name)
inline

Get a value from an object associated with the name.

前置条件
IsObject() == true
模板参数
SourceAllocatorAllocator of the name value
注解
Compared to operator[](T*), this version is faster because it does not need a StrLen(). And it can also handle strings with embedded null characters.
Linear time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::operator[] ( SizeType  index)
inline

Get an element from array by index.

前置条件
IsArray() == true
参数
indexZero-based index of element.
参见
operator[](T*)
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::PopBack ( )
inline

Remove the last element in the array.

注解
Constant time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::PushBack ( GenericValue< Encoding, Allocator > &  value,
Allocator allocator 
)
inline

Append a GenericValue at the end of the array.

参数
valueValue to be appended.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
前置条件
IsArray() == true
后置条件
value.IsNull() == true
返回
The value itself for fluent API.
注解
The ownership of value will be transferred to this array on success.
If the number of elements to be appended is known, calls Reserve() once first may be more efficient.
Amortized constant time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::PushBack ( StringRefType  value,
Allocator allocator 
)
inline

Append a constant string reference at the end of the array.

参数
valueConstant string reference to be appended.
allocatorAllocator for reallocating memory. It must be the same one used previously. Commonly use GenericDocument::GetAllocator().
前置条件
IsArray() == true
返回
The value itself for fluent API.
注解
If the number of elements to be appended is known, calls Reserve() once first may be more efficient.
Amortized constant time complexity.
参见
GenericStringRef
template<typename Encoding, typename Allocator>
template<typename T >
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::PushBack ( value,
Allocator allocator 
)
inline

Append a primitive value at the end of the array.

模板参数
TEither Type, int, unsigned, int64_t, uint64_t
参数
valueValue of primitive type T to be appended.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
前置条件
IsArray() == true
返回
The value itself for fluent API.
注解
If the number of elements to be appended is known, calls Reserve() once first may be more efficient.
The source type T explicitly disallows all pointer types, especially (const) Ch*. This helps avoiding implicitly referencing character strings with insufficient lifetime, use PushBack(GenericValue&, Allocator&) or PushBack(StringRefType, Allocator&). All other pointer types would implicitly convert to bool, use an explicit cast instead, if needed.
Amortized constant time complexity.
template<typename Encoding, typename Allocator>
void rapidjson::GenericValue< Encoding, Allocator >::RemoveAllMembers ( )
inline

Remove all members in the object.

This function do not deallocate memory in the object, i.e. the capacity is unchanged.

注解
Linear time complexity.
template<typename Encoding, typename Allocator>
bool rapidjson::GenericValue< Encoding, Allocator >::RemoveMember ( const Ch name)
inline

Remove a member in object by its name.

参数
nameName of member to be removed.
返回
Whether the member existed.
注解
This function may reorder the object members. Use EraseMember(ConstMemberIterator) if you need to preserve the relative order of the remaining members.
Linear time complexity.
template<typename Encoding, typename Allocator>
MemberIterator rapidjson::GenericValue< Encoding, Allocator >::RemoveMember ( MemberIterator  m)
inline

Remove a member in object by iterator.

参数
mmember iterator (obtained by FindMember() or MemberBegin()).
返回
the new iterator after removal.
注解
This function may reorder the object members. Use EraseMember(ConstMemberIterator) if you need to preserve the relative order of the remaining members.
Constant time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::Reserve ( SizeType  newCapacity,
Allocator allocator 
)
inline

Request the array to have enough capacity to store elements.

参数
newCapacityThe capacity that the array at least need to have.
allocatorAllocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
注解
Linear time complexity.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetArray ( )
inline

Set this value as an empty array.

后置条件
IsArray == true
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetBool ( bool  b)
inline
后置条件
IsBool() == true
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetObject ( )
inline

Set this value as an empty object.

后置条件
IsObject() == true
template<typename Encoding, typename Allocator>
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.

参数
ssource string pointer.
lengthThe length of source string, excluding the trailing null terminator.
返回
The value itself for fluent API.
后置条件
IsString() == true && GetString() == s && GetStringLength() == length
参见
SetString(StringRefType)
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetString ( StringRefType  s)
inline

Set this value as a string without copying source string.

参数
ssource string reference
返回
The value itself for fluent API.
后置条件
IsString() == true && GetString() == s && GetStringLength() == s.length
template<typename Encoding, typename Allocator>
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.

参数
ssource string.
lengthThe length of source string, excluding the trailing null terminator.
allocatorAllocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
后置条件
IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetString ( const Ch s,
Allocator allocator 
)
inline

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

参数
ssource string.
allocatorAllocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
后置条件
IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::SetString ( const std::basic_string< Ch > &  s,
Allocator allocator 
)
inline

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

参数
ssource string.
allocatorAllocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator().
返回
The value itself for fluent API.
后置条件
IsString() == true && GetString() != s.data() && strcmp(GetString(),s.data() == 0 && GetStringLength() == s.size()
注解
Requires the definition of the preprocessor symbol RAPIDJSON_HAS_STDSTRING.
template<typename Encoding, typename Allocator>
GenericValue& rapidjson::GenericValue< Encoding, Allocator >::Swap ( GenericValue< Encoding, Allocator > &  other)
inline

Exchange the contents of this value with those of other.

参数
otherAnother value.
注解
Constant complexity.

友元及相关函数文档

template<typename Encoding, typename Allocator>
template<typename T >
bool operator!= ( const T &  lhs,
const GenericValue< Encoding, Allocator > &  rhs 
)
friend

Not-Equal-to operator with arbitrary types (symmetric version)

返回
!(rhs == lhs)
template<typename Encoding, typename Allocator>
template<typename T >
bool operator== ( const T &  lhs,
const GenericValue< Encoding, Allocator > &  rhs 
)
friend

Equal-to operator with arbitrary types (symmetric version)

返回
(rhs == lhs)
template<typename Encoding, typename Allocator>
void swap ( GenericValue< Encoding, Allocator > &  a,
GenericValue< Encoding, Allocator > &  b 
)
friend

free-standing swap function helper

Helper function to enable support for common swap implementation pattern based on std::swap:

void swap(MyClass& a, MyClass& b) {
using std::swap;
swap(a.value, b.value);
// ...
}
参见
Swap()

该类的文档由以下文件生成: