From bd87e9a93b2b29ec44dad3fc74a11676f5b1d628 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Sun, 19 Jan 2025 19:17:50 +0100 Subject: [PATCH] ParseComponents.hpp: Add two helper functions for ParseTree.parent Signed-off-by: Username404-59 --- src/headers/parsing/ParseComponents.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/headers/parsing/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp index 9095fbe..5260188 100644 --- a/src/headers/parsing/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -74,6 +74,11 @@ public: inline constant_iterator cend() const noexcept { return subComponents.cend(); } const decltype(parent)& getParent() const { return parent; } + void traverse_parent(const auto& lambda) const + { if (parent.has_value()) for_each(parent.value().get().begin(), parent.value().get().end(), lambda); } + bool any_parent(const auto& lambda) const + { return parent.has_value() and any_of(parent.value().get().begin(), parent.value().get().end(), lambda); } + IS_PARSECOMPONENT vector findById() const {