Public Member Functions
document_order_comparator Struct Reference

List of all members.

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

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

Definition at line 6692 of file pugixml.cpp.

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

                {
                        // 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);
                }

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

Generated on Mon Sep 15 2014 01:23:55 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001