From e91ba1faf25790eea34e7ae743aff06752f1ea8c Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Wed, 3 Dec 2014 17:01:46 +0100 Subject: Convenience versions for SelectorNode::getChildren. --- src/core/CSS.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 5 deletions(-) (limited to 'src/core/CSS.cpp') diff --git a/src/core/CSS.cpp b/src/core/CSS.cpp index c2397d1..8beb075 100644 --- a/src/core/CSS.cpp +++ b/src/core/CSS.cpp @@ -20,19 +20,23 @@ namespace ousia { +/* + * different versions of "getChildren". + */ + std::vector> SelectorNode::getChildren( - const SelectionOperator &op, const std::string &className, - const PseudoSelector &select) + const SelectionOperator *op, const std::string *className, + const PseudoSelector *select) { std::vector> out; for (auto &e : edges) { - if (e->getSelectionOperator() != op) { + if (op && e->getSelectionOperator() != *op) { continue; } - if (e->getTarget()->getName() != className) { + if (className && e->getTarget()->getName() != *className) { continue; } - if (e->getTarget()->getPseudoSelector() != select) { + if (select && e->getTarget()->getPseudoSelector() != *select) { continue; } out.push_back(e->getTarget()); @@ -40,6 +44,58 @@ std::vector> SelectorNode::getChildren( return out; } +std::vector> SelectorNode::getChildren( + const SelectionOperator &op, const std::string &className, + const PseudoSelector &select) +{ + return getChildren(&op, &className, &select); +} + +std::vector> SelectorNode::getChildren( + const std::string &className, const PseudoSelector &select) +{ + return getChildren(NULL, &className, &select); +} + +std::vector> SelectorNode::getChildren( + const SelectionOperator &op, const PseudoSelector &select) +{ + return getChildren(&op, NULL, &select); +} + +std::vector> SelectorNode::getChildren( + const SelectionOperator &op, const std::string &className) +{ + return getChildren(&op, &className, NULL); +} + +std::vector> SelectorNode::getChildren( + const SelectionOperator &op) +{ + return getChildren(&op, NULL, NULL); +} + +std::vector> SelectorNode::getChildren( + const std::string &className) +{ + return getChildren(NULL, &className, NULL); +} + +std::vector> SelectorNode::getChildren( + const PseudoSelector &select) +{ + return getChildren(NULL, NULL, &select); +} + +std::vector> SelectorNode::getChildren() +{ + return getChildren(NULL, NULL, NULL); +} + +/* + * append + */ + std::vector> SelectorNode::append( Rooted edge) { -- cgit v1.2.3