GenericDocument< Encoding, Allocator, StackAllocator > Class Template Reference#
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... | |
| typedef StackAllocator | StackAllocatorType |
| StackAllocator type from template parameter. More... | |
Public Types inherited from GenericValue< Encoding, RAPIDJSON_DEFAULT_ALLOCATOR > | |
| typedef GenericMember< Encoding, RAPIDJSON_DEFAULT_ALLOCATOR > | Member |
| Name-value pair in an object. More... | |
| typedef Encoding | EncodingType |
| Encoding type from template parameter. More... | |
| typedef RAPIDJSON_DEFAULT_ALLOCATOR | AllocatorType |
| Allocator type from template parameter. More... | |
| typedef Encoding::Ch | Ch |
| Character type derived from Encoding. More... | |
| typedef GenericStringRef< Ch > | StringRefType |
| Reference to a constant string. More... | |
| typedef GenericMemberIterator< false, Encoding, RAPIDJSON_DEFAULT_ALLOCATOR >::Iterator | MemberIterator |
| Member iterator for iterating in object. More... | |
| typedef GenericMemberIterator< true, Encoding, RAPIDJSON_DEFAULT_ALLOCATOR >::Iterator | 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... | |
| typedef GenericValue< Encoding, RAPIDJSON_DEFAULT_ALLOCATOR > | ValueType |
| Value type of itself. More... | |
| typedef GenericArray< false, ValueType > | Array |
| typedef GenericArray< true, ValueType > | ConstArray |
| typedef GenericObject< false, ValueType > | Object |
| typedef GenericObject< true, ValueType > | ConstObject |
| enum | |
| Assignment with move semantics. More... | |
Public Member Functions | |
| GenericDocument (Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0) | |
| Constructor. More... | |
| GenericDocument (Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0) | |
| Constructor. More... | |
| ~GenericDocument () | |
| GenericDocument & | Swap (GenericDocument &rhs) RAPIDJSON_NOEXCEPT |
| Exchange the contents of this document with those of another. More... | |
| template<typename Generator > | |
| GenericDocument & | Populate (Generator &g) |
| Populate this document by a generator which produces SAX events. More... | |
| Allocator & | GetAllocator () |
| Get the allocator of this document. More... | |
| size_t | GetStackCapacity () const |
| Get the capacity of stack in bytes. More... | |
| bool | Null () |
| bool | Bool (bool b) |
| bool | Int (int i) |
| bool | Uint (unsigned i) |
| bool | Int64 (int64_t i) |
| bool | Uint64 (uint64_t i) |
| bool | Double (double d) |
| bool | RawNumber (const Ch *str, SizeType length, bool copy) |
| bool | String (const Ch *str, SizeType length, bool copy) |
| bool | StartObject () |
| bool | Key (const Ch *str, SizeType length, bool copy) |
| bool | EndObject (SizeType memberCount) |
| bool | StartArray () |
| bool | EndArray (SizeType elementCount) |
Parse from stream | |
| template<unsigned parseFlags, typename SourceEncoding , typename InputStream > | |
| GenericDocument & | ParseStream (InputStream &is) |
| Parse JSON text from an input stream (with Encoding conversion) More... | |
| template<unsigned parseFlags, typename InputStream > | |
| GenericDocument & | ParseStream (InputStream &is) |
| Parse JSON text from an input stream. More... | |
| template<typename InputStream > | |
| GenericDocument & | ParseStream (InputStream &is) |
| Parse JSON text from an input stream (with kParseDefaultFlags) More... | |
Parse in-place from mutable string | |
| template<unsigned parseFlags> | |
| GenericDocument & | ParseInsitu (Ch *str) |
| Parse JSON text from a mutable string. More... | |
| GenericDocument & | ParseInsitu (Ch *str) |
| Parse JSON text from a mutable string (with kParseDefaultFlags) More... | |
Parse from read-only string | |
| template<unsigned parseFlags, typename SourceEncoding > | |
| GenericDocument & | Parse (const typename SourceEncoding::Ch *str) |
| Parse JSON text from a read-only string (with Encoding conversion) More... | |
| template<unsigned parseFlags> | |
| GenericDocument & | Parse (const Ch *str) |
| Parse JSON text from a read-only string. More... | |
| GenericDocument & | Parse (const Ch *str) |
| Parse JSON text from a read-only string (with kParseDefaultFlags) More... | |
| template<unsigned parseFlags, typename SourceEncoding > | |
| GenericDocument & | Parse (const typename SourceEncoding::Ch *str, size_t length) |
| Parse JSON text from a read-only string (with Encoding conversion) More... | |
| template<unsigned parseFlags> | |
| GenericDocument & | Parse (const Ch *str, size_t length) |
| Parse JSON text from a read-only string (with Encoding conversion) More... | |
| GenericDocument & | Parse (const Ch *str, size_t length) |
| Parse JSON text from a read-only string (with Encoding conversion) More... | |
Handling parse errors | |
| bool | HasParseError () const |
| Whether a parse error has occurred in the last parsing. More... | |
| ParseErrorCode | GetParseError () const |
| Get the ParseErrorCode of last parsing. More... | |
| size_t | GetErrorOffset () const |
| Get the position of last parsing error in input, 0 otherwise. More... | |
| operator ParseResult () const | |
| Implicit conversion to get the last parse result. More... | |
Public Member Functions inherited from GenericValue< Encoding, RAPIDJSON_DEFAULT_ALLOCATOR > | |
| GenericValue & | operator= (GenericValue &rhs) RAPIDJSON_NOEXCEPT |
| Assignment with move semantics. More... | |
| GenericValue & | operator= (StringRefType str) RAPIDJSON_NOEXCEPT |
| Assignment of constant string reference (no copy) More... | |
| RAPIDJSON_DISABLEIF_RETURN ((internal::IsPointer< T >),(GenericValue &)) operator | |
| Assignment with primitive types. More... | |
| RAPIDJSON_FORCEINLINE const Ch * | GetStringPointer () const |
| Assignment with move semantics. More... | |
| RAPIDJSON_FORCEINLINE const Ch * | SetStringPointer (const Ch *str) |
| Assignment with move semantics. More... | |
| RAPIDJSON_FORCEINLINE GenericValue * | GetElementsPointer () const |
| Assignment with move semantics. More... | |
| RAPIDJSON_FORCEINLINE GenericValue * | SetElementsPointer (GenericValue *elements) |
| Assignment with move semantics. More... | |
| RAPIDJSON_FORCEINLINE Member * | GetMembersPointer () const |
| Assignment with move semantics. More... | |
| RAPIDJSON_FORCEINLINE Member * | SetMembersPointer (Member *members) |
| Assignment with move semantics. More... | |
| RAPIDJSON_FORCEINLINE Member * | DoAllocMembers (SizeType capacity, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) |
| Assignment with move semantics. More... | |
| void | DoReserveMembers (SizeType newCapacity, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) |
| Assignment with move semantics. More... | |
| MemberIterator | DoFindMember (const GenericValue< Encoding, SourceAllocator > &name) |
| Assignment with move semantics. More... | |
| void | DoClearMembers () |
| Assignment with move semantics. More... | |
| void | DoFreeMembers () |
| Assignment with move semantics. More... | |
| void | DoAddMember (GenericValue &name, GenericValue &value, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) |
| Assignment with move semantics. More... | |
| MemberIterator | DoRemoveMember (MemberIterator m) |
| Assignment with move semantics. More... | |
| MemberIterator | DoEraseMembers (ConstMemberIterator first, ConstMemberIterator last) |
| Assignment with move semantics. More... | |
| void | DoCopyMembers (const GenericValue< Encoding, SourceAllocator > &rhs, RAPIDJSON_DEFAULT_ALLOCATOR &allocator, bool copyConstStrings) |
| Assignment with move semantics. More... | |
| void | SetArrayRaw (GenericValue *values, SizeType count, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) |
| Assignment with move semantics. More... | |
| void | SetObjectRaw (Member *members, SizeType count, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) |
| Initialize this value as object with initial data, without calling destructor. More... | |
| void | SetStringRaw (StringRefType s) RAPIDJSON_NOEXCEPT |
| Initialize this value as constant string, without calling destructor. More... | |
| void | SetStringRaw (StringRefType s, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) |
| Initialize this value as copy string with initial data, without calling destructor. More... | |
| void | RawAssign (GenericValue &rhs) RAPIDJSON_NOEXCEPT |
| Assignment without calling destructor. More... | |
| bool | StringEqual (const GenericValue< Encoding, SourceAllocator > &rhs) const |
| Assignment with move semantics. More... | |
| GenericValue () RAPIDJSON_NOEXCEPT | |
| Default constructor creates a null value. More... | |
| GenericValue (Type type) RAPIDJSON_NOEXCEPT | |
| Constructor with JSON value type. More... | |
| GenericValue (const GenericValue< Encoding, SourceAllocator > &rhs, RAPIDJSON_DEFAULT_ALLOCATOR &allocator, bool copyConstStrings=false) | |
| Explicit copy constructor (with allocator) More... | |
| GenericValue (T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) RAPIDJSON_NOEXCEPT | |
| Constructor for boolean value. More... | |
| GenericValue (int i) RAPIDJSON_NOEXCEPT | |
| Constructor for int value. More... | |
| GenericValue (unsigned u) RAPIDJSON_NOEXCEPT | |
| Constructor for unsigned value. More... | |
| GenericValue (int64_t i64) RAPIDJSON_NOEXCEPT | |
| Constructor for int64_t value. More... | |
| GenericValue (uint64_t u64) RAPIDJSON_NOEXCEPT | |
| Constructor for uint64_t value. More... | |
| GenericValue (double d) RAPIDJSON_NOEXCEPT | |
| Constructor for double value. More... | |
| GenericValue (float f) RAPIDJSON_NOEXCEPT | |
| Constructor for float value. More... | |
| GenericValue (const Ch *s, SizeType length) RAPIDJSON_NOEXCEPT | |
| Constructor for constant string (i.e. do not make a copy of string) More... | |
| GenericValue (StringRefType s) RAPIDJSON_NOEXCEPT | |
| Constructor for constant string (i.e. do not make a copy of string) More... | |
| GenericValue (const Ch *s, SizeType length, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) | |
| Constructor for copy-string (i.e. do make a copy of string) More... | |
| GenericValue (const Ch *s, RAPIDJSON_DEFAULT_ALLOCATOR &allocator) | |
| Constructor for copy-string (i.e. do make a copy of string) More... | |
| GenericValue (Array a) RAPIDJSON_NOEXCEPT | |
| Constructor for Array. More... | |
| GenericValue (Object o) RAPIDJSON_NOEXCEPT | |
| Constructor for Object. More... | |
| ~GenericValue () | |
| Destructor. More... | |
Friends | |
| template<typename , typename > | |
| class | GenericValue |
| void | swap (GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT |
| free-standing swap function helper More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from GenericValue< Encoding, RAPIDJSON_DEFAULT_ALLOCATOR > | |
| static RAPIDJSON_FORCEINLINE const Ch * | DataString (const Data &data) |
| Assignment with move semantics. More... | |
| static RAPIDJSON_FORCEINLINE SizeType | DataStringLength (const Data &data) |
| Assignment with move semantics. More... | |
Public Attributes inherited from GenericValue< Encoding, RAPIDJSON_DEFAULT_ALLOCATOR > | |
| Data | data_ |
| Assignment with move semantics. More... | |
Static Public Attributes inherited from GenericValue< Encoding, RAPIDJSON_DEFAULT_ALLOCATOR > | |
| static const SizeType | kDefaultArrayCapacity |
| Assignment with move semantics. More... | |
| static const SizeType | kDefaultObjectCapacity |
| Assignment with move semantics. More... | |
Detailed Description
template<typename Encoding, typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR, typename StackAllocator = RAPIDJSON_DEFAULT_STACK_ALLOCATOR>
class GenericDocument< Encoding, Allocator, StackAllocator >
A document for parsing JSON text as DOM.
- Note
- implements Handler concept
- Template Parameters
-
Encoding Encoding for both parsing and string storage. Allocator Allocator for allocating memory for the DOM StackAllocator Allocator for allocating memory for stack during parsing.
- Warning
- Although GenericDocument inherits from GenericValue, the API does not provide any virtual functions, especially no virtual destructor. To avoid memory leaks, do not
deletea GenericDocument object via a pointer to a GenericValue.
Member Typedef Documentation
◆ AllocatorType
| typedef Allocator GenericDocument< Encoding, Allocator, StackAllocator >::AllocatorType |
Allocator type from template parameter.
◆ Ch
| typedef Encoding::Ch GenericDocument< Encoding, Allocator, StackAllocator >::Ch |
Character type derived from Encoding.
◆ StackAllocatorType
| typedef StackAllocator GenericDocument< Encoding, Allocator, StackAllocator >::StackAllocatorType |
StackAllocator type from template parameter.
◆ ValueType
| typedef GenericValue<Encoding, Allocator> GenericDocument< Encoding, Allocator, StackAllocator >::ValueType |
Value type of the document.
Constructor & Destructor Documentation
◆ GenericDocument() [1/2]
|
inlineexplicit |
Constructor.
Creates an empty document of specified type.
- Parameters
-
type Mandatory type of object to create. allocator Optional allocator for allocating memory. stackCapacity Optional initial capacity of stack in bytes. stackAllocator Optional allocator for allocating memory for stack.
◆ GenericDocument() [2/2]
|
inline |
Constructor.
Creates an empty document which type is Null.
- Parameters
-
allocator Optional allocator for allocating memory. stackCapacity Optional initial capacity of stack in bytes. stackAllocator Optional allocator for allocating memory for stack.
◆ ~GenericDocument()
|
inline |
Member Function Documentation
◆ Bool()
|
inline |
◆ Double()
|
inline |
◆ EndArray()
|
inline |
◆ EndObject()
|
inline |
◆ GetAllocator()
|
inline |
Get the allocator of this document.
◆ GetErrorOffset()
|
inline |
Get the position of last parsing error in input, 0 otherwise.
◆ GetParseError()
|
inline |
Get the ParseErrorCode of last parsing.
◆ GetStackCapacity()
|
inline |
Get the capacity of stack in bytes.
◆ HasParseError()
|
inline |
Whether a parse error has occurred in the last parsing.
◆ Int()
|
inline |
◆ Int64()
|
inline |
◆ Key()
|
inline |
◆ Null()
|
inline |
◆ operator ParseResult()
|
inline |
Implicit conversion to get the last parse result.
- Returns
- ParseResult of the last parse operation
◆ Parse() [1/6]
|
inline |
Parse JSON text from a read-only string.
- Template Parameters
-
parseFlags Combination of ParseFlag (must not contain kParseInsituFlag).
- Parameters
-
str Read-only zero-terminated string to be parsed.
◆ Parse() [2/6]
|
inline |
Parse JSON text from a read-only string (with kParseDefaultFlags)
- Parameters
-
str Read-only zero-terminated string to be parsed.
◆ Parse() [3/6]
|
inline |
Parse JSON text from a read-only string (with Encoding conversion)
- Template Parameters
-
parseFlags Combination of ParseFlag (must not contain kParseInsituFlag). SourceEncoding Transcoding from input Encoding
- Parameters
-
str Read-only zero-terminated string to be parsed.
◆ Parse() [4/6]
|
inline |
Parse JSON text from a read-only string (with Encoding conversion)
- Template Parameters
-
parseFlags Combination of ParseFlag (must not contain kParseInsituFlag). SourceEncoding Transcoding from input Encoding
- Parameters
-
str Read-only zero-terminated string to be parsed.
◆ Parse() [5/6]
|
inline |
Parse JSON text from a read-only string (with Encoding conversion)
- Template Parameters
-
parseFlags Combination of ParseFlag (must not contain kParseInsituFlag). SourceEncoding Transcoding from input Encoding
- Parameters
-
str Read-only zero-terminated string to be parsed.
◆ Parse() [6/6]
|
inline |
Parse JSON text from a read-only string (with Encoding conversion)
- Template Parameters
-
parseFlags Combination of ParseFlag (must not contain kParseInsituFlag). SourceEncoding Transcoding from input Encoding
- Parameters
-
str Read-only zero-terminated string to be parsed.
◆ ParseInsitu() [1/2]
|
inline |
Parse JSON text from a mutable string.
- Template Parameters
-
parseFlags Combination of ParseFlag.
- Parameters
-
str Mutable zero-terminated string to be parsed.
- Returns
- The document itself for fluent API.
◆ ParseInsitu() [2/2]
|
inline |
Parse JSON text from a mutable string (with kParseDefaultFlags)
- Parameters
-
str Mutable zero-terminated string to be parsed.
- Returns
- The document itself for fluent API.
◆ ParseStream() [1/3]
|
inline |
Parse JSON text from an input stream (with Encoding conversion)
- Template Parameters
-
parseFlags Combination of ParseFlag. SourceEncoding Encoding of input stream InputStream Type of input stream, implementing Stream concept
- Parameters
-
is Input stream to be parsed.
- Returns
- The document itself for fluent API.
◆ ParseStream() [2/3]
|
inline |
Parse JSON text from an input stream.
- Template Parameters
-
parseFlags Combination of ParseFlag. InputStream Type of input stream, implementing Stream concept
- Parameters
-
is Input stream to be parsed.
- Returns
- The document itself for fluent API.
◆ ParseStream() [3/3]
|
inline |
Parse JSON text from an input stream (with kParseDefaultFlags)
- Template Parameters
-
InputStream Type of input stream, implementing Stream concept
- Parameters
-
is Input stream to be parsed.
- Returns
- The document itself for fluent API.
◆ Populate()
|
inline |
Populate this document by a generator which produces SAX events.
- Template Parameters
-
Generator A functor with bool f(Handler)prototype.
- Parameters
-
g Generator functor which sends SAX events to the parameter.
- Returns
- The document itself for fluent API.
◆ RawNumber()
|
inline |
◆ StartArray()
|
inline |
◆ StartObject()
|
inline |
◆ String()
|
inline |
◆ Swap()
|
inline |
Exchange the contents of this document with those of another.
- Parameters
-
rhs Another document.
- Note
- Constant complexity.
- See also
- GenericValue::Swap
◆ Uint()
|
inline |
◆ Uint64()
|
inline |
Friends And Related Function Documentation
◆ GenericValue
|
friend |
◆ swap
|
friend |
free-standing swap function helper
Helper function to enable support for common swap implementation pattern based on std::swap:@code void swap(MyClass& a, MyClass& b) { using std::swap; swap(a.doc, b.doc); // ... }
- See also
- Swap()
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/rapidjson/document.h
Public Types inherited from