Home | Libraries | People | FAQ | More |
trial::protocol::json::basic_reader — Incremental JSON reader.
// In header: <boost/libs/trial.protocol/include/trial/protocol/json/reader.hpp> template<typename CharT> class basic_reader { public: // types typedef unspecified value_type; typedef unspecified size_type; typedef unspecified view_type; // construct/copy/destruct basic_reader(const view_type &); basic_reader(const basic_reader &); // public member functions bool next(); bool next(token::code::value); size_type level() const noexcept; token::code::value code() const noexcept; token::symbol::value symbol() const noexcept; token::category::value category() const noexcept; std::error_code error() const noexcept; template<typename ReturnType> ReturnType value() const; const view_type & literal() const noexcept; const view_type & tail() const noexcept; };
Parse a JSON formatted input buffer incrementally. Incrementally means that the reader only parses enough of the input to identify the next token. The entire input has to be parsed by repeating parsing the next token until the end of the input.
basic_reader
public
construct/copy/destructbasic_reader(const view_type & view);Construct an incremental JSON reader.
The first token is automatically parsed.
The reader does not assume ownership of the view.
Parameters: |
|
basic_reader(const basic_reader & other);Copy-construct an incremental JSON reader.
Copies the internal parsing state from the input reader, and continues parsing independently from where the input reader had reached.
Parameters: |
|
basic_reader
public member functionsbool next();Parse the next token.
Returns: |
false if an error occurred or end-of-input was reached, true otherwise. |
bool next(token::code::value expect);Parse the next token if current token has a given value.
Parameters: |
|
||
Returns: |
false if current token does not have the expected value. |
size_type level() const noexcept;Get the current nesting level.
Keep track of the nesting level of containers. The outermost root level is 0.
Returns: |
The current nesting level. |
token::code::value code() const noexcept;Get the current token as a detailed code.
Returns: |
The code of the current token. |
token::symbol::value symbol() const noexcept;Get the current token as a symbol.
Returns: |
The symbol of the current token. |
token::category::value category() const noexcept;Get the current token as a category.
Returns: |
The category of the current token. |
std::error_code error() const noexcept;Get the current error.
The error code contains an error enumerator. If parsing did not result in an error, the json::no_error enumerator is used.
Returns: |
The current error code. |
template<typename ReturnType> ReturnType value() const;Converts the current value into ReturnType.
The following conversions are valid:
Convert a symbol::boolean token into bool.
Convert a symbol::integer token into an integral C++ type (expect bool.)
Convert a symbol::real token into a floating-point C++ type.
Convert a symbol::string token into std::string.
Returns: |
The converted value. |
Throws: |
json::error If requested type is incompatible with the current token. |
const view_type & literal() const noexcept;
Returns: |
A view of the current value before it is converted into its type. |
const view_type & tail() const noexcept;
Returns: |
A view of the remaining buffer. |