diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-04-20 16:50:36 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-28 19:42:51 +0200 |
commit | 75a0c7f9b52cde47f20fdc1b89e1264d60350848 (patch) | |
tree | f8869a328f2205bd9027b0580f49f3cf9bd60a85 /src | |
parent | 00b961c37f82977615ab9c4d03e185229cc55154 (diff) |
[SIC] Make non-const the QRegExp methods that modify the internals
These methods modify QRegExp internals and should not have been
const. It's actually dangerous to have them const, since users may
think it's safe to use the matching method in a thread-safe manner.
Task-number: QTBUG-25064
Change-Id: Ia370eb42fd0407a94924f420297c5e83d3908214
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qregexp.cpp | 18 | ||||
-rw-r--r-- | src/corelib/tools/qregexp.h | 6 |
2 files changed, 6 insertions, 18 deletions
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 79ceba5ceb..e2167c5999 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -4204,7 +4204,6 @@ 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 @@ -4220,12 +4219,9 @@ 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) const +bool QRegExp::exactMatch(const QString &str) { prepareEngineForMatch(priv, str); priv->matchState.match(str.unicode(), str.length(), 0, priv->minimal, true, 0); @@ -4238,7 +4234,6 @@ bool QRegExp::exactMatch(const QString &str) const } } -// ### 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 @@ -4257,9 +4252,6 @@ bool QRegExp::exactMatch(const QString &str) const 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. @@ -4267,7 +4259,7 @@ bool QRegExp::exactMatch(const QString &str) const \sa lastIndexIn(), exactMatch() */ -int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const +int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) { prepareEngineForMatch(priv, str); if (offset < 0) @@ -4277,7 +4269,6 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const 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 @@ -4289,16 +4280,13 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const 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) const +int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode) { prepareEngineForMatch(priv, str); if (offset < 0) diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h index 0455e1603e..234bb624e4 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) const; + bool exactMatch(const QString &str); - 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 indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero); + int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero); int matchedLength() const; #ifndef QT_NO_REGEXP_CAPTURE int captureCount() const; |