Unserialize a JSON document into a Value. More...
#include <reader.h>
Classes | |
class | ErrorInfo |
class | Token |
Public Types | |
typedef char | Char |
typedef const Char * | Location |
Public Member Functions | |
std::string | getFormatedErrorMessages () const |
Returns a user friendly string that list errors in the parsed document. | |
bool | parse (const std::string &document, Value &root, bool collectComments=true) |
Read a Value from a JSON document. | |
bool | parse (const char *beginDoc, const char *endDoc, Value &root, bool collectComments=true) |
Read a Value from a JSON document. | |
bool | parse (std::istream &is, Value &root, bool collectComments=true) |
Parse from input stream. | |
Reader () | |
Constructs a Reader allowing all features for parsing. | |
Reader (const Features &features) | |
Constructs a Reader allowing the specified feature set for parsing. | |
Private Types | |
typedef std::deque< ErrorInfo > | Errors |
typedef std::stack< Value * > | Nodes |
enum | TokenType { tokenEndOfStream = 0, tokenObjectBegin, tokenObjectEnd, tokenArrayBegin, tokenArrayEnd, tokenString, tokenNumber, tokenTrue, tokenFalse, tokenNull, tokenArraySeparator, tokenMemberSeparator, tokenComment, tokenError } |
Private Member Functions | |
void | addComment (Location begin, Location end, CommentPlacement placement) |
bool | addError (const std::string &message, Token &token, Location extra=0) |
bool | addErrorAndRecover (const std::string &message, Token &token, TokenType skipUntilToken) |
Value & | currentValue () |
bool | decodeDouble (Token &token) |
bool | decodeNumber (Token &token) |
bool | decodeString (Token &token) |
bool | decodeString (Token &token, std::string &decoded) |
bool | decodeUnicodeCodePoint (Token &token, Location ¤t, Location end, unsigned int &unicode) |
bool | decodeUnicodeEscapeSequence (Token &token, Location ¤t, Location end, unsigned int &unicode) |
bool | expectToken (TokenType type, Token &token, const char *message) |
void | getLocationLineAndColumn (Location location, int &line, int &column) const |
std::string | getLocationLineAndColumn (Location location) const |
Char | getNextChar () |
bool | match (Location pattern, int patternLength) |
bool | readArray (Token &token) |
bool | readComment () |
bool | readCppStyleComment () |
bool | readCStyleComment () |
void | readNumber () |
bool | readObject (Token &token) |
bool | readString () |
bool | readToken (Token &token) |
bool | readValue () |
bool | recoverFromError (TokenType skipUntilToken) |
void | skipCommentTokens (Token &token) |
void | skipSpaces () |
void | skipUntilSpace () |
Private Attributes | |
Location | begin_ |
bool | collectComments_ |
std::string | commentsBefore_ |
Location | current_ |
std::string | document_ |
Location | end_ |
Errors | errors_ |
Features | features_ |
Value * | lastValue_ |
Location | lastValueEnd_ |
Nodes | nodes_ |
typedef char Json::Reader::Char |
typedef std::deque<ErrorInfo> Json::Reader::Errors [private] |
typedef const Char* Json::Reader::Location |
typedef std::stack<Value *> Json::Reader::Nodes [private] |
enum Json::Reader::TokenType [private] |
Constructs a Reader allowing all features for parsing.
Definition at line 109 of file json_reader.cpp.
Json::Reader::Reader | ( | const Features & | features | ) |
Constructs a Reader allowing the specified feature set for parsing.
Definition at line 115 of file json_reader.cpp.
void Json::Reader::addComment | ( | Location | begin, |
Location | end, | ||
CommentPlacement | placement | ||
) | [private] |
Definition at line 406 of file json_reader.cpp.
bool Json::Reader::addError | ( | const std::string & | message, |
Token & | token, | ||
Location | extra = 0 |
||
) | [private] |
Definition at line 760 of file json_reader.cpp.
bool Json::Reader::addErrorAndRecover | ( | const std::string & | message, |
Token & | token, | ||
TokenType | skipUntilToken | ||
) | [private] |
Definition at line 791 of file json_reader.cpp.
Value & Json::Reader::currentValue | ( | ) | [private] |
Definition at line 801 of file json_reader.cpp.
bool Json::Reader::decodeDouble | ( | Token & | token | ) | [private] |
Definition at line 620 of file json_reader.cpp.
bool Json::Reader::decodeNumber | ( | Token & | token | ) | [private] |
Definition at line 582 of file json_reader.cpp.
bool Json::Reader::decodeString | ( | Token & | token | ) | [private] |
Definition at line 647 of file json_reader.cpp.
bool Json::Reader::decodeString | ( | Token & | token, |
std::string & | decoded | ||
) | [private] |
Definition at line 658 of file json_reader.cpp.
bool Json::Reader::decodeUnicodeCodePoint | ( | Token & | token, |
Location & | current, | ||
Location | end, | ||
unsigned int & | unicode | ||
) | [private] |
Definition at line 704 of file json_reader.cpp.
bool Json::Reader::decodeUnicodeEscapeSequence | ( | Token & | token, |
Location & | current, | ||
Location | end, | ||
unsigned int & | unicode | ||
) | [private] |
Definition at line 734 of file json_reader.cpp.
bool Json::Reader::expectToken | ( | TokenType | type, |
Token & | token, | ||
const char * | message | ||
) | [private] |
Definition at line 264 of file json_reader.cpp.
std::string Json::Reader::getFormatedErrorMessages | ( | ) | const |
Returns a user friendly string that list errors in the parsed document.
Definition at line 858 of file json_reader.cpp.
void Json::Reader::getLocationLineAndColumn | ( | Location | location, |
int & | line, | ||
int & | column | ||
) | const [private] |
Definition at line 817 of file json_reader.cpp.
std::string Json::Reader::getLocationLineAndColumn | ( | Location | location | ) | const [private] |
Definition at line 847 of file json_reader.cpp.
Reader::Char Json::Reader::getNextChar | ( | ) | [private] |
Definition at line 808 of file json_reader.cpp.
bool Json::Reader::match | ( | Location | pattern, |
int | patternLength | ||
) | [private] |
Definition at line 363 of file json_reader.cpp.
bool Json::Reader::parse | ( | const std::string & | document, |
Value & | root, | ||
bool | collectComments = true |
||
) |
Read a Value from a JSON document.
document | UTF-8 encoded string containing the document to read. |
root | [out] Contains the root value of the document if it was successfully parsed. |
collectComments | true to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false . |
true
if the document was successfully parsed, false
if an error occurred. Definition at line 122 of file json_reader.cpp.
bool Json::Reader::parse | ( | const char * | beginDoc, |
const char * | endDoc, | ||
Value & | root, | ||
bool | collectComments = true |
||
) |
Read a Value from a JSON document.
document | UTF-8 encoded string containing the document to read. |
root | [out] Contains the root value of the document if it was successfully parsed. |
collectComments | true to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false . |
true
if the document was successfully parsed, false
if an error occurred. Definition at line 151 of file json_reader.cpp.
bool Json::Reader::parse | ( | std::istream & | is, |
Value & | root, | ||
bool | collectComments = true |
||
) |
Parse from input stream.
Definition at line 134 of file json_reader.cpp.
bool Json::Reader::readArray | ( | Token & | token | ) | [private] |
Definition at line 539 of file json_reader.cpp.
bool Json::Reader::readComment | ( | ) | [private] |
Definition at line 378 of file json_reader.cpp.
bool Json::Reader::readCppStyleComment | ( | ) | [private] |
Definition at line 439 of file json_reader.cpp.
bool Json::Reader::readCStyleComment | ( | ) | [private] |
Definition at line 426 of file json_reader.cpp.
void Json::Reader::readNumber | ( | ) | [private] |
Definition at line 452 of file json_reader.cpp.
bool Json::Reader::readObject | ( | Token & | token | ) | [private] |
Definition at line 480 of file json_reader.cpp.
bool Json::Reader::readString | ( | ) | [private] |
Definition at line 464 of file json_reader.cpp.
bool Json::Reader::readToken | ( | Token & | token | ) | [private] |
Definition at line 274 of file json_reader.cpp.
bool Json::Reader::readValue | ( | ) | [private] |
Definition at line 195 of file json_reader.cpp.
bool Json::Reader::recoverFromError | ( | TokenType | skipUntilToken | ) | [private] |
Definition at line 774 of file json_reader.cpp.
void Json::Reader::skipCommentTokens | ( | Token & | token | ) | [private] |
Definition at line 246 of file json_reader.cpp.
void Json::Reader::skipSpaces | ( | ) | [private] |
Definition at line 349 of file json_reader.cpp.
void Json::Reader::skipUntilSpace | ( | ) | [private] |
Location Json::Reader::begin_ [private] |
bool Json::Reader::collectComments_ [private] |
std::string Json::Reader::commentsBefore_ [private] |
Location Json::Reader::current_ [private] |
std::string Json::Reader::document_ [private] |
Location Json::Reader::end_ [private] |
Errors Json::Reader::errors_ [private] |
Features Json::Reader::features_ [private] |
Value* Json::Reader::lastValue_ [private] |
Location Json::Reader::lastValueEnd_ [private] |
Nodes Json::Reader::nodes_ [private] |