Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QRegularExpressionMatchIterator Class

The QRegularExpressionMatchIterator class provides an iterator on the results of a global match of a QRegularExpression object against a string. More...

 #include <QRegularExpressionMatchIterator>

Note: All functions in this class are reentrant.

This class was introduced in Qt 5.0.

Public Functions

QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator & iterator)
~QRegularExpressionMatchIterator()
bool hasNext() const
bool isValid() const
QRegularExpression::MatchOptions matchOptions() const
QRegularExpression::MatchType matchType() const
QRegularExpressionMatch next()
QRegularExpressionMatch peekNext() const
QRegularExpression regularExpression() const
void swap(QRegularExpressionMatchIterator & other)
QRegularExpressionMatchIterator & operator=(const QRegularExpressionMatchIterator & iterator)

Detailed Description

The QRegularExpressionMatchIterator class provides an iterator on the results of a global match of a QRegularExpression object against a string.

A QRegularExpressionMatchIterator object is a forward only Java-like iterator; it can be obtained by calling the QRegularExpression::globalMatch() function. A new QRegularExpressionMatchIterator will be positioned before the first result. You can then call the hasNext() function to check if there are more results available; if so, the next() function will return the next result and advance the iterator.

Each result is a QRegularExpressionMatch object holding all the information for that result (including captured substrings).

For instance:

 // extracts the words
 QRegularExpression re("(\w+)");
 QString subject("the quick fox");
 QRegularExpressionMatchIterator i = re.globalMatch(subject);
 while (i.hasNext()) {
     QRegularExpressionMatch match = i.next();
     // ...
 }

Moreover, QRegularExpressionMatchIterator offers a peekNext() function to get the next result without advancing the iterator.

You can retrieve the QRegularExpression object the subject string was matched against by calling the regularExpression() function; the match type and the match options are available as well by calling the matchType() and the matchOptions() respectively.

Please refer to the QRegularExpression documentation for more information about the Qt regular expression classes.

See also QRegularExpression and QRegularExpressionMatch.

Member Function Documentation

QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator & iterator)

Constructs a QRegularExpressionMatchIterator object as a copy of iterator.

See also operator=().

QRegularExpressionMatchIterator::~QRegularExpressionMatchIterator()

Destroys the QRegularExpressionMatchIterator object.

bool QRegularExpressionMatchIterator::hasNext() const

Returns true if there is at least one match result ahead of the iterator; otherwise it returns false.

See also next().

bool QRegularExpressionMatchIterator::isValid() const

Returns true if the iterator object was obtained as a result from the QRegularExpression::globalMatch() function invoked on a valid QRegularExpression object; returns false if the QRegularExpression was invalid.

See also QRegularExpression::globalMatch() and QRegularExpression::isValid().

QRegularExpression::MatchOptions QRegularExpressionMatchIterator::matchOptions() const

Returns the match options that were used to get this QRegularExpressionMatchIterator object, that is, the match options that were passed to QRegularExpression::globalMatch().

See also QRegularExpression::globalMatch(), regularExpression(), and matchType().

QRegularExpression::MatchType QRegularExpressionMatchIterator::matchType() const

Returns the match type that was used to get this QRegularExpressionMatchIterator object, that is, the match type that was passed to QRegularExpression::globalMatch().

See also QRegularExpression::globalMatch(), regularExpression(), and matchOptions().

QRegularExpressionMatch QRegularExpressionMatchIterator::next()

Returns the next match result and advances the iterator by one position.

Note: Calling this function when the iterator is at the end of the result set leads to undefined results.

QRegularExpressionMatch QRegularExpressionMatchIterator::peekNext() const

Returns the next match result without moving the iterator.

Note: Calling this function when the iterator is at the end of the result set leads to undefined results.

QRegularExpression QRegularExpressionMatchIterator::regularExpression() const

Returns the QRegularExpression object whose globalMatch() function returned this object.

See also QRegularExpression::globalMatch(), matchType(), and matchOptions().

void QRegularExpressionMatchIterator::swap(QRegularExpressionMatchIterator & other)

Swaps the iterator other with this iterator object. This operation is very fast and never fails.

QRegularExpressionMatchIterator & QRegularExpressionMatchIterator::operator=(const QRegularExpressionMatchIterator & iterator)

Assigns the iterator iterator to this object, and returns a reference to the copy.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web