Qt 4.8
Public Functions | Protected Functions | Protected Variables | Friends | List of all members
QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType > Class Template Reference

Helper class for ListIterator, and should only be instantiated through sub-classing. More...

#include <qabstractxmlforwarditerator_p.h>

Inheritance diagram for QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >:
QAbstractXmlForwardIterator< OutputType > QSharedData QPatternist::ListIterator< Item > QPatternist::ListIterator< QXmlNodeModelIndexIteratorPointer, QVector< QXmlNodeModelIndexIteratorPointer > > QPatternist::StringListIterator QPatternist::DeduplicateIterator QPatternist::IteratorVector

Public Functions

virtual QAbstractXmlForwardIterator< OutputType >::Ptr copy () const
 Copies this QAbstractXmlForwardIterator and returns the copy. More...
 
virtual qint64 count ()
 Determines the number of items this QAbstractXmlForwardIterator represents. More...
 
virtual OutputType current () const
 Returns the current item in the sequence. More...
 
virtual OutputType next ()
 Returns the next item in the sequence, or a null object if the end has been reached. More...
 
virtual qint64 position () const
 Returns the current position in the sequence represented by this. More...
 
- Public Functions inherited from QAbstractXmlForwardIterator< OutputType >
virtual bool isEmpty ()
 Returns true if the sequence is empty. More...
 
virtual OutputType 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< OutputType > toList ()
 Performs a copy of this QAbstractXmlForwardIterator(with copy()), and returns its items in a QList. More...
 
virtual QAbstractXmlForwardIterator< OutputType >::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...
 

Protected Functions

 ListIteratorPlatform (const ListType &list)
 Constructs a ListIteratorPlatform that walks the given list. More...
 

Protected Variables

OutputType m_current
 
const ListType m_list
 
qint64 m_position
 

Friends

class DeduplicateIterator
 

Additional Inherited Members

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

Detailed Description

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
class QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >

Helper class for ListIterator, and should only be instantiated through sub-classing.

Note
This class or function is reentrant.
Since
4.4
Warning
This function is not part of the public interface.

ListIteratorPlatform iterates an InputList with instances of InputType. For every item in it, it returns an item from it, that is converted to OutputType by calling a function on Derived that has the following signature:

OutputType inputToOutputItem(const InputType &inputType) const;

TODO Document why this class doesn't duplicate ItemMappingIterator.

Definition at line 134 of file qabstractxmlforwarditerator_p.h.

Constructors and Destructors

◆ ListIteratorPlatform()

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::ListIteratorPlatform ( const ListType &  list)
inlineprotected

Constructs a ListIteratorPlatform that walks the given list.

Definition at line 180 of file qabstractxmlforwarditerator_p.h.

Functions

◆ copy()

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
virtual QAbstractXmlForwardIterator<OutputType>::Ptr QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::copy ( ) const
inlinevirtual

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< OutputType >.

Reimplemented in QPatternist::IteratorVector, and QPatternist::DeduplicateIterator.

Definition at line 174 of file qabstractxmlforwarditerator_p.h.

175  {
176  return QExplicitlySharedDataPointer<QAbstractXmlForwardIterator<OutputType> >(new ListIteratorPlatform<InputType, OutputType, Derived, ListType>(m_list));
177  }
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136

◆ count()

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
virtual qint64 QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::count ( )
inlinevirtual

Determines the number of items this QAbstractXmlForwardIterator represents.

Warning
This function is not part of the public interface.

Note that this function is not const. It modifies the QAbstractXmlForwardIterator. The reason for this is efficiency. If this QAbstractXmlForwardIterator must not be changed, get a copy() before performing the count.

The default implementation simply calls next() until the end is reached. Hence, it may be of interest to override this function if the sub-class knows a better way of computing its count.

The number of items in the sequence is returned.

Reimplemented from QAbstractXmlForwardIterator< OutputType >.

Reimplemented in QPatternist::DeduplicateIterator.

Definition at line 169 of file qabstractxmlforwarditerator_p.h.

170  {
171  return m_list.count();
172  }

◆ current()

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
virtual OutputType QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::current ( ) const
inlinevirtual

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< OutputType >.

Definition at line 159 of file qabstractxmlforwarditerator_p.h.

160  {
161  return m_current;
162  }

◆ next()

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
virtual OutputType QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::next ( )
inlinevirtual

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

Implements QAbstractXmlForwardIterator< OutputType >.

Reimplemented in QPatternist::DeduplicateIterator.

Definition at line 142 of file qabstractxmlforwarditerator_p.h.

143  {
144  if(m_position == -1)
145  return OutputType();
146 
147  if(m_position == m_list.count())
148  {
149  m_position = -1;
150  m_current = OutputType();
151  return OutputType();
152  }
153 
154  m_current = static_cast<const Derived *>(this)->inputToOutputItem(m_list.at(m_position));
155  ++m_position;
156  return m_current;
157  }

◆ position()

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
virtual qint64 QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::position ( ) const
inlinevirtual

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< OutputType >.

Definition at line 164 of file qabstractxmlforwarditerator_p.h.

165  {
166  return m_position;
167  }

Friends and Related Functions

◆ DeduplicateIterator

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
friend class DeduplicateIterator
friend

Definition at line 139 of file qabstractxmlforwarditerator_p.h.

Properties

◆ m_current

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
OutputType QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::m_current
protected

◆ m_list

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
const ListType QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::m_list
protected

◆ m_position

template<typename InputType, typename OutputType, typename Derived, typename ListType = QList<InputType>>
qint64 QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >::m_position
protected

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