diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-28 03:30:38 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-28 03:30:38 +0100 |
commit | 6f25c96065a7ced66d3808e95344a2127055de05 (patch) | |
tree | 0bab7f90cee0ca402175bb5ff4dc9c80fd32de73 /src/core/parser | |
parent | f7d20e142adc3fcab9ce528c58ee2f70f5802d10 (diff) |
Implemented select<T> function
Diffstat (limited to 'src/core/parser')
-rw-r--r-- | src/core/parser/ParserScope.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
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 @@ -342,6 +342,19 @@ public: Rooted<Node> 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<class T> + Rooted<T> select(int maxDepth = -1) { + return select(RttiSet{&typeOf<T>()}, maxDepth).cast<T>(); + } + + /** * Sets a parser flag for the current stack depth. * * @param flag is the flag that should be set. |