Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
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 >:
Inheritance graph
Collaboration diagram for GenericDocument< Encoding, Allocator, StackAllocator >:
Collaboration graph

Classes

struct  ClearStackOnExit
 

Public Types

typedef Encoding::Ch Ch
 Character type derived from Encoding. More...
 
typedef GenericValue< Encoding, AllocatorValueType
 Value type of the document. More...
 
typedef Allocator AllocatorType
 Allocator type from template parameter. More...
 
- Public Types inherited from GenericValue< Encoding, MemoryPoolAllocator<> >
typedef GenericMember< Encoding, MemoryPoolAllocator<> > Member
 Name-value pair in an object. More...
 
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 GenericStringRef< ChStringRefType
 Reference to a constant string. More...
 
typedef GenericMemberIterator< false, Encoding, MemoryPoolAllocator<> >::Iterator MemberIterator
 Member iterator for iterating in object. More...
 
typedef GenericMemberIterator< true, Encoding, MemoryPoolAllocator<> >::Iterator ConstMemberIterator
 Constant member iterator for iterating in object. More...
 
typedef GenericValueValueIterator
 Value iterator for iterating in array. More...
 
typedef const GenericValueConstValueIterator
 Constant value iterator for iterating in array. More...
 
typedef GenericValue< Encoding, MemoryPoolAllocator<> > ValueType
 Value type of itself. More...
 
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. More...
 
 GenericDocument (Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
 Constructor. More...
 
 ~GenericDocument ()
 
GenericDocumentSwap (GenericDocument &rhs) RAPIDJSON_NOEXCEPT
 Exchange the contents of this document with those of another. More...
 
template<typename Generator >
GenericDocumentPopulate (Generator &g)
 Populate this document by a generator which produces SAX events. More...
 
AllocatorGetAllocator ()
 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 >
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>
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 typename SourceEncoding::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...
 
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 occured 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, MemoryPoolAllocator<> >
GenericValueoperator= (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment with move semantics. More...
 
GenericValueoperator= (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 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. More...
 
void SetStringRaw (StringRefType s) RAPIDJSON_NOEXCEPT
 Initialize this value as constant string, without calling destructor. More...
 
void SetStringRaw (StringRefType s, MemoryPoolAllocator<> &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
 
 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, MemoryPoolAllocator<> &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, 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 (Array a) RAPIDJSON_NOEXCEPT
 Constructor for Array. More...
 
 GenericValue (Object o) RAPIDJSON_NOEXCEPT
 Constructor for Object. More...
 
 ~GenericValue ()
 Destructor. More...
 

Private Member Functions

 GenericDocument (const GenericDocument &)
 Prohibit copying. More...
 
GenericDocumentoperator= (const GenericDocument &)
 Prohibit assignment. More...
 
void ClearStack ()
 
void Destroy ()
 

Private Attributes

Allocatorallocator_
 
AllocatorownAllocator_
 
internal::Stack< StackAllocator > stack_
 
ParseResult parseResult_
 

Static Private Attributes

static const size_t kDefaultStackCapacity = 1024
 

Friends

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

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 >

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
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 2087 of file document.h.

Member Typedef Documentation

◆ AllocatorType

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

Allocator type from template parameter.

Definition at line 2091 of file document.h.

◆ Ch

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

Character type derived from Encoding.

Definition at line 2089 of file document.h.

◆ ValueType

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

Value type of the document.

Definition at line 2090 of file document.h.

Constructor & Destructor Documentation

◆ GenericDocument() [1/3]

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

Constructor.

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 2100 of file document.h.

2100 :
2101 GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2102 {
2103 if (!allocator_)
2105 }
ParseResult parseResult_
Definition: document.h:2465
Allocator * allocator_
Definition: document.h:2462
internal::Stack< StackAllocator > stack_
Definition: document.h:2464
Allocator * ownAllocator_
Definition: document.h:2463
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:551
Concept for allocating, resizing and freeing memory block.
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition: rapidjson.h:599

References GenericDocument< Encoding, Allocator, StackAllocator >::allocator_, GenericDocument< Encoding, Allocator, StackAllocator >::ownAllocator_, and RAPIDJSON_NEW.

◆ GenericDocument() [2/3]

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

Constructor.

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 2113 of file document.h.

2113 :
2114 allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2115 {
2116 if (!allocator_)
2118 }

References GenericDocument< Encoding, Allocator, StackAllocator >::allocator_, GenericDocument< Encoding, Allocator, StackAllocator >::ownAllocator_, and RAPIDJSON_NEW.

◆ ~GenericDocument()

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

Definition at line 2135 of file document.h.

2135 {
2136 Destroy();
2137 }
void Destroy()
Definition: document.h:2457

References GenericDocument< Encoding, Allocator, StackAllocator >::Destroy().

Here is the call graph for this function:

◆ GenericDocument() [3/3]

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

Prohibit copying.

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 2401 of file document.h.

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

References GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ ClearStack()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
void GenericDocument< Encoding, Allocator, StackAllocator >::ClearStack ( )
inlineprivate

Definition at line 2448 of file document.h.

2448 {
2449 if (Allocator::kNeedFree)
2450 while (stack_.GetSize() > 0) // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects)
2451 (stack_.template Pop<ValueType>(1))->~ValueType();
2452 else
2453 stack_.Clear();
2455 }
void Clear()
Definition: stack.h:98
void ShrinkToFit()
Definition: stack.h:100
size_t GetSize() const
Definition: stack.h:177

References internal::Stack< Allocator >::Clear(), internal::Stack< Allocator >::GetSize(), internal::Stack< Allocator >::ShrinkToFit(), and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

Referenced by GenericDocument< Encoding, Allocator, StackAllocator >::ClearStackOnExit::~ClearStackOnExit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Destroy()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
void GenericDocument< Encoding, Allocator, StackAllocator >::Destroy ( )
inlineprivate

Definition at line 2457 of file document.h.

2457 {
2459 }
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition: rapidjson.h:603

References GenericDocument< Encoding, Allocator, StackAllocator >::ownAllocator_, and RAPIDJSON_DELETE.

Referenced by GenericDocument< Encoding, Allocator, StackAllocator >::~GenericDocument().

Here is the caller graph for this function:

◆ Double()

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

Definition at line 2406 of file document.h.

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

References GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ EndArray()

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

Definition at line 2436 of file document.h.

2436 {
2437 ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2438 stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());
2439 return true;
2440 }
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:2375

References GenericDocument< Encoding, Allocator, StackAllocator >::GetAllocator(), and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

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 2428 of file document.h.

2428 {
2429 typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2430 stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount, GetAllocator());
2431 return true;
2432 }
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:554

References GenericDocument< Encoding, Allocator, StackAllocator >::GetAllocator(), and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

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

◆ GetErrorOffset()

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

Get the position of last parsing error in input, 0 otherwise.

Definition at line 2357 of file document.h.

2357{ return parseResult_.Offset(); }
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition: error.h:118

References ParseResult::Offset(), and GenericDocument< Encoding, Allocator, StackAllocator >::parseResult_.

Here is the call graph for this function:

◆ GetParseError()

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

Get the ParseErrorCode of last parsing.

Definition at line 2354 of file document.h.

2354{ return parseResult_.Code(); }
ParseErrorCode Code() const
Get the error code.
Definition: error.h:116

References ParseResult::Code(), and GenericDocument< Encoding, Allocator, StackAllocator >::parseResult_.

Here is the call graph for this function:

◆ GetStackCapacity()

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

Get the capacity of stack in bytes.

Definition at line 2381 of file document.h.

2381{ return stack_.GetCapacity(); }
size_t GetCapacity() const
Definition: stack.h:178

References internal::Stack< Allocator >::GetCapacity(), and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

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

Whether a parse error has occured in the last parsing.

Definition at line 2351 of file document.h.

2351{ return parseResult_.IsError(); }
bool IsError() const
Whether the result is an error.
Definition: error.h:123

References ParseResult::IsError(), and GenericDocument< Encoding, Allocator, StackAllocator >::parseResult_.

Here is the call 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 2402 of file document.h.

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

References process_bag::i, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ Int64()

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

Definition at line 2404 of file document.h.

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

References process_bag::i, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ 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 2426 of file document.h.

2426{ return String(str, length, copy); }
bool String(const Ch *str, SizeType length, bool copy)
Definition: document.h:2416

References GenericDocument< Encoding, Allocator, StackAllocator >::String().

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 2400 of file document.h.

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

References GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ operator ParseResult()

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

Implicit conversion to get the last parse result.

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());
A document for parsing JSON text as DOM.
Definition: document.h:2087
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition: document.h:2288
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 2371 of file document.h.

2371{ return parseResult_; }

References GenericDocument< Encoding, Allocator, StackAllocator >::parseResult_.

◆ operator=()

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::operator= ( const GenericDocument< Encoding, Allocator, StackAllocator > &  )
private

Prohibit assignment.

◆ 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

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.

Definition at line 2299 of file document.h.

2299 {
2300 return Parse<parseFlags, Encoding>(str);
2301 }

◆ Parse() [2/6]

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

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

Parameters
strRead-only zero-terminated string to be parsed.

Definition at line 2306 of file document.h.

2306 {
2307 return Parse<kParseDefaultFlags>(str);
2308 }

◆ 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 2320 of file document.h.

2320 {
2321 return Parse<parseFlags, Encoding>(str, length);
2322 }

◆ 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 2324 of file document.h.

2324 {
2325 return Parse<kParseDefaultFlags>(str, length);
2326 }

◆ 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

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.

Definition at line 2288 of file document.h.

2288 {
2289 RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2291 return ParseStream<parseFlags, SourceEncoding>(s);
2292 }
@ kParseInsituFlag
In-situ(destructive) parsing.
Definition: reader.h:149
Read-only string stream.
Definition: stream.h:110

References kParseInsituFlag, and RAPIDJSON_ASSERT.

◆ 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 2311 of file document.h.

2311 {
2312 RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2313 MemoryStream ms(reinterpret_cast<const char*>(str), length * sizeof(typename SourceEncoding::Ch));
2315 ParseStream<parseFlags, SourceEncoding>(is);
2316 return *this;
2317 }
Input byte stream wrapper with a statically bound encoding.
Definition: encodedstream.h:39
Represents an in-memory input byte stream.
Definition: memorystream.h:40

References kParseInsituFlag, and RAPIDJSON_ASSERT.

◆ ParseInsitu() [1/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags>
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::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.

Definition at line 2265 of file document.h.

2265 {
2267 return ParseStream<parseFlags | kParseInsituFlag>(s);
2268 }
A read-write string stream.
Definition: stream.h:144

◆ ParseInsitu() [2/2]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::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.

Definition at line 2274 of file document.h.

2274 {
2275 return ParseInsitu<kParseDefaultFlags>(str);
2276 }

◆ 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

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.

Definition at line 2222 of file document.h.

2222 {
2225 ClearStackOnExit scope(*this);
2226 parseResult_ = reader.template Parse<parseFlags>(is, *this);
2227 if (parseResult_) {
2228 RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2229 ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2230 }
2231 return *this;
2232 }
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition: reader.h:539
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:809
bool HasAllocator() const
Definition: stack.h:167
Allocator & GetAllocator()
Definition: stack.h:171

References internal::Stack< Allocator >::GetAllocator(), internal::Stack< Allocator >::GetSize(), internal::Stack< Allocator >::HasAllocator(), GenericValue< Encoding, Allocator >::operator=(), GenericDocument< Encoding, Allocator, StackAllocator >::parseResult_, RAPIDJSON_ASSERT, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

Here is the call 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

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.

Definition at line 2241 of file document.h.

2241 {
2242 return ParseStream<parseFlags, Encoding, InputStream>(is);
2243 }

◆ ParseStream() [3/3]

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<typename InputStream >
GenericDocument & GenericDocument< Encoding, Allocator, StackAllocator >::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.

Definition at line 2251 of file document.h.

2251 {
2252 return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2253 }

◆ Populate()

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

Populate this document by a generator which produces SAX events.

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 2202 of file document.h.

2202 {
2203 ClearStackOnExit scope(*this);
2204 if (g(*this)) {
2205 RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2206 ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2207 }
2208 return *this;
2209 }

References internal::Stack< Allocator >::GetSize(), GenericValue< Encoding, Allocator >::operator=(), RAPIDJSON_ASSERT, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

Here is the call 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 2408 of file document.h.

2408 {
2409 if (copy)
2410 new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2411 else
2412 new (stack_.template Push<ValueType>()) ValueType(str, length);
2413 return true;
2414 }

References GenericDocument< Encoding, Allocator, StackAllocator >::GetAllocator(), and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

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 2434 of file document.h.

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

References kArrayType, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ StartObject()

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

Definition at line 2424 of file document.h.

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

References kObjectType, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ 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 2416 of file document.h.

2416 {
2417 if (copy)
2418 new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2419 else
2420 new (stack_.template Push<ValueType>()) ValueType(str, length);
2421 return true;
2422 }

References GenericDocument< Encoding, Allocator, StackAllocator >::GetAllocator(), and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

Referenced by GenericDocument< Encoding, Allocator, StackAllocator >::Key().

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

Exchange the contents of this document with those of another.

Parameters
rhsAnother document.
Note
Constant complexity.
See also
GenericValue::Swap

Definition at line 2169 of file document.h.

2169 {
2170 ValueType::Swap(rhs);
2171 stack_.Swap(rhs.stack_);
2175 return *this;
2176 }
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT
Definition: stack.h:89
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition: swap.h:33

References GenericDocument< Encoding, Allocator, StackAllocator >::allocator_, GenericDocument< Encoding, Allocator, StackAllocator >::ownAllocator_, GenericDocument< Encoding, Allocator, StackAllocator >::parseResult_, GenericDocument< Encoding, Allocator, StackAllocator >::stack_, internal::Stack< Allocator >::Swap(), and internal::Swap().

Here is the call 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 2403 of file document.h.

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

References process_bag::i, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

◆ Uint64()

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

Definition at line 2405 of file document.h.

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

References process_bag::i, and GenericDocument< Encoding, Allocator, StackAllocator >::stack_.

Friends And Related Function Documentation

◆ GenericValue

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

Definition at line 2396 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

free-standing swap function helper

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:2194
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1121
See also
Swap()

Definition at line 2194 of file document.h.

2194{ a.Swap(b); }

Member Data Documentation

◆ allocator_

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
Allocator* GenericDocument< Encoding, Allocator, StackAllocator >::allocator_
private

◆ kDefaultStackCapacity

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
const size_t GenericDocument< Encoding, Allocator, StackAllocator >::kDefaultStackCapacity = 1024
staticprivate

Definition at line 2461 of file document.h.

◆ ownAllocator_

template<typename Encoding , typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
Allocator* GenericDocument< Encoding, Allocator, StackAllocator >::ownAllocator_
private

◆ parseResult_

◆ stack_


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