document_order_comparator Struct Reference

## Public Member Functions

bool | operator() (const xpath_node &lhs, const xpath_node &rhs) const

## Detailed Description

Definition at line 6690 of file pugixml.cpp.

## Member Function Documentation

## operator()()

bool document_order_comparator::operator() | ( | const xpath_node & | lhs,
|  | const xpath_node & | rhs
| ) |  | const

inline

Definition at line 6692 of file pugixml.cpp.

{
// optimized document order based check
const void* lo = document_order(lhs);
const void* ro = document_order(rhs);
if (lo && ro) return lo < ro;
// slow comparison
xml_node ln = lhs.node(), rn = rhs.node();
// compare attributes
if (lhs.attribute() && rhs.attribute())
{
// shared parent
if (lhs.parent() == rhs.parent())
{
// determine sibling order
for (xml_attribute a = lhs.attribute(); a; a = a.next_attribute())
if (a == rhs.attribute())
return true;
return false;
}
// compare attribute parents
ln = lhs.parent();
rn = rhs.parent();
}
else if (lhs.attribute())
{
// attributes go after the parent element
if (lhs.parent() == rhs.node()) return false;
ln = lhs.parent();
}
else if (rhs.attribute())
{
// attributes go after the parent element
if (rhs.parent() == lhs.node()) return true;
rn = rhs.parent();
}
if (ln == rn) return false;
unsigned int lh = node_height(ln);
unsigned int rh = node_height(rn);
return node_is_before(ln, lh, rn, rh);
}
node_is_before
PUGI__FN bool node_is_before(xml_node ln, unsigned int lh, xml_node rn, unsigned int rh)
Definition: pugixml.cpp:6633
node_height
PUGI__FN unsigned int node_height(xml_node n)
Definition: pugixml.cpp:6620
document_order
PUGI__FN const void * document_order(const xpath_node &xnode)
Definition: pugixml.cpp:6667

References document_order(), node_height(), and node_is_before().

The documentation for this struct was generated from the following file:

- pugixml.cpp