| 1234567891011121314151617181920212223242526272829303132 |
- #pragma once
- #include <optional>
- #include <jvalidate/detail/reference.h>
- #include <jvalidate/forward.h>
- namespace jvalidate {
- template <Adapter A> struct ParserContext {
- using Object = decltype(std::declval<A>().as_object());
- Schema & root;
- A schema;
- std::optional<Object> parent = std::nullopt;
- schema::Version version;
- detail::Reference where = {};
- ParserContext child(A const & child, std::string const & key) const {
- return {root, child, schema.as_object(), version, where / key};
- }
- ParserContext child(A const & child, size_t index) const {
- return {root, child, std::nullopt, version, where / index};
- }
- ParserContext neighbor(std::string const & key) const {
- return {root, (*parent)[key], parent, version, where.parent() / key};
- }
- schema::Node const * resolve(std::string_view uri) const;
- schema::Node const * node() const;
- };
- }
|