本文整理汇总了C++中NodeSet::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeSet::isEmpty方法的具体用法?C++ NodeSet::isEmpty怎么用?C++ NodeSet::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeSet
的用法示例。
在下文中一共展示了NodeSet::isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nodesInAxis
// Result nodes are ordered in axis order. Node test (including merged
// predicates) is applied.
void Step::nodesInAxis(EvaluationContext& evaluationContext, Node* context, NodeSet& nodes) const
{
ASSERT(nodes.isEmpty());
switch (m_axis) {
case ChildAxis:
// In XPath model, attribute nodes do not have children.
if (context->isAttributeNode())
return;
for (Node* n = context->firstChild(); n; n = n->nextSibling()) {
if (nodeMatches(evaluationContext, n, ChildAxis, nodeTest()))
nodes.append(n);
}
return;
case DescendantAxis:
// In XPath model, attribute nodes do not have children.
if (context->isAttributeNode())
return;
for (Node* n = context->firstChild(); n; n = NodeTraversal::next(*n, context)) {
if (nodeMatches(evaluationContext, n, DescendantAxis, nodeTest()))
nodes.append(n);
}
return;
case ParentAxis:
if (context->isAttributeNode()) {
Element* n = toAttr(context)->ownerElement();
if (nodeMatches(evaluationContext, n, ParentAxis, nodeTest()))
nodes.append(n);
} else {
ContainerNode* n = context->parentNode();
if (n && nodeMatches(evaluationContext, n, ParentAxis, nodeTest()))
nodes.append(n);
}
return;
case AncestorAxis: {
Node* n = context;
if (context->isAttributeNode()) {
n = toAttr(context)->ownerElement();
if (nodeMatches(evaluationContext, n, AncestorAxis, nodeTest()))
nodes.append(n);
}
for (n = n->parentNode(); n; n = n->parentNode()) {
if (nodeMatches(evaluationContext, n, AncestorAxis, nodeTest()))
nodes.append(n);
}
nodes.markSorted(false);
return;
}
case FollowingSiblingAxis:
if (context->nodeType() == Node::ATTRIBUTE_NODE)
return;
for (Node* n = context->nextSibling(); n; n = n->nextSibling()) {
if (nodeMatches(evaluationContext, n, FollowingSiblingAxis, nodeTest()))
nodes.append(n);
}
return;
case PrecedingSiblingAxis:
if (context->nodeType() == Node::ATTRIBUTE_NODE)
return;
for (Node* n = context->previousSibling(); n; n = n->previousSibling()) {
if (nodeMatches(evaluationContext, n, PrecedingSiblingAxis, nodeTest()))
nodes.append(n);
}
nodes.markSorted(false);
return;
case FollowingAxis:
if (context->isAttributeNode()) {
for (Node* p = NodeTraversal::next(*toAttr(context)->ownerElement()); p; p = NodeTraversal::next(*p)) {
if (nodeMatches(evaluationContext, p, FollowingAxis, nodeTest()))
nodes.append(p);
}
} else {
for (Node* p = context; !isRootDomNode(p); p = p->parentNode()) {
for (Node* n = p->nextSibling(); n; n = n->nextSibling()) {
if (nodeMatches(evaluationContext, n, FollowingAxis, nodeTest()))
nodes.append(n);
for (Node* c = n->firstChild(); c; c = NodeTraversal::next(*c, n)) {
if (nodeMatches(evaluationContext, c, FollowingAxis, nodeTest()))
nodes.append(c);
}
}
}
}
return;
case PrecedingAxis: {
if (context->isAttributeNode())
context = toAttr(context)->ownerElement();
//.........这里部分代码省略.........
示例2: nodesInAxis
// Result nodes are ordered in axis order. Node test (including merged predicates) is applied.
void Step::nodesInAxis(Node* context, NodeSet& nodes) const
{
ASSERT(nodes.isEmpty());
switch (m_axis) {
case ChildAxis:
if (context->isAttributeNode()) // In XPath model, attribute nodes do not have children.
return;
for (Node* n = context->firstChild(); n; n = n->nextSibling())
if (nodeMatches(n, ChildAxis, m_nodeTest))
nodes.append(n);
return;
case DescendantAxis:
if (context->isAttributeNode()) // In XPath model, attribute nodes do not have children.
return;
for (Node* n = context->firstChild(); n; n = NodeTraversal::next(*n, context))
if (nodeMatches(n, DescendantAxis, m_nodeTest))
nodes.append(n);
return;
case ParentAxis:
if (context->isAttributeNode()) {
Element* n = toAttr(context)->ownerElement();
if (nodeMatches(n, ParentAxis, m_nodeTest))
nodes.append(n);
} else {
ContainerNode* n = context->parentNode();
if (n && nodeMatches(n, ParentAxis, m_nodeTest))
nodes.append(n);
}
return;
case AncestorAxis: {
Node* n = context;
if (context->isAttributeNode()) {
n = toAttr(context)->ownerElement();
if (nodeMatches(n, AncestorAxis, m_nodeTest))
nodes.append(n);
}
for (n = n->parentNode(); n; n = n->parentNode())
if (nodeMatches(n, AncestorAxis, m_nodeTest))
nodes.append(n);
nodes.markSorted(false);
return;
}
case FollowingSiblingAxis:
if (context->nodeType() == Node::ATTRIBUTE_NODE ||
context->nodeType() == Node::XPATH_NAMESPACE_NODE)
return;
for (Node* n = context->nextSibling(); n; n = n->nextSibling())
if (nodeMatches(n, FollowingSiblingAxis, m_nodeTest))
nodes.append(n);
return;
case PrecedingSiblingAxis:
if (context->nodeType() == Node::ATTRIBUTE_NODE ||
context->nodeType() == Node::XPATH_NAMESPACE_NODE)
return;
for (Node* n = context->previousSibling(); n; n = n->previousSibling())
if (nodeMatches(n, PrecedingSiblingAxis, m_nodeTest))
nodes.append(n);
nodes.markSorted(false);
return;
case FollowingAxis:
if (context->isAttributeNode()) {
Node* p = toAttr(context)->ownerElement();
while ((p = NodeTraversal::next(*p))) {
if (nodeMatches(p, FollowingAxis, m_nodeTest))
nodes.append(p);
}
} else {
for (Node* p = context; !isRootDomNode(p); p = p->parentNode()) {
for (Node* n = p->nextSibling(); n; n = n->nextSibling()) {
if (nodeMatches(n, FollowingAxis, m_nodeTest))
nodes.append(n);
for (Node* c = n->firstChild(); c; c = NodeTraversal::next(*c, n))
if (nodeMatches(c, FollowingAxis, m_nodeTest))
nodes.append(c);
}
}
}
return;
case PrecedingAxis: {
if (context->isAttributeNode())
context = toAttr(context)->ownerElement();
Node* n = context;
while (ContainerNode* parent = n->parentNode()) {
for (n = NodeTraversal::previous(*n); n != parent; n = NodeTraversal::previous(*n))
if (nodeMatches(n, PrecedingAxis, m_nodeTest))
nodes.append(n);
n = parent;
}
nodes.markSorted(false);
return;
}
case AttributeAxis: {
if (!context->isElementNode())
//.........这里部分代码省略.........
示例3: nodesInAxis
void Step::nodesInAxis(Node* context, NodeSet& nodes) const
{
ASSERT(nodes.isEmpty());
switch (m_axis) {
case ChildAxis:
if (context->isAttributeNode()) // In XPath model, attribute nodes do not have children.
return;
for (Node* n = context->firstChild(); n; n = n->nextSibling())
if (nodeMatches(n))
nodes.append(n);
return;
case DescendantAxis:
if (context->isAttributeNode()) // In XPath model, attribute nodes do not have children.
return;
for (Node* n = context->firstChild(); n; n = n->traverseNextNode(context))
if (nodeMatches(n))
nodes.append(n);
return;
case ParentAxis:
if (context->isAttributeNode()) {
Node* n = static_cast<Attr*>(context)->ownerElement();
if (nodeMatches(n))
nodes.append(n);
} else {
Node* n = context->parentNode();
if (n && nodeMatches(n))
nodes.append(n);
}
return;
case AncestorAxis: {
Node* n = context;
if (context->isAttributeNode()) {
n = static_cast<Attr*>(context)->ownerElement();
if (nodeMatches(n))
nodes.append(n);
}
for (n = n->parentNode(); n; n = n->parentNode())
if (nodeMatches(n))
nodes.append(n);
nodes.reverse();
return;
}
case FollowingSiblingAxis:
if (context->nodeType() == Node::ATTRIBUTE_NODE ||
context->nodeType() == Node::XPATH_NAMESPACE_NODE)
return;
for (Node* n = context->nextSibling(); n; n = n->nextSibling())
if (nodeMatches(n))
nodes.append(n);
return;
case PrecedingSiblingAxis:
if (context->nodeType() == Node::ATTRIBUTE_NODE ||
context->nodeType() == Node::XPATH_NAMESPACE_NODE)
return;
for (Node* n = context->previousSibling(); n; n = n->previousSibling())
if (nodeMatches(n))
nodes.append(n);
nodes.reverse();
return;
case FollowingAxis:
if (context->isAttributeNode()) {
Node* p = static_cast<Attr*>(context)->ownerElement();
while ((p = p->traverseNextNode()))
if (nodeMatches(p))
nodes.append(p);
} else {
for (Node* p = context; !isRootDomNode(p); p = p->parentNode()) {
for (Node* n = p->nextSibling(); n; n = n->nextSibling()) {
if (nodeMatches(n))
nodes.append(n);
for (Node* c = n->firstChild(); c; c = c->traverseNextNode(n))
if (nodeMatches(c))
nodes.append(c);
}
}
}
return;
case PrecedingAxis:
if (context->isAttributeNode())
context = static_cast<Attr*>(context)->ownerElement();
for (Node* p = context; !isRootDomNode(p); p = p->parentNode()) {
for (Node* n = p->previousSibling(); n ; n = n->previousSibling()) {
if (nodeMatches(n))
nodes.append(n);
for (Node* c = n->firstChild(); c; c = c->traverseNextNode(n))
if (nodeMatches(c))
nodes.append(c);
}
}
nodes.markSorted(false);
return;
case AttributeAxis: {
if (context->nodeType() != Node::ELEMENT_NODE)
return;
//.........这里部分代码省略.........