Torque3D Documentation / _generateds / GenericDocument

GenericDocument

Engine/source/persistence/rapidjson/document.h

A document for parsing JSON text as DOM.

More...

Classes:

Parse from stream

ParseStream(InputStream & is)

Parse JSON text from an input stream (with Encoding conversion)

ParseStream(InputStream & is)

Parse JSON text from an input stream.

ParseStream(InputStream & is)

Parse JSON text from an input stream (with kParseDefaultFlags)

Parse in-place from mutable string

ParseInsitu(Ch * str)

Parse JSON text from a mutable string.

ParseInsitu(Ch * str)

Parse JSON text from a mutable string (with kParseDefaultFlags)

Parse from read-only string

Parse(const typename SourceEncoding::Ch * str)

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

Parse(const Ch * str)

Parse JSON text from a read-only string.

Parse(const Ch * str)

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

Parse(const typename SourceEncoding::Ch * str, size_t length)
Parse(const Ch * str, size_t length)
Parse(const Ch * str, size_t length)

Handling parse errors

bool

Whether a parse error has occurred in the last parsing.

Get the ParseErrorCode of last parsing.

size_t

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

Implicit conversion to get the last parse result.

Public Types

AllocatorType 

Allocator type from template parameter.

Encoding::Ch
Ch 

Character type derived from Encoding.

ValueType 

Value type of the document.

Public Friends

free-standing swap function helper

Private Static Attributes

Public Functions

GenericDocument(Allocator * allocator, size_t stackCapacity, StackAllocator * stackAllocator)

Constructor.

GenericDocument(Type type, Allocator * allocator, size_t stackCapacity, StackAllocator * stackAllocator)

Constructor.

bool
Bool(bool b)
bool
Double(double d)
bool
EndArray(SizeType elementCount)
bool
EndObject(SizeType memberCount)

Get the allocator of this document.

size_t

Get the capacity of stack in bytes.

bool
Int(int i)
bool
bool
Key(const Ch * str, SizeType length, bool copy)
bool
Null()
Populate(Generator & g)

Populate this document by a generator which produces SAX events.

bool
RawNumber(const Ch * str, SizeType length, bool copy)
bool
bool
bool
String(const Ch * str, SizeType length, bool copy)

Exchange the contents of this document with those of another.

bool
Uint(unsigned i)
bool

Private Functions

Detailed Description

A document for parsing JSON text as DOM.

note:

implements Handler concept

Parameters:
Encoding

Encoding for both parsing and string storage.

Allocator

Allocator for allocating memory for the DOM

StackAllocator

Allocator for allocating memory for stack during parsing.

warning:

Although GenericDocument inherits from GenericValue, the API does not provide any virtual functions, especially no virtual destructor. To avoid memory leaks, do not

delete
a GenericDocument object via a pointer to a GenericValue.

Parse from stream

ParseStream(InputStream & is)

Parse JSON text from an input stream (with Encoding conversion)

Parameters:

parseFlags

Combination of ParseFlag.

SourceEncoding

Encoding of input stream

InputStream

Type of input stream, implementing Stream concept

Parameters:
is

Input stream to be parsed.

return:

The document itself for fluent API.

ParseStream(InputStream & is)

Parse JSON text from an input stream.

Parameters:

parseFlags

Combination of ParseFlag.

InputStream

Type of input stream, implementing Stream concept

Parameters:
is

Input stream to be parsed.

return:

The document itself for fluent API.

ParseStream(InputStream & is)

Parse JSON text from an input stream (with kParseDefaultFlags)

Parameters:

InputStream

Type of input stream, implementing Stream concept

Parameters:
is

Input stream to be parsed.

return:

The document itself for fluent API.

Parse in-place from mutable string

ParseInsitu(Ch * str)

Parse JSON text from a mutable string.

Parameters:

parseFlags

Combination of ParseFlag.

Parameters:
str

Mutable zero-terminated string to be parsed.

return:

The document itself for fluent API.

ParseInsitu(Ch * str)

Parse JSON text from a mutable string (with kParseDefaultFlags)

Parameters:

str

Mutable zero-terminated string to be parsed.

return:

The document itself for fluent API.

Parse from read-only string

Parse(const typename SourceEncoding::Ch * str)

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

Parameters:

parseFlags

Combination of ParseFlag (must not contain kParseInsituFlag).

SourceEncoding

Transcoding from input Encoding

Parameters:
str

Read-only zero-terminated string to be parsed.

Parse(const Ch * str)

Parse JSON text from a read-only string.

Parameters:

parseFlags

Combination of ParseFlag (must not contain kParseInsituFlag).

Parameters:
str

Read-only zero-terminated string to be parsed.

Parse(const Ch * str)

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

Parameters:

str

Read-only zero-terminated string to be parsed.

Parse(const typename SourceEncoding::Ch * str, size_t length)

Parse(const Ch * str, size_t length)

Parse(const Ch * str, size_t length)

Handling parse errors

HasParseError()

Whether a parse error has occurred in the last parsing.

GetParseError()

Get the ParseErrorCode of last parsing.

GetErrorOffset()

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

operator ParseResult()

Implicit conversion to get the last parse result.

return:

ParseResult of the last parse operation

Document doc;
ParseResult ok = doc.Parse(json);
if (!ok)
  printf( "JSON parse error: %s (%u)\n", GetParseError_En(ok.Code()), ok.Offset());

Public Types

typedef Allocator AllocatorType 

Allocator type from template parameter.

typedef Encoding::Ch Ch 

Character type derived from Encoding.

typedef GenericValue< Encoding, Allocator > ValueType 

Value type of the document.

Public Friends

Private Static Attributes

const size_t kDefaultStackCapacity 

Private Attributes

Allocator * allocator_ 
Allocator * ownAllocator_ 
ParseResult parseResult_ 
internal::Stack< StackAllocator > stack_ 

Public Functions

GenericDocument(Allocator * allocator, size_t stackCapacity, StackAllocator * stackAllocator)

Constructor.

Creates an empty document which type is Null. Parameters:

allocator

Optional allocator for allocating memory.

stackCapacity

Optional initial capacity of stack in bytes.

stackAllocator

Optional allocator for allocating memory for stack.

GenericDocument(Type type, Allocator * allocator, size_t stackCapacity, StackAllocator * stackAllocator)

Constructor.

Creates an empty document of specified type. Parameters:

type

Mandatory type of object to create.

allocator

Optional allocator for allocating memory.

stackCapacity

Optional initial capacity of stack in bytes.

stackAllocator

Optional allocator for allocating memory for stack.

~GenericDocument()

Bool(bool b)

Double(double d)

EndArray(SizeType elementCount)

EndObject(SizeType memberCount)

GetAllocator()

Get the allocator of this document.

GetStackCapacity()

Get the capacity of stack in bytes.

Int(int i)

Int64(int64_t i)

Key(const Ch * str, SizeType length, bool copy)

Null()

Populate(Generator & g)

Populate this document by a generator which produces SAX events.

Parameters:

Generator

A functor with

bool f(Handler)
prototype.

Parameters:
g

Generator functor which sends SAX events to the parameter.

return:

The document itself for fluent API.

RawNumber(const Ch * str, SizeType length, bool copy)

StartArray()

StartObject()

String(const Ch * str, SizeType length, bool copy)

Swap(GenericDocument & rhs)

Exchange the contents of this document with those of another.

Parameters:

rhs

Another document.

note:

Constant complexity.

see:

GenericValue::Swap

Uint(unsigned i)

Uint64(uint64_t i)

Private Functions

GenericDocument(const GenericDocument & )

Prohibit copying.

ClearStack()

Destroy()

operator=(const GenericDocument & )

Prohibit assignment.