summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2012-12-16 15:05:19 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-07 16:11:19 +0100
commit998899cf3a2501d3bf30ad06ce47a2cf81e1d60b (patch)
tree141fb19b0b2114d7690e366bfaf49e6c68e84fac /src/corelib
parentbc5a2336ab9a681411a81a53d8639b4b79f80073 (diff)
Introduce QRegularExpression::NoMatch match type
This match type doesn't do any match at all; it's only necessary to properly introduce default constructors for QRegularExpressionMatch and QRegularExpressionMatchIterator (since they return the match type that created them). Change-Id: Ibfe92459c7fdd23129cf3afe073cd443c461ddeb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qregularexpression.cpp17
-rw-r--r--src/corelib/tools/qregularexpression.h4
2 files changed, 20 insertions, 1 deletions
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 5c6b3ff044..1585389d22 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
+** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -725,6 +726,13 @@ QT_BEGIN_NAMESPACE
that (in this text) there are other characters beyond the end of the
subject string. This can lead to surprising results; see the discussion
in the \l{partial matching} section for more details.
+
+ \value NoMatch
+ No matching is done. This value is returned as the match type by a
+ default constructed QRegularExpressionMatch or
+ QRegularExpressionMatchIterator. Using this match type is not very
+ useful for the user, as no matching ever happens. This enum value
+ has been introduced in Qt 5.1.
*/
/*!
@@ -1200,6 +1208,15 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString
return new QRegularExpressionMatchPrivate(re, subject, matchType, matchOptions, 0);
}
+ // skip optimizing and doing the actual matching if NoMatch type was requested
+ if (matchType == QRegularExpression::NoMatch) {
+ QRegularExpressionMatchPrivate *priv = new QRegularExpressionMatchPrivate(re, subject,
+ matchType, matchOptions,
+ 0);
+ priv->isValid = true;
+ return priv;
+ }
+
QRegularExpressionMatchPrivate *priv = new QRegularExpressionMatchPrivate(re, subject,
matchType, matchOptions,
capturingCount);
diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h
index e312b10ff1..57d03a34e5 100644
--- a/src/corelib/tools/qregularexpression.h
+++ b/src/corelib/tools/qregularexpression.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
+** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -99,7 +100,8 @@ public:
enum MatchType {
NormalMatch = 0,
PartialPreferCompleteMatch,
- PartialPreferFirstMatch
+ PartialPreferFirstMatch,
+ NoMatch
};
enum MatchOption {