Qt 4.8
Public Types | Public Functions | Properties | Related Functions | List of all members
QAbstractXmlForwardIterator< T > Class Template Referenceabstract

The QAbstractXmlForwardIterator class is a base class for forward iterators. More...

#include <qabstractxmlforwarditerator_p.h>

Inheritance diagram for QAbstractXmlForwardIterator< T >:
QSharedData QPatternist::ListIteratorPlatform< T, T, ListIterator< T, ListType >, ListType > QPatternist::AccelIterator QPatternist::DistinctIterator QPatternist::EmptyIterator< T > QPatternist::IndexOfIterator QPatternist::InsertionIterator QPatternist::SingletonIterator< T > QPatternist::SubsequenceIterator QPatternist::UnionIterator

Public Types

typedef QList< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< T > > > List
 A QList containing QAbstractXmlForwardIterator::Ptr instances. More...
 
typedef QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< T > > Ptr
 A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass. More...
 
typedef QVector< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< T > > > Vector
 A QVector containing QAbstractXmlForwardIterator::Ptr instances. More...
 

Public Functions

virtual QAbstractXmlForwardIterator< T >::Ptr copy () const
 Copies this QAbstractXmlForwardIterator and returns the copy. More...
 
virtual qint64 count ()
 Determines the number of items this QAbstractXmlForwardIterator represents. More...
 
virtual T current () const =0
 Returns the current item in the sequence. More...
 
virtual bool isEmpty ()
 Returns true if the sequence is empty. More...
 
virtual T last ()
 Returns the item at the end of this QAbstractXmlForwardIterator. More...
 
virtual T next ()=0
 Returns the next item in the sequence, or a null object if the end has been reached. More...
 
virtual qint64 position () const =0
 Returns the current position in the sequence represented by this. More...
 
 QAbstractXmlForwardIterator ()
 Default constructor. More...
 
virtual qint64 sizeHint () const
 Gives a hint to the size of the contained sequence. More...
 
virtual QList< T > toList ()
 Performs a copy of this QAbstractXmlForwardIterator(with copy()), and returns its items in a QList. More...
 
virtual QAbstractXmlForwardIterator< T >::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...
 

Properties

QAbstractXmlForwardIteratorPrivate * d_ptr
 

Related Functions

(Note that these are not member functions.)

template<typename TResult , typename TSource , typename TMapper >
static QAbstractXmlForwardIterator< TResult >::Ptr makeSequenceMappingIterator (const TMapper &mapper, const QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< TSource > > &source, const DynamicContext::Ptr &context)
 An object generator for SequenceMappingIterator. More...
 
bool qIsForwardIteratorEnd (const T &unit)
 The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence. More...
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

template<typename T>
class QAbstractXmlForwardIterator< T >

The QAbstractXmlForwardIterator class is a base class for forward iterators.

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

This abstract base class is for creating iterators for traversing custom data structures modeled to look like XML. An item can be instantiated in QAbstractXmlForwardIterator if:

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 90 of file qabstractxmlforwarditerator_p.h.

Typedefs

◆ List

template<typename T>
QAbstractXmlForwardIterator< T >::List

A QList containing QAbstractXmlForwardIterator::Ptr instances.

Definition at line 99 of file qabstractxmlforwarditerator_p.h.

◆ Ptr

template<typename T>
QAbstractXmlForwardIterator< T >::Ptr

A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.

Definition at line 98 of file qabstractxmlforwarditerator_p.h.

◆ Vector

template<typename T>
QAbstractXmlForwardIterator< T >::Vector

A QVector containing QAbstractXmlForwardIterator::Ptr instances.

Definition at line 100 of file qabstractxmlforwarditerator_p.h.

Constructors and Destructors

◆ QAbstractXmlForwardIterator()

template<typename T>
QAbstractXmlForwardIterator< T >::QAbstractXmlForwardIterator ( )
inline

Default constructor.

Definition at line 102 of file qabstractxmlforwarditerator_p.h.

102 : d_ptr(0) {}
QAbstractXmlForwardIteratorPrivate * d_ptr

◆ ~QAbstractXmlForwardIterator()

template<typename T>
QAbstractXmlForwardIterator< T >::~QAbstractXmlForwardIterator ( )
inlinevirtual

Destructor.

Definition at line 103 of file qabstractxmlforwarditerator_p.h.

103 {}

Functions

◆ copy()

template<typename T >
QAbstractXmlForwardIterator< T >::Ptr QAbstractXmlForwardIterator< T >::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 in QPatternist::IteratorVector, QPatternist::AttributeIterator, QPatternist::PrecedingIterator, QPatternist::FollowingIterator, QPatternist::DescendantIterator< IncludeSelf >, QPatternist::SiblingIterator< IsFollowing >, QPatternist::ChildIterator, QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >, QPatternist::ListIteratorPlatform< QVariant, Item, VariantListIterator >, QPatternist::ListIteratorPlatform< QString, Item, StringListIterator >, QPatternist::ListIteratorPlatform< T, T, ListIterator< T, ListType >, ListType >, QPatternist::ItemMappingIterator< TResult, TSource, TMapper, Context >, QPatternist::AncestorIterator< IncludeSelf >, QPatternist::SingletonIterator< T >, QPatternist::EmptyIterator< T >, QPatternist::EmptyIterator< QPatternist::Item >, QPatternist::RangeIterator, QPatternist::SequenceMappingIterator< TResult, TSource, TMapper >, QPatternist::RemovalIterator, QPatternist::DistinctIterator, QPatternist::IndexOfIterator, QPatternist::InsertionIterator, QPatternist::SubsequenceIterator, QPatternist::CachingIterator, QPatternist::ToCodepointsIterator, QPatternist::DeduplicateIterator, QPatternist::IntersectIterator, QPatternist::ExceptIterator, and QPatternist::UnionIterator.

Definition at line 317 of file qabstractxmlforwarditerator_p.h.

Referenced by QPatternist::AttributeIterator::AttributeIterator(), QPatternist::ChildIterator::ChildIterator(), QPatternist::SequenceMappingIterator< TResult, TSource, TMapper >::copy(), QPatternist::ItemMappingIterator< TResult, TSource, TMapper, Context >::copy(), QPatternist::FollowingIterator::FollowingIterator(), QPatternist::PrecedingIterator::PrecedingIterator(), and QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

318 {
319  Q_ASSERT_X(false, Q_FUNC_INFO,
320  "This function is internal, unsupported, and should never be called.");
321  return typename QAbstractXmlForwardIterator<T>::Ptr();
322 }
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< T > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ count()

template<typename T >
qint64 QAbstractXmlForwardIterator< T >::count ( )
virtual

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 in QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >, QPatternist::ListIteratorPlatform< QVariant, Item, VariantListIterator >, QPatternist::ListIteratorPlatform< QString, Item, StringListIterator >, QPatternist::ListIteratorPlatform< T, T, ListIterator< T, ListType >, ListType >, QPatternist::SingletonIterator< T >, QPatternist::RangeIterator, QPatternist::EmptyIterator< T >, QPatternist::EmptyIterator< QPatternist::Item >, QPatternist::RemovalIterator, QPatternist::SequenceMappingIterator< TResult, TSource, TMapper >, QPatternist::InsertionIterator, QPatternist::ToCodepointsIterator, and QPatternist::DeduplicateIterator.

Definition at line 280 of file qabstractxmlforwarditerator_p.h.

Referenced by QPatternist::DeduplicateIterator::count(), QPatternist::SequenceMappingIterator< TResult, TSource, TMapper >::count(), and QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

281 {
282  qint64 retval = 0;
283 
284  while(!qIsForwardIteratorEnd(next()))
285  ++retval;
286 
287  return retval;
288 }
__int64 qint64
Definition: qglobal.h:942
bool qIsForwardIteratorEnd(const T &unit)
The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence...
virtual T next()=0
Returns the next item in the sequence, or a null object if the end has been reached.

◆ current()

template<typename T>
T QAbstractXmlForwardIterator< T >::current ( ) const
pure virtual

◆ isEmpty()

template<typename T >
bool QAbstractXmlForwardIterator< T >::isEmpty ( )
virtual

Returns true if the sequence is empty.

Warning
This function is not part of the public interface.

Definition at line 325 of file qabstractxmlforwarditerator_p.h.

Referenced by QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

326 {
327  return qIsForwardIteratorEnd(next());
328 }
bool qIsForwardIteratorEnd(const T &unit)
The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence...
virtual T next()=0
Returns the next item in the sequence, or a null object if the end has been reached.

◆ last()

template<typename T >
T QAbstractXmlForwardIterator< T >::last ( )
virtual

Returns the item at the end of this QAbstractXmlForwardIterator.

Warning
This function is not part of the public interface.

The default implementation calls next() until the end is reached.

Definition at line 306 of file qabstractxmlforwarditerator_p.h.

Referenced by QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

307 {
308  T item(next());
309 
310  while(!qIsForwardIteratorEnd(item))
311  item = next();
312 
313  return item;
314 }
bool qIsForwardIteratorEnd(const T &unit)
The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence...
virtual T next()=0
Returns the next item in the sequence, or a null object if the end has been reached.

◆ next()

template<typename T>
T QAbstractXmlForwardIterator< T >::next ( )
pure virtual

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

Implemented in QPatternist::AttributeIterator, QPatternist::PrecedingIterator, QPatternist::FollowingIterator, QPatternist::DescendantIterator< IncludeSelf >, QPatternist::SiblingIterator< IsFollowing >, QPatternist::ChildIterator, QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >, QPatternist::ListIteratorPlatform< QVariant, Item, VariantListIterator >, QPatternist::ListIteratorPlatform< QString, Item, StringListIterator >, QPatternist::ListIteratorPlatform< T, T, ListIterator< T, ListType >, ListType >, QPatternist::AncestorIterator< IncludeSelf >, QPatternist::ItemMappingIterator< TResult, TSource, TMapper, Context >, QPatternist::RangeIterator, QPatternist::SequenceMappingIterator< TResult, TSource, TMapper >, QPatternist::DistinctIterator, QPatternist::IndexOfIterator, QPatternist::InsertionIterator, QPatternist::RemovalIterator, QPatternist::SubsequenceIterator, QPatternist::SingletonIterator< T >, StringSplitter, QPatternist::CachingIterator, QPatternist::ToCodepointsIterator, QPatternist::DeduplicateIterator, QPatternist::EmptyIterator< T >, QPatternist::EmptyIterator< QPatternist::Item >, QPatternist::IntersectIterator, QPatternist::ExceptIterator, and QPatternist::UnionIterator.

Referenced by QPatternist::AttributeIterator::AttributeIterator(), QPatternist::ChildIterator::ChildIterator(), QPatternist::SequenceMappingIterator< TResult, TSource, TMapper >::count(), QAbstractXmlForwardIterator< OutputType >::count(), QPatternist::FollowingIterator::FollowingIterator(), QAbstractXmlForwardIterator< OutputType >::isEmpty(), QAbstractXmlForwardIterator< OutputType >::last(), QPatternist::SequenceMappingIterator< TResult, TSource, TMapper >::next(), QPatternist::ItemMappingIterator< TResult, TSource, TMapper, Context >::next(), QPatternist::PrecedingIterator::PrecedingIterator(), QAbstractXmlForwardIterator< OutputType >::toList(), QAbstractXmlForwardIterator< OutputType >::toReversed(), and QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

◆ position()

template<typename T>
qint64 QAbstractXmlForwardIterator< T >::position ( ) const
pure virtual

◆ sizeHint()

template<typename T >
qint64 QAbstractXmlForwardIterator< T >::sizeHint ( ) const
virtual

Gives a hint to the size of the contained sequence.

Warning
This function is not part of the public interface.

The hint is assumed to be as close as possible to the actual size.

If no sensible estimate can be computed, -1 should be returned.

Definition at line 331 of file qabstractxmlforwarditerator_p.h.

Referenced by QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

332 {
333  Q_ASSERT_X(false, Q_FUNC_INFO, "This function is currently not expected to be used.");
334  return -1;
335 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ toList()

template<typename T >
QList< T > QAbstractXmlForwardIterator< T >::toList ( )
virtual

Performs a copy of this QAbstractXmlForwardIterator(with copy()), and returns its items in a QList.

Warning
This function is not part of the public interface.

Thus, this function acts as a conversion function, converting the sequence to a QList.

This function may modify the iterator. It is not a getter, but potentially alters the iterator in the same way the next() function does. If this QAbstractXmlForwardIterator must not be modified, such that it can be used for evaluation with next(), use a copy().

Reimplemented in QPatternist::ListIterator< T, ListType >, QPatternist::ListIterator< Item >, and QPatternist::ListIterator< QXmlNodeModelIndexIteratorPointer, QVector< QXmlNodeModelIndexIteratorPointer > >.

Definition at line 265 of file qabstractxmlforwarditerator_p.h.

Referenced by QPatternist::ListIterator< QXmlNodeModelIndexIteratorPointer, QVector< QXmlNodeModelIndexIteratorPointer > >::toList(), and QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

266 {
267  QList<T> result;
268  T item(next());
269 
270  while(!qIsForwardIteratorEnd(item))
271  {
272  result.append(item);
273  item = next();
274  }
275 
276  return result;
277 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
bool qIsForwardIteratorEnd(const T &unit)
The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence...
virtual T next()=0
Returns the next item in the sequence, or a null object if the end has been reached.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ toReversed()

template<typename T >
QAbstractXmlForwardIterator< T >::Ptr QAbstractXmlForwardIterator< T >::toReversed ( )
virtual

Returns a reverse iterator for the sequence.

Warning
This function is not part of the public interface.

This function may modify the iterator, it can be considered a function that evaluates this QAbstractXmlForwardIterator. It is not a getter, but potentially alters the iterator in the same way the next() function does. If this QAbstractXmlForwardIterator must not be modified, such that it can be used for evaluation with next(), use a copy().

Reimplemented in QPatternist::SingletonIterator< T >, QPatternist::RangeIterator, QPatternist::EmptyIterator< T >, and QPatternist::EmptyIterator< QPatternist::Item >.

Definition at line 291 of file qabstractxmlforwarditerator_p.h.

Referenced by QAbstractXmlForwardIterator< OutputType >::~QAbstractXmlForwardIterator().

292 {
293  T item(next());
294  QList<T> result;
295 
296  while(!qIsForwardIteratorEnd(item))
297  {
298  result.prepend(item);
299  item = next();
300  }
301 
303 }
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
bool qIsForwardIteratorEnd(const T &unit)
The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence...
Bridges values in Qt&#39;s QList container class into an QAbstractXmlForwardIterator. ...
virtual T next()=0
Returns the next item in the sequence, or a null object if the end has been reached.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Friends and Related Functions

◆ makeSequenceMappingIterator()

template<typename TResult , typename TSource , typename TMapper >
static QAbstractXmlForwardIterator< TResult >::Ptr makeSequenceMappingIterator ( const TMapper &  mapper,
const QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< TSource > > &  source,
const DynamicContext::Ptr &  context 
)
related

An object generator for SequenceMappingIterator.

makeSequenceMappingIterator() is a convenience function for avoiding specifying the full template instantiation for SequenceMappingIterator. Conceptually, it is identical to Qt's qMakePair().

Returns
a SequenceMappingIterator wrapped in a smart pointer, that has been passed the constructor arguments mapper, source, and context.
See also
makeMappingCallbackPtr()

Definition at line 224 of file qsequencemappingiterator_p.h.

227  {
229  (new SequenceMappingIterator<TResult, TSource, TMapper>(mapper, source, context));
230  }
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< T > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.

◆ qIsForwardIteratorEnd()

template<typename T>
bool qIsForwardIteratorEnd ( const T &  unit)
related

The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence.

Since
4.4

If unit is a value that would signal the end of a sequence (typically a default constructed value), this function returns true, otherwise false.

This implementation works for any type that has a boolean operator. For example, this function should work satisfactory for pointers.

Definition at line 72 of file qabstractxmlforwarditerator_p.h.

Referenced by QAbstractXmlForwardIterator< OutputType >::count(), QAbstractXmlForwardIterator< OutputType >::isEmpty(), QAbstractXmlForwardIterator< OutputType >::last(), QPatternist::SingletonIterator< T >::SingletonIterator(), QAbstractXmlForwardIterator< OutputType >::toList(), and QAbstractXmlForwardIterator< OutputType >::toReversed().

73 {
74  return !unit;
75 }

Properties

◆ d_ptr

template<typename T>
QAbstractXmlForwardIteratorPrivate* QAbstractXmlForwardIterator< T >::d_ptr
private

Definition at line 121 of file qabstractxmlforwarditerator_p.h.


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