|
JSON Voorhees
Killer JSON for C++
|
Splits input into tokens, allowing traversal of JSON without verification. More...
#include <jsonv/tokenizer.hpp>
Classes | |
| struct | token |
| A representation of what this tokenizer has. More... | |
Public Types | |
| using | size_type = std::vector< char >::size_type |
Public Member Functions | |
| tokenizer (string_view input) | |
| Construct a tokenizer to read the given non-owned input. | |
| tokenizer (std::istream &input) | |
| Construct a tokenizer from the provided input. | |
| const string_view & | input () const |
| Get the input this instance is reading from. | |
| bool | next () |
| Attempt to go to the next token in the input stream. More... | |
| const token & | current () const |
Get the current token and its associated token_kind. More... | |
| void | buffer_reserve (size_type sz) |
Static Public Member Functions | |
| static size_type | min_buffer_size () |
| static void | set_min_buffer_size (size_type sz) |
Splits input into tokens, allowing traversal of JSON without verification.
This is the basis for JSON parsers.
An important thing to remember is a tokenizer does not perform any real validation of any kind beyond emitting a token_kind::unknown when it encounters complete garbage. What does this mean? Given the input string:
A tokenizer will emit token_kind::array_begin, token_kind::object_begin, token_kind::array_end and so on, even though it is illegal JSON. It is up to a higher-level construct to detect such failures.
Definition at line 99 of file tokenizer.hpp.
| void jsonv::tokenizer::buffer_reserve | ( | size_type | sz | ) |
| const token& jsonv::tokenizer::current | ( | ) | const |
Get the current token and its associated token_kind.
| std::logic_error | if next has not been called or if it returned false. |
|
static |
| bool jsonv::tokenizer::next | ( | ) |
Attempt to go to the next token in the input stream.
The contents of current will be cleared.
true if another token was obtained; false if we reached EOF or an I/O failure. Check input to see which.
|
static |