SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator. More...
#include <reader.h>
Public Types | |
typedef SourceEncoding::Ch | Ch |
SourceEncoding character type. | |
Public Member Functions | |
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... | |
bool | HasParseError () const |
Whether a parse error has occured in the last parsing. | |
ParseErrorCode | GetParseErrorCode () const |
Get the ParseErrorCode of last parsing. | |
size_t | GetErrorOffset () const |
Get the position of last parsing error in input, 0 otherwise. | |
Protected Member Functions | |
void | SetParseError (ParseErrorCode code, size_t offset) |
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.
|
inline |
Constructor.
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) |
|
inline |
Parse JSON text.
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. |
|
inline |
Parse JSON text (with kParseDefaultFlags)
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. |