Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
document_order_comparator Struct Reference

Public Member Functions

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

Detailed Description

Definition at line 8277 of file pugixml.cc.

Member Function Documentation

◆ operator()()

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

Definition at line 8279 of file pugixml.cc.

8280 {
8281 // optimized document order based check
8282 const void* lo = document_buffer_order(lhs);
8283 const void* ro = document_buffer_order(rhs);
8284
8285 if (lo && ro) return lo < ro;
8286
8287 // slow comparison
8288 xml_node ln = lhs.node(), rn = rhs.node();
8289
8290 // compare attributes
8291 if (lhs.attribute() && rhs.attribute())
8292 {
8293 // shared parent
8294 if (lhs.parent() == rhs.parent())
8295 {
8296 // determine sibling order
8297 for (xml_attribute a = lhs.attribute(); a; a = a.next_attribute())
8298 if (a == rhs.attribute())
8299 return true;
8300
8301 return false;
8302 }
8303
8304 // compare attribute parents
8305 ln = lhs.parent();
8306 rn = rhs.parent();
8307 }
8308 else if (lhs.attribute())
8309 {
8310 // attributes go after the parent element
8311 if (lhs.parent() == rhs.node()) return false;
8312
8313 ln = lhs.parent();
8314 }
8315 else if (rhs.attribute())
8316 {
8317 // attributes go after the parent element
8318 if (rhs.parent() == lhs.node()) return true;
8319
8320 rn = rhs.parent();
8321 }
8322
8323 if (ln == rn) return false;
8324
8325 if (!ln || !rn) return ln < rn;
8326
8327 return node_is_before(ln.internal_object(), rn.internal_object());
8328 }
PUGI__FN const void * document_buffer_order(const xpath_node &xnode)
Definition pugixml.cc:8246
PUGI__FN bool node_is_before(xml_node_struct *ln, xml_node_struct *rn)
Definition pugixml.cc:8196

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