21#include <initializer_list>
38class reader_lookahead;
140 explicit reader(std::string_view source);
196 void validate() const;
205 bool owns_source() const noexcept;
243 template <typename TAstNode>
250 if (
auto matched = expect(TAstNode::type()); !matched)
251 return std::unexpected(matched.error());
253 return current().as<TAstNode>();
295 const
path& current_path() const;
319 bool next_token() noexcept;
391 bool next_structure() noexcept;
422 bool next_value() noexcept;
451 class impl_parse_index;
452 class impl_parse_index_owning;
454 class impl_value_owning;
456 template <typename TImpl, typename... TArgs>
457 explicit
reader(
std::in_place_type_t<TImpl>, TArgs&&...);
459 explicit
reader(
std::unique_ptr<impl> impl) noexcept;
465 friend class detail::reader_lookahead;
471 std::unique_ptr<impl> _impl;
566 std::default_sentinel_t end() const noexcept
568 return std::default_sentinel;
575 std::unique_ptr<impl> _impl;
608 iterator& operator++();
609 void operator++(
int) { ++*
this; }
614 friend bool operator==(
const iterator& self, std::default_sentinel_t)
noexcept
616 return self.at_end();
622 explicit iterator(impl* owner) noexcept :
626 bool at_end() const noexcept;
629 impl* _owner =
nullptr;
Utilities for directly dealing with a JSON AST.
Represents an entry in a JSON AST.
The JSON documents in one input, read one after another, each through a reader of its own.
friend bool operator==(const iterator &self, std::default_sentinel_t) noexcept
Is self at the end of its documents?
documents(std::string_view source, const parse_options &parse_options)
Read the documents in JSON source.
std::ptrdiff_t difference_type
What every iterator has to name, although stepping through documents never measures a distance.
documents(std::string &&source)
Read the documents in JSON source.
documents(std::string_view source)
Read the documents in JSON source.
documents(const char *source)
Read the documents in JSON source.
documents(std::istream &source, const parse_options &parse_options)
Read the documents in what is left of the source stream, as reader(std::istream&) reads one.
documents(documents &&) noexcept
Moving transfers the source and the position in it.
documents(std::string &&source, const parse_options &parse_options)
Read the documents in JSON source.
iterator() noexcept=default
Create an iterator which is already at the end.
documents(std::istream &source)
Read the documents in what is left of the source stream, as reader(std::istream&) reads one.
std::input_iterator_tag iterator_concept
What this models in C++20 terms: an input iterator, since each document is parsed onto the tape of th...
documents(const char *source, const parse_options &parse_options)
Read the documents in JSON source.
Represents the index of a parsed AST.
Configuration for various parsing options.
Represents an exact path in some JSON structure.
A reader instance reads from some form of JSON source (probably a string) and converts it into a JSON...
static reader from_value(const value &value)
Create a reader which reads from an in-memory value.
reader(std::string_view source, const parse_options &parse_options)
Create a reader which reads from JSON source.
reader(std::string &&source, const parse_options &parse_options)
Create a reader which reads from JSON source.
reader(std::istream &source)
Create a reader which reads JSON from what is left of the source stream, as parse(std::istream&) does...
reader(const char *source, const parse_options &parse_options)
Create a reader which reads from JSON source.
reader(parse_index index)
Create a reader which reads from the given index.
reader(std::string &&source)
Create a reader which reads from JSON source.
reader(std::istream &source, const parse_options &parse_options)
Create a reader which reads JSON from what is left of the source stream, as parse(std::istream&) does...
reader(std::string_view source)
Create a reader which reads from JSON source.
static reader from_value(value &&value)
Create a reader which reads from an in-memory value.
reader(const char *source)
Create a reader which reads from JSON source.
optional< const value & > current_value() const noexcept
Get the in-memory value this reader is positioned on, if it has one to lend.
reader(reader &&) noexcept
Moving a reader transfers its implementation, leaving the source moved-from: good is false and the ac...
Represents a single JSON value, which can be any one of a potential kind, each behaving slightly diff...
Copyright (c) 2014-2020 by Travis Gockel.
#define JSONV_NODISCARD
Warn if the caller discards the result of this function.
#define JSONV_PUBLIC
This function or class is part of the public API for JSON Voorhees.
ast_node_type
Marker type for an encountered token type.
Pulls in an implementation of optional.
typename detail::optional_type< T >::type optional
Represents a value that may or may not be present.