From 4284cda04b3a1b1f4c5d4368cc8663d01b6925c6 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 3 Feb 2015 02:28:20 +0100 Subject: Some refactoring, added function for extracting current type signature --- src/core/parser/ParserScope.hpp | 103 ++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 40 deletions(-) (limited to 'src/core/parser/ParserScope.hpp') diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp index 2ef33d9..30db92f 100644 --- a/src/core/parser/ParserScope.hpp +++ b/src/core/parser/ParserScope.hpp @@ -104,6 +104,69 @@ public: */ Rooted resolve(const Rtti &type, const std::vector &path, Logger &logger); + + /** + * Returns true if the stack is empty. + * + * @return true if there is no element on the stack. + */ + bool isEmpty() const; + + /** + * Returns a reference at the internal node stack. + * + * @return a const reference at the internal node stack. + */ + const NodeVector &getStack() const; + + /** + * Returns a list containing the Rtti type of each Node that is currently + * in the stack. + * + * @return the type signature of the current node stack. + */ + std::vector getStackTypeSignature() const; + + /** + * Returns the top-most Node instance in the ParserScopeBase hirarchy. + * + * @return a reference at the root node. + */ + Rooted getRoot() const; + + /** + * Returns the bottom-most Node instance in the ParserScopeBase hirarchy, + * e.g. the node that was pushed last onto the stack. + * + * @return a reference at the leaf node. + */ + 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. + */ + 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(); + } + }; /** @@ -343,46 +406,6 @@ public: */ NodeVector getTopLevelNodes() const; - /** - * Returns the top-most Node instance in the ParserScope hirarchy. - * - * @return a reference at the root node. - */ - Rooted getRoot() const; - - /** - * Returns the bottom-most Node instance in the ParserScope hirarchy, e.g. - * the node that was pushed last onto the stack. - * - * @return a reference at the leaf node. - */ - 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. - */ - 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