NCBI C++ ToolKit
|
Search Toolkit Book for rapidjson::GenericReader
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator. More...
#include <misc/jsonwrapp/rapidjson11/reader.h>
Classes | |
struct | ClearStackOnExit |
class | NumberStream |
class | NumberStream< InputStream, false, false > |
class | NumberStream< InputStream, true, false > |
class | NumberStream< InputStream, true, true > |
class | StackStream |
Public Types | |
typedef SourceEncoding::Ch | Ch |
SourceEncoding character type. More... | |
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. 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... | |
Protected Member Functions | |
void | SetParseError (ParseErrorCode code, size_t offset) |
Private Member Functions | |
GenericReader (const GenericReader &) | |
GenericReader & | operator= (const GenericReader &) |
void | ClearStack () |
template<unsigned parseFlags, typename InputStream > | |
void | SkipWhitespaceAndComments (InputStream &is) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseObject (InputStream &is, Handler &handler) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseArray (InputStream &is, Handler &handler) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseNull (InputStream &is, Handler &handler) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseTrue (InputStream &is, Handler &handler) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseFalse (InputStream &is, Handler &handler) |
template<typename InputStream > | |
unsigned | ParseHex4 (InputStream &is, size_t escapeOffset) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseString (InputStream &is, Handler &handler, bool isKey=false) |
template<unsigned parseFlags, typename SEncoding , typename TEncoding , typename InputStream , typename OutputStream > | |
RAPIDJSON_FORCEINLINE void | ParseStringToStream (InputStream &is, OutputStream &os) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseNumber (InputStream &is, Handler &handler) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
void | ParseValue (InputStream &is, Handler &handler) |
RAPIDJSON_FORCEINLINE Token | Tokenize (Ch c) |
RAPIDJSON_FORCEINLINE IterativeParsingState | Predict (IterativeParsingState state, Token token) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
RAPIDJSON_FORCEINLINE IterativeParsingState | Transit (IterativeParsingState src, Token token, IterativeParsingState dst, InputStream &is, Handler &handler) |
template<typename InputStream > | |
void | HandleError (IterativeParsingState src, InputStream &is) |
template<unsigned parseFlags, typename InputStream , typename Handler > | |
ParseResult | IterativeParse (InputStream &is, Handler &handler) |
Static Private Member Functions | |
template<typename InputStream > | |
static RAPIDJSON_FORCEINLINE bool | Consume (InputStream &is, typename InputStream::Ch expect) |
template<typename InputStream , typename OutputStream > | |
static RAPIDJSON_FORCEINLINE void | ScanCopyUnescapedString (InputStream &, OutputStream &) |
Private Attributes | |
internal::Stack< StackAllocator > | stack_ |
A stack for storing decoded string temporarily during non-destructive parsing. More... | |
ParseResult | parseResult_ |
Static Private Attributes | |
static const size_t | kDefaultStackCapacity = 256 |
Default stack capacity in bytes for storing a single decoded string. More... | |
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.
typedef SourceEncoding::Ch rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Ch |
|
private |
|
private |
|
private |
|
inline |
|
private |
|
inlineprivate |
|
inlinestaticprivate |
Definition at line 730 of file reader.h.
References expect, and RAPIDJSON_LIKELY.
|
inline |
|
inline |
Get the ParseErrorCode of last parsing.
|
inlineprivate |
Definition at line 1786 of file reader.h.
References rapidjson::kParseErrorArrayMissCommaOrSquareBracket, rapidjson::kParseErrorDocumentEmpty, rapidjson::kParseErrorDocumentRootNotSingular, rapidjson::kParseErrorObjectMissColon, rapidjson::kParseErrorObjectMissCommaOrCurlyBracket, rapidjson::kParseErrorObjectMissName, rapidjson::kParseErrorValueInvalid, RAPIDJSON_ASSERT, and RAPIDJSON_PARSE_ERROR.
|
inline |
|
inlineprivate |
Definition at line 1807 of file reader.h.
References rapidjson::ParseResult::Clear(), rapidjson::kParseStopWhenDoneFlag, n, and t.
|
private |
|
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. |
Definition at line 471 of file reader.h.
References rapidjson::kParseErrorDocumentEmpty, rapidjson::kParseErrorDocumentRootNotSingular, rapidjson::kParseIterativeFlag, rapidjson::kParseStopWhenDoneFlag, RAPIDJSON_PARSE_ERROR_NORETURN, and RAPIDJSON_UNLIKELY.
Referenced by CJson_Document::Walk().
|
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. |
|
inlineprivate |
Definition at line 643 of file reader.h.
References rapidjson::kParseErrorArrayMissCommaOrSquareBracket, rapidjson::kParseErrorTermination, rapidjson::kParseTrailingCommasFlag, RAPIDJSON_ASSERT, RAPIDJSON_PARSE_ERROR, and RAPIDJSON_UNLIKELY.
|
inlineprivate |
Definition at line 717 of file reader.h.
References rapidjson::kParseErrorTermination, rapidjson::kParseErrorValueInvalid, RAPIDJSON_ASSERT, RAPIDJSON_LIKELY, RAPIDJSON_PARSE_ERROR, and RAPIDJSON_UNLIKELY.
|
inlineprivate |
Definition at line 741 of file reader.h.
References i, rapidjson::kParseErrorStringUnicodeEscapeInvalidHex, and RAPIDJSON_PARSE_ERROR_NORETURN.
|
inlineprivate |
Definition at line 691 of file reader.h.
References rapidjson::kParseErrorTermination, rapidjson::kParseErrorValueInvalid, RAPIDJSON_ASSERT, RAPIDJSON_LIKELY, RAPIDJSON_PARSE_ERROR, and RAPIDJSON_UNLIKELY.
|
inlineprivate |
Definition at line 1118 of file reader.h.
References copy(), head, i, infinity, rapidjson::kParseErrorNumberMissExponent, rapidjson::kParseErrorNumberMissFraction, rapidjson::kParseErrorNumberTooBig, rapidjson::kParseErrorTermination, rapidjson::kParseErrorValueInvalid, rapidjson::kParseFullPrecisionFlag, rapidjson::kParseInsituFlag, rapidjson::kParseNanAndInfFlag, rapidjson::kParseNumbersAsStringsFlag, rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::StackStream< CharType >::Length(), minus(), rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::StackStream< CharType >::Pop(), rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::StackStream< CharType >::Put(), RAPIDJSON_ASSERT, RAPIDJSON_LIKELY, RAPIDJSON_PARSE_ERROR, RAPIDJSON_UINT64_C2, RAPIDJSON_UNLIKELY, str(), rapidjson::internal::StrtodFullPrecision(), and rapidjson::internal::StrtodNormalPrecision().
|
inlineprivate |
Definition at line 575 of file reader.h.
References rapidjson::kParseErrorObjectMissColon, rapidjson::kParseErrorObjectMissCommaOrCurlyBracket, rapidjson::kParseErrorObjectMissName, rapidjson::kParseErrorTermination, rapidjson::kParseTrailingCommasFlag, RAPIDJSON_ASSERT, RAPIDJSON_PARSE_ERROR, and RAPIDJSON_UNLIKELY.
|
inlineprivate |
Definition at line 794 of file reader.h.
References copy(), head, rapidjson::kParseErrorTermination, rapidjson::kParseInsituFlag, rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::StackStream< CharType >::Length(), rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::StackStream< CharType >::Pop(), RAPIDJSON_ASSERT, RAPIDJSON_PARSE_ERROR, RAPIDJSON_UNLIKELY, and str().
|
inlineprivate |
Definition at line 826 of file reader.h.
References Encode(), rapidjson::kParseErrorStringEscapeInvalid, rapidjson::kParseErrorStringInvalidEncoding, rapidjson::kParseErrorStringMissQuotationMark, rapidjson::kParseErrorStringUnicodeSurrogateInvalid, rapidjson::kParseValidateEncodingFlag, offset, RAPIDJSON_LIKELY, RAPIDJSON_PARSE_ERROR, RAPIDJSON_UNLIKELY, and Z16.
|
inlineprivate |
Definition at line 704 of file reader.h.
References rapidjson::kParseErrorTermination, rapidjson::kParseErrorValueInvalid, RAPIDJSON_ASSERT, RAPIDJSON_LIKELY, RAPIDJSON_PARSE_ERROR, and RAPIDJSON_UNLIKELY.
|
inlineprivate |
|
inlineprivate |
|
inlinestaticprivate |
|
inlineprotected |
|
inlineprivate |
Definition at line 546 of file reader.h.
References rapidjson::kParseCommentsFlag, rapidjson::kParseErrorUnspecificSyntaxError, RAPIDJSON_LIKELY, RAPIDJSON_PARSE_ERROR, RAPIDJSON_UNLIKELY, and rapidjson::SkipWhitespace().
|
inlineprivate |
|
inlineprivate |
Definition at line 1634 of file reader.h.
References rapidjson::kParseErrorObjectMissName, rapidjson::kParseErrorTermination, rapidjson::kParseErrorValueInvalid, rapidjson::kParseTrailingCommasFlag, n, RAPIDJSON_ASSERT, and RAPIDJSON_PARSE_ERROR_NORETURN.
|
staticprivate |
|
private |
|
private |