|
| | GenericReader (StackAllocator *stackAllocator=0, size_t stackCapacity=kDefaultStackCapacity) |
| | Constructor. More...
|
| |
| template<unsigned parseFlags, typename InputStream , typename Handler > |
| ParseResult | Parse (InputStream &is, Handler &handler) |
| | Parse JSON text. More...
|
| |
| template<typename InputStream , typename Handler > |
| ParseResult | Parse (InputStream &is, Handler &handler) |
| | Parse JSON text (with kParseDefaultFlags) More...
|
| |
| void | IterativeParseInit () |
| | Initialize JSON text token-by-token parsing. More...
|
| |
| template<unsigned parseFlags, typename InputStream , typename Handler > |
| bool | IterativeParseNext (InputStream &is, Handler &handler) |
| | Parse one token from JSON text. More...
|
| |
| RAPIDJSON_FORCEINLINE bool | IterativeParseComplete () const |
| | Check if token-by-token parsing JSON text is complete. More...
|
| |
| bool | HasParseError () const |
| | Whether a parse error has occurred in the last parsing. More...
|
| |
| ParseErrorCode | GetParseErrorCode () const |
| | Get the ParseErrorCode of last parsing. More...
|
| |
| size_t | GetErrorOffset () const |
| | Get the position of last parsing error in input, 0 otherwise. More...
|
| |
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
class GenericReader< SourceEncoding, TargetEncoding, StackAllocator >
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.
- Template Parameters
-
| SourceEncoding | Encoding of the input stream. |
| TargetEncoding | Encoding of the parse output. |
| StackAllocator | Allocator type for stack. |
Definition at line 88 of file fwd.h.
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
| bool GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IterativeParseNext |
( |
InputStream & |
is, |
|
|
Handler & |
handler |
|
) |
| |
|
inline |
Parse one token from JSON text.
- Template Parameters
-
| InputStream | Type of input stream, implementing Stream concept |
| Handler | Type of handler, implementing Handler concept. |
- Parameters
-
| is | Input stream to be parsed. |
| handler | The handler to receive events. |
- Returns
- Whether the parsing is successful.
Definition at line 618 of file reader.h.
620 SkipWhitespaceAndComments<parseFlags>(is);
622 Token t = Tokenize(is.Peek());
623 IterativeParsingState n = Predict(state_, t);
624 IterativeParsingState d = Transit<parseFlags>(state_, t, n, is, handler);
629 if (d == IterativeParsingErrorState) {
630 HandleError(state_, is);
641 SkipWhitespaceAndComments<parseFlags>(is);
642 if (is.Peek() !=
'\0') {
644 HandleError(state_, is);
657 if (!IsIterativeParsingDelimiterState(n))
664 if (state_ != IterativeParsingFinishState) {
665 HandleError(state_, is);
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
After parsing a complete JSON root from stream, stop further processing the rest of stream...
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
#define RAPIDJSON_ASSERT(x)
Assertion.
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<typename InputStream , typename Handler >
| ParseResult GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Parse |
( |
InputStream & |
is, |
|
|
Handler & |
handler |
|
) |
| |
|
inline |
Parse JSON text (with kParseDefaultFlags)
- Template Parameters
-
| InputStream | Type of input stream, implementing Stream concept |
| Handler | Type of handler, implementing Handler concept. |
- Parameters
-
| is | Input stream to be parsed. |
| handler | The handler to receive events. |
- Returns
- Whether the parsing is successful.
Definition at line 598 of file reader.h.
599 return Parse<kParseDefaultFlags>(is, handler);