DeepCover Embedded Security in IoT: Public-key Secured Data Paths
Dependencies: MaximInterface
GenericDocument< Encoding, Allocator, StackAllocator > Class Template Reference
A document for parsing JSON text as DOM. More...
#include <document.h>
Inherits GenericValue< Encoding, Allocator >.
Public Types | |
typedef Encoding::Ch | Ch |
Character type derived from Encoding. | |
typedef GenericValue< Encoding, Allocator > | ValueType |
Value type of the document. | |
typedef Allocator | AllocatorType |
Allocator type from template parameter. | |
typedef GenericMember < Encoding, Allocator > | Member |
Name-value pair in an object. | |
typedef Encoding | EncodingType |
Encoding type from template parameter. | |
typedef GenericStringRef< Ch > | StringRefType |
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 GenericValue * | ValueIterator |
Value iterator for iterating in array. | |
typedef const GenericValue * | ConstValueIterator |
Constant value iterator for iterating in array. | |
Public Member Functions | |
GenericDocument (Type type, Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0) | |
Constructor. | |
GenericDocument (Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0) | |
Constructor. | |
GenericDocument (GenericDocument &&rhs) RAPIDJSON_NOEXCEPT | |
Move constructor in C++11. | |
GenericDocument & | operator= (GenericDocument &&rhs) RAPIDJSON_NOEXCEPT |
Move assignment in C++11. | |
GenericDocument & | Swap (GenericDocument &rhs) RAPIDJSON_NOEXCEPT |
Exchange the contents of this document with those of another. | |
template<typename Generator > | |
GenericDocument & | Populate (Generator &g) |
Populate this document by a generator which produces SAX events. | |
Allocator & | GetAllocator () |
Get the allocator of this document. | |
size_t | GetStackCapacity () const |
Get the capacity of stack in bytes. | |
template<typename T > | |
RAPIDJSON_DISABLEIF_RETURN ((internal::IsPointer< T >),(GenericValue &)) operator | |
Assignment with primitive types. | |
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. | |
Parse from stream | |
template<unsigned parseFlags, typename SourceEncoding , typename InputStream > | |
GenericDocument & | ParseStream (InputStream &is) |
Parse JSON text from an input stream (with Encoding conversion) | |
template<unsigned parseFlags, typename InputStream > | |
GenericDocument & | ParseStream (InputStream &is) |
Parse JSON text from an input stream. | |
template<typename InputStream > | |
GenericDocument & | ParseStream (InputStream &is) |
Parse JSON text from an input stream (with kParseDefaultFlags) | |
Parse in-place from mutable string | |
template<unsigned parseFlags> | |
GenericDocument & | ParseInsitu (Ch *str) |
Parse JSON text from a mutable string. | |
GenericDocument & | ParseInsitu (Ch *str) |
Parse JSON text from a mutable string (with kParseDefaultFlags) | |
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) | |
template<unsigned parseFlags> | |
GenericDocument & | Parse (const Ch *str) |
Parse JSON text from a read-only string. | |
GenericDocument & | Parse (const Ch *str) |
Parse JSON text from a read-only string (with kParseDefaultFlags) | |
template<unsigned parseFlags, typename SourceEncoding > | |
GenericDocument & | Parse (const typename SourceEncoding::Ch *str, size_t length) |
template<unsigned parseFlags> | |
GenericDocument & | Parse (const Ch *str, size_t length) |
GenericDocument & | Parse (const Ch *str, size_t length) |
template<unsigned parseFlags, typename SourceEncoding > | |
GenericDocument & | Parse (const std::basic_string< typename SourceEncoding::Ch > &str) |
template<unsigned parseFlags> | |
GenericDocument & | Parse (const std::basic_string< Ch > &str) |
GenericDocument & | Parse (const std::basic_string< Ch > &str) |
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. | |
operator ParseResult () const | |
Implicit conversion to get the last parse result. | |
Friends | |
class | GenericValue |
void | swap (GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT |
free-standing swap function helper | |
class | GenericDocument |
Detailed Description
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
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
delete
a GenericDocument object via a pointer to a GenericValue.
Definition at line 2024 of file document.h.
Member Typedef Documentation
typedef Allocator AllocatorType |
Allocator type from template parameter.
Reimplemented from GenericValue< Encoding, Allocator >.
Definition at line 2028 of file document.h.
typedef Encoding::Ch Ch |
Character type derived from Encoding.
Reimplemented from GenericValue< Encoding, Allocator >.
Definition at line 2026 of file document.h.
typedef GenericMemberIterator<true,Encoding,Allocator>::Iterator ConstMemberIterator [inherited] |
Constant member iterator for iterating in object.
Definition at line 549 of file document.h.
typedef const GenericValue* ConstValueIterator [inherited] |
Constant value iterator for iterating in array.
Definition at line 551 of file document.h.
typedef Encoding EncodingType [inherited] |
Encoding type from template parameter.
Definition at line 544 of file document.h.
typedef GenericMember<Encoding, Allocator> Member [inherited] |
Name-value pair in an object.
Definition at line 543 of file document.h.
typedef GenericMemberIterator<false,Encoding,Allocator>::Iterator MemberIterator [inherited] |
Member iterator for iterating in object.
Definition at line 548 of file document.h.
typedef GenericStringRef<Ch> StringRefType [inherited] |
Reference to a constant string.
Definition at line 547 of file document.h.
typedef GenericValue* ValueIterator [inherited] |
Value iterator for iterating in array.
Definition at line 550 of file document.h.
typedef GenericValue<Encoding, Allocator> ValueType |
Value type of the document.
Reimplemented from GenericValue< Encoding, Allocator >.
Definition at line 2027 of file document.h.
Constructor & Destructor Documentation
GenericDocument | ( | Type | type, |
Allocator * | allocator = 0 , |
||
size_t | stackCapacity = kDefaultStackCapacity , |
||
StackAllocator * | stackAllocator = 0 |
||
) | [explicit] |
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.
Definition at line 2037 of file document.h.
GenericDocument | ( | Allocator * | allocator = 0 , |
size_t | stackCapacity = kDefaultStackCapacity , |
||
StackAllocator * | stackAllocator = 0 |
||
) |
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.
Definition at line 2050 of file document.h.
GenericDocument | ( | GenericDocument< Encoding, Allocator, StackAllocator > && | rhs ) |
Move constructor in C++11.
Definition at line 2059 of file document.h.
Member Function Documentation
Allocator& GetAllocator | ( | ) |
Get the allocator of this document.
Definition at line 2308 of file document.h.
size_t GetErrorOffset | ( | ) | const |
Get the position of last parsing error in input, 0 otherwise.
Definition at line 2290 of file document.h.
ParseErrorCode GetParseError | ( | ) | const |
Get the ParseErrorCode of last parsing.
Definition at line 2287 of file document.h.
size_t GetStackCapacity | ( | ) | const |
Get the capacity of stack in bytes.
Definition at line 2314 of file document.h.
bool HasParseError | ( | ) | const |
Whether a parse error has occured in the last parsing.
Definition at line 2284 of file document.h.
operator ParseResult | ( | ) | const |
Implicit conversion to get the last parse result.
- Returns:
- ParseResult of the last parse operation
Document doc; ParseResult ok = doc.Parse(json); if (!ok) printf( "JSON parse error: %s (%u)\n", GetParseError_En(ok.Code()), ok.Offset());
Definition at line 2304 of file document.h.
GenericDocument& operator= | ( | GenericDocument< Encoding, Allocator, StackAllocator > && | rhs ) |
Move assignment in C++11.
Reimplemented from GenericValue< Encoding, Allocator >.
Definition at line 2078 of file document.h.
GenericDocument& Parse | ( | const typename SourceEncoding::Ch * | str ) |
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.
Definition at line 2221 of file document.h.
GenericDocument& Parse | ( | const Ch * | str ) |
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.
Definition at line 2232 of file document.h.
GenericDocument& Parse | ( | const Ch * | str ) |
Parse JSON text from a read-only string (with kParseDefaultFlags)
- Parameters:
-
str Read-only zero-terminated string to be parsed.
Definition at line 2239 of file document.h.
GenericDocument& ParseInsitu | ( | Ch * | str ) |
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.
Definition at line 2207 of file document.h.
GenericDocument& ParseInsitu | ( | Ch * | str ) |
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.
Definition at line 2198 of file document.h.
GenericDocument& ParseStream | ( | InputStream & | is ) |
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.
Definition at line 2155 of file document.h.
GenericDocument& ParseStream | ( | InputStream & | is ) |
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.
Definition at line 2174 of file document.h.
GenericDocument& ParseStream | ( | InputStream & | is ) |
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.
Definition at line 2184 of file document.h.
GenericDocument& Populate | ( | Generator & | g ) |
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.
Definition at line 2135 of file document.h.
RAPIDJSON_DISABLEIF_RETURN | ( | (internal::IsPointer< T >) | , |
(GenericValue< Encoding, Allocator > &) | |||
) | [inherited] |
Assignment with primitive types.
- Template Parameters:
-
T Either Type, int
,unsigned
,int64_t
,uint64_t
- Parameters:
-
value The 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 tobool
, use SetBool() instead. Set boolean value
void RawAssign | ( | GenericValue< Encoding, Allocator > & | rhs ) | [inherited] |
Assignment without calling destructor.
Definition at line 1984 of file document.h.
Initialize this value as object with initial data, without calling destructor.
Definition at line 1947 of file document.h.
void SetStringRaw | ( | StringRefType | s, |
Allocator & | allocator | ||
) | [inherited] |
Initialize this value as copy string with initial data, without calling destructor.
Definition at line 1967 of file document.h.
void SetStringRaw | ( | StringRefType | s ) | [inherited] |
Initialize this value as constant string, without calling destructor.
Definition at line 1960 of file document.h.
GenericDocument& Swap | ( | GenericDocument< Encoding, Allocator, StackAllocator > & | rhs ) |
Exchange the contents of this document with those of another.
- Parameters:
-
rhs Another document.
- Note:
- Constant complexity.
- See also:
- GenericValue::Swap
Definition at line 2106 of file document.h.
Friends And Related Function Documentation
void swap | ( | GenericDocument< Encoding, Allocator, StackAllocator > & | a, |
GenericDocument< Encoding, Allocator, StackAllocator > & | b | ||
) | [friend] |
Generated on Tue Jul 12 2022 12:06:50 by 1.7.2