Simpleson
|
Value reader. More...
#include <json.h>
Public Types | |
enum | push_result { ACCEPTED , REJECTED , WHITESPACE } |
Public Member Functions | |
reader () | |
Reader constructor. | |
virtual void | clear () |
Resets the reader. More... | |
virtual push_result | push (const char next) |
virtual jtype::jtype | type () const |
Checks the value. More... | |
virtual bool | is_valid () const |
Checks if the stored value is valid. More... | |
virtual std::string | readout () const |
Returns the stored value. More... | |
virtual | ~reader () |
Destructor. | |
Protected Types | |
enum | string_reader_enum { STRING_EMPTY = 0 , STRING_OPENING_QUOTE , STRING_OPEN , STRING_ESCAPED , STRING_CODE_POINT_START , STRING_CODE_POINT_1 , STRING_CODE_POINT_2 , STRING_CODE_POINT_3 , STRING_CLOSED } |
Enumeration of the state machine for strings. More... | |
enum | number_reader_enum { NUMBER_EMPTY = 0 , NUMBER_OPEN_NEGATIVE , NUMBER_ZERO , NUMBER_INTEGER_DIGITS , NUMBER_DECIMAL , NUMBER_FRACTION_DIGITS , NUMBER_EXPONENT , NUMBER_EXPONENT_SIGN , NUMBER_EXPONENT_DIGITS } |
enum | array_reader_enum { ARRAY_EMPTY = 0 , ARRAY_OPEN_BRACKET , ARRAY_READING_VALUE , ARRAY_AWAITING_NEXT_LINE , ARRAY_CLOSED } |
enum | object_reader_enum { OBJECT_EMPTY = 0 , OBJECT_OPEN_BRACE , OBJECT_READING_ENTRY , OBJECT_AWAITING_NEXT_LINE , OBJECT_CLOSED } |
Protected Member Functions | |
push_result | push_string (const char next) |
Pushes a character to a string value. | |
push_result | push_array (const char next) |
Pushes a character to an array value. | |
push_result | push_object (const char next) |
Pushes a character to an object value. | |
push_result | push_number (const char next) |
Pushes a character to a number value. | |
push_result | push_boolean (const char next) |
Pushes a character to a boolean value. | |
push_result | push_null (const char next) |
Pushes a character to a null value. | |
template<typename T > | |
T | get_state () const |
Returns the stored state. More... | |
template<typename T > | |
void | set_state (const T state) |
Stores the reader state. More... | |
Protected Attributes | |
reader * | sub_reader |
The subreader used during reading. More... | |
Value reader.
|
protected |
|
protected |
|
protected |
|
protected |
Enumeration of the state machine for strings.
Enumerator | |
---|---|
STRING_EMPTY | No values have been read. |
STRING_OPENING_QUOTE | The opening quote has been read. Equivalant to STRING_OPEN, but used for debugging the state. |
STRING_OPEN | The opening quote has been read and the last character was not an escape character. |
STRING_ESCAPED | The last character was an reverse solidus (), indicating the next character should be a control character. |
STRING_CODE_POINT_START | An encoded unicode character is encountered. Expecting four following hex digits. |
STRING_CODE_POINT_1 | An encoded unicode character is encountered. Expecting three following hex digits (one has already been read). |
STRING_CODE_POINT_2 | An encoded unicode character is encountered. Expecting two following hex digits (two have already been read). |
STRING_CODE_POINT_3 | An encoded unicode character is encountered. Expecting one following hex digit (three has already been read). |
STRING_CLOSED | The closing quote has been read. Reading should cease. |
|
virtual |
Resets the reader.
Reimplemented in json::kvp_reader.
|
inlineprotected |
Returns the stored state.
This template is intended for use with string_reader_enum, number_reader_enum, array_reader_enum, and object_reader_enum
|
virtual |
Checks if the stored value is valid.
true
if the stored value is valid, false
otherwise Reimplemented in json::kvp_reader.
|
virtual |
\ brief Pushes a value to the back of the reader
next | the value to be pushed |
ACCEPTED
if the value was added to the reader, WHITESPACE
if the input was whitespace that was not stored, and REJECTED
is the input was invalid for the value type Reimplemented in json::kvp_reader.
|
inlinevirtual |
Returns the stored value.
Reimplemented in json::kvp_reader.
|
inlineprotected |
Stores the reader state.
This template is intended for use with string_reader_enum, number_reader_enum, array_reader_enum, and object_reader_enum
|
inlinevirtual |
Checks the value.
not_valid
if no value is stored
|
protected |
The subreader used during reading.
Arrays and objects will use a sub reader to store underlying values