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

Forms an QAbstractXmlForwardIterator over a sequence of integers, which each is the position of where a search parameter appeared in another QAbstractXmlForwardIterator. More...

#include <qindexofiterator_p.h>

Inheritance diagram for QPatternist::IndexOfIterator:
QAbstractXmlForwardIterator< T > QPatternist::ComparisonPlatform< IndexOfIterator, false > QPatternist::SourceLocationReflection QSharedData

Public Functions

virtual const SourceLocationReflectionactualReflection () const
 
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...
 
 IndexOfIterator (const Item::Iterator::Ptr &inputSequence, const Item &searchParam, const AtomicComparator::Ptr &comp, const DynamicContext::Ptr &context, const Expression::ConstPtr &expr)
 
virtual Item next ()
 Returns the next item in the sequence, or a null object if the end has been reached. More...
 
AtomicComparator::Operator operatorID () const
 
virtual xsInteger position () const
 Returns the current position in the sequence represented by this. More...
 
- Public Functions inherited from QAbstractXmlForwardIterator< T >
virtual qint64 count ()
 Determines the number of items this QAbstractXmlForwardIterator represents. 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...
 
 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...
 
- Public Functions inherited from QPatternist::SourceLocationReflection
virtual QString description () const
 
virtual QSourceLocation sourceLocation () const
 
 SourceLocationReflection ()
 
virtual ~SourceLocationReflection ()
 

Properties

const DynamicContext::Ptr m_context
 
Item m_current
 
const Expression::ConstPtr m_expr
 
xsInteger m_position
 
const Item m_searchParam
 
const Item::Iterator::Ptr m_seq
 
xsInteger m_seqPos
 

Additional Inherited Members

- Public Types inherited from QAbstractXmlForwardIterator< T >
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 Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QPatternist::ComparisonPlatform< IndexOfIterator, false >
const AtomicComparator::Ptrcomparator () const
 
bool compare (const Item &i1, const Item &i2, const AtomicComparator::Ptr &comp, const AtomicComparator::Operator op) const
 Compares i1 and i2 with operator op, using comparator comp. All input arguments must be valid, and not null. More...
 
 ComparisonPlatform ()
 
AtomicComparator::ComparisonResult detailedFlexibleCompare (const Item &it1, const Item &it2, const DynamicContext::Ptr &context) const
 like flexibleCompare(), but returns the result as an AtomicComparator::Operator instead of bool. More...
 
AtomicComparator::Ptr fetchComparator (const ItemType::Ptr &type1, const ItemType::Ptr &type2, const ReportContext::Ptr &context) const
 
bool flexibleCompare (const Item &it1, const Item &it2, const DynamicContext::Ptr &context) const
 Compares it1 against it2, using comparator() and operatorID(). More...
 
void prepareComparison (const AtomicComparator::Ptr &comparator)
 
void useCaseInsensitiveComparator ()
 

Detailed Description

Forms an QAbstractXmlForwardIterator over a sequence of integers, which each is the position of where a search parameter appeared in another QAbstractXmlForwardIterator.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 15.1.3 fn:index-of
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 76 of file qindexofiterator_p.h.

Constructors and Destructors

◆ IndexOfIterator()

IndexOfIterator::IndexOfIterator ( const Item::Iterator::Ptr inputSequence,
const Item searchParam,
const AtomicComparator::Ptr comp,
const DynamicContext::Ptr context,
const Expression::ConstPtr expr 
)

Creates an IndexOfIterator, whose next() function returns integers being the index positions of where searchParam was found in inputSequence.

Parameters
compthe AtomicComparator to be used for comparing values. This may be null, meaning the IndexOfIterator iterator will dynamically determine what comparator to use on an item per item basis, which is slower.
searchParamthe item which should be compared to the items in inputSequence.
inputSequencethe input sequence which indexes of the searchParam should be returned for.
contextthe usual DynamicContext
exprthe Expression that this IndexOfIterator is evaluating for. It is used for error reporting, via actualReflection().

Definition at line 50 of file qindexofiterator.cpp.

Referenced by copy().

55  : m_seq(seq)
56  , m_searchParam(searchParam)
57  , m_context(context)
58  , m_expr(expr)
59  , m_position(0)
60  , m_seqPos(0)
61 {
62  Q_ASSERT(seq);
63  Q_ASSERT(searchParam);
64  prepareComparison(comp);
65 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const DynamicContext::Ptr m_context
const Expression::ConstPtr m_expr
const Item::Iterator::Ptr m_seq
void prepareComparison(const AtomicComparator::Ptr &comparator)

Functions

◆ actualReflection()

const SourceLocationReflection * IndexOfIterator::actualReflection ( ) const
virtual

Implements QPatternist::SourceLocationReflection.

Definition at line 110 of file qindexofiterator.cpp.

Referenced by operatorID().

111 {
112  return m_expr.data();
113 }
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
const Expression::ConstPtr m_expr

◆ copy()

Item::Iterator::Ptr IndexOfIterator::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< T >.

Definition at line 101 of file qindexofiterator.cpp.

102 {
103  return Item::Iterator::Ptr(new IndexOfIterator(m_seq->copy(),
105  comparator(),
106  m_context,
107  m_expr));
108 }
const DynamicContext::Ptr m_context
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.
const Expression::ConstPtr m_expr
IndexOfIterator(const Item::Iterator::Ptr &inputSequence, const Item &searchParam, const AtomicComparator::Ptr &comp, const DynamicContext::Ptr &context, const Expression::ConstPtr &expr)
const Item::Iterator::Ptr m_seq

◆ current()

Item IndexOfIterator::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< T >.

Definition at line 91 of file qindexofiterator.cpp.

92 {
93  return m_current;
94 }

◆ next()

Item IndexOfIterator::next ( )
virtual

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

Implements QAbstractXmlForwardIterator< T >.

Definition at line 67 of file qindexofiterator.cpp.

68 {
69  if(m_position == -1)
70  return Item();
71 
72  const Item item(m_seq->next());
73  ++m_seqPos;
74 
75  if(!item)
76  {
77  m_current.reset();
78  m_position = -1;
79  return Item();
80  }
81 
83  {
84  ++m_position;
85  return Integer::fromValue(m_seqPos);
86  }
87 
88  return next();
89 }
const DynamicContext::Ptr m_context
static Item fromValue(const xsInteger num)
Definition: qinteger.cpp:52
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
bool flexibleCompare(const Item &it1, const Item &it2, const DynamicContext::Ptr &context) const
Compares it1 against it2, using comparator() and operatorID().
const Item::Iterator::Ptr m_seq
virtual Item next()
Returns the next item in the sequence, or a null object if the end has been reached.

◆ operatorID()

AtomicComparator::Operator QPatternist::IndexOfIterator::operatorID ( ) const
inline

◆ position()

xsInteger IndexOfIterator::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< T >.

Definition at line 96 of file qindexofiterator.cpp.

97 {
98  return m_position;
99 }

Properties

◆ m_context

const DynamicContext::Ptr QPatternist::IndexOfIterator::m_context
private

Definition at line 117 of file qindexofiterator_p.h.

Referenced by copy(), and next().

◆ m_current

Item QPatternist::IndexOfIterator::m_current
private

Definition at line 119 of file qindexofiterator_p.h.

Referenced by current(), and next().

◆ m_expr

const Expression::ConstPtr QPatternist::IndexOfIterator::m_expr
private

Definition at line 118 of file qindexofiterator_p.h.

Referenced by actualReflection(), and copy().

◆ m_position

xsInteger QPatternist::IndexOfIterator::m_position
private

Definition at line 120 of file qindexofiterator_p.h.

Referenced by next(), and position().

◆ m_searchParam

const Item QPatternist::IndexOfIterator::m_searchParam
private

Definition at line 116 of file qindexofiterator_p.h.

Referenced by copy(), and next().

◆ m_seq

const Item::Iterator::Ptr QPatternist::IndexOfIterator::m_seq
private

Definition at line 115 of file qindexofiterator_p.h.

Referenced by copy(), and next().

◆ m_seqPos

xsInteger QPatternist::IndexOfIterator::m_seqPos
private

Definition at line 121 of file qindexofiterator_p.h.

Referenced by next().


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