attaching schema nodes progress

This commit is contained in:
Sascha Kühl
2025-07-10 16:02:25 +02:00
parent 7fd11ad174
commit 6982eebfd6
7 changed files with 61 additions and 36 deletions
+5 -5
View File
@@ -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
+1 -1
View File
@@ -6,7 +6,7 @@
namespace matador::utils {
std::string error::message() const {
return ec_.message();
return error_message_;
}
std::string error::category() const {