| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #pragma once
- #include <functional>
- #include <optional>
- #include <jvalidate/detail/reference.h>
- #include <jvalidate/detail/vocabulary.h>
- #include <jvalidate/forward.h>
- namespace jvalidate::detail {
- template <Adapter A> class ReferenceManager;
- template <Adapter A> struct ParserContext {
- using Object = decltype(std::declval<A>().as_object());
- Schema & root;
- A schema;
- Vocabulary<A> const * vocab;
- ReferenceManager<A> & ref;
- std::optional<Object> parent = std::nullopt;
- Reference where = {};
- Reference dynamic_where = {};
- ParserContext rebind(A const & new_schema, Reference const & new_loc, Reference const & new_dyn,
- std::optional<Object> parent = std::nullopt) const {
- return {root, new_schema, vocab, ref, parent, new_loc, new_dyn};
- }
- ParserContext child(A const & child, std::string const & key) const {
- return rebind(child, where / key, dynamic_where / key, schema.as_object());
- }
- ParserContext child(A const & child, size_t index) const {
- return rebind(child, where / index, dynamic_where / index);
- }
- ParserContext neighbor(std::string const & key) const {
- return rebind((*parent)[key], where.parent() / key, dynamic_where.parent() / key, parent);
- }
- schema::Node const * node() const;
- schema::Node const * always() const;
- schema::Node const * fixed_schema(bool accept) const;
- };
- }
|