|
A document for parsing JSON text as DOM. More...
#include <document.h>
Public Types | |
typedef Encoding::Ch | Ch |
Character type derived from Encoding. More... | |
typedef GenericValue< Encoding, Allocator > | ValueType |
Value type of the document. More... | |
typedef Allocator | AllocatorType |
Allocator type from template parameter. More... | |
Public Types inherited from rapidjson::GenericValue< Encoding, MemoryPoolAllocator<> > | |
typedef Encoding | EncodingType |
Encoding type from template parameter. More... | |
typedef MemoryPoolAllocator<> | AllocatorType |
Allocator type from template parameter. More... | |
typedef Encoding::Ch | Ch |
Character type derived from Encoding. More... | |
typedef Member * | MemberIterator |
Member iterator for iterating in object. More... | |
typedef const Member * | ConstMemberIterator |
Constant member iterator for iterating in object. More... | |
typedef GenericValue * | ValueIterator |
Value iterator for iterating in array. More... | |
typedef const GenericValue * | ConstValueIterator |
Constant value iterator for iterating in array. More... | |
Public Member Functions | |
GenericDocument (Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity) | |
Constructor. More... | |
template<unsigned parseFlags, typename Stream > | |
GenericDocument & | ParseStream (Stream &stream) |
Parse JSON text from an input stream. More... | |
template<unsigned parseFlags> | |
GenericDocument & | ParseInsitu (Ch *str) |
Parse JSON text from a mutable string. More... | |
template<unsigned parseFlags> | |
GenericDocument & | Parse (const Ch *str) |
Parse JSON text from a read-only string. More... | |
bool | HasParseError () const |
Whether a parse error was occured in the last parsing. More... | |
const char * | GetParseError () const |
Get the message of parsing error. More... | |
size_t | GetErrorOffset () const |
Get the offset in character of the parsing error. More... | |
Allocator & | GetAllocator () |
Get the allocator of this document. More... | |
size_t | GetStackCapacity () const |
Get the capacity of stack in bytes. More... | |
Public Member Functions inherited from rapidjson::GenericValue< Encoding, MemoryPoolAllocator<> > | |
GenericValue & | operator= (GenericValue &rhs) |
Assignment with move semantics. More... | |
GenericValue & | operator= (T value) |
Assignment with primitive types. 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 |
GenericValue & | SetNull_ () |
bool | GetBool_ () const |
GenericValue & | SetBool_ (bool b) |
GenericValue & | SetObject () |
Set this value as an empty object. More... | |
GenericValue & | operator[] (const Ch *name) |
Get the value associated with the object's name. More... | |
const GenericValue & | operator[] (const Ch *name) const |
ConstMemberIterator | MemberBegin () const |
Member iterators. More... | |
MemberIterator | MemberBegin () |
ConstMemberIterator | MemberEnd () const |
MemberIterator | MemberEnd () |
bool | HasMember (const Ch *name) const |
Check whether a member exists in the object. More... | |
GenericValue & | AddMember (GenericValue &name, GenericValue &value, MemoryPoolAllocator<> &allocator) |
Add a member (name-value pair) to the object. More... | |
GenericValue & | AddMember (const Ch *name, MemoryPoolAllocator<> &nameAllocator, GenericValue &value, MemoryPoolAllocator<> &allocator) |
GenericValue & | AddMember (const Ch *name, GenericValue &value, MemoryPoolAllocator<> &allocator) |
GenericValue & | AddMember (const Ch *name, T value, MemoryPoolAllocator<> &allocator) |
bool | RemoveMember (const Ch *name) |
Remove a member in object by its name. More... | |
GenericValue & | operator[] (SizeType index) |
Get an element from array by index. More... | |
const GenericValue & | operator[] (SizeType index) const |
GenericValue & | SetArray () |
Set this value as an empty array. More... | |
SizeType | Size () const |
Get the number of elements in array. More... | |
SizeType | Capacity () const |
Get the capacity of array. More... | |
bool | Empty () const |
Check whether the array is empty. More... | |
void | Clear () |
Remove all elements in the array. More... | |
ValueIterator | Begin () |
Element iterator. More... | |
ConstValueIterator | Begin () const |
ValueIterator | End () |
ConstValueIterator | End () const |
GenericValue & | Reserve (SizeType newCapacity, MemoryPoolAllocator<> &allocator) |
Request the array to have enough capacity to store elements. More... | |
GenericValue & | PushBack (GenericValue &value, MemoryPoolAllocator<> &allocator) |
Append a value at the end of the array. More... | |
GenericValue & | PushBack (T value, MemoryPoolAllocator<> &allocator) |
GenericValue & | PopBack () |
Remove the last element in the array. More... | |
int | GetInt () const |
unsigned | GetUint () const |
int64_t | GetInt64 () const |
uint64_t | GetUint64 () const |
double | GetDouble () const |
GenericValue & | SetInt (int i) |
GenericValue & | SetUint (unsigned u) |
GenericValue & | SetInt64 (int64_t i64) |
GenericValue & | SetUint64 (uint64_t u64) |
GenericValue & | SetDouble (double d) |
const Ch * | GetString () const |
SizeType | GetStringLength () const |
Get the length of string. More... | |
GenericValue & | SetString (const Ch *s, SizeType length) |
Set this value as a string without copying source string. More... | |
GenericValue & | SetString (const Ch *s) |
Set this value as a string without copying source string. More... | |
GenericValue & | SetString (const Ch *s, SizeType length, MemoryPoolAllocator<> &allocator) |
Set this value as a string by copying from source string. More... | |
GenericValue & | SetString (const Ch *s, MemoryPoolAllocator<> &allocator) |
Set this value as a string by copying from source string. More... | |
const GenericValue & | Accept (Handler &handler) const |
Generate events of this value to a Handler. More... | |
GenericValue () | |
Default constructor creates a null value. More... | |
GenericValue (Type type) | |
Constructor with JSON value type. More... | |
GenericValue (bool b) | |
Constructor for boolean value. More... | |
GenericValue (int i) | |
Constructor for int value. More... | |
GenericValue (unsigned u) | |
Constructor for unsigned value. More... | |
GenericValue (int64_t i64) | |
Constructor for int64_t value. More... | |
GenericValue (uint64_t u64) | |
Constructor for uint64_t value. More... | |
GenericValue (double d) | |
Constructor for double value. More... | |
GenericValue (const Ch *s, SizeType length) | |
Constructor for constant string (i.e. do not make a copy of string) More... | |
GenericValue (const Ch *s) | |
Constructor for constant string (i.e. do not make a copy of string) More... | |
GenericValue (const Ch *s, SizeType length, MemoryPoolAllocator<> &allocator) | |
Constructor for copy-string (i.e. do make a copy of string) More... | |
GenericValue (const Ch *s, MemoryPoolAllocator<> &allocator) | |
Constructor for copy-string (i.e. do make a copy of string) More... | |
~GenericValue () | |
Destructor. More... | |
Private Member Functions | |
GenericDocument & | operator= (const GenericDocument &) |
void | Null_ () |
void | Bool_ (bool b) |
void | Int (int i) |
void | Uint (unsigned i) |
void | Int64 (int64_t i) |
void | Uint64 (uint64_t i) |
void | Double (double d) |
void | String (const Ch *str, SizeType length, bool copy) |
void | StartObject () |
void | EndObject (SizeType memberCount) |
void | StartArray () |
void | EndArray (SizeType elementCount) |
void | ClearStack () |
Private Attributes | |
internal::Stack< Allocator > | stack_ |
const char * | parseError_ |
size_t | errorOffset_ |
Static Private Attributes | |
static const size_t | kDefaultStackCapacity = 1024 |
Friends | |
class | GenericReader< Encoding, Allocator > |
A document for parsing JSON text as DOM.
Encoding | encoding for both parsing and string storage. |
Alloactor | allocator for allocating memory for the DOM, and the stack during parsing. |
typedef Allocator rapidjson::GenericDocument< Encoding, Allocator >::AllocatorType |
Allocator type from template parameter.
typedef Encoding::Ch rapidjson::GenericDocument< Encoding, Allocator >::Ch |
Character type derived from Encoding.
typedef GenericValue<Encoding, Allocator> rapidjson::GenericDocument< Encoding, Allocator >::ValueType |
Value type of the document.
|
inline |
Constructor.
allocator | Optional allocator for allocating stack memory. |
stackCapacity | Initial capacity of stack in bytes. |
|
inlineprivate |
References rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inlineprivate |
References rapidjson::GenericDocument< Encoding, Allocator >::stack_.
Referenced by rapidjson::GenericDocument< Encoding, Allocator >::ParseStream().
|
inlineprivate |
|
inlineprivate |
References rapidjson::GenericDocument< Encoding, Allocator >::GetAllocator(), and rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inlineprivate |
References rapidjson::GenericDocument< Encoding, Allocator >::GetAllocator(), and rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inline |
Get the allocator of this document.
References rapidjson::GenericDocument< Encoding, Allocator >::stack_.
Referenced by rapidjson::GenericDocument< Encoding, Allocator >::EndArray(), rapidjson::GenericDocument< Encoding, Allocator >::EndObject(), and rapidjson::GenericDocument< Encoding, Allocator >::String().
|
inline |
Get the offset in character of the parsing error.
References rapidjson::GenericDocument< Encoding, Allocator >::errorOffset_.
|
inline |
Get the message of parsing error.
References rapidjson::GenericDocument< Encoding, Allocator >::parseError_.
|
inline |
Get the capacity of stack in bytes.
References rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inline |
Whether a parse error was occured in the last parsing.
References rapidjson::GenericDocument< Encoding, Allocator >::parseError_.
|
inlineprivate |
References constants::i, and rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inlineprivate |
References constants::i, and rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inlineprivate |
|
private |
|
inline |
Parse JSON text from a read-only string.
parseFlags | Combination of ParseFlag (must not contain kParseInsituFlag). |
str | Read-only zero-terminated string to be parsed. |
References rapidjson::kParseInsituFlag, and RAPIDJSON_ASSERT.
|
inline |
Parse JSON text from a mutable string.
parseFlags | Combination of ParseFlag. |
str | Mutable zero-terminated string to be parsed. |
|
inline |
Parse JSON text from an input stream.
parseFlags | Combination of ParseFlag. |
stream | Input stream to be parsed. |
References rapidjson::GenericDocument< Encoding, Allocator >::ClearStack(), rapidjson::GenericDocument< Encoding, Allocator >::errorOffset_, rapidjson::GenericReader< Encoding, Allocator >::GetErrorOffset(), rapidjson::GenericReader< Encoding, Allocator >::GetParseError(), rapidjson::GenericDocument< Encoding, Allocator >::parseError_, RAPIDJSON_ASSERT, rapidjson::GenericValue< Encoding, MemoryPoolAllocator<> >::RawAssign(), rapidjson::GenericValue< Encoding, Allocator >::SetNull_(), and rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
References constants::i, and rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
inlineprivate |
References constants::i, and rapidjson::GenericDocument< Encoding, Allocator >::stack_.
|
friend |
|
private |
|
staticprivate |
|
private |
|
private |
Referenced by rapidjson::GenericDocument< Encoding, Allocator >::Bool_(), rapidjson::GenericDocument< Encoding, Allocator >::ClearStack(), rapidjson::GenericDocument< Encoding, Allocator >::Double(), rapidjson::GenericDocument< Encoding, Allocator >::EndArray(), rapidjson::GenericDocument< Encoding, Allocator >::EndObject(), rapidjson::GenericDocument< Encoding, Allocator >::GetAllocator(), rapidjson::GenericDocument< Encoding, Allocator >::GetStackCapacity(), rapidjson::GenericDocument< Encoding, Allocator >::Int(), rapidjson::GenericDocument< Encoding, Allocator >::Int64(), rapidjson::GenericDocument< Encoding, Allocator >::Null_(), rapidjson::GenericDocument< Encoding, Allocator >::ParseStream(), rapidjson::GenericDocument< Encoding, Allocator >::StartArray(), rapidjson::GenericDocument< Encoding, Allocator >::StartObject(), rapidjson::GenericDocument< Encoding, Allocator >::String(), rapidjson::GenericDocument< Encoding, Allocator >::Uint(), and rapidjson::GenericDocument< Encoding, Allocator >::Uint64().