Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
GenericDocument< Encoding, Allocator, StackAllocator > Class Template Reference

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

#include <document.h>

Inheritance diagram for GenericDocument< Encoding, Allocator, StackAllocator >:
Collaboration diagram for GenericDocument< Encoding, Allocator, StackAllocator >:

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 GenericValue< Encoding, MemoryPoolAllocator<> >
typedef GenericMember< Encoding, MemoryPoolAllocator<> > Member
 Name-value pair in an object.
 
typedef Encoding EncodingType
 Encoding type from template parameter.
 
typedef MemoryPoolAllocator<> 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, MemoryPoolAllocator<> >::Iterator MemberIterator
 Member iterator for iterating in object.
 
typedef GenericMemberIterator< true, Encoding, MemoryPoolAllocator<> >::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, MemoryPoolAllocator<> > ValueType
 Value type of itself.
 
typedef GenericArray< false, ValueTypeArray
 
typedef GenericArray< true, ValueTypeConstArray
 
typedef GenericObject< false, ValueTypeObject
 
typedef GenericObject< true, ValueTypeConstObject
 
enum  
 

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 ()
 
GenericDocumentSwap (GenericDocument &rhs) RAPIDJSON_NOEXCEPT
 Exchange the contents of this document with those of another.
 
template<typename Generator >
GenericDocumentPopulate (Generator &g)
 Populate this document by a generator which produces SAX events.
 
AllocatorGetAllocator ()
 Get the allocator of this document.
 
size_t GetStackCapacity () const
 Get the capacity of stack in bytes.
 
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 >
GenericDocumentParseStream (InputStream &is)
 Parse JSON text from an input stream (with Encoding conversion)
 
template<unsigned parseFlags, typename InputStream >
GenericDocumentParseStream (InputStream &is)
 Parse JSON text from an input stream.
 
template<typename InputStream >
GenericDocumentParseStream (InputStream &is)
 Parse JSON text from an input stream (with kParseDefaultFlags)
 
Parse in-place from mutable string
template<unsigned parseFlags>
GenericDocumentParseInsitu (Ch *str)
 Parse JSON text from a mutable string.
 
GenericDocumentParseInsitu (Ch *str)
 Parse JSON text from a mutable string (with kParseDefaultFlags)
 
Parse from read-only string
template<unsigned parseFlags, typename SourceEncoding >
GenericDocumentParse (const typename SourceEncoding::Ch *str)
 Parse JSON text from a read-only string (with Encoding conversion)
 
template<unsigned parseFlags>
GenericDocumentParse (const Ch *str)
 Parse JSON text from a read-only string.
 
GenericDocumentParse (const Ch *str)
 Parse JSON text from a read-only string (with kParseDefaultFlags)
 
template<unsigned parseFlags, typename SourceEncoding >
GenericDocumentParse (const typename SourceEncoding::Ch *str, size_t length)
 
template<unsigned parseFlags>
GenericDocumentParse (const Ch *str, size_t length)
 
GenericDocumentParse (const Ch *str, size_t length)
 
Handling parse errors
bool HasParseError () const
 Whether a parse error has occurred 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.
 
- Public Member Functions inherited from GenericValue< Encoding, MemoryPoolAllocator<> >
GenericValueoperator= (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment with move semantics.
 
GenericValueoperator= (StringRefType str) RAPIDJSON_NOEXCEPT
 Assignment of constant string reference (no copy)
 
 RAPIDJSON_DISABLEIF_RETURN ((internal::IsPointer< T >),(GenericValue &)) operator
 Assignment with primitive types.
 
RAPIDJSON_FORCEINLINE const ChGetStringPointer () const
 
RAPIDJSON_FORCEINLINE const ChSetStringPointer (const Ch *str)
 
RAPIDJSON_FORCEINLINE GenericValueGetElementsPointer () const
 
RAPIDJSON_FORCEINLINE GenericValueSetElementsPointer (GenericValue *elements)
 
RAPIDJSON_FORCEINLINE MemberGetMembersPointer () const
 
RAPIDJSON_FORCEINLINE MemberSetMembersPointer (Member *members)
 
void SetArrayRaw (GenericValue *values, SizeType count, MemoryPoolAllocator<> &allocator)
 
void SetObjectRaw (Member *members, SizeType count, MemoryPoolAllocator<> &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, MemoryPoolAllocator<> &allocator)
 Initialize this value as copy string with initial data, without calling destructor.
 
void RawAssign (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment without calling destructor.
 
bool StringEqual (const GenericValue< Encoding, SourceAllocator > &rhs) const
 
 GenericValue () RAPIDJSON_NOEXCEPT
 Default constructor creates a null value.
 
 GenericValue (Type type) RAPIDJSON_NOEXCEPT
 Constructor with JSON value type.
 
 GenericValue (const GenericValue< Encoding, SourceAllocator > &rhs, MemoryPoolAllocator<> &allocator, bool copyConstStrings=false)
 Explicit copy constructor (with allocator)
 
 GenericValue (T b, RAPIDJSON_ENABLEIF((internal::IsSame< bool, T >))) 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 (float f) RAPIDJSON_NOEXCEPT
 Constructor for float 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, MemoryPoolAllocator<> &allocator)
 Constructor for copy-string (i.e. do make a copy of string)
 
 GenericValue (const Ch *s, MemoryPoolAllocator<> &allocator)
 Constructor for copy-string (i.e. do make a copy of string)
 
 GenericValue (Array a) RAPIDJSON_NOEXCEPT
 Constructor for Array.
 
 GenericValue (Object o) RAPIDJSON_NOEXCEPT
 Constructor for Object.
 
 ~GenericValue ()
 Destructor.
 

Friends

template<typename , typename >
class GenericValue
 
void swap (GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
 free-standing swap function helper
 

Additional Inherited Members

- Public Attributes inherited from GenericValue< Encoding, MemoryPoolAllocator<> >
Data data_
 
- Static Public Attributes inherited from GenericValue< Encoding, MemoryPoolAllocator<> >
static const SizeType kDefaultArrayCapacity
 
static const SizeType kDefaultObjectCapacity
 

Detailed Description

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
class GenericDocument< Encoding, Allocator, StackAllocator >
Note
implements Handler concept
Template Parameters
EncodingEncoding for both parsing and string storage.
AllocatorAllocator for allocating memory for the DOM
StackAllocatorAllocator 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 2124 of file document.h.

Member Typedef Documentation

◆ AllocatorType

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
Allocator GenericDocument< Encoding, Allocator, StackAllocator >::AllocatorType

Definition at line 2128 of file document.h.

◆ Ch

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
Encoding::Ch GenericDocument< Encoding, Allocator, StackAllocator >::Ch

Definition at line 2126 of file document.h.

◆ ValueType

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericValue<Encoding, Allocator> GenericDocument< Encoding, Allocator, StackAllocator >::ValueType

Definition at line 2127 of file document.h.

Constructor & Destructor Documentation

◆ GenericDocument() [1/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument< Encoding, Allocator, StackAllocator >::GenericDocument ( Type type,
Allocator * allocator = 0,
size_t stackCapacity = kDefaultStackCapacity,
StackAllocator * stackAllocator = 0 )
inlineexplicit

Creates an empty document of specified type.

Parameters
typeMandatory type of object to create.
allocatorOptional allocator for allocating memory.
stackCapacityOptional initial capacity of stack in bytes.
stackAllocatorOptional allocator for allocating memory for stack.

Definition at line 2137 of file document.h.

2137 :
2138 GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2139 {
2140 if (!allocator_)
2141 ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2142 }
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition document.h:578
Concept for allocating, resizing and freeing memory block.
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition rapidjson.h:627

◆ GenericDocument() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument< Encoding, Allocator, StackAllocator >::GenericDocument ( Allocator * allocator = 0,
size_t stackCapacity = kDefaultStackCapacity,
StackAllocator * stackAllocator = 0 )
inline

Creates an empty document which type is Null.

Parameters
allocatorOptional allocator for allocating memory.
stackCapacityOptional initial capacity of stack in bytes.
stackAllocatorOptional allocator for allocating memory for stack.

Definition at line 2150 of file document.h.

2150 :
2151 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2152 {
2153 if (!allocator_)
2154 ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2155 }

◆ ~GenericDocument()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument< Encoding, Allocator, StackAllocator >::~GenericDocument ( )
inline

Definition at line 2172 of file document.h.

2172 {
2173 Destroy();
2174 }

Member Function Documentation

◆ Bool()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Bool ( bool b)
inline

Definition at line 2438 of file document.h.

2438{ new (stack_.template Push<ValueType>()) ValueType(b); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition document.h:2127

◆ Double()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Double ( double d)
inline

Definition at line 2443 of file document.h.

2443{ new (stack_.template Push<ValueType>()) ValueType(d); return true; }

◆ EndArray()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::EndArray ( SizeType elementCount)
inline

Definition at line 2473 of file document.h.

2473 {
2474 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2475 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());
2476 return true;
2477 }
Allocator & GetAllocator()
Get the allocator of this document.
Definition document.h:2412
Here is the call graph for this function:

◆ EndObject()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::EndObject ( SizeType memberCount)
inline

Definition at line 2465 of file document.h.

2465 {
2466 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2467 stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount, GetAllocator());
2468 return true;
2469 }
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition document.h:581
Here is the call graph for this function:

◆ GetAllocator()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
Allocator & GenericDocument< Encoding, Allocator, StackAllocator >::GetAllocator ( )
inline

Definition at line 2412 of file document.h.

2412 {
2413 RAPIDJSON_ASSERT(allocator_);
2414 return *allocator_;
2415 }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:406
Here is the caller graph for this function:

◆ GetErrorOffset()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
size_t GenericDocument< Encoding, Allocator, StackAllocator >::GetErrorOffset ( ) const
inline

Definition at line 2394 of file document.h.

2394{ return parseResult_.Offset(); }
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition error.h:118
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetParseError()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
ParseErrorCode GenericDocument< Encoding, Allocator, StackAllocator >::GetParseError ( ) const
inline

Definition at line 2391 of file document.h.

2391{ return parseResult_.Code(); }
ParseErrorCode Code() const
Get the error code.
Definition error.h:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStackCapacity()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
size_t GenericDocument< Encoding, Allocator, StackAllocator >::GetStackCapacity ( ) const
inline

Definition at line 2418 of file document.h.

2418{ return stack_.GetCapacity(); }
size_t GetCapacity() const
Definition stack.h:179
Here is the call graph for this function:

◆ HasParseError()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::HasParseError ( ) const
inline

Definition at line 2388 of file document.h.

2388{ return parseResult_.IsError(); }
bool IsError() const
Whether the result is an error.
Definition error.h:123
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Int()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Int ( int i)
inline

Definition at line 2439 of file document.h.

2439{ new (stack_.template Push<ValueType>()) ValueType(i); return true; }

◆ Int64()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Int64 ( int64_t i)
inline

Definition at line 2441 of file document.h.

2441{ new (stack_.template Push<ValueType>()) ValueType(i); return true; }

◆ Key()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Key ( const Ch * str,
SizeType length,
bool copy )
inline

Definition at line 2463 of file document.h.

2463{ return String(str, length, copy); }
bool String(const Ch *str, SizeType length, bool copy)
Definition document.h:2453
Here is the call graph for this function:

◆ Null()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Null ( )
inline

Definition at line 2437 of file document.h.

2437{ new (stack_.template Push<ValueType>()) ValueType(); return true; }

◆ operator ParseResult()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument< Encoding, Allocator, StackAllocator >::operator ParseResult ( ) const
inline
Returns
ParseResult of the last parse operation
ParseResult ok = doc.Parse(json);
if (!ok)
printf( "JSON parse error: %s (%u)\n", GetParseError_En(ok.Code()), ok.Offset());
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition document.h:2325
RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.
Definition en.h:36
Result of parsing (wraps ParseErrorCode)
Definition error.h:106

Definition at line 2408 of file document.h.

2408{ return parseResult_; }

◆ Parse() [1/6]

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

Definition at line 2336 of file document.h.

2336 {
2337 return Parse<parseFlags, Encoding>(str);
2338 }
Here is the call graph for this function:

◆ Parse() [2/6]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::Parse ( const Ch * str)
inline
Parameters
strRead-only zero-terminated string to be parsed.

Definition at line 2343 of file document.h.

2343 {
2344 return Parse<kParseDefaultFlags>(str);
2345 }
Here is the call graph for this function:

◆ Parse() [3/6]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags>
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::Parse ( const Ch * str,
size_t length )
inline

Definition at line 2357 of file document.h.

2357 {
2358 return Parse<parseFlags, Encoding>(str, length);
2359 }
Here is the call graph for this function:

◆ Parse() [4/6]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::Parse ( const Ch * str,
size_t length )
inline

Definition at line 2361 of file document.h.

2361 {
2362 return Parse<kParseDefaultFlags>(str, length);
2363 }
Here is the call graph for this function:

◆ Parse() [5/6]

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

Definition at line 2325 of file document.h.

2325 {
2326 RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2329 }
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
Definition document.h:2259
@ kParseInsituFlag
In-situ(destructive) parsing.
Definition reader.h:147
Read-only string stream.
Definition stream.h:154
char * s
Here is the call graph for this function:

◆ Parse() [6/6]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename SourceEncoding >
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::Parse ( const typename SourceEncoding::Ch * str,
size_t length )
inline

Definition at line 2348 of file document.h.

2348 {
2349 RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2350 MemoryStream ms(reinterpret_cast<const char*>(str), length * sizeof(typename SourceEncoding::Ch));
2353 return *this;
2354 }
Input byte stream wrapper with a statically bound encoding.
Represents an in-memory input byte stream.
Here is the call graph for this function:

◆ ParseInsitu() [1/2]

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

Definition at line 2302 of file document.h.

2302 {
2305 }
A read-write string stream.
Definition stream.h:188
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseInsitu() [2/2]

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

Definition at line 2311 of file document.h.

2311 {
2313 }
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
Definition document.h:2302
Here is the call graph for this function:

◆ ParseStream() [1/3]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename SourceEncoding , typename InputStream >
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::ParseStream ( InputStream & is)
inline
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.

Definition at line 2259 of file document.h.

2259 {
2261 stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2262 ClearStackOnExit scope(*this);
2263 parseResult_ = reader.template Parse<parseFlags>(is, *this);
2264 if (parseResult_) {
2265 RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2266 ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2267 }
2268 return *this;
2269 }
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition reader.h:537
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition document.h:836
bool HasAllocator() const
Definition stack.h:168
Allocator & GetAllocator()
Definition stack.h:172
size_t GetSize() const
Definition stack.h:178
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseStream() [2/3]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream >
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::ParseStream ( InputStream & is)
inline
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.

Definition at line 2278 of file document.h.

2278 {
2280 }
Here is the call graph for this function:

◆ ParseStream() [3/3]

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

Definition at line 2288 of file document.h.

Here is the call graph for this function:

◆ Populate()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<typename Generator >
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::Populate ( Generator & g)
inline
Template Parameters
GeneratorA functor with bool f(Handler) prototype.
Parameters
gGenerator functor which sends SAX events to the parameter.
Returns
The document itself for fluent API.

Definition at line 2239 of file document.h.

2239 {
2240 ClearStackOnExit scope(*this);
2241 if (g(*this)) {
2242 RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2243 ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2244 }
2245 return *this;
2246 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RawNumber()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::RawNumber ( const Ch * str,
SizeType length,
bool copy )
inline

Definition at line 2445 of file document.h.

2445 {
2446 if (copy)
2447 new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2448 else
2449 new (stack_.template Push<ValueType>()) ValueType(str, length);
2450 return true;
2451 }
Here is the call graph for this function:

◆ StartArray()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::StartArray ( )
inline

Definition at line 2471 of file document.h.

2471{ new (stack_.template Push<ValueType>()) ValueType(kArrayType); return true; }
@ kArrayType
array
Definition rapidjson.h:649

◆ StartObject()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::StartObject ( )
inline

Definition at line 2461 of file document.h.

2461{ new (stack_.template Push<ValueType>()) ValueType(kObjectType); return true; }
@ kObjectType
object
Definition rapidjson.h:648

◆ String()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::String ( const Ch * str,
SizeType length,
bool copy )
inline

Definition at line 2453 of file document.h.

2453 {
2454 if (copy)
2455 new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2456 else
2457 new (stack_.template Push<ValueType>()) ValueType(str, length);
2458 return true;
2459 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Swap()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::Swap ( GenericDocument< Encoding, Allocator, StackAllocator > & rhs)
inline
Parameters
rhsAnother document.
Note
Constant complexity.
See also
GenericValue::Swap

Definition at line 2206 of file document.h.

2206 {
2207 ValueType::Swap(rhs);
2208 stack_.Swap(rhs.stack_);
2209 internal::Swap(allocator_, rhs.allocator_);
2210 internal::Swap(ownAllocator_, rhs.ownAllocator_);
2211 internal::Swap(parseResult_, rhs.parseResult_);
2212 return *this;
2213 }
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT
Definition stack.h:90
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition swap.h:33
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Uint()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Uint ( unsigned i)
inline

Definition at line 2440 of file document.h.

2440{ new (stack_.template Push<ValueType>()) ValueType(i); return true; }

◆ Uint64()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Uint64 ( uint64_t i)
inline

Definition at line 2442 of file document.h.

2442{ new (stack_.template Push<ValueType>()) ValueType(i); return true; }

Friends And Related Symbol Documentation

◆ GenericValue

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<typename , typename >
friend class GenericValue
friend

Definition at line 2433 of file document.h.

◆ swap

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
void swap ( GenericDocument< Encoding, Allocator, StackAllocator > & a,
GenericDocument< Encoding, Allocator, StackAllocator > & b )
friend

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.doc, b.doc);
// ...
}
friend void swap(GenericDocument &a, GenericDocument &b) RAPIDJSON_NOEXCEPT
free-standing swap function helper
Definition document.h:2231
void swap(picojson::value &x, picojson::value &y)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
See also
Swap()

Definition at line 2231 of file document.h.

2231{ a.Swap(b); }

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