Unserialize a JSON document into a Value.
更多...
#include <reader.h>
|
| | Reader () |
| | Constructs a Reader allowing all features for parsing.
|
| |
| | Reader (const Features &features) |
| | Constructs a Reader allowing the specified feature set for parsing.
|
| |
| 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 (IStream &is, Value &root, bool collectComments=true) |
| | Parse from input stream.
|
| |
| String | getFormatedErrorMessages () const |
| | Returns a user friendly string that list errors in the parsed document.
|
| |
| String | getFormattedErrorMessages () const |
| | Returns a user friendly string that list errors in the parsed document.
|
| |
| std::vector< StructuredError > | getStructuredErrors () const |
| | Returns a vector of structured errors encountered while parsing.
|
| |
| bool | pushError (const Value &value, const String &message) |
| | Add a semantic error message.
|
| |
| bool | pushError (const Value &value, const String &message, const Value &extra) |
| | Add a semantic error message with extra context.
|
| |
| bool | good () const |
| | Return whether there are any errors.
|
| |
|
| enum | TokenType {
tokenEndOfStream = 0
, tokenObjectBegin
, tokenObjectEnd
, tokenArrayBegin
,
tokenArrayEnd
, tokenString
, tokenNumber
, tokenTrue
,
tokenFalse
, tokenNull
, tokenArraySeparator
, tokenMemberSeparator
,
tokenComment
, tokenError
} |
| |
| using | Errors = std::deque< ErrorInfo > |
| |
| using | Nodes = std::stack< Value * > |
| |
|
| bool | readToken (Token &token) |
| |
| void | skipSpaces () |
| |
| bool | match (const Char *pattern, int patternLength) |
| |
| bool | readComment () |
| |
| bool | readCStyleComment () |
| |
| bool | readCppStyleComment () |
| |
| bool | readString () |
| |
| void | readNumber () |
| |
| bool | readValue () |
| |
| bool | readObject (Token &token) |
| |
| bool | readArray (Token &token) |
| |
| bool | decodeNumber (Token &token) |
| |
| bool | decodeNumber (Token &token, Value &decoded) |
| |
| bool | decodeString (Token &token) |
| |
| bool | decodeString (Token &token, String &decoded) |
| |
| bool | decodeDouble (Token &token) |
| |
| bool | decodeDouble (Token &token, Value &decoded) |
| |
| bool | decodeUnicodeCodePoint (Token &token, Location ¤t, Location end, unsigned int &unicode) |
| |
| bool | decodeUnicodeEscapeSequence (Token &token, Location ¤t, Location end, unsigned int &unicode) |
| |
| bool | addError (const String &message, Token &token, Location extra=nullptr) |
| |
| bool | recoverFromError (TokenType skipUntilToken) |
| |
| bool | addErrorAndRecover (const String &message, Token &token, TokenType skipUntilToken) |
| |
| void | skipUntilSpace () |
| |
| Value & | currentValue () |
| |
| Char | getNextChar () |
| |
| void | getLocationLineAndColumn (Location location, int &line, int &column) const |
| |
| String | getLocationLineAndColumn (Location location) const |
| |
| void | addComment (Location begin, Location end, CommentPlacement placement) |
| |
| void | skipCommentTokens (Token &token) |
| |
Unserialize a JSON document into a Value.
- 弃用:
- Use CharReader and CharReaderBuilder.
◆ Char
◆ Errors
◆ Location
◆ Nodes
◆ TokenType
| 枚举值 |
|---|
| tokenEndOfStream | |
| tokenObjectBegin | |
| tokenObjectEnd | |
| tokenArrayBegin | |
| tokenArrayEnd | |
| tokenString | |
| tokenNumber | |
| tokenTrue | |
| tokenFalse | |
| tokenNull | |
| tokenArraySeparator | |
| tokenMemberSeparator | |
| tokenComment | |
| tokenError | |
◆ Reader() [1/2]
| nim_cpp_wrapper_util::Json::Reader::Reader |
( |
| ) |
|
Constructs a Reader allowing all features for parsing.
◆ Reader() [2/2]
| nim_cpp_wrapper_util::Json::Reader::Reader |
( |
const Features & |
features | ) |
|
Constructs a Reader allowing the specified feature set for parsing.
◆ addComment()
◆ addError()
| bool nim_cpp_wrapper_util::Json::Reader::addError |
( |
const String & |
message, |
|
|
Token & |
token, |
|
|
Location |
extra = nullptr |
|
) |
| |
|
private |
◆ addErrorAndRecover()
| bool nim_cpp_wrapper_util::Json::Reader::addErrorAndRecover |
( |
const String & |
message, |
|
|
Token & |
token, |
|
|
TokenType |
skipUntilToken |
|
) |
| |
|
private |
◆ containsNewLine()
◆ currentValue()
| Value & nim_cpp_wrapper_util::Json::Reader::currentValue |
( |
| ) |
|
|
private |
◆ decodeDouble() [1/2]
| bool nim_cpp_wrapper_util::Json::Reader::decodeDouble |
( |
Token & |
token | ) |
|
|
private |
◆ decodeDouble() [2/2]
| bool nim_cpp_wrapper_util::Json::Reader::decodeDouble |
( |
Token & |
token, |
|
|
Value & |
decoded |
|
) |
| |
|
private |
◆ decodeNumber() [1/2]
| bool nim_cpp_wrapper_util::Json::Reader::decodeNumber |
( |
Token & |
token | ) |
|
|
private |
◆ decodeNumber() [2/2]
| bool nim_cpp_wrapper_util::Json::Reader::decodeNumber |
( |
Token & |
token, |
|
|
Value & |
decoded |
|
) |
| |
|
private |
◆ decodeString() [1/2]
| bool nim_cpp_wrapper_util::Json::Reader::decodeString |
( |
Token & |
token | ) |
|
|
private |
◆ decodeString() [2/2]
| bool nim_cpp_wrapper_util::Json::Reader::decodeString |
( |
Token & |
token, |
|
|
String & |
decoded |
|
) |
| |
|
private |
◆ decodeUnicodeCodePoint()
| bool nim_cpp_wrapper_util::Json::Reader::decodeUnicodeCodePoint |
( |
Token & |
token, |
|
|
Location & |
current, |
|
|
Location |
end, |
|
|
unsigned int & |
unicode |
|
) |
| |
|
private |
◆ decodeUnicodeEscapeSequence()
| bool nim_cpp_wrapper_util::Json::Reader::decodeUnicodeEscapeSequence |
( |
Token & |
token, |
|
|
Location & |
current, |
|
|
Location |
end, |
|
|
unsigned int & |
unicode |
|
) |
| |
|
private |
◆ getFormatedErrorMessages()
| String nim_cpp_wrapper_util::Json::Reader::getFormatedErrorMessages |
( |
| ) |
const |
Returns a user friendly string that list errors in the parsed document.
- 返回
- 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.
- 弃用:
- Use getFormattedErrorMessages() instead (typo fix).
◆ getFormattedErrorMessages()
| String nim_cpp_wrapper_util::Json::Reader::getFormattedErrorMessages |
( |
| ) |
const |
Returns a user friendly string that list errors in the parsed document.
- 返回
- 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.
◆ getLocationLineAndColumn() [1/2]
| String nim_cpp_wrapper_util::Json::Reader::getLocationLineAndColumn |
( |
Location |
location | ) |
const |
|
private |
◆ getLocationLineAndColumn() [2/2]
| void nim_cpp_wrapper_util::Json::Reader::getLocationLineAndColumn |
( |
Location |
location, |
|
|
int & |
line, |
|
|
int & |
column |
|
) |
| const |
|
private |
◆ getNextChar()
| Reader::Char nim_cpp_wrapper_util::Json::Reader::getNextChar |
( |
| ) |
|
|
private |
◆ getStructuredErrors()
Returns a vector of structured errors encountered while parsing.
- 返回
- A (possibly empty) vector of StructuredError objects. Currently only one error can be returned, but the caller should tolerate multiple errors. This can occur if the parser recovers from a non-fatal parse error and then encounters additional errors.
◆ good()
| bool nim_cpp_wrapper_util::Json::Reader::good |
( |
| ) |
const |
Return whether there are any errors.
- 返回
true if there are no errors to report false if errors have occurred.
◆ match()
| bool nim_cpp_wrapper_util::Json::Reader::match |
( |
const Char * |
pattern, |
|
|
int |
patternLength |
|
) |
| |
|
private |
◆ normalizeEOL()
◆ parse() [1/3]
| bool nim_cpp_wrapper_util::Json::Reader::parse |
( |
const char * |
beginDoc, |
|
|
const char * |
endDoc, |
|
|
Value & |
root, |
|
|
bool |
collectComments = true |
|
) |
| |
Read a Value from a JSON document.
- 参数
-
| beginDoc | Pointer on the beginning of the UTF-8 encoded string of the document to read. |
| endDoc | Pointer on the end of the UTF-8 encoded string of the document to read. Must be >= beginDoc. |
| [out] | root | 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.
◆ parse() [2/3]
| bool nim_cpp_wrapper_util::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. |
| [out] | root | 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.
◆ parse() [3/3]
◆ pushError() [1/2]
| bool nim_cpp_wrapper_util::Json::Reader::pushError |
( |
const Value & |
value, |
|
|
const String & |
message |
|
) |
| |
Add a semantic error message.
- 参数
-
| value | JSON Value location associated with the error |
| message | The error message. |
- 返回
true if the error was successfully added, false if the Value offset exceeds the document size.
◆ pushError() [2/2]
| bool nim_cpp_wrapper_util::Json::Reader::pushError |
( |
const Value & |
value, |
|
|
const String & |
message, |
|
|
const Value & |
extra |
|
) |
| |
Add a semantic error message with extra context.
- 参数
-
| value | JSON Value location associated with the error |
| message | The error message. |
| extra | Additional JSON Value location to contextualize the error |
- 返回
true if the error was successfully added, false if either Value offset exceeds the document size.
◆ readArray()
| bool nim_cpp_wrapper_util::Json::Reader::readArray |
( |
Token & |
token | ) |
|
|
private |
◆ readComment()
| bool nim_cpp_wrapper_util::Json::Reader::readComment |
( |
| ) |
|
|
private |
◆ readCppStyleComment()
| bool nim_cpp_wrapper_util::Json::Reader::readCppStyleComment |
( |
| ) |
|
|
private |
◆ readCStyleComment()
| bool nim_cpp_wrapper_util::Json::Reader::readCStyleComment |
( |
| ) |
|
|
private |
◆ readNumber()
| void nim_cpp_wrapper_util::Json::Reader::readNumber |
( |
| ) |
|
|
private |
◆ readObject()
| bool nim_cpp_wrapper_util::Json::Reader::readObject |
( |
Token & |
token | ) |
|
|
private |
◆ readString()
| bool nim_cpp_wrapper_util::Json::Reader::readString |
( |
| ) |
|
|
private |
◆ readToken()
| bool nim_cpp_wrapper_util::Json::Reader::readToken |
( |
Token & |
token | ) |
|
|
private |
◆ readValue()
| bool nim_cpp_wrapper_util::Json::Reader::readValue |
( |
| ) |
|
|
private |
◆ recoverFromError()
| bool nim_cpp_wrapper_util::Json::Reader::recoverFromError |
( |
TokenType |
skipUntilToken | ) |
|
|
private |
◆ skipCommentTokens()
| void nim_cpp_wrapper_util::Json::Reader::skipCommentTokens |
( |
Token & |
token | ) |
|
|
private |
◆ skipSpaces()
| void nim_cpp_wrapper_util::Json::Reader::skipSpaces |
( |
| ) |
|
|
private |
◆ skipUntilSpace()
| void nim_cpp_wrapper_util::Json::Reader::skipUntilSpace |
( |
| ) |
|
|
private |
◆ begin_
| Location nim_cpp_wrapper_util::Json::Reader::begin_ {} |
|
private |
◆ collectComments_
| bool nim_cpp_wrapper_util::Json::Reader::collectComments_ {} |
|
private |
◆ commentsBefore_
| String nim_cpp_wrapper_util::Json::Reader::commentsBefore_ |
|
private |
◆ current_
| Location nim_cpp_wrapper_util::Json::Reader::current_ {} |
|
private |
◆ document_
| String nim_cpp_wrapper_util::Json::Reader::document_ |
|
private |
◆ end_
| Location nim_cpp_wrapper_util::Json::Reader::end_ {} |
|
private |
◆ errors_
| Errors nim_cpp_wrapper_util::Json::Reader::errors_ |
|
private |
◆ features_
| Features nim_cpp_wrapper_util::Json::Reader::features_ |
|
private |
◆ lastValue_
| Value* nim_cpp_wrapper_util::Json::Reader::lastValue_ {} |
|
private |
◆ lastValueEnd_
| Location nim_cpp_wrapper_util::Json::Reader::lastValueEnd_ {} |
|
private |
◆ nodes_
| Nodes nim_cpp_wrapper_util::Json::Reader::nodes_ |
|
private |
该类的文档由以下文件生成:
- D:/GitLab/builds/5sbaxrcd/0/nim-pc/california/nim-cross-platform-sdk/exports/wrapper/nim_wrapper_util/json/reader.h
- D:/GitLab/builds/5sbaxrcd/0/nim-pc/california/nim-cross-platform-sdk/exports/wrapper/nim_wrapper_util/json_reader.cpp