ParseComponents.hpp: Add two helper functions for ParseTree.parent

Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404-59 2025-01-19 19:17:50 +01:00
parent a3e2427017
commit bd87e9a93b
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 5 additions and 0 deletions

View File

@ -74,6 +74,11 @@ public:
inline constant_iterator cend() const noexcept { return subComponents.cend(); } inline constant_iterator cend() const noexcept { return subComponents.cend(); }
const decltype(parent)& getParent() const { return parent; } 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 IS_PARSECOMPONENT
vector<T*> findById() const { vector<T*> findById() const {