All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
rapidjson::GenericDocument< Encoding, Allocator, StackAllocator > Class Template Reference

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

#include <document.h>

Inheritance diagram for rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >:
rapidjson::GenericValue< Encoding, Allocator >

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 rapidjson::GenericValue< Encoding, Allocator >
enum  {
  kBoolFlag = 0x100, kNumberFlag = 0x200, kIntFlag = 0x400, kUintFlag = 0x800,
  kInt64Flag = 0x1000, kUint64Flag = 0x2000, kDoubleFlag = 0x4000, kStringFlag = 0x100000,
  kCopyFlag = 0x200000, kInlineStrFlag = 0x400000, 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 = 0xFF
}
 
typedef GenericMember< Encoding, AllocatorMember
 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...
 

Public Member Functions

 GenericDocument (Allocator *allocator=0, size_t stackCapacity=kDefaultStackCapacity, StackAllocator *stackAllocator=0)
 Constructor. More...
 
 ~GenericDocument ()
 
AllocatorGetAllocator ()
 Get the allocator of this document. More...
 
size_t GetStackCapacity () const
 Get the capacity of stack in bytes. More...
 
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, typename SourceEncoding >
GenericDocumentParseInsitu (Ch *str)
 Parse JSON text from a mutable string (with Encoding conversion) More...
 
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 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...
 
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...
 
- Public Member Functions inherited from rapidjson::GenericValue< Encoding, Allocator >
template<typename T >
 RAPIDJSON_DISABLEIF_RETURN ((internal::IsPointer< T >),(GenericValue &)) operator
 Assignment with primitive types. More...
 
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)
 Explicit copy constructor (with allocator) More...
 
template<typename T >
 GenericValue (T b, RAPIDJSON_ENABLEIF((internal::IsSame< T, bool >))) 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 (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 ()
 Destructor. More...
 

Private Member Functions

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 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)
 
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 , typename >
class GenericReader
 
template<typename , typename >
class GenericValue
 

Additional Inherited Members

- Public Attributes inherited from rapidjson::GenericValue< Encoding, Allocator >
Data data_
 
unsigned flags_
 
- Static Public Attributes inherited from rapidjson::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 rapidjson::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 1622 of file document.h.

Member Typedef Documentation

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

Allocator type from template parameter.

Definition at line 1626 of file document.h.

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

Character type derived from Encoding.

Definition at line 1624 of file document.h.

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

Value type of the document.

Definition at line 1625 of file document.h.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 1633 of file document.h.

1633  :
1634  allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
1635  {
1636  if (!allocator_)
1637  ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
1638  }
#define RAPIDJSON_NEW(x)
! customization point for global new
Definition: rapidjson.h:408
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::~GenericDocument ( )
inline

Definition at line 1655 of file document.h.

1655  {
1656  Destroy();
1657  }

Member Function Documentation

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

Definition at line 1831 of file document.h.

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

Definition at line 1868 of file document.h.

1868  {
1869  if (Allocator::kNeedFree)
1870  while (stack_.GetSize() > 0) // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects)
1871  (stack_.template Pop<ValueType>(1))->~ValueType();
1872  else
1873  stack_.Clear();
1874  stack_.ShrinkToFit();
1875  }
size_t GetSize() const
Definition: stack.h:133
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
void rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::Destroy ( )
inlineprivate

Definition at line 1877 of file document.h.

1877  {
1879  }
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition: rapidjson.h:412
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::Double ( double  d)
inlineprivate

Definition at line 1836 of file document.h.

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

Definition at line 1858 of file document.h.

1858  {
1859  ValueType* elements = stack_.template Pop<ValueType>(elementCount);
1860  stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());
1861  return true;
1862  }
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:1809
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
void SetArrayRaw(GenericValue *values, SizeType count, Allocator &allocator)
Definition: document.h:1541
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::EndObject ( SizeType  memberCount)
inlineprivate

Definition at line 1850 of file document.h.

1850  {
1851  typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);
1852  stack_.template Top<ValueType>()->SetObjectRaw(members, (SizeType)memberCount, GetAllocator());
1853  return true;
1854  }
void SetObjectRaw(Member *members, SizeType count, Allocator &allocator)
Initialize this value as object with initial data, without calling destructor.
Definition: document.h:1549
unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:247
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:1809
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
GenericMember< Encoding, Allocator > Member
Name-value pair in an object.
Definition: document.h:424
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
Allocator& rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::GetAllocator ( )
inline

Get the allocator of this document.

Definition at line 1809 of file document.h.

1809 { return *allocator_; }
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
size_t rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::GetErrorOffset ( ) const
inline

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

Definition at line 1804 of file document.h.

1804 { return parseResult_.Offset(); }
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition: error.h:115
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
ParseErrorCode rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::GetParseError ( ) const
inline

Get the ParseErrorCode of last parsing.

Definition at line 1801 of file document.h.

1801 { return parseResult_.Code(); }
ParseErrorCode Code() const
Get the error code.
Definition: error.h:113
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
size_t rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::GetStackCapacity ( ) const
inline

Get the capacity of stack in bytes.

Definition at line 1812 of file document.h.

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

Whether a parse error has occured in the last parsing.

Definition at line 1798 of file document.h.

1798 { return parseResult_.IsError(); }
bool IsError() const
Whether the result is an error.
Definition: error.h:120
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::Int ( int  i)
inlineprivate

Definition at line 1832 of file document.h.

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

Definition at line 1834 of file document.h.

1834 { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::Key ( const Ch str,
SizeType  length,
bool  copy 
)
inlineprivate

Definition at line 1848 of file document.h.

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

Definition at line 1830 of file document.h.

1830 { new (stack_.template Push<ValueType>()) ValueType(); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument& rapidjson::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& rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::Parse ( const 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 1771 of file document.h.

1771  {
1772  RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));
1773  GenericStringStream<SourceEncoding> s(str);
1774  return ParseStream<parseFlags, SourceEncoding>(s);
1775  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:269
In-situ(destructive) parsing.
Definition: reader.h:129
static const double s
Definition: Units.h:99
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags>
GenericDocument& rapidjson::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 1782 of file document.h.

1782  {
1783  return Parse<parseFlags, Encoding>(str);
1784  }
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument& rapidjson::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 1789 of file document.h.

1789  {
1790  return Parse<kParseDefaultFlags>(str);
1791  }
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename SourceEncoding >
GenericDocument& rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::ParseInsitu ( Ch str)
inline

Parse JSON text from a mutable string (with Encoding conversion)

Template Parameters
parseFlagsCombination of ParseFlag.
SourceEncodingTranscoding from input Encoding
Parameters
strMutable zero-terminated string to be parsed.
Returns
The document itself for fluent API.

Definition at line 1738 of file document.h.

1738  {
1739  GenericInsituStringStream<Encoding> s(str);
1740  return ParseStream<parseFlags | kParseInsituFlag, SourceEncoding>(s);
1741  }
static const double s
Definition: Units.h:99
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags>
GenericDocument& rapidjson::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 1749 of file document.h.

1749  {
1750  return ParseInsitu<parseFlags, Encoding>(str);
1751  }
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
GenericDocument& rapidjson::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 1757 of file document.h.

1757  {
1758  return ParseInsitu<kParseDefaultFlags, Encoding>(str);
1759  }
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename SourceEncoding , typename InputStream >
GenericDocument& rapidjson::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 1694 of file document.h.

1694  {
1695  ValueType::SetNull(); // Remove existing root if exist
1696  GenericReader<SourceEncoding, Encoding, Allocator> reader(&GetAllocator());
1697  ClearStackOnExit scope(*this);
1698  parseResult_ = reader.template Parse<parseFlags>(is, *this);
1699  if (parseResult_) {
1700  RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object
1701  this->RawAssign(*stack_.template Pop<ValueType>(1)); // Add this-> to prevent issue 13.
1702  }
1703  return *this;
1704  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:269
void RawAssign(GenericValue &rhs) RAPIDJSON_NOEXCEPT
Assignment without calling destructor.
Definition: document.h:1581
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:1809
size_t GetSize() const
Definition: stack.h:133
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream >
GenericDocument& rapidjson::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 1713 of file document.h.

1713  {
1714  return ParseStream<parseFlags,Encoding,InputStream>(is);
1715  }
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
template<typename InputStream >
GenericDocument& rapidjson::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 1723 of file document.h.

1723  {
1724  return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);
1725  }
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::StartArray ( )
inlineprivate

Definition at line 1856 of file document.h.

1856 { new (stack_.template Push<ValueType>()) ValueType(kArrayType); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::StartObject ( )
inlineprivate

Definition at line 1846 of file document.h.

1846 { new (stack_.template Push<ValueType>()) ValueType(kObjectType); return true; }
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::String ( const Ch str,
SizeType  length,
bool  copy 
)
inlineprivate

Definition at line 1838 of file document.h.

1838  {
1839  if (copy)
1840  new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());
1841  else
1842  new (stack_.template Push<ValueType>()) ValueType(str, length);
1843  return true;
1844  }
Allocator & GetAllocator()
Get the allocator of this document.
Definition: document.h:1809
GenericValue< Encoding, Allocator > ValueType
Value type of the document.
Definition: document.h:1625
internal::Stack< StackAllocator > stack_
Definition: document.h:1884
T copy(T const &v)
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>
bool rapidjson::GenericDocument< Encoding, Allocator, StackAllocator >::Uint ( unsigned  i)
inlineprivate

Definition at line 1833 of file document.h.

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

Definition at line 1835 of file document.h.

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

Friends And Related Function Documentation

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

Definition at line 1826 of file document.h.

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

Definition at line 1827 of file document.h.

Member Data Documentation

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

Definition at line 1882 of file document.h.

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

Definition at line 1881 of file document.h.

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

Definition at line 1883 of file document.h.

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

Definition at line 1885 of file document.h.

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

Definition at line 1884 of file document.h.


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