From 21a91f26dc1c86fef631d22bf15bbd78414736d0 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Wed, 28 Jan 2015 01:07:16 +0100 Subject: Added select method and repair of some Doxygen comments --- src/core/parser/ParserScope.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/core/parser/ParserScope.cpp') diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp index 0e2350f..3d1ba78 100644 --- a/src/core/parser/ParserScope.cpp +++ b/src/core/parser/ParserScope.cpp @@ -168,6 +168,20 @@ Rooted ParserScope::getRoot() const { return nodes.front(); } Rooted ParserScope::getLeaf() const { return nodes.back(); } +Rooted ParserScope::select(RttiSet types, int maxDepth) +{ + ssize_t minDepth = 0; + if (maxDepth >= 0) { + minDepth = static_cast(nodes.size()) - (maxDepth + 1); + } + for (ssize_t i = nodes.size() - 1; i >= minDepth; i--) { + if (nodes[i]->type().isOneOf(types)) { + return nodes[i]; + } + } + return nullptr; +} + void ParserScope::setFlag(ParserFlag flag, bool value) { // Fetch the current stack depth -- cgit v1.2.3