![]() |
XII Release 0.1.0
|
#include <JSONParser.h>
Public Member Functions | |
| xiiJSONParser () | |
| Constructor. | |
| void | SetLogInterface (xiiLogInterface *pLog) |
| Allows to specify a xiiLogInterface through which errors and warnings are reported. | |
Protected Member Functions | |
| void | SetInputStream (xiiStreamReader &stream, xiiUInt32 uiFirstLineOffset=0) |
| Resets the parser to the start state and configures it to read from the given stream. | |
| bool | ContinueParsing () |
| void | ParseAll () |
| Calls ContinueParsing() in a loop until that returns false. | |
| void | SkipObject () |
| void | SkipArray () |
| void | ParsingError (xiiStringView sMessage, bool bFatal) |
| Outputs that a parsing error was detected (via OnParsingError) and stops further parsing, if bFatal is set to true. | |
Protected Attributes | |
| xiiLogInterface * | m_pLogInterface = nullptr |
Private Member Functions | |
| virtual bool | OnVariable (xiiStringView sVarName)=0 |
| virtual void | OnReadValue (xiiStringView sValue)=0 |
| virtual void | OnReadValue (double fValue)=0 |
| virtual void | OnReadValue (bool bValue)=0 |
| virtual void | OnReadValueNULL ()=0 |
| virtual void | OnBeginObject ()=0 |
| virtual void | OnEndObject ()=0 |
| Called when the end of an object is encountered. | |
| virtual void | OnBeginArray ()=0 |
| virtual void | OnEndArray ()=0 |
| Called when the end of an array is encountered. | |
| virtual void | OnParsingError (xiiStringView sMessage, bool bFatal, xiiUInt32 uiLine, xiiUInt32 uiColumn) |
A low level JSON parser that can incrementally parse the structure of a JSON document.
The document structure is returned through virtual functions that need to be overridden.
| xiiJSONParser::xiiJSONParser | ( | ) |
Constructor.
Copyright (c) Theophilus Eriata. All Rights Reserved.
|
protected |
Does one parsing step.
While this function returns true, the document has not been parsed completely. This function may call any of the OnSomething functions through which the structure of the document is obtained. This function calls at most one such callback, but there is no guarantee that it calls any at all, it might just advance its internal state.
|
privatepure virtual |
Called when a new array is encountered.
Directly following a call to OnVariable(), this means the variable is of type 'array' (and has a name). In between calls to OnBeginArray() and OnEndArray() it is another value in the array.
Implemented in xiiJSONReader.
|
privatepure virtual |
Called when a new object is encountered.
Directly following a call to OnVariable(), this means the variable is of type 'object' (and has a name). In between calls to OnBeginArray() and OnEndArray() it is another value in the array.
Implemented in xiiJSONReader.
|
privatepure virtual |
Called when the end of an array is encountered.
Implemented in xiiJSONReader.
|
privatepure virtual |
Called when the end of an object is encountered.
Implemented in xiiJSONReader.
|
inlineprivatevirtual |
Called when something unexpected is encountered in the JSON document.
The error message describes what was expected and what was encountered. If bFatal is true, the error has left the parser in an unrecoverable state and thus it not continue parsing. In that case client code will need to clean up it's open state, as no further OnEndObject() / OnEndArray() will be called. If bFatal is false, the document does not contain valid JSON, but the parser is able to continue still.
Reimplemented in xiiJSONReader.
|
privatepure virtual |
Called whenever a new value is read.
Directly following a call to OnVariable(), this means that the variable is a simple variable. In between calls to OnBeginArray() and OnEndArray() it is another value in the array.
Implemented in xiiJSONReader.
|
privatepure virtual |
Called whenever a new value is read.
Directly following a call to OnVariable(), this means that the variable is a simple variable. In between calls to OnBeginArray() and OnEndArray() it is another value in the array.
Implemented in xiiJSONReader.
|
privatepure virtual |
Called whenever a new value is read.
Directly following a call to OnVariable(), this means that the variable is a simple variable. In between calls to OnBeginArray() and OnEndArray() it is another value in the array.
Implemented in xiiJSONReader.
|
privatepure virtual |
Called whenever a new value is read.
Directly following a call to OnVariable(), this means that the variable is a simple variable. In between calls to OnBeginArray() and OnEndArray() it is another value in the array.
Implemented in xiiJSONReader.
|
privatepure virtual |
Called whenever a new variable is encountered. The variable name is passed along. At this point the type of the variable (simple, array, object) is not yet determined.
The entire variable (independent of whether it is a simple value, an array or an object) can be skipped by returning false.
Implemented in xiiJSONReader.
|
protected |
Skips the rest of the currently open array. No OnEndArray() and OnEndObject() calls will be done for this object, cleanup must be done manually.
|
protected |
Skips the rest of the currently open object. No OnEndArray() and OnEndObject() calls will be done for this object, cleanup must be done manually.