rapidjson::GenericDocument< Encoding, Allocator > Class Template Reference

A document for parsing JSON text as DOM. More...

#include <document.h>

Inheritance diagram for rapidjson::GenericDocument< Encoding, Allocator >:
rapidjson::GenericValue< Encoding, Allocator >

Public Types

typedef Encoding::Ch Ch
 Character type derived from Encoding.
 
typedef GenericValue< Encoding, AllocatorValueType
 Value type of the document.
 
typedef Allocator AllocatorType
 Allocator type from template parameter.
 
- Public Types inherited from rapidjson::GenericValue< Encoding, Allocator >
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.
 

Public Member Functions

 GenericDocument (Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity)
 Constructor. More...
 
AllocatorGetAllocator ()
 Get the allocator of this document.
 
size_t GetStackCapacity () const
 Get the capacity of stack in bytes.
 
Parse from stream
template<unsigned parseFlags, typename SourceEncoding , typename InputStream >
GenericDocumentParseStream (InputStream &is)
 Parse JSON text from an input stream (with Encoding conversion) More...
 
template<unsigned parseFlags, typename InputStream >
GenericDocumentParseStream (InputStream &is)
 Parse JSON text from an input stream. More...
 
template<typename InputStream >
GenericDocumentParseStream (InputStream &is)
 Parse JSON text from an input stream (with kParseDefaultFlags) More...
 
Parse in-place from mutable string
template<unsigned parseFlags, typename SourceEncoding >
GenericDocumentParseInsitu (Ch *str)
 Parse JSON text from a mutable string (with Encoding conversion) More...
 
template<unsigned parseFlags>
GenericDocumentParseInsitu (Ch *str)
 Parse JSON text from a mutable string. More...
 
GenericDocumentParseInsitu (Ch *str)
 Parse JSON text from a mutable string (with kParseDefaultFlags) More...
 
Parse from read-only string
template<unsigned parseFlags, typename SourceEncoding >
GenericDocumentParse (const Ch *str)
 Parse JSON text from a read-only string (with Encoding conversion) More...
 
template<unsigned parseFlags>
GenericDocumentParse (const Ch *str)
 Parse JSON text from a read-only string. More...
 
GenericDocumentParse (const Ch *str)
 Parse JSON text from a read-only string (with kParseDefaultFlags) More...
 
Handling parse errors
bool HasParseError () const
 Whether a parse error has occured in the last parsing.
 
ParseErrorCode GetParseError () const
 Get the ParseErrorCode of last parsing.
 
size_t GetErrorOffset () const
 Get the position of last parsing error in input, 0 otherwise.
 
- Public Member Functions inherited from rapidjson::GenericValue< Encoding, Allocator >
template<typename Handler >
bool Accept (Handler &handler) const
 Generate events of this value to a Handler. More...
 
GenericValueoperator= (GenericValue &rhs)
 Assignment with move semantics. More...
 
GenericValueoperator= (StringRefType str)
 Assignment of constant string reference (no copy) More...
 
template<typename T >
GenericValueoperator= (T value)
 Assignment with primitive types. More...
 
template<typename SourceAllocator >
GenericValueCopyFrom (const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator)
 Deep-copy assignment from Value. More...
 
GenericValueSwap (GenericValue &other)
 Exchange the contents of this value with those of other. More...
 
GenericValueMove ()
 Prepare Value for move semantics. More...
 
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
 
GenericValueSetNull ()
 
bool GetBool () const
 Set boolean value.
 
GenericValueSetBool (bool b)
 
GenericValueSetObject ()
 Set this value as an empty object. More...
 
GenericValueoperator[] (const Ch *name)
 Get the value associated with the name. More...
 
const GenericValueoperator[] (const Ch *name) const
 
GenericValueoperator[] (const GenericValue &name)
 
const GenericValueoperator[] (const GenericValue &name) const
 
ConstMemberIterator MemberBegin () const
 Const member iterator. More...
 
ConstMemberIterator MemberEnd () const
 Const past-the-end member iterator. More...
 
MemberIterator MemberBegin ()
 Member iterator. More...
 
MemberIterator MemberEnd ()
 Past-the-end member iterator More...
 
bool HasMember (const Ch *name) const
 Check whether a member exists in the object. More...
 
bool HasMember (const GenericValue &name) const
 
MemberIterator FindMember (const Ch *name)
 Find member by name. More...
 
ConstMemberIterator FindMember (const Ch *name) const
 
MemberIterator FindMember (const GenericValue &name)
 
ConstMemberIterator FindMember (const GenericValue &name) const
 
GenericValueAddMember (GenericValue &name, GenericValue &value, Allocator &allocator)
 Add a member (name-value pair) to the object. More...
 
GenericValueAddMember (StringRefType name, GenericValue &value, Allocator &allocator)
 Add a member (name-value pair) to the object. More...
 
GenericValueAddMember (StringRefType name, StringRefType value, Allocator &allocator)
 Add a constant string value as member (name-value pair) to the object. More...
 
template<typename T >
GenericValueAddMember (StringRefType name, T value, Allocator &allocator)
 Add any primitive value as member (name-value pair) to the object. More...
 
bool RemoveMember (const Ch *name)
 Remove a member in object by its name. More...
 
bool RemoveMember (const GenericValue &name)
 
MemberIterator RemoveMember (MemberIterator m)
 Remove a member in object by iterator. More...
 
GenericValueSetArray ()
 Set this value as an empty array. More...
 
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. More...
 
GenericValueoperator[] (SizeType index)
 Get an element from array by index. More...
 
const GenericValueoperator[] (SizeType index) const
 
ValueIterator Begin ()
 Element iterator.
 
ValueIterator End ()
 
ConstValueIterator Begin () const
 
ConstValueIterator End () const
 
GenericValueReserve (SizeType newCapacity, Allocator &allocator)
 Request the array to have enough capacity to store elements. More...
 
GenericValuePushBack (GenericValue &value, Allocator &allocator)
 Append a GenericValue at the end of the array. More...
 
GenericValuePushBack (StringRefType value, Allocator &allocator)
 Append a constant string reference at the end of the array. More...
 
template<typename T >
GenericValuePushBack (T value, Allocator &allocator)
 Append a primitive value at the end of the array(.) More...
 
GenericValuePopBack ()
 Remove the last element in the array.
 
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)
 
const ChGetString () const
 
SizeType GetStringLength () const
 Get the length of string. More...
 
GenericValueSetString (const Ch *s, SizeType length)
 Set this value as a string without copying source string. More...
 
GenericValueSetString (StringRefType s)
 Set this value as a string without copying source string. More...
 
GenericValueSetString (const Ch *s, SizeType length, Allocator &allocator)
 Set this value as a string by copying from source string. More...
 
GenericValueSetString (const Ch *s, Allocator &allocator)
 Set this value as a string by copying from source string. More...
 
 GenericValue ()
 Default constructor creates a null value.
 
 GenericValue (Type type)
 Constructor with JSON value type. More...
 
template<typename SourceAllocator >
 GenericValue (const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator)
 Explicit copy constructor (with allocator) More...
 
 GenericValue (bool b)
 Constructor for boolean value. More...
 
 GenericValue (int i)
 Constructor for int value.
 
 GenericValue (unsigned u)
 Constructor for unsigned value.
 
 GenericValue (int64_t i64)
 Constructor for int64_t value.
 
 GenericValue (uint64_t u64)
 Constructor for uint64_t value.
 
 GenericValue (double d)
 Constructor for double value.
 
 GenericValue (const Ch *s, SizeType length)
 Constructor for constant string (i.e. do not make a copy of string)
 
 GenericValue (StringRefType s)
 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 ()
 Destructor. More...
 

Friends

template<typename , typename , typename >
class GenericReader
 
class GenericValue< Encoding, Allocator >
 

Detailed Description

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
class rapidjson::GenericDocument< Encoding, Allocator >

A document for parsing JSON text as DOM.

Note
implements Handler concept
Template Parameters
Encodingencoding for both parsing and string storage.
Allocatorallocator for allocating memory for the DOM, and the stack during parsing.
Warning
Although GenericDocument inherits from GenericValue, the API does not provide any virtual functions, especially no virtual destructors. To avoid memory leaks, do not delete a GenericDocument object via a pointer to a GenericValue.

Constructor & Destructor Documentation

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
rapidjson::GenericDocument< Encoding, Allocator >::GenericDocument ( Allocator allocator = 0,
size_t  stackCapacity = kDefaultStackCapacity 
)
inline

Constructor.

Parameters
allocatorOptional allocator for allocating stack memory.
stackCapacityInitial capacity of stack in bytes.

Member Function Documentation

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags, typename SourceEncoding >
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::Parse ( const Ch str)
inline

Parse JSON text from a read-only string (with Encoding conversion)

Template Parameters
parseFlagsCombination of ParseFlag (must not contain kParseInsituFlag).
SourceEncodingTranscoding from input Encoding
Parameters
strRead-only zero-terminated string to be parsed.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags>
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::Parse ( const Ch str)
inline

Parse JSON text from a read-only string.

Template Parameters
parseFlagsCombination of ParseFlag (must not contain kParseInsituFlag).
Parameters
strRead-only zero-terminated string to be parsed.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::Parse ( const Ch str)
inline

Parse JSON text from a read-only string (with kParseDefaultFlags)

Parameters
strRead-only zero-terminated string to be parsed.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags, typename SourceEncoding >
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::ParseInsitu ( Ch str)
inline

Parse JSON text from a mutable string (with Encoding conversion)

Template Parameters
parseFlagsCombination of ParseFlag.
SourceEncodingTranscoding from input Encoding
Parameters
strMutable zero-terminated string to be parsed.
Returns
The document itself for fluent API.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags>
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::ParseInsitu ( Ch str)
inline

Parse JSON text from a mutable string.

Template Parameters
parseFlagsCombination of ParseFlag.
Parameters
strMutable zero-terminated string to be parsed.
Returns
The document itself for fluent API.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::ParseInsitu ( Ch str)
inline

Parse JSON text from a mutable string (with kParseDefaultFlags)

Parameters
strMutable zero-terminated string to be parsed.
Returns
The document itself for fluent API.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags, typename SourceEncoding , typename InputStream >
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::ParseStream ( InputStream &  is)
inline

Parse JSON text from an input stream (with Encoding conversion)

Template Parameters
parseFlagsCombination of ParseFlag.
SourceEncodingEncoding of input stream
InputStreamType of input stream, implementing Stream concept
Parameters
isInput stream to be parsed.
Returns
The document itself for fluent API.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags, typename InputStream >
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::ParseStream ( InputStream &  is)
inline

Parse JSON text from an input stream.

Template Parameters
parseFlagsCombination of ParseFlag.
InputStreamType of input stream, implementing Stream concept
Parameters
isInput stream to be parsed.
Returns
The document itself for fluent API.
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
template<typename InputStream >
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator >::ParseStream ( InputStream &  is)
inline

Parse JSON text from an input stream (with kParseDefaultFlags)

Template Parameters
InputStreamType of input stream, implementing Stream concept
Parameters
isInput stream to be parsed.
Returns
The document itself for fluent API.

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