JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
jsonv::parse_index Class Referencefinal

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_indexoperator= (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 &)
 

Detailed Description

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.

Member Typedef Documentation

◆ const_iterator

Constructor & Destructor Documentation

◆ parse_index()

jsonv::parse_index::parse_index ( parse_index &&  src)
inlinenoexcept

Definition at line 75 of file parse_index.hpp.

Member Function Documentation

◆ cbegin()

iterator jsonv::parse_index::cbegin ( ) const
inline

Definition at line 133 of file parse_index.hpp.

◆ cend()

iterator jsonv::parse_index::cend ( ) const
inline

Definition at line 136 of file parse_index.hpp.

◆ extract_tree()

value jsonv::parse_index::extract_tree ( const extract_options options) const
Parameters
optionsThe options used to control how values are extracted from this source. If unspecified, these will be extract_options::create_default().

◆ operator=()

parse_index & jsonv::parse_index::operator= ( parse_index &&  src)
inlinenoexcept

Definition at line 79 of file parse_index.hpp.

◆ parse()

static parse_index jsonv::parse_index::parse ( string_view  src,
const parse_options options,
optional< std::size_t >  initial_buffer_capacity 
)
static

Create an parse_index from the given src JSON.

Parameters
optionsThe options used to control parsing. If unspecified, these will be parse_options::create_default().
initial_buffer_capacityThe initial capacity of the underlying buffer. By default (nullopt), this will size the buffer according to the length of the src string.

◆ 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_errorif the parse was not successful. This will contain additional details about why the parse failed.
std::invalid_argumentif this instance was default-constructed or moved-from.

Friends And Related Symbol Documentation

◆ 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.


The documentation for this class was generated from the following file: