Explorar el Código

refactor: move ConstraintFactory into ReferenceManager for vocabulary support

Sam Jaffe hace 1 año
padre
commit
d72d27c53e
Se han modificado 2 ficheros con 6 adiciones y 5 borrados
  1. 5 4
      include/jvalidate/detail/reference_manager.h
  2. 1 1
      include/jvalidate/schema.h

+ 5 - 4
include/jvalidate/detail/reference_manager.h

@@ -24,6 +24,7 @@ public:
   using Keywords = std::unordered_map<std::string_view, std::set<schema::Wraps>>;
 
 private:
+  ConstraintFactory<A> const & constraints_;
   DocumentCache<A> & external_;
   ReferenceCache references_;
 
@@ -34,9 +35,9 @@ private:
 
 public:
   ReferenceManager(DocumentCache<A> & external, A const & root, schema::Version version,
-                   Keywords const & keywords)
-      : external_(external), roots_{{{}, root}} {
-    prime(root, {}, version, keywords);
+                   ConstraintFactory<A> const & constraints)
+      : external_(external), constraints_(constraints), roots_{{{}, root}} {
+    prime(root, {}, version, constraints_.keywords(version));
   }
 
   auto dynamic_scope(Reference const & ref) {
@@ -57,7 +58,7 @@ public:
 
     // TODO(samjaffe): Change Versions if needed...
     references_.emplace(ref.uri());
-    prime(*external, ref, context.version, context.factory.keywords(context.version));
+    prime(*external, ref, context.version, constraints_.keywords(context.version));
 
     // May have a sub-id that we map to
     if (auto it = roots_.find(ref.root()); it != roots_.end()) {

+ 1 - 1
include/jvalidate/schema.h

@@ -112,7 +112,7 @@ public:
       return;
     }
 
-    detail::ReferenceManager<A> ref(external, json, version, factory.keywords(version));
+    detail::ReferenceManager<A> ref(external, json, version, factory);
     detail::ParserContext<A> root{*this, json, version, factory, ref};
 
     root.where = root.dynamic_where = ref.canonicalize({}, {}, false);