attaching schema nodes progress
This commit is contained in:
@@ -89,7 +89,7 @@ void schema::dump(std::ostream &os) const {
|
||||
|
||||
utils::result<schema::node_ptr, utils::error> schema::attach_node(const std::shared_ptr<schema_node> &node,
|
||||
const std::string &parent) {
|
||||
if (has_node(node->type_index(), node->name())) {
|
||||
if (has_node(node)) {
|
||||
return utils::failure(make_error(error_code::NodeAlreadyExists, "Node '" + node->name() + "' already exists."));
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ utils::result<schema::node_ptr, utils::error> schema::attach_node(const std::sha
|
||||
insert_node(parent_node, node);
|
||||
|
||||
// Todo: check return value
|
||||
nodes_by_name_.insert({node->name(), node})/*.first*/;
|
||||
nodes_by_name_.insert({node->name(), node});
|
||||
nodes_by_type_.insert({node->type_index(), node});
|
||||
|
||||
return utils::ok(node);
|
||||
@@ -116,7 +116,7 @@ utils::result<schema::node_ptr, utils::error> schema::attach_node(const std::sha
|
||||
|
||||
utils::result<schema::node_ptr, utils::error> schema::attach_node(const std::shared_ptr<schema_node> &node,
|
||||
const std::type_index &type_index) {
|
||||
if (has_node(node->type_index(), node->name())) {
|
||||
if (has_node(node)) {
|
||||
return utils::failure(make_error(error_code::NodeAlreadyExists, "Node '" + node->name() + "' already exists."));
|
||||
}
|
||||
auto result = find_node(type_index);
|
||||
@@ -202,7 +202,7 @@ bool schema::has_node(const std::type_index &index) const {
|
||||
return nodes_by_type_.count(index) > 0;
|
||||
}
|
||||
|
||||
bool schema::has_node(const std::type_index &index, const std::string &name) const {
|
||||
return nodes_by_name_.count(name) > 0 || nodes_by_type_.count(index) > 0;
|
||||
bool schema::has_node(const node_ptr& node) const {
|
||||
return nodes_by_name_.count(node->name()) > 0 || nodes_by_type_.count(node->type_index()) > 0;
|
||||
}
|
||||
} // namespace matador::object
|
||||
|
||||
Reference in New Issue
Block a user