Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QPatternist::ExceptIterator Class Reference

Implements the except operator. That is, the computation of the sequence of nodes from one sequence, that doesn't appear in the other. More...

#include <qexceptiterator_p.h>

Inheritance diagram for QPatternist::ExceptIterator:
QAbstractXmlForwardIterator< Item > QSharedData

Public Functions

virtual Item::Iterator::Ptr copy () const
 Copies this QAbstractXmlForwardIterator and returns the copy. More...
 
virtual Item current () const
 Returns the current item in the sequence. More...
 
 ExceptIterator (const Item::Iterator::Ptr &it1, const Item::Iterator::Ptr &it2)
 
virtual Item next ()
 Returns the next item in the sequence, or a null object if the end has been reached. More...
 
virtual xsInteger position () const
 Returns the current position in the sequence represented by this. More...
 
- Public Functions inherited from QAbstractXmlForwardIterator< Item >
virtual qint64 count ()
 Determines the number of items this QAbstractXmlForwardIterator represents. More...
 
virtual bool isEmpty ()
 Returns true if the sequence is empty. More...
 
virtual Item last ()
 Returns the item at the end of this QAbstractXmlForwardIterator. More...
 
 QAbstractXmlForwardIterator ()
 Default constructor. More...
 
virtual qint64 sizeHint () const
 Gives a hint to the size of the contained sequence. More...
 
virtual QList< ItemtoList ()
 Performs a copy of this QAbstractXmlForwardIterator(with copy()), and returns its items in a QList. More...
 
virtual QAbstractXmlForwardIterator< Item >::Ptr toReversed ()
 Returns a reverse iterator for the sequence. More...
 
virtual ~QAbstractXmlForwardIterator ()
 Destructor. More...
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Private Functions

Item fromFirstOperand ()
 

Properties

Item m_current
 
const Item::Iterator::Ptr m_it1
 
const Item::Iterator::Ptr m_it2
 
Item m_node1
 
Item m_node2
 
xsInteger m_position
 

Additional Inherited Members

- Public Types inherited from QAbstractXmlForwardIterator< Item >
typedef QList< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > > List
 A QList containing QAbstractXmlForwardIterator::Ptr instances. More...
 
typedef QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > Ptr
 A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass. More...
 
typedef QVector< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > > Vector
 A QVector containing QAbstractXmlForwardIterator::Ptr instances. More...
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Implements the except operator. That is, the computation of the sequence of nodes from one sequence, that doesn't appear in the other.

Definition at line 70 of file qexceptiterator_p.h.

Constructors and Destructors

◆ ExceptIterator()

ExceptIterator::ExceptIterator ( const Item::Iterator::Ptr it1,
const Item::Iterator::Ptr it2 
)

It is assumed that it1 and it2 are in document order and without duplicates.

Definition at line 50 of file qexceptiterator.cpp.

Referenced by copy().

51  : m_it1(it1)
52  , m_it2(it2)
53  , m_position(0)
54  , m_node1(m_it1->next())
55  , m_node2(m_it2->next())
56 {
57  Q_ASSERT(m_it1);
58  Q_ASSERT(m_it2);
59 }
const Item::Iterator::Ptr m_it2
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const Item::Iterator::Ptr m_it1

Functions

◆ copy()

Item::Iterator::Ptr ExceptIterator::copy ( ) const
virtual

Copies this QAbstractXmlForwardIterator and returns the copy.

Warning
This function is not part of the public interface.

A copy and the original instance are completely independent of each other. Because evaluating an QAbstractXmlForwardIterator modifies it, one should always use a copy when an QAbstractXmlForwardIterator needs to be used several times.

Reimplemented from QAbstractXmlForwardIterator< Item >.

Definition at line 117 of file qexceptiterator.cpp.

118 {
119  return Item::Iterator::Ptr(new ExceptIterator(m_it1->copy(), m_it2->copy()));
120 }
ExceptIterator(const Item::Iterator::Ptr &it1, const Item::Iterator::Ptr &it2)
const Item::Iterator::Ptr m_it2
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.
const Item::Iterator::Ptr m_it1

◆ current()

Item ExceptIterator::current ( ) const
virtual

Returns the current item in the sequence.

If this function is called before the first call to next(), a null object is returned. If the end of the sequence has been reached, a null object is returned.

Implements QAbstractXmlForwardIterator< Item >.

Definition at line 107 of file qexceptiterator.cpp.

108 {
109  return m_current;
110 }

◆ fromFirstOperand()

Item ExceptIterator::fromFirstOperand ( )
inlineprivate

Definition at line 61 of file qexceptiterator.cpp.

Referenced by next().

62 {
63  ++m_position;
65  m_node1 = m_it1->next();
66 
67  return m_current;
68 }
const Item::Iterator::Ptr m_it1

◆ next()

Item ExceptIterator::next ( )
virtual

Returns the next item in the sequence, or a null object if the end has been reached.

Implements QAbstractXmlForwardIterator< Item >.

Definition at line 70 of file qexceptiterator.cpp.

71 {
72  while(true)
73  {
74  if(!m_node1)
75  {
76  m_position = -1;
77  m_current = Item();
78  return Item();
79  }
80  else if(!m_node2)
81  return fromFirstOperand();
82 
83  if(m_node1.asNode().model() != m_node2.asNode().model())
84  return fromFirstOperand();
85 
87  {
89  return fromFirstOperand();
91  {
92  m_node2 = m_it2->next();
93  if(m_node2)
94  continue;
95  else
96  return fromFirstOperand();
97  }
98  default:
99  {
100  m_node1 = m_it1->next();
101  m_node2 = m_it2->next();
102  }
103  }
104  }
105 }
DocumentOrder compareOrder(const QXmlNodeModelIndex &other) const
Definition: qitem_p.h:481
const Item::Iterator::Ptr m_it2
const QAbstractXmlNodeModel * model() const
Returns the QAbstractXmlNodeModel that this node index refers to.
const QXmlNodeModelIndex & asNode() const
Definition: qitem_p.h:379
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
const Item::Iterator::Ptr m_it1

◆ position()

xsInteger ExceptIterator::position ( ) const
virtual

Returns the current position in the sequence represented by this.

The first position is 1, not 0. If next() hasn't been called, 0 is returned. If this has reached the end, -1 is returned.

Implements QAbstractXmlForwardIterator< Item >.

Definition at line 112 of file qexceptiterator.cpp.

113 {
114  return m_position;
115 }

Properties

◆ m_current

Item QPatternist::ExceptIterator::m_current
private

Definition at line 90 of file qexceptiterator_p.h.

Referenced by current(), fromFirstOperand(), and next().

◆ m_it1

const Item::Iterator::Ptr QPatternist::ExceptIterator::m_it1
private

Definition at line 88 of file qexceptiterator_p.h.

Referenced by copy(), ExceptIterator(), fromFirstOperand(), and next().

◆ m_it2

const Item::Iterator::Ptr QPatternist::ExceptIterator::m_it2
private

Definition at line 89 of file qexceptiterator_p.h.

Referenced by copy(), ExceptIterator(), and next().

◆ m_node1

Item QPatternist::ExceptIterator::m_node1
private

Definition at line 92 of file qexceptiterator_p.h.

Referenced by fromFirstOperand(), and next().

◆ m_node2

Item QPatternist::ExceptIterator::m_node2
private

Definition at line 93 of file qexceptiterator_p.h.

Referenced by next().

◆ m_position

xsInteger QPatternist::ExceptIterator::m_position
private

Definition at line 91 of file qexceptiterator_p.h.

Referenced by fromFirstOperand(), next(), and position().


The documentation for this class was generated from the following files: