Public Member Functions | List of all members
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.

6693 {
6694 // optimized document order based check
6695 const void* lo = document_order(lhs);
6696 const void* ro = document_order(rhs);
6697
6698 if (lo && ro) return lo < ro;
6699
6700 // slow comparison
6701 xml_node ln = lhs.node(), rn = rhs.node();
6702
6703 // compare attributes
6704 if (lhs.attribute() && rhs.attribute())
6705 {
6706 // shared parent
6707 if (lhs.parent() == rhs.parent())
6708 {
6709 // determine sibling order
6710 for (xml_attribute a = lhs.attribute(); a; a = a.next_attribute())
6711 if (a == rhs.attribute())
6712 return true;
6713
6714 return false;
6715 }
6716
6717 // compare attribute parents
6718 ln = lhs.parent();
6719 rn = rhs.parent();
6720 }
6721 else if (lhs.attribute())
6722 {
6723 // attributes go after the parent element
6724 if (lhs.parent() == rhs.node()) return false;
6725
6726 ln = lhs.parent();
6727 }
6728 else if (rhs.attribute())
6729 {
6730 // attributes go after the parent element
6731 if (rhs.parent() == lhs.node()) return true;
6732
6733 rn = rhs.parent();
6734 }
6735
6736 if (ln == rn) return false;
6737
6738 unsigned int lh = node_height(ln);
6739 unsigned int rh = node_height(rn);
6740
6741 return node_is_before(ln, lh, rn, rh);
6742 }
PUGI__FN bool node_is_before(xml_node ln, unsigned int lh, xml_node rn, unsigned int rh)
Definition pugixml.cpp:6633
PUGI__FN unsigned int node_height(xml_node n)
Definition pugixml.cpp:6620
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:

Generated on Sat Feb 3 2024 04:23:15 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001