From 89fb7e8a8d2cb68437deef4dab90f0d197a52981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20K=C3=BChl?= Date: Sun, 2 Feb 2025 22:13:52 +0100 Subject: [PATCH] fixed compilation --- include/matador/object/schema.hpp | 10 +++++++--- include/matador/object/schema_node.hpp | 6 +++--- source/core/object/schema.cpp | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/matador/object/schema.hpp b/include/matador/object/schema.hpp index 932bcc9..5b87edc 100644 --- a/include/matador/object/schema.hpp +++ b/include/matador/object/schema.hpp @@ -21,13 +21,17 @@ public: utils::result attach(const std::string name, const std::string &parent = "") { auto node = schema_node::make_node(*this, name); - attach_node(node, parent); + auto result = attach_node(node, parent); + if (!result) { + return utils::failure(result.err()); + } + return utils::ok(); } template utils::result attach(const std::string name) { - // auto node = std::make_unique(*this); + auto node = schema_node::make_node(*this, name); return utils::ok(); } @@ -47,7 +51,7 @@ private: utils::result, utils::error> find_parent(const std::string &name) const; utils::result, utils::error> find_node(const std::string &name) const; - utils::result, utils::error> push_back_child(const node_ptr &parent, const node_ptr &child); + void push_back_child(const node_ptr &parent, const node_ptr &child); bool has_node(const std::type_index& index, const std::string &name) const; diff --git a/include/matador/object/schema_node.hpp b/include/matador/object/schema_node.hpp index 36aed05..0ba6722 100644 --- a/include/matador/object/schema_node.hpp +++ b/include/matador/object/schema_node.hpp @@ -14,7 +14,7 @@ class schema_node final { public: template < typename Type > static std::shared_ptr make_node(schema& tree, const std::string& name) { - return std::make_shared(tree, name, static_cast(nullptr)); + return std::shared_ptr(new schema_node(tree, name, static_cast(nullptr))); } schema_node(const schema_node& other) = delete; @@ -47,8 +47,8 @@ private: schema_node(schema& tree, std::string name, Type *obj) : schema_(tree) , info_(std::make_unique>(*this)) - , first_child_(std::make_shared(tree)) - , last_child_(std::make_shared(tree)) + , first_child_(std::shared_ptr(new schema_node(tree))) + , last_child_(std::shared_ptr(new schema_node(tree))) , name_(std::move(name)) { first_child_->next_sibling_ = last_child_; last_child_->previous_sibling_ = first_child_; diff --git a/source/core/object/schema.cpp b/source/core/object/schema.cpp index 5eb186d..bb41ac5 100644 --- a/source/core/object/schema.cpp +++ b/source/core/object/schema.cpp @@ -34,7 +34,7 @@ utils::result, utils::error> schema::attach_node(co } parent_node = *result; - result = push_back_child(root_, node); + push_back_child(root_, node); // if (!pk.is_null()) { // node->primary_key_ = pk; @@ -81,7 +81,8 @@ utils::result, utils::error> schema::find_node(cons } return utils::ok(i->second); } -utils::result, utils::error> schema::push_back_child(const node_ptr &parent, const node_ptr &child) { + +void schema::push_back_child(const node_ptr &parent, const node_ptr &child) { child->parent_ = parent; child->previous_sibling_ = parent->last_child_->previous_sibling_; child->next_sibling_ = parent->last_child_;