fixed compilation
This commit is contained in:
@@ -21,13 +21,17 @@ public:
|
|||||||
utils::result<void, utils::error> attach(const std::string name, const std::string &parent = "") {
|
utils::result<void, utils::error> attach(const std::string name, const std::string &parent = "") {
|
||||||
auto node = schema_node::make_node<Type>(*this, name);
|
auto node = schema_node::make_node<Type>(*this, name);
|
||||||
|
|
||||||
attach_node(node, parent);
|
auto result = attach_node(node, parent);
|
||||||
|
if (!result) {
|
||||||
|
return utils::failure(result.err());
|
||||||
|
}
|
||||||
|
|
||||||
return utils::ok<void>();
|
return utils::ok<void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type, typename ParentType>
|
template <typename Type, typename ParentType>
|
||||||
utils::result<void, utils::error> attach(const std::string name) {
|
utils::result<void, utils::error> attach(const std::string name) {
|
||||||
// auto node = std::make_unique<schema_node>(*this);
|
auto node = schema_node::make_node<Type>(*this, name);
|
||||||
|
|
||||||
return utils::ok<void>();
|
return utils::ok<void>();
|
||||||
}
|
}
|
||||||
@@ -47,7 +51,7 @@ private:
|
|||||||
utils::result<std::shared_ptr<schema_node>, utils::error> find_parent(const std::string &name) const;
|
utils::result<std::shared_ptr<schema_node>, utils::error> find_parent(const std::string &name) const;
|
||||||
utils::result<std::shared_ptr<schema_node>, utils::error> find_node(const std::string &name) const;
|
utils::result<std::shared_ptr<schema_node>, utils::error> find_node(const std::string &name) const;
|
||||||
|
|
||||||
utils::result<std::shared_ptr<schema_node>, 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;
|
bool has_node(const std::type_index& index, const std::string &name) const;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class schema_node final {
|
|||||||
public:
|
public:
|
||||||
template < typename Type >
|
template < typename Type >
|
||||||
static std::shared_ptr<schema_node> make_node(schema& tree, const std::string& name) {
|
static std::shared_ptr<schema_node> make_node(schema& tree, const std::string& name) {
|
||||||
return std::make_shared<schema_node>(tree, name, static_cast<Type*>(nullptr));
|
return std::shared_ptr<schema_node>(new schema_node(tree, name, static_cast<Type*>(nullptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
schema_node(const schema_node& other) = delete;
|
schema_node(const schema_node& other) = delete;
|
||||||
@@ -47,8 +47,8 @@ private:
|
|||||||
schema_node(schema& tree, std::string name, Type *obj)
|
schema_node(schema& tree, std::string name, Type *obj)
|
||||||
: schema_(tree)
|
: schema_(tree)
|
||||||
, info_(std::make_unique<object_info<Type>>(*this))
|
, info_(std::make_unique<object_info<Type>>(*this))
|
||||||
, first_child_(std::make_shared<schema_node>(tree))
|
, first_child_(std::shared_ptr<schema_node>(new schema_node(tree)))
|
||||||
, last_child_(std::make_shared<schema_node>(tree))
|
, last_child_(std::shared_ptr<schema_node>(new schema_node(tree)))
|
||||||
, name_(std::move(name)) {
|
, name_(std::move(name)) {
|
||||||
first_child_->next_sibling_ = last_child_;
|
first_child_->next_sibling_ = last_child_;
|
||||||
last_child_->previous_sibling_ = first_child_;
|
last_child_->previous_sibling_ = first_child_;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ utils::result<std::shared_ptr<schema_node>, utils::error> schema::attach_node(co
|
|||||||
}
|
}
|
||||||
parent_node = *result;
|
parent_node = *result;
|
||||||
|
|
||||||
result = push_back_child(root_, node);
|
push_back_child(root_, node);
|
||||||
|
|
||||||
// if (!pk.is_null()) {
|
// if (!pk.is_null()) {
|
||||||
// node->primary_key_ = pk;
|
// node->primary_key_ = pk;
|
||||||
@@ -81,7 +81,8 @@ utils::result<std::shared_ptr<schema_node>, utils::error> schema::find_node(cons
|
|||||||
}
|
}
|
||||||
return utils::ok(i->second);
|
return utils::ok(i->second);
|
||||||
}
|
}
|
||||||
utils::result<std::shared_ptr<schema_node>, 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->parent_ = parent;
|
||||||
child->previous_sibling_ = parent->last_child_->previous_sibling_;
|
child->previous_sibling_ = parent->last_child_->previous_sibling_;
|
||||||
child->next_sibling_ = parent->last_child_;
|
child->next_sibling_ = parent->last_child_;
|
||||||
|
|||||||
Reference in New Issue
Block a user