| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #pragma once
- #include <optional>
- #include <jvalidate/detail/reference.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;
- schema::Version version;
- ConstraintFactory<A> const & factory;
- 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, version, factory, 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;
- };
- }
|