diff --git a/dbal/cpp/build-config/CMakeLists.txt b/dbal/cpp/build-config/CMakeLists.txt index b158a968c..5b3109f3d 100644 --- a/dbal/cpp/build-config/CMakeLists.txt +++ b/dbal/cpp/build-config/CMakeLists.txt @@ -91,8 +91,6 @@ target_link_libraries(integration_tests dbal_core dbal_adapters) target_link_libraries(conformance_tests dbal_core dbal_adapters) target_link_libraries(http_server_security_test Threads::Threads) -target_link_libraries(dbal_adapters PRIVATE cpr::cpr) - add_test(NAME client_test COMMAND client_test) add_test(NAME query_test COMMAND query_test) add_test(NAME integration_tests COMMAND integration_tests) diff --git a/dbal/cpp/src/entities/component/crud/get_children.hpp b/dbal/cpp/src/entities/component/crud/get_children.hpp new file mode 100644 index 000000000..a4beadb7e --- /dev/null +++ b/dbal/cpp/src/entities/component/crud/get_children.hpp @@ -0,0 +1,46 @@ +#ifndef DBAL_GET_COMPONENT_CHILDREN_HPP +#define DBAL_GET_COMPONENT_CHILDREN_HPP + +#include "dbal/errors.hpp" +#include "../../../store/in_memory_store.hpp" +#include +#include + +namespace dbal { +namespace entities { +namespace component { + +inline Result> getChildren(InMemoryStore& store, const std::string& parent_id) { + if (parent_id.empty()) { + return Error::validationError("parent_id is required"); + } + + auto parent_it = store.components.find(parent_id); + if (parent_it == store.components.end()) { + return Error::notFound("Component not found: " + parent_id); + } + + auto children_it = store.components_by_parent.find(parent_id); + if (children_it == store.components_by_parent.end()) { + return Result>(std::vector()); + } + + std::vector child_ids = children_it->second; + std::sort(child_ids.begin(), child_ids.end(), [&](const std::string& a, const std::string& b) { + return store.components.at(a).order < store.components.at(b).order; + }); + + std::vector children; + children.reserve(child_ids.size()); + for (const auto& child_id : child_ids) { + children.push_back(store.components.at(child_id)); + } + + return Result>(children); +} + +} // namespace component +} // namespace entities +} // namespace dbal + +#endif diff --git a/dbal/cpp/src/entities/component/index.hpp b/dbal/cpp/src/entities/component/index.hpp index d5a9a5d3d..9efb6db31 100644 --- a/dbal/cpp/src/entities/component/index.hpp +++ b/dbal/cpp/src/entities/component/index.hpp @@ -10,5 +10,6 @@ #include "crud/move_component.hpp" #include "crud/get_tree.hpp" #include "crud/search_components.hpp" +#include "crud/get_children.hpp" #endif