Represents the index of a parsed AST.
More...
#include <jsonv/parse_index.hpp>
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 29 of file parse_index.hpp.
◆ const_iterator
◆ parse_index()
◆ cbegin()
| iterator jsonv::parse_index::cbegin |
( |
| ) |
const |
|
inline |
◆ cend()
| iterator jsonv::parse_index::cend |
( |
| ) |
const |
|
inline |
◆ extract_tree() [1/2]
| value jsonv::parse_index::extract_tree |
( |
| ) |
const |
Build a value from the document this index holds.
Extraction is controlled by options where they are given, and by deserialize_options::create_default() where they are not.
- Exceptions
-
| parse_error | if the document holds no value, which is the case for source text that is empty, only whitespace or – with parse_options::comments – only comments. Such an index is a valid one (validate does not throw for it), but there is nothing to build a value from. The error is the input ending unexpectedly, at the end of the source text. |
◆ extract_tree() [2/2]
Build a value from the document this index holds.
Extraction is controlled by options where they are given, and by deserialize_options::create_default() where they are not.
- Exceptions
-
| parse_error | if the document holds no value, which is the case for source text that is empty, only whitespace or – with parse_options::comments – only comments. Such an index is a valid one (validate does not throw for it), but there is nothing to build a value from. The error is the input ending unexpectedly, at the end of the source text. |
◆ operator=()
◆ parse() [1/4]
| static parse_index jsonv::parse_index::parse |
( |
std::string_view |
src | ) |
|
|
static |
Create a parse_index from the given src JSON.
Parsing is controlled by options where they are given, and by parse_options::create_default() where they are not. The underlying buffer starts with an initial_buffer_capacity where one is given; without one, or when it is nullopt, the buffer is sized according to the length of the src string.
- Exceptions
-
| std::length_error | if a given initial_buffer_capacity is too large for the buffer's size in bytes to be represented in a std::size_t. |
◆ parse() [2/4]
Create a parse_index from the given src JSON.
Parsing is controlled by options where they are given, and by parse_options::create_default() where they are not. The underlying buffer starts with an initial_buffer_capacity where one is given; without one, or when it is nullopt, the buffer is sized according to the length of the src string.
- Exceptions
-
| std::length_error | if a given initial_buffer_capacity is too large for the buffer's size in bytes to be represented in a std::size_t. |
◆ parse() [3/4]
| static parse_index jsonv::parse_index::parse |
( |
std::string_view |
src, |
|
|
const parse_options & |
options, |
|
|
std::optional< std::size_t > |
initial_buffer_capacity |
|
) |
| |
|
static |
Create a parse_index from the given src JSON.
Parsing is controlled by options where they are given, and by parse_options::create_default() where they are not. The underlying buffer starts with an initial_buffer_capacity where one is given; without one, or when it is nullopt, the buffer is sized according to the length of the src string.
- Exceptions
-
| std::length_error | if a given initial_buffer_capacity is too large for the buffer's size in bytes to be represented in a std::size_t. |
◆ parse() [4/4]
| static parse_index jsonv::parse_index::parse |
( |
std::string_view |
src, |
|
|
std::optional< std::size_t > |
initial_buffer_capacity |
|
) |
| |
|
static |
Create a parse_index from the given src JSON.
Parsing is controlled by options where they are given, and by parse_options::create_default() where they are not. The underlying buffer starts with an initial_buffer_capacity where one is given; without one, or when it is nullopt, the buffer is sized according to the length of the src string.
- Exceptions
-
| std::length_error | if a given initial_buffer_capacity is too large for the buffer's size in bytes to be represented in a std::size_t. |
◆ success()
| bool jsonv::parse_index::success |
( |
| ) |
const |
|
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.
- Note
- Even if this returns true, it is possible that conversion to a
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.
◆ validate()
| void jsonv::parse_index::validate |
( |
| ) |
const |
Validate that the parse was a success.
- Exceptions
-
| 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. |
◆ operator<<
| std::ostream & operator<< |
( |
std::ostream & |
, |
|
|
const parse_index & |
|
|
) |
| |
|
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.
◆ to_string
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.
The documentation for this class was generated from the following file: