|
JSON Voorhees
Killer JSON for C++
|
Represents the index of a parsed AST. More...
#include <jsonv/parse_index.hpp>
Classes | |
| class | iterator |
Public Types | |
| using | const_iterator = iterator |
Public Member Functions | |
| parse_index () noexcept=default | |
| Creates an empty not-an-AST instance. | |
| parse_index (parse_index &&src) noexcept | |
| parse_index & | operator= (parse_index &&src) noexcept |
| void | reset () |
| Clear the contents of this instance. | |
| bool | success () const noexcept |
| Check if this instance represents a valid AST. | |
| operator bool () const noexcept | |
| See success. | |
| void | validate () const |
Validate that the parse was a success. | |
| iterator | begin () const |
| iterator | cbegin () const |
| iterator | end () const |
| iterator | cend () const |
| value | extract_tree (const extract_options &options) const |
| value | extract_tree () const |
Static Public Member Functions | |
| static parse_index | parse (string_view src, const parse_options &options, optional< std::size_t > initial_buffer_capacity) |
| static parse_index | parse (string_view src, optional< std::size_t > initial_buffer_capacity) |
| static parse_index | parse (string_view src, const parse_options &options) |
| static parse_index | parse (string_view src) |
Friends | |
| std::ostream & | operator<< (std::ostream &, const parse_index &) |
| std::string | to_string (const parse_index &) |
Represents the index of a parsed AST.
When combined with the original text, can be used to create a value. See parse_index::parse to construct instances from JSON source text.
Definition at line 27 of file parse_index.hpp.
Definition at line 69 of file parse_index.hpp.
|
inlinenoexcept |
Definition at line 75 of file parse_index.hpp.
|
inline |
Definition at line 133 of file parse_index.hpp.
|
inline |
Definition at line 136 of file parse_index.hpp.
| value jsonv::parse_index::extract_tree | ( | const extract_options & | options | ) | const |
| options | The options used to control how values are extracted from this source. If unspecified, these will be extract_options::create_default(). |
|
inlinenoexcept |
Definition at line 79 of file parse_index.hpp.
|
static |
Create an parse_index from the given src JSON.
| options | The options used to control parsing. If unspecified, these will be parse_options::create_default(). |
| initial_buffer_capacity | The initial capacity of the underlying buffer. By default (nullopt), this will size the buffer according to the length of the src string. |
|
noexcept |
Check if this instance represents a valid AST.
This will be false if the source JSON was not valid JSON text. This will also be false if this instance was default-constructed or moved-from.
jsonv::value will throw an exception. For example, if the value of a number exceeds the range of an int64_t. This is because JSON does not specify an acceptable range for numbers, but the storage of jsonv::value does. | void jsonv::parse_index::validate | ( | ) | const |
Validate that the parse was a success.
| parse_error | if the parse was not successful. This will contain additional details about why the parse failed. |
| std::invalid_argument | if this instance was default-constructed or moved-from. |
|
friend |
Get a string representation of the AST.
+-----------------—+-----—+ | ast_node_type | Output | +-----------------—+-----—+ | document_start | ^ | | document_end | $ | | object_begin | { | | object_end | } | | array_begin | [ | | array_end | ] | | string_canonical | s | | string_escaped | S | | key_canonical | k | | key_escaped | K | | literal_true | t | | literal_false | f | | literal_null | n | | integer | i | | decimal | d | | error | ! | +-----------------—+-----—+
This exists primarily for debugging purposes.