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

Represents a stream of Unicode codepoints, which are computed from a string. More...

#include <qtocodepointsiterator_p.h>

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

Public Functions

virtual Item::Iterator::Ptr copy () const
 Copies this QAbstractXmlForwardIterator and returns the copy. More...
 
virtual xsInteger count ()
 Determines the number of items this QAbstractXmlForwardIterator represents. More...
 
virtual Item current () const
 Returns the current item in the sequence. More...
 
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...
 
 ToCodepointsIterator (const QString &string)
 
- Public Functions inherited from QAbstractXmlForwardIterator< Item >
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...
 

Properties

Item m_current
 
const int m_len
 
xsInteger m_position
 
const QString m_string
 

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

Represents a stream of Unicode codepoints, which are computed from a string.

ToCodepointsIterator takes in its constructor a string, whose Unicode characters' codepoints it forms an QAbstractXmlForwardIterator over.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 7.2.2 fn:string-to-codepoints
StringToCodepointsFN
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 75 of file qtocodepointsiterator_p.h.

Constructors and Destructors

◆ ToCodepointsIterator()

ToCodepointsIterator::ToCodepointsIterator ( const QString string)

Constructs a ToCodepointsIterator.

Parameters
stringthe string to retrieve Unicode codepoints from. Can not be empty.

Definition at line 50 of file qtocodepointsiterator.cpp.

Referenced by copy().

51  : m_string(string),
52  m_len(string.length()),
53  m_position(0)
54 {
55  Q_ASSERT(!string.isEmpty());
56 }
virtual bool isEmpty()
Returns true if the sequence is empty.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

Functions

◆ copy()

Item::Iterator::Ptr ToCodepointsIterator::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 90 of file qtocodepointsiterator.cpp.

91 {
93 }
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.

◆ count()

xsInteger ToCodepointsIterator::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 from QAbstractXmlForwardIterator< Item >.

Definition at line 75 of file qtocodepointsiterator.cpp.

76 {
77  return m_len;
78 }

◆ current()

Item ToCodepointsIterator::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 80 of file qtocodepointsiterator.cpp.

◆ next()

Item ToCodepointsIterator::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 58 of file qtocodepointsiterator.cpp.

59 {
60  if(m_position == -1)
61  return Item();
62 
63  ++m_position;
64  if(m_position > m_len)
65  {
66  m_position = -1;
67  m_current.reset();
68  return m_current;
69  }
70 
72  return m_current;
73 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
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

◆ position()

xsInteger ToCodepointsIterator::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 85 of file qtocodepointsiterator.cpp.

86 {
87  return m_position;
88 }

Properties

◆ m_current

Item QPatternist::ToCodepointsIterator::m_current
private

Definition at line 94 of file qtocodepointsiterator_p.h.

Referenced by current(), and next().

◆ m_len

const int QPatternist::ToCodepointsIterator::m_len
private

Definition at line 93 of file qtocodepointsiterator_p.h.

Referenced by count(), and next().

◆ m_position

xsInteger QPatternist::ToCodepointsIterator::m_position
private

Definition at line 95 of file qtocodepointsiterator_p.h.

Referenced by next(), and position().

◆ m_string

const QString QPatternist::ToCodepointsIterator::m_string
private

Definition at line 92 of file qtocodepointsiterator_p.h.

Referenced by copy(), and next().


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