summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-05-03 12:42:36 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-03 16:14:21 +0200
commitbabd3e252b87a3b9c91cd44189d4fcb5cd8ab270 (patch)
tree64104a9f17bbf8e1a6e0a9f7d011c177240d7c35
parent26f6a93ca55715ebb55beb413be8d29f8180a072 (diff)
Revert "[SIC] Make non-const the QRegExp methods that modify the internals"
This reverts commit 75a0c7f9b52cde47f20fdc1b89e1264d60350848. The source-incompatible change proved to be more trouble than it's worth. Too much intrusion into the porting effort of applications for no appreciable gain, especially considering that we have a replacement class. Change-Id: Ia99a2360390a2062a8ddb6e12c8f2099287a2704 Discussed-on: http://lists.qt-project.org/pipermail/development/2012-May/003562.html Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--dist/changes-5.0.07
-rw-r--r--src/corelib/tools/qregexp.cpp18
-rw-r--r--src/corelib/tools/qregexp.h6
3 files changed, 18 insertions, 13 deletions
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0
index 353c7694d6..0df359f3ed 100644
--- a/dist/changes-5.0.0
+++ b/dist/changes-5.0.0
@@ -353,13 +353,6 @@ QtCore
QRegularExpressionMatchIterator. They aim to replace QRegExp with a more
powerful and flexible regular expression engine.
-* Certain methods in QRegExp that modified the object's internals are no longer marked
- const. They were accidentally marked const in Qt 4 but the problem could not be
- fixed. The following are suggestions to adapt code to this change:
- - make sure the QRegExp object is not const in the given context
- - create a copy of the QRegExp object before using it
- - invert the operation and use QString. E.g., rx.indexIn(string) becomes string.indexOf(rx)
-
* QEvent::AccessibilityPrepare, AccessibilityHelp and AccessibilityDescription removed:
* The enum values simply didn't make sense in the first place and should simply be dropped.
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index e2167c5999..79ceba5ceb 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -4204,6 +4204,7 @@ void QRegExp::setMinimal(bool minimal)
priv->minimal = minimal;
}
+// ### Qt 5: make non-const
/*!
Returns true if \a str is matched exactly by this regular
expression; otherwise returns false. You can determine how much of
@@ -4219,9 +4220,12 @@ void QRegExp::setMinimal(bool minimal)
bluebell, \c blutak and \c lightblue, exactMatch() returns false
and matchedLength() will return 4, 3 and 0 respectively.
+ Although const, this function sets matchedLength(),
+ capturedTexts(), and pos().
+
\sa indexIn(), lastIndexIn()
*/
-bool QRegExp::exactMatch(const QString &str)
+bool QRegExp::exactMatch(const QString &str) const
{
prepareEngineForMatch(priv, str);
priv->matchState.match(str.unicode(), str.length(), 0, priv->minimal, true, 0);
@@ -4234,6 +4238,7 @@ bool QRegExp::exactMatch(const QString &str)
}
}
+// ### Qt 5: make non-const
/*!
Attempts to find a match in \a str from position \a offset (0 by
default). If \a offset is -1, the search starts at the last
@@ -4252,6 +4257,9 @@ bool QRegExp::exactMatch(const QString &str)
Example:
\snippet code/src_corelib_tools_qregexp.cpp 13
+ Although const, this function sets matchedLength(),
+ capturedTexts() and pos().
+
If the QRegExp is a wildcard expression (see setPatternSyntax())
and want to test a string against the whole wildcard expression,
use exactMatch() instead of this function.
@@ -4259,7 +4267,7 @@ bool QRegExp::exactMatch(const QString &str)
\sa lastIndexIn(), exactMatch()
*/
-int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode)
+int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const
{
prepareEngineForMatch(priv, str);
if (offset < 0)
@@ -4269,6 +4277,7 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode)
return priv->matchState.captured[0];
}
+// ### Qt 5: make non-const
/*!
Attempts to find a match backwards in \a str from position \a
offset. If \a offset is -1 (the default), the search starts at the
@@ -4280,13 +4289,16 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode)
The \a caretMode parameter can be used to instruct whether \b{^}
should match at index 0 or at \a offset.
+ Although const, this function sets matchedLength(),
+ capturedTexts() and pos().
+
\warning Searching backwards is much slower than searching
forwards.
\sa indexIn(), exactMatch()
*/
-int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode)
+int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode) const
{
prepareEngineForMatch(priv, str);
if (offset < 0)
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 234bb624e4..0455e1603e 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -93,10 +93,10 @@ public:
bool isMinimal() const;
void setMinimal(bool minimal);
- bool exactMatch(const QString &str);
+ bool exactMatch(const QString &str) const;
- int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero);
- int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero);
+ int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const;
+ int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const;
int matchedLength() const;
#ifndef QT_NO_REGEXP_CAPTURE
int captureCount() const;