Unserialize a JSON document into a Value.
More...
|
enum | TokenType {
tokenEndOfStream = 0,
tokenObjectBegin,
tokenObjectEnd,
tokenArrayBegin,
tokenArrayEnd,
tokenString,
tokenInteger,
tokenDouble,
tokenTrue,
tokenFalse,
tokenNull,
tokenArraySeparator,
tokenMemberSeparator,
tokenComment,
tokenError
} |
|
using | Errors = std::deque< ErrorInfo > |
|
using | Nodes = std::stack< Value * > |
|
|
bool | expectToken (TokenType type, Token &token, const char *message) |
|
bool | readToken (Token &token) |
|
void | skipSpaces () |
|
bool | match (Location pattern, int patternLength) |
|
bool | readComment () |
|
bool | readCStyleComment () |
|
bool | readCppStyleComment () |
|
bool | readString () |
|
Reader::TokenType | readNumber () |
|
bool | readValue (unsigned depth) |
|
bool | readObject (Token &token, unsigned depth) |
|
bool | readArray (Token &token, unsigned depth) |
|
bool | decodeNumber (Token &token) |
|
bool | decodeString (Token &token) |
|
bool | decodeString (Token &token, std::string &decoded) |
|
bool | decodeDouble (Token &token) |
|
bool | decodeUnicodeCodePoint (Token &token, Location ¤t, Location end, unsigned int &unicode) |
|
bool | decodeUnicodeEscapeSequence (Token &token, Location ¤t, Location end, unsigned int &unicode) |
|
bool | addError (std::string const &message, Token &token, Location extra=0) |
|
bool | recoverFromError (TokenType skipUntilToken) |
|
bool | addErrorAndRecover (std::string const &message, Token &token, TokenType skipUntilToken) |
|
void | skipUntilSpace () |
|
Value & | currentValue () |
|
Char | getNextChar () |
|
void | getLocationLineAndColumn (Location location, int &line, int &column) const |
|
std::string | getLocationLineAndColumn (Location location) const |
|
void | skipCommentTokens (Token &token) |
|
Unserialize a JSON document into a Value.
Definition at line 36 of file json_reader.h.
◆ Char
◆ Location
◆ Errors
◆ Nodes
◆ TokenType
Enumerator |
---|
tokenEndOfStream | |
tokenObjectBegin | |
tokenObjectEnd | |
tokenArrayBegin | |
tokenArrayEnd | |
tokenString | |
tokenInteger | |
tokenDouble | |
tokenTrue | |
tokenFalse | |
tokenNull | |
tokenArraySeparator | |
tokenMemberSeparator | |
tokenComment | |
tokenError | |
Definition at line 93 of file json_reader.h.
◆ Reader()
Constructs a Reader allowing all features for parsing.
◆ parse() [1/4]
Read a Value from a JSON document.
- Parameters
-
document | UTF-8 encoded string containing the document to read. |
root | [out] Contains the root value of the document if it was successfully parsed. |
- Returns
true
if the document was successfully parsed, false
if an error occurred.
Definition at line 74 of file json_reader.cpp.
◆ parse() [2/4]
bool Json::Reader::parse |
( |
const char * |
beginDoc, |
|
|
const char * |
endDoc, |
|
|
Value & |
root |
|
) |
| |
Read a Value from a JSON document.
- Parameters
-
document | UTF-8 encoded string containing the document to read. |
root | [out] Contains the root value of the document if it was successfully parsed. |
- Returns
true
if the document was successfully parsed, false
if an error occurred.
Definition at line 98 of file json_reader.cpp.
◆ parse() [3/4]
◆ parse() [4/4]
template<class BufferSequence >
bool Json::Reader::parse |
( |
Value & |
root, |
|
|
BufferSequence const & |
bs |
|
) |
| |
Read a Value from a JSON buffer sequence.
- Parameters
-
root | [out] Contains the root value of the document if it was successfully parsed. |
UTF-8 | encoded buffer sequence. |
- Returns
true
if the buffer was successfully parsed, false
if an error occurred.
Definition at line 212 of file json_reader.h.
◆ getFormatedErrorMessages()
std::string Json::Reader::getFormatedErrorMessages |
( |
| ) |
const |
Returns a user friendly string that list errors in the parsed document.
- Returns
- Formatted error message with the list of errors with their location in the parsed document. An empty string is returned if no error occurred during parsing.
Definition at line 931 of file json_reader.cpp.
◆ expectToken()
bool Json::Reader::expectToken |
( |
TokenType |
type, |
|
|
Token & |
token, |
|
|
const char * |
message |
|
) |
| |
|
private |
◆ readToken()
bool Json::Reader::readToken |
( |
Token & |
token | ) |
|
|
private |
◆ skipSpaces()
void Json::Reader::skipSpaces |
( |
| ) |
|
|
private |
◆ match()
bool Json::Reader::match |
( |
Location |
pattern, |
|
|
int |
patternLength |
|
) |
| |
|
private |
◆ readComment()
bool Json::Reader::readComment |
( |
| ) |
|
|
private |
◆ readCStyleComment()
bool Json::Reader::readCStyleComment |
( |
| ) |
|
|
private |
◆ readCppStyleComment()
bool Json::Reader::readCppStyleComment |
( |
| ) |
|
|
private |
◆ readString()
bool Json::Reader::readString |
( |
| ) |
|
|
private |
◆ readNumber()
◆ readValue()
bool Json::Reader::readValue |
( |
unsigned |
depth | ) |
|
|
private |
◆ readObject()
bool Json::Reader::readObject |
( |
Token & |
token, |
|
|
unsigned |
depth |
|
) |
| |
|
private |
◆ readArray()
bool Json::Reader::readArray |
( |
Token & |
token, |
|
|
unsigned |
depth |
|
) |
| |
|
private |
◆ decodeNumber()
bool Json::Reader::decodeNumber |
( |
Token & |
token | ) |
|
|
private |
◆ decodeString() [1/2]
bool Json::Reader::decodeString |
( |
Token & |
token | ) |
|
|
private |
◆ decodeString() [2/2]
◆ decodeDouble()
bool Json::Reader::decodeDouble |
( |
Token & |
token | ) |
|
|
private |
◆ decodeUnicodeCodePoint()
bool Json::Reader::decodeUnicodeCodePoint |
( |
Token & |
token, |
|
|
Location & |
current, |
|
|
Location |
end, |
|
|
unsigned int & |
unicode |
|
) |
| |
|
private |
◆ decodeUnicodeEscapeSequence()
bool Json::Reader::decodeUnicodeEscapeSequence |
( |
Token & |
token, |
|
|
Location & |
current, |
|
|
Location |
end, |
|
|
unsigned int & |
unicode |
|
) |
| |
|
private |
◆ addError()
◆ recoverFromError()
bool Json::Reader::recoverFromError |
( |
TokenType |
skipUntilToken | ) |
|
|
private |
◆ addErrorAndRecover()
◆ skipUntilSpace()
void Json::Reader::skipUntilSpace |
( |
| ) |
|
|
private |
◆ currentValue()
Value & Json::Reader::currentValue |
( |
| ) |
|
|
private |
◆ getNextChar()
◆ getLocationLineAndColumn() [1/2]
void Json::Reader::getLocationLineAndColumn |
( |
Location |
location, |
|
|
int & |
line, |
|
|
int & |
column |
|
) |
| const |
|
private |
◆ getLocationLineAndColumn() [2/2]
◆ skipCommentTokens()
void Json::Reader::skipCommentTokens |
( |
Token & |
token | ) |
|
|
private |
◆ nest_limit
constexpr unsigned Json::Reader::nest_limit {25} |
|
staticconstexpr |
◆ nodes_
Nodes Json::Reader::nodes_ |
|
private |
◆ errors_
◆ document_
◆ begin_
◆ end_
◆ current_
◆ lastValueEnd_
◆ lastValue_
Value* Json::Reader::lastValue_ |
|
private |