You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
847 B

#include "Node.h"
#include "TagNode.h"
Node::Node(NodeType type) {
nodeType = type;
}
Node::~Node() {
}
std::vector<std::string> Node::getSourceList() {
std::vector<std::string> returnVec;
for (std::shared_ptr<Node>& child : children) {
auto childSrcs = child->getSourceList();
returnVec.insert(returnVec.end(),
childSrcs.begin(),
childSrcs.end());
}
return returnVec;
}
std::shared_ptr<Node> Node::findTagNodeParent(std::string tag, std::shared_ptr<Node> node) {
if (!node.get()) {
// found root?
return nullptr;
}
TagNode *tagNode = dynamic_cast<TagNode*>(node.get());
if (tagNode) {
if (tagNode->tag == tag) {
return node;
}
}
return Node::findTagNodeParent(tag, node->parent);
}