From 6f25c96065a7ced66d3808e95344a2127055de05 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Wed, 28 Jan 2015 03:30:38 +0100 Subject: Implemented select function --- src/core/parser/ParserScope.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/core/parser/ParserScope.hpp') diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp index 1191cbc..07fb639 100644 --- a/src/core/parser/ParserScope.hpp +++ b/src/core/parser/ParserScope.hpp @@ -341,6 +341,19 @@ public: */ Rooted select(RttiSet types, int maxDepth = -1); + /** + * Ascends in the stack starting with the leaf node, returns the first node + * that matches the given type or nullptr if none matches. + * + * @tparam T is the type that should be searched in the stack. + * @param maxDepth is the maximum number of stack entries the selection + * function may ascend. A negative value indicates no limitation. + */ + template + Rooted select(int maxDepth = -1) { + return select(RttiSet{&typeOf()}, maxDepth).cast(); + } + /** * Sets a parser flag for the current stack depth. * -- cgit v1.2.3