|
|
|
@ -34,3 +34,21 @@ std::shared_ptr<Node> Node::findTagNodeParent(std::string tag, std::shared_ptr<N
@@ -34,3 +34,21 @@ std::shared_ptr<Node> Node::findTagNodeParent(std::string tag, std::shared_ptr<N
|
|
|
|
|
} |
|
|
|
|
return Node::findTagNodeParent(tag, node->parent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Node::findTagNodeChild(std::string tag, std::shared_ptr<Node> node, std::vector< std::shared_ptr<Node> > &results) { |
|
|
|
|
// check self
|
|
|
|
|
TagNode *tagNode = dynamic_cast<TagNode*>(node.get()); |
|
|
|
|
if (tagNode) { |
|
|
|
|
if (tagNode->tag == tag) { |
|
|
|
|
results.push_back(node); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// check children
|
|
|
|
|
for(auto child : node->children) { |
|
|
|
|
Node::findTagNodeChild(tag, child, results); |
|
|
|
|
} |
|
|
|
|
// not in us or any of our children
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|