#pragma once #include #include #include namespace jvalidate::detail { template class ReferenceManager; template struct ParserContext { using Object = decltype(std::declval().as_object()); Schema & root; A schema; schema::Version version; ConstraintFactory const & factory; ReferenceManager & ref; std::optional parent = std::nullopt; Reference where = {}; Reference dynamic_where = {}; ParserContext rebind(A const & new_schema, Reference const & new_loc, Reference const & new_dyn, std::optional 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; }; }