Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
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 >:
GenericValue< Encoding, Allocator >

Classes

struct  ClearStackOnExit
 

Public Types

typedef Encoding::Ch Ch
 Character type derived from Encoding. More...
 
typedef GenericValue< Encoding, Allocator > ValueType
 Value type of the document. More...
 
typedef Allocator AllocatorType
 Allocator type from template parameter. More...
 
- Public Types inherited from GenericValue< Encoding, Allocator >
enum  {
  kBoolFlag = 0x0008, kNumberFlag = 0x0010, kIntFlag = 0x0020, kUintFlag = 0x0040,
  kInt64Flag = 0x0080, kUint64Flag = 0x0100, kDoubleFlag = 0x0200, kStringFlag = 0x0400,
  kCopyFlag = 0x0800, kInlineStrFlag = 0x1000, kNullFlag = kNullType, kTrueFlag = kTrueType | kBoolFlag,
  kFalseFlag = kFalseType | kBoolFlag, kNumberIntFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag, kNumberUintFlag = kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag, kNumberInt64Flag = kNumberType | kNumberFlag | kInt64Flag,
  kNumberUint64Flag = kNumberType | kNumberFlag | kUint64Flag, kNumberDoubleFlag = kNumberType | kNumberFlag | kDoubleFlag, kNumberAnyFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag, kConstStringFlag = kStringType | kStringFlag,
  kCopyStringFlag = kStringType | kStringFlag | kCopyFlag, kShortStringFlag = kStringType | kStringFlag | kCopyFlag | kInlineStrFlag, kObjectFlag = kObjectType, kArrayFlag = kArrayType,
  kTypeMask = 0x07
}
 
typedef GenericMember< Encoding, Allocator > Member
 Name-value pair in an object. More...
 
typedef Encoding EncodingType
 Encoding type from template parameter. More...
 
typedef Allocator 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, Allocator >::Iterator MemberIterator
 Member iterator for iterating in object. More...
 
typedef GenericMemberIterator< true, Encoding, Allocator >::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, Allocator > ValueType
 Value type of itself. More...
 
typedef GenericArray< false, ValueTypeArray
 
typedef GenericArray< true, ValueTypeConstArray
 
typedef GenericObject< false, ValueTypeObject
 
typedef GenericObject< true, ValueTypeConstObject
 

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...
 
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 >
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 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, Allocator >
template<typename T >
 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, Allocator &allocator)
 
void SetObjectRaw (Member *members, SizeType count, 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, 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...
 
template<typename SourceAllocator >
bool StringEqual (const GenericValue< Encoding, SourceAllocator > &rhs) const
 
GenericValueoperator= (GenericValue &rhs) RAPIDJSON_NOEXCEPT
 Assignment with move semantics. More...
 
GenericValueoperator= (StringRefType str) RAPIDJSON_NOEXCEPT
 Assignment of constant string reference (no copy) More...
 
 GenericValue () RAPIDJSON_NOEXCEPT
 Default constructor creates a null value. More...
 
 GenericValue (Type type) RAPIDJSON_NOEXCEPT
 Constructor with JSON value type. More...
 
template<typename SourceAllocator >
 GenericValue (const GenericValue< Encoding, SourceAllocator > &rhs, Allocator &allocator, bool copyConstStrings=false)
 Explicit copy constructor (with allocator) More...
 
template<typename T >
 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, Allocator &allocator)
 Constructor for copy-string (i.e. do make a copy of string) More...
 
 GenericValue (const Ch *s, 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...
 

Private Member Functions

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

Private Attributes

Allocator * allocator_
 
Allocator * ownAllocator_
 
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, Allocator >
Data data_
 
- Static Public Attributes inherited from GenericValue< Encoding, Allocator >
static const SizeType kDefaultArrayCapacity = 16
 
static const SizeType kDefaultObjectCapacity = 16
 

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

Member Typedef Documentation

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

Allocator type from template parameter.

Definition at line 2124 of file document.h.

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

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

Constructor & Destructor Documentation

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

2133  :
2134  GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2135  {
2136  if (!allocator_)
2137  ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2138  }
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:57
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition: rapidjson.h:601
Allocator * ownAllocator_
Definition: document.h:2496
ParseResult parseResult_
Definition: document.h:2498
static QCString type
Definition: declinfo.cpp:672
Allocator * allocator_
Definition: document.h:2495
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 2146 of file document.h.

2146  :
2147  allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
2148  {
2149  if (!allocator_)
2150  ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
2151  }
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition: rapidjson.h:601
Allocator * ownAllocator_
Definition: document.h:2496
ParseResult parseResult_
Definition: document.h:2498
Allocator * allocator_
Definition: document.h:2495
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument< Encoding, Allocator, StackAllocator >::~GenericDocument ( )
inline

Definition at line 2168 of file document.h.

2168  {
2169  Destroy();
2170  }
void Destroy()
Definition: document.h:2490
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

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

Definition at line 2434 of file document.h.

2434 { new (stack_.template Push<ValueType>()) ValueType(b); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
void GenericDocument< Encoding, Allocator, StackAllocator >::ClearStack ( )
inlineprivate

Definition at line 2481 of file document.h.

2481  {
2482  if (Allocator::kNeedFree)
2483  while (stack_.GetSize() > 0) // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects)
2484  (stack_.template Pop<ValueType>(1))->~ValueType();
2485  else
2486  stack_.Clear();
2487  stack_.ShrinkToFit();
2488  }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
void Clear()
Definition: stack.h:98
size_t GetSize() const
Definition: stack.h:177
void ShrinkToFit()
Definition: stack.h:100
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
void GenericDocument< Encoding, Allocator, StackAllocator >::Destroy ( )
inlineprivate

Definition at line 2490 of file document.h.

2490  {
2492  }
Allocator * ownAllocator_
Definition: document.h:2496
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition: rapidjson.h:605
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Double ( double  d)
inline

Definition at line 2439 of file document.h.

2439 { new (stack_.template Push<ValueType>()) ValueType(d); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::EndArray ( SizeType  elementCount)
inline

Definition at line 2469 of file document.h.

2469  {
2470  ValueType* elements = stack_.template Pop<ValueType>(elementCount);
2471  stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());
2472  return true;
2473  }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
void SetArrayRaw(GenericValue *values, SizeType count, Allocator &allocator)
Definition: document.h:2030
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:2408
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::EndObject ( SizeType  memberCount)
inline

Definition at line 2461 of file document.h.

2461  {
2462  typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
2463  stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount, GetAllocator());
2464  return true;
2465  }
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:578
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:2408
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
Definition: document.h:2043
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
Allocator& GenericDocument< Encoding, Allocator, StackAllocator >::GetAllocator ( )
inline

Get the allocator of this document.

Definition at line 2408 of file document.h.

2408  {
2410  return *allocator_;
2411  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Allocator * allocator_
Definition: document.h:2495
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 2390 of file document.h.

2390 { return parseResult_.Offset(); }
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition: error.h:118
ParseResult parseResult_
Definition: document.h:2498
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 2387 of file document.h.

2387 { return parseResult_.Code(); }
ParseResult parseResult_
Definition: document.h:2498
ParseErrorCode Code() const
Get the error code.
Definition: error.h:116
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 2414 of file document.h.

2414 { return stack_.GetCapacity(); }
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
size_t GetCapacity() const
Definition: stack.h:178
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::HasParseError ( ) const
inline

Whether a parse error has occurred in the last parsing.

Definition at line 2384 of file document.h.

2384 { return parseResult_.IsError(); }
ParseResult parseResult_
Definition: document.h:2498
bool IsError() const
Whether the result is an error.
Definition: error.h:123
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Int ( int  i)
inline

Definition at line 2435 of file document.h.

2435 { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Int64 ( int64_t  i)
inline

Definition at line 2437 of file document.h.

2437 { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
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 2459 of file document.h.

2459 { return String(str, length, copy); }
bool String(const Ch *str, SizeType length, bool copy)
Definition: document.h:2449
T copy(T const &v)
static QCString str
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Null ( )
inline

Definition at line 2433 of file document.h.

2433 { new (stack_.template Push<ValueType>()) ValueType(); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
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());

Definition at line 2404 of file document.h.

2404 { return parseResult_; }
ParseResult parseResult_
Definition: document.h:2498
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument& GenericDocument< Encoding, Allocator, StackAllocator >::operator= ( const GenericDocument< Encoding, Allocator, StackAllocator > &  )
private

Prohibit assignment.

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

2321  {
2322  RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2324  return ParseStream<parseFlags, SourceEncoding>(s);
2325  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Read-only string stream.
Definition: fwd.h:47
static QCString * s
Definition: config.cpp:1042
static QCString str
In-situ(destructive) parsing.
Definition: reader.h:147
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 2332 of file document.h.

2332  {
2333  return Parse<parseFlags, Encoding>(str);
2334  }
static QCString str
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 2339 of file document.h.

2339  {
2340  return Parse<kParseDefaultFlags>(str);
2341  }
static QCString str
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 2344 of file document.h.

2344  {
2345  RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
2346  MemoryStream ms(reinterpret_cast<const char*>(str), length * sizeof(typename SourceEncoding::Ch));
2348  ParseStream<parseFlags, SourceEncoding>(is);
2349  return *this;
2350  }
Represents an in-memory input byte stream.
Definition: memorystream.h:40
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Input byte stream wrapper with a statically bound encoding.
Definition: encodedstream.h:39
static const double ms
Definition: Units.h:99
static QCString str
In-situ(destructive) parsing.
Definition: reader.h:147
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 2353 of file document.h.

2353  {
2354  return Parse<parseFlags, Encoding>(str, length);
2355  }
static QCString str
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 2357 of file document.h.

2357  {
2358  return Parse<kParseDefaultFlags>(str, length);
2359  }
static QCString str
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 2298 of file document.h.

2298  {
2300  return ParseStream<parseFlags | kParseInsituFlag>(s);
2301  }
A read-write string stream.
Definition: fwd.h:52
static QCString * s
Definition: config.cpp:1042
static QCString str
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 2307 of file document.h.

2307  {
2308  return ParseInsitu<kParseDefaultFlags>(str);
2309  }
static QCString str
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 2255 of file document.h.

2255  {
2257  stack_.HasAllocator() ? &stack_.GetAllocator() : 0);
2258  ClearStackOnExit scope(*this);
2259  parseResult_ = reader.template Parse<parseFlags>(is, *this);
2260  if (parseResult_) {
2261  RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2262  ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2263  }
2264  return *this;
2265  }
static QCString scope
Definition: declinfo.cpp:668
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition: fwd.h:88
ParseResult parseResult_
Definition: document.h:2498
size_t GetSize() const
Definition: stack.h:177
Allocator & GetAllocator()
Definition: stack.h:171
bool HasAllocator() const
Definition: stack.h:167
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:833
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 2274 of file document.h.

2274  {
2275  return ParseStream<parseFlags, Encoding, InputStream>(is);
2276  }
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 2284 of file document.h.

2284  {
2285  return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
2286  }
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 2235 of file document.h.

2235  {
2236  ClearStackOnExit scope(*this);
2237  if (g(*this)) {
2238  RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
2239  ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document
2240  }
2241  return *this;
2242  }
static QCString scope
Definition: declinfo.cpp:668
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
static const double g
Definition: Units.h:144
size_t GetSize() const
Definition: stack.h:177
GenericValue & operator=(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment with move semantics.
Definition: document.h:833
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 2441 of file document.h.

2441  {
2442  if (copy)
2443  new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2444  else
2445  new (stack_.template Push<ValueType>()) ValueType(str, length);
2446  return true;
2447  }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:2408
T copy(T const &v)
static QCString str
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::StartArray ( )
inline

Definition at line 2467 of file document.h.

2467 { new (stack_.template Push<ValueType>()) ValueType(kArrayType); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
array
Definition: rapidjson.h:623
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::StartObject ( )
inline

Definition at line 2457 of file document.h.

2457 { new (stack_.template Push<ValueType>()) ValueType(kObjectType); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
object
Definition: rapidjson.h:622
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
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 2449 of file document.h.

2449  {
2450  if (copy)
2451  new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
2452  else
2453  new (stack_.template Push<ValueType>()) ValueType(str, length);
2454  return true;
2455  }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:2408
T copy(T const &v)
static QCString str
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 2202 of file document.h.

2202  {
2203  ValueType::Swap(rhs);
2204  stack_.Swap(rhs.stack_);
2208  return *this;
2209  }
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
Allocator * ownAllocator_
Definition: document.h:2496
ParseResult parseResult_
Definition: document.h:2498
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition: swap.h:33
Allocator * allocator_
Definition: document.h:2495
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT
Definition: stack.h:89
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Uint ( unsigned  i)
inline

Definition at line 2436 of file document.h.

2436 { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool GenericDocument< Encoding, Allocator, StackAllocator >::Uint64 ( uint64_t  i)
inline

Definition at line 2438 of file document.h.

2438 { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:2123
internal::Stack< StackAllocator > stack_
Definition: document.h:2497

Friends And Related Function Documentation

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

Definition at line 2429 of file document.h.

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);
// ...
}
See also
Swap()

Definition at line 2227 of file document.h.

2227 { a.Swap(b); }
GenericDocument & Swap(GenericDocument &rhs) RAPIDJSON_NOEXCEPT
Exchange the contents of this document with those of another.
Definition: document.h:2202

Member Data Documentation

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

Definition at line 2495 of file document.h.

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

Definition at line 2494 of file document.h.

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

Definition at line 2496 of file document.h.

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
ParseResult GenericDocument< Encoding, Allocator, StackAllocator >::parseResult_
private

Definition at line 2498 of file document.h.

template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
internal::Stack<StackAllocator> GenericDocument< Encoding, Allocator, StackAllocator >::stack_
private

Definition at line 2497 of file document.h.


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