GenericReader
Engine/source/persistence/rapidjson/reader.h
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Classes:
Private Types
IterativeParsingState { IterativeParsingFinishState = 0 IterativeParsingErrorState IterativeParsingStartState IterativeParsingObjectInitialState IterativeParsingMemberKeyState IterativeParsingMemberValueState IterativeParsingObjectFinishState IterativeParsingArrayInitialState IterativeParsingElementState IterativeParsingArrayFinishState IterativeParsingValueState IterativeParsingElementDelimiterState IterativeParsingMemberDelimiterState IterativeParsingKeyValueDelimiterState cIterativeParsingStateCount }
Token { LeftBracketToken = 0 RightBracketToken LeftCurlyBracketToken RightCurlyBracketToken CommaToken ColonToken StringToken FalseToken TrueToken NullToken NumberToken kTokenCount }
Public Types
SourceEncoding::Ch
Ch
SourceEncoding character type.
Private Static Attributes
const size_t
Default stack capacity in bytes for storing a single decoded string.
Private Attributes
internal::Stack< StackAllocator >
A stack for storing decoded string temporarily during non-destructive parsing.
IterativeParsingState
Public Functions
GenericReader(StackAllocator * stackAllocator, size_t stackCapacity)
Constructor.
size_t
Get the position of last parsing error in input, 0 otherwise.
Get the ParseErrorCode of last parsing.
bool
Whether a parse error has occurred in the last parsing.
RAPIDJSON_FORCEINLINE bool
Check if token-by-token parsing JSON text is complete.
Initialize JSON text token-by-token parsing.
bool
IterativeParseNext(InputStream & is, Handler & handler)
Parse one token from JSON text.
Parse JSON text (with kParseDefaultFlags)
Protected Functions
SetParseError(ParseErrorCode code, size_t offset)
Private Functions
HandleError(IterativeParsingState src, InputStream & is)
RAPIDJSON_FORCEINLINE bool
IsIterativeParsingCompleteState(IterativeParsingState s)
RAPIDJSON_FORCEINLINE bool
IsIterativeParsingDelimiterState(IterativeParsingState s)
IterativeParse(InputStream & is, Handler & handler)
ParseArray(InputStream & is, Handler & handler)
ParseFalse(InputStream & is, Handler & handler)
unsigned
ParseHex4(InputStream & is, size_t escapeOffset)
ParseNumber(InputStream & is, Handler & handler)
ParseObject(InputStream & is, Handler & handler)
ParseString(InputStream & is, Handler & handler, bool isKey)
RAPIDJSON_FORCEINLINE void
ParseStringToStream(InputStream & is, OutputStream & os)
ParseValue(InputStream & is, Handler & handler)
SkipWhitespaceAndComments(InputStream & is)
Private Static Functions
RAPIDJSON_FORCEINLINE bool
Consume(InputStream & is, typename InputStream::Ch expect)
RAPIDJSON_FORCEINLINE void
ScanCopyUnescapedString(InputStream & , OutputStream & )
Detailed Description
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
GenericReader parses JSON text from a stream, and send events synchronously to an object implementing Handler concept.
It needs to allocate a stack for storing a single decoded string during non-destructive parsing.
For in-situ parsing, the decoded string is directly written to the source text string, no temporary buffer is required.
A GenericReader object can be reused for parsing multiple JSON text.
Parameters:
SourceEncoding | Encoding of the input stream. |
TargetEncoding | Encoding of the parse output. |
StackAllocator | Allocator type for stack. |
Private Types
IterativeParsingState
Enumerator
- IterativeParsingFinishState = 0
- IterativeParsingErrorState
- IterativeParsingStartState
- IterativeParsingObjectInitialState
- IterativeParsingMemberKeyState
- IterativeParsingMemberValueState
- IterativeParsingObjectFinishState
- IterativeParsingArrayInitialState
- IterativeParsingElementState
- IterativeParsingArrayFinishState
- IterativeParsingValueState
- IterativeParsingElementDelimiterState
- IterativeParsingMemberDelimiterState
- IterativeParsingKeyValueDelimiterState
- cIterativeParsingStateCount
Token
Enumerator
- LeftBracketToken = 0
- RightBracketToken
- LeftCurlyBracketToken
- RightCurlyBracketToken
- CommaToken
- ColonToken
- StringToken
- FalseToken
- TrueToken
- NullToken
- NumberToken
- kTokenCount
Public Types
typedef SourceEncoding::Ch Ch
SourceEncoding character type.
Private Static Attributes
const size_t kDefaultStackCapacity
Default stack capacity in bytes for storing a single decoded string.
Private Attributes
ParseResult parseResult_
internal::Stack< StackAllocator > stack_
A stack for storing decoded string temporarily during non-destructive parsing.
IterativeParsingState state_
Public Functions
GenericReader(StackAllocator * stackAllocator, size_t stackCapacity)
Constructor.
Parameters:
stackAllocator | Optional allocator for allocating stack memory. (Only use for non-destructive parsing) |
stackCapacity | stack capacity in bytes for storing a single decoded string. (Only use for non-destructive parsing) |
GetErrorOffset()
Get the position of last parsing error in input, 0 otherwise.
GetParseErrorCode()
Get the ParseErrorCode of last parsing.
HasParseError()
Whether a parse error has occurred in the last parsing.
IterativeParseComplete()
Check if token-by-token parsing JSON text is complete.
Whether the JSON has been fully decoded.
IterativeParseInit()
Initialize JSON text token-by-token parsing.
IterativeParseNext(InputStream & is, Handler & handler)
Parse one token from JSON text.
Parameters:
InputStream | Type of input stream, implementing Stream concept |
Handler | Type of handler, implementing Handler concept. |
is | Input stream to be parsed. |
handler | The handler to receive events. |
Whether the parsing is successful.
Parse(InputStream & is, Handler & handler)
Parse JSON text.
Parameters:
parseFlags | Combination of ParseFlag. |
InputStream | Type of input stream, implementing Stream concept. |
Handler | Type of handler, implementing Handler concept. |
is | Input stream to be parsed. |
handler | The handler to receive events. |
Whether the parsing is successful.
Parse(InputStream & is, Handler & handler)
Parse JSON text (with kParseDefaultFlags)
Parameters:
InputStream | Type of input stream, implementing Stream concept |
Handler | Type of handler, implementing Handler concept. |
is | Input stream to be parsed. |
handler | The handler to receive events. |
Whether the parsing is successful.
Protected Functions
SetParseError(ParseErrorCode code, size_t offset)
Private Functions
GenericReader(const GenericReader & )
ClearStack()
HandleError(IterativeParsingState src, InputStream & is)
IsIterativeParsingCompleteState(IterativeParsingState s)
IsIterativeParsingDelimiterState(IterativeParsingState s)
IterativeParse(InputStream & is, Handler & handler)
operator=(const GenericReader & )
ParseArray(InputStream & is, Handler & handler)
ParseFalse(InputStream & is, Handler & handler)
ParseHex4(InputStream & is, size_t escapeOffset)
ParseNull(InputStream & is, Handler & handler)
ParseNumber(InputStream & is, Handler & handler)
ParseObject(InputStream & is, Handler & handler)
ParseString(InputStream & is, Handler & handler, bool isKey)
ParseStringToStream(InputStream & is, OutputStream & os)
ParseTrue(InputStream & is, Handler & handler)
ParseValue(InputStream & is, Handler & handler)
Predict(IterativeParsingState state, Token token)
SkipWhitespaceAndComments(InputStream & is)
Tokenize(Ch c)
Transit(IterativeParsingState src, Token token, IterativeParsingState dst, InputStream & is, Handler & handler)
Private Static Functions
Consume(InputStream & is, typename InputStream::Ch expect)
ScanCopyUnescapedString(InputStream & , OutputStream & )