From ec6306ad1e746d47ed66af6274fb6710c70933a2 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 3 Feb 2015 22:54:17 +0100 Subject: Fixed XML-Importer failing --- src/core/parser/ParserScope.hpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src/core/parser/ParserScope.hpp') diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp index dc1b1bf..7be3c4a 100644 --- a/src/core/parser/ParserScope.hpp +++ b/src/core/parser/ParserScope.hpp @@ -143,6 +143,33 @@ public: */ Rooted getLeaf() const; + /** + * Ascends in the stack starting with the leaf node, returns the first node + * that matches the type given in the RttiSet or nullptr if none matches. + * + * @param types is a set of Rtti types for which 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. + * @return the matching node or nullptr if the node was not found. + */ + 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. + * @return the matching node or nullptr if the node was not found. + */ + template + Rooted select(int maxDepth = -1) + { + return select(RttiSet{&typeOf()}, maxDepth).cast(); + } + /** * Ascends in the stack starting with the leaf node, returns the first node * that matches the type given in the RttiSet. Throws an exception if no @@ -154,7 +181,7 @@ public: * function may ascend. A negative value indicates no limitation. * @return the matching node. */ - Rooted select(RttiSet types, int maxDepth = -1); + Rooted selectOrThrow(RttiSet types, int maxDepth = -1); /** * Ascends in the stack starting with the leaf node, returns the first node @@ -166,9 +193,9 @@ public: * @return the matching node. */ template - Rooted select(int maxDepth = -1) + Rooted selectOrThrow(int maxDepth = -1) { - return select(RttiSet{&typeOf()}, maxDepth).cast(); + return selectOrThrow(RttiSet{&typeOf()}, maxDepth).cast(); } }; -- cgit v1.2.3