MCPcopy Create free account
hub / github.com/MyGUI/mygui / node_is_before

Function node_is_before

UnitTests/TestApp/pugixml.cpp:6770–6799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6768}
6769
6770PUGI__FN bool node_is_before(xml_node ln, unsigned int lh, xml_node rn, unsigned int rh)
6771{
6772 // normalize heights
6773 for (unsigned int i = rh; i < lh; i++)
6774 ln = ln.parent();
6775 for (unsigned int j = lh; j < rh; j++)
6776 rn = rn.parent();
6777
6778 // one node is the ancestor of the other
6779 if (ln == rn)
6780 return lh < rh;
6781
6782 // find common ancestor
6783 while (ln.parent() != rn.parent())
6784 {
6785 ln = ln.parent();
6786 rn = rn.parent();
6787 }
6788
6789 // there is no common ancestor (the shared parent is null), nodes are from different documents
6790 if (!ln.parent())
6791 return ln < rn;
6792
6793 // determine sibling order
6794 for (; ln; ln = ln.next_sibling())
6795 if (ln == rn)
6796 return true;
6797
6798 return false;
6799}
6800
6801PUGI__FN bool node_is_ancestor(xml_node parent, xml_node node)
6802{

Callers 1

operator()Method · 0.70

Calls 2

parentMethod · 0.45
next_siblingMethod · 0.45

Tested by

no test coverage detected