Class xpath_node_set

Synopsis

#include <src/pugixml.hpp>

class PUGIXML_CLASS xpath_node_set

Description

A fixed-size collection of XPath nodes.

Mentioned in

Methods

xpath_node_set overloadDefault constructor. Constructs empty set.
xpath_node_set overloadConstructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful.
xpath_node_set overloadCopy constructor/assignment operator.
xpath_node_set overloadMove semantics support.
~xpath_node_setDestructor.
beginCollection iterators.
emptyCheck if collection is empty.
end
firstGet first node in the collection by document order.
operator= overload
operator[]Indexing operator.
sizeGet collection size.
sortSort the collection in ascending/descending order by document order.
typeGet collection type.

Source

Lines 1352-1420 in src/pugixml.hpp.

class PUGIXML_CLASS xpath_node_set
{
public:
    // Collection type
    enum type_t
    {
        type_unsorted,          // Not ordered
        type_sorted,            // Sorted by document order (ascending)
        type_sorted_reverse     // Sorted by document order (descending)
    };
    // Constant iterator type
    typedef const xpath_node* const_iterator;
    // We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work
    typedef const xpath_node* iterator;
    // Default constructor. Constructs empty set.
    xpath_node_set();
    // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful
    xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
    // Destructor
    ~xpath_node_set();
    // Copy constructor/assignment operator
    xpath_node_set(const xpath_node_set& ns);
    xpath_node_set& operator=(const xpath_node_set& ns);
#ifdef PUGIXML_HAS_MOVE
    // Move semantics support
    xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
    xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
#endif
    // Get collection type
    type_t type() const;
    // Get collection size
    size_t size() const;
    // Indexing operator
    const xpath_node& operator[](size_t index) const;
    // Collection iterators
    const_iterator begin() const;
    const_iterator end() const;
    // Sort the collection in ascending/descending order by document order
    void sort(bool reverse = false);
    // Get first node in the collection by document order
    xpath_node first() const;
    // Check if collection is empty
    bool empty() const;
private:
    type_t _type;
    xpath_node _storage[1];
    xpath_node* _begin;
    xpath_node* _end;
    void _assign(const_iterator begin, const_iterator end, type_t type);
    void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT;
};





Add Discussion as Guest

Log in