Patternist::Iterator< T > Class Template Reference
[Iterators]

Base class for all Iterator classes, the primary way to represent data. More...

#include <Iterator.h>

Inheritance diagram for Patternist::Iterator< T >:

Inheritance graph
[legend]
Collaboration diagram for Patternist::Iterator< T >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef QList< typename Iterator<
T >::Ptr
List
typedef PlainSharedPtr< Iterator<
T > > 
Ptr
typedef QVector< typename
Iterator< T >::Ptr
Vector

Public Member Functions

virtual Cardinality cardinality ()
virtual Iterator< T >::Ptr copy () const=0
 Copies this Iterator and returns the copy.
virtual xsInteger count ()
virtual T current () const=0
 Iterator ()
virtual T next ()=0
virtual xsInteger position () const=0
virtual QList< T > toList ()
virtual Iterator< T >::Ptr toReversed ()
virtual ~Iterator ()

Related Functions

(Note that these are not member functions.)

static Iterator< TResult
>::Ptr 
makeSequenceMappingIterator (const TMapper &mapper, const PlainSharedPtr< Iterator< TSource > > &source, const DynamicContext::Ptr &context)
 An object generator for SequenceMappingIterator.

Detailed Description

template<typename T>
class Patternist::Iterator< T >

Base class for all Iterator classes, the primary way to represent data.

In order for an item to be able to be instantiated in Iterator, it needs to:

Author:
Frans Englich <frans.englich@telia.com>

Definition at line 54 of file Iterator.h.


Member Typedef Documentation

template<typename T>
typedef QList<typename Iterator<T>::Ptr> Patternist::Iterator< T >::List

A list of Iterator instances, each wrapped in a smart pointer.

Definition at line 65 of file Iterator.h.

template<typename T>
typedef PlainSharedPtr<Iterator<T> > Patternist::Iterator< T >::Ptr

A smart pointer wrapping an Item instance.

Definition at line 60 of file Iterator.h.

template<typename T>
typedef QVector<typename Iterator<T>::Ptr> Patternist::Iterator< T >::Vector

A vector of Iterator instances, each wrapped in a smart pointer.

Definition at line 70 of file Iterator.h.


Member Function Documentation

template<typename T>
Cardinality Patternist::Iterator< T >::cardinality (  )  [virtual]

Determines the cardinality of the sequence the Iterator this Iterator iterates over. The returned cardinality must not be a union but an exact cardinality; for example, Cardinality::empty() is but Cardinality::zeroOrMore() isn't. Thus, valid return values are Cardinality::empty(), Cardinality::exactlyOne(), and Cardinality::twoOrMore.

The default implementation calls next() for determining the cardinality.

Note:
This function may modify the iterator, it can be considered a function that evaluates this Iterator. It is not a getter, but potentially alters the iterator in the same way the next() function does. If this Iterator should stay intact, such that it can be used for evaluation with next(), one should first copy this Iterator with the copy() function.

Reimplemented in Patternist::EmptyIterator< T >, Patternist::ListIterator< T >, Patternist::RangeIterator, Patternist::RemovalIterator, Patternist::SingletonIterator< T >, Patternist::ToCodepointsIterator, and Patternist::EmptyIterator< Patternist::PlainSharedPtrlainSharedPtr< Item > >.

Definition at line 200 of file Iterator.h.

References Patternist::Cardinality::empty(), Patternist::Cardinality::exactlyOne(), Patternist::isIteratorEnd(), Patternist::Iterator< T >::next(), and Patternist::Cardinality::twoOrMore().

Here is the call graph for this function:

template<typename T>
virtual Iterator<T>::Ptr Patternist::Iterator< T >::copy (  )  const [pure virtual]

Copies this Iterator and returns the copy.

A copy and the original instance are completely independent of each other, and doesn't affect each other in anyway. Since evaluating an Iterator modifies it one should always use a copy when an Iterator needs to be used several times.

Returns:
a copy of this Iterator.

Implemented in Patternist::AncestorIterator< IncludeSelf >, Patternist::ChildIterator, Patternist::SiblingIterator< IsFollowing >, Patternist::DescendantIterator< IncludeSelf >, Patternist::FollowingIterator, Patternist::PrecedingIterator, Patternist::AttributeIterator, Patternist::DistinctIterator, Patternist::EmptyIterator< T >, Patternist::IndexOfIterator, Patternist::InsertionIterator, Patternist::ItemMappingIterator< TResult, TSource, TMapper >, Patternist::ListIterator< T >, Patternist::RangeIterator, Patternist::RemovalIterator, Patternist::SequenceMappingIterator< TResult, TSource, TMapper >, Patternist::SingletonIterator< T >, Patternist::SubsequenceIterator, Patternist::ToCodepointsIterator, and Patternist::EmptyIterator< Patternist::PlainSharedPtrlainSharedPtr< Item > >.

Referenced by Patternist::SequenceMappingIterator< TResult, TSource, TMapper >::copy(), and Patternist::ItemMappingIterator< TResult, TSource, TMapper >::copy().

Here is the caller graph for this function:

template<typename T>
xsInteger Patternist::Iterator< T >::count (  )  [virtual]

Determines the amount of items this Iterator represents.

Note that this function is not const, it modifies the Iterator as opposed to for example Qt's container classes functions by the same name. The reason for this is efficiency. If this Iterator should stay intact, one should use a copy().

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.

Returns:
the size of the sequence, the number of items in the sequence.

Reimplemented in Patternist::EmptyIterator< T >, Patternist::InsertionIterator, Patternist::ListIterator< T >, Patternist::RangeIterator, Patternist::RemovalIterator, Patternist::SequenceMappingIterator< TResult, TSource, TMapper >, Patternist::SingletonIterator< T >, Patternist::ToCodepointsIterator, and Patternist::EmptyIterator< Patternist::PlainSharedPtrlainSharedPtr< Item > >.

Definition at line 189 of file Iterator.h.

References Patternist::isIteratorEnd(), and Patternist::Iterator< T >::next().

Here is the call graph for this function:

template<typename T>
virtual T Patternist::Iterator< T >::current (  )  const [pure virtual]

Returns:
the current item in the sequence. If it is called before any call to next(), null is returned. If the end of the sequence have beeen reached null.

Implemented in Patternist::AccelIterator, Patternist::DistinctIterator, Patternist::EmptyIterator< T >, Patternist::IndexOfIterator, Patternist::InsertionIterator, Patternist::ItemMappingIterator< TResult, TSource, TMapper >, Patternist::ListIterator< T >, Patternist::RangeIterator, Patternist::RemovalIterator, Patternist::SequenceMappingIterator< TResult, TSource, TMapper >, Patternist::SingletonIterator< T >, Patternist::SubsequenceIterator, Patternist::ToCodepointsIterator, and Patternist::EmptyIterator< Patternist::PlainSharedPtrlainSharedPtr< Item > >.

template<typename T>
virtual T Patternist::Iterator< T >::next (  )  [pure virtual]

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

Implemented in Patternist::AncestorIterator< IncludeSelf >, Patternist::ChildIterator, Patternist::SiblingIterator< IsFollowing >, Patternist::DescendantIterator< IncludeSelf >, Patternist::FollowingIterator, Patternist::PrecedingIterator, Patternist::AttributeIterator, Patternist::DistinctIterator, Patternist::EmptyIterator< T >, Patternist::IndexOfIterator, Patternist::InsertionIterator, Patternist::ItemMappingIterator< TResult, TSource, TMapper >, Patternist::ListIterator< T >, Patternist::RangeIterator, Patternist::RemovalIterator, Patternist::SequenceMappingIterator< TResult, TSource, TMapper >, Patternist::SingletonIterator< T >, Patternist::SubsequenceIterator, Patternist::ToCodepointsIterator, and Patternist::EmptyIterator< Patternist::PlainSharedPtrlainSharedPtr< Item > >.

Referenced by Patternist::Iterator< T >::cardinality(), Patternist::SequenceMappingIterator< TResult, TSource, TMapper >::count(), Patternist::Iterator< T >::count(), Patternist::SequenceMappingIterator< TResult, TSource, TMapper >::next(), Patternist::ItemMappingIterator< TResult, TSource, TMapper >::next(), Patternist::Iterator< T >::toList(), and Patternist::Iterator< T >::toReversed().

Here is the caller graph for this function:

template<typename T>
virtual xsInteger Patternist::Iterator< T >::position (  )  const [pure virtual]

Returns the current position in the stream.

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

Returns:
the current position

Implemented in Patternist::AccelIterator, Patternist::DistinctIterator, Patternist::EmptyIterator< T >, Patternist::IndexOfIterator, Patternist::InsertionIterator, Patternist::ItemMappingIterator< TResult, TSource, TMapper >, Patternist::ListIterator< T >, Patternist::RangeIterator, Patternist::RemovalIterator, Patternist::SequenceMappingIterator< TResult, TSource, TMapper >, Patternist::SingletonIterator< T >, Patternist::SubsequenceIterator, Patternist::ToCodepointsIterator, and Patternist::EmptyIterator< Patternist::PlainSharedPtrlainSharedPtr< Item > >.

template<typename T>
QList< T > Patternist::Iterator< T >::toList (  )  [virtual]

Performs a copy of this Iterator(with copy()), and returns its items in a QList. Thus, this function acts as a conversion function, by allowing a sequence of items to be converted into a QList, instead of being represented by an Iterator.

Note:
This function may modify the iterator, it can be considered a function that evaluates this Iterator. It is not a getter, but potentially alters the iterator in the same way the next() function does. If this Iterator should stay intact, such that it can be used for evaluation with next(), one should first copy this Iterator with the copy() function.

Reimplemented in Patternist::ListIterator< T >.

Definition at line 174 of file Iterator.h.

References Patternist::isIteratorEnd(), and Patternist::Iterator< T >::next().

Here is the call graph for this function:

template<typename T>
Iterator< T >::Ptr Patternist::Iterator< T >::toReversed (  )  [virtual]

Retrieves an iterator working in a reverse direction over the sequence.

Note:
This function may modify the iterator, it can be considered a function that evaluates this Iterator. It is not a getter, but potentially alters the iterator in the same way the next() function does. If this Iterator should stay intact, such that it can be used for evaluation with next(), one should first copy this Iterator with the copy() function.
See also:
XQuery 1.0 and XPath 2.0 Functions and Operators, 15.1.9 fn:reverse
Returns:
an iterator that iterates the sequence this iterator represents, in reverse order.

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

Definition at line 216 of file Iterator.h.

References Patternist::isIteratorEnd(), and Patternist::Iterator< T >::next().

Here is the call graph for this function:


Friends And Related Function Documentation

template<typename T>
static Iterator< TResult >::Ptr makeSequenceMappingIterator ( const TMapper &  mapper,
const PlainSharedPtr< Iterator< 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 185 of file SequenceMappingIterator.h.


The documentation for this class was generated from the following files:
Generated on Thu Feb 8 14:54:34 2007 for Patternist by  doxygen 1.5.1