Browse Source

findTagNodeChild()

master
Odilitime 1 year ago
parent
commit
bc6a942195
2 changed files with 19 additions and 0 deletions
  1. 18
    0
      src/parsers/markup/Node.cpp
  2. 1
    0
      src/parsers/markup/Node.h

+ 18
- 0
src/parsers/markup/Node.cpp View File

@@ -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;
}


+ 1
- 0
src/parsers/markup/Node.h View File

@@ -25,6 +25,7 @@ public:
std::shared_ptr<Component> component;

static std::shared_ptr<Node> findTagNodeParent(std::string tag, std::shared_ptr<Node> node);
static void findTagNodeChild(std::string tag, std::shared_ptr<Node> node, std::vector< std::shared_ptr<Node> > &results);
virtual std::vector<std::string> getSourceList();
};


Loading…
Cancel
Save