From 36fcfd962d0514a49ec242122989e6b4a58f1349 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 6 Nov 2019 13:29:37 +0100 Subject: [PATCH] Remove redundant overloads in QString These were added since we couldn't add default parameters in the Qt 5 lifetime. Change-Id: Idf04df78cc7f56c6c1dc1fe6c07e30003350ed0d Reviewed-by: Edward Welbourne Reviewed-by: Vitaly Fanaskov --- src/corelib/doc/snippets/qstring/main.cpp | 8 +--- src/corelib/text/qstring.cpp | 52 +---------------------- src/corelib/text/qstring.h | 11 +++-- 3 files changed, 9 insertions(+), 62 deletions(-) diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index ac7fc7d078c..f797890e5d9 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -433,14 +433,12 @@ void Widget::firstIndexOfFunction() //! [93] QString str = "the minimum"; str.indexOf(QRegularExpression("m[aeiou]"), 0); // returns 4 - //! [93] - //! [99] QString str = "the minimum"; QRegularExpressionMatch match; str.indexOf(QRegularExpression("m[aeiou]"), 0, &match); // returns 4 // match.captured() == mi - //! [99] + //! [93] } void Widget::insertFunction() @@ -490,14 +488,12 @@ void Widget::lastIndexOfFunction() //! [94] QString str = "the minimum"; str.lastIndexOf(QRegularExpression("m[aeiou]")); // returns 8 - //! [94] - //! [100] QString str = "the minimum"; QRegularExpressionMatch match; str.lastIndexOf(QRegularExpression("m[aeiou]"), -1, &match); // returns 8 // match.captured() == mu - //! [100] + //! [94] } void Widget::leftFunction() diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index edce0ff720d..dcdc87181e9 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -4431,24 +4431,6 @@ int QString::count(const QRegExp& rx) const #if QT_CONFIG(regularexpression) /*! - \overload indexOf() - \since 5.0 - - Returns the index position of the first match of the regular - expression \a re in the string, searching forward from index - position \a from. Returns -1 if \a re didn't match anywhere. - - Example: - - \snippet qstring/main.cpp 93 -*/ -int QString::indexOf(const QRegularExpression& re, int from) const -{ - return indexOf(re, from, nullptr); -} - -/*! - \overload \since 5.5 Returns the index position of the first match of the regular @@ -4461,7 +4443,7 @@ int QString::indexOf(const QRegularExpression& re, int from) const Example: - \snippet qstring/main.cpp 99 + \snippet qstring/main.cpp 93 */ int QString::indexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const { @@ -4482,24 +4464,6 @@ int QString::indexOf(const QRegularExpression &re, int from, QRegularExpressionM } /*! - \overload lastIndexOf() - \since 5.0 - - Returns the index position of the last match of the regular - expression \a re in the string, which starts before the index - position \a from. Returns -1 if \a re didn't match anywhere. - - Example: - - \snippet qstring/main.cpp 94 -*/ -int QString::lastIndexOf(const QRegularExpression &re, int from) const -{ - return lastIndexOf(re, from, nullptr); -} - -/*! - \overload \since 5.5 Returns the index position of the last match of the regular @@ -4512,7 +4476,7 @@ int QString::lastIndexOf(const QRegularExpression &re, int from) const Example: - \snippet qstring/main.cpp 100 + \snippet qstring/main.cpp 94 */ int QString::lastIndexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const { @@ -4539,19 +4503,7 @@ int QString::lastIndexOf(const QRegularExpression &re, int from, QRegularExpress return lastIndex; } -/*! \overload contains() - \since 5.0 - - Returns \c true if the regular expression \a re matches somewhere in - this string; otherwise returns \c false. -*/ -bool QString::contains(const QRegularExpression &re) const -{ - return contains(re, nullptr); -} - /*! - \overload contains() \since 5.1 Returns \c true if the regular expression \a re matches somewhere in this diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 5def2c81a12..46359620573 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -425,12 +425,11 @@ public: #endif #if QT_CONFIG(regularexpression) - int indexOf(const QRegularExpression &re, int from = 0) const; - int indexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads - int lastIndexOf(const QRegularExpression &re, int from = -1) const; - int lastIndexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads - bool contains(const QRegularExpression &re) const; - bool contains(const QRegularExpression &re, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads + int indexOf(const QRegularExpression &re, int from = 0, + QRegularExpressionMatch *rmatch = nullptr) const; + int lastIndexOf(const QRegularExpression &re, int from = -1, + QRegularExpressionMatch *rmatch = nullptr) const; + bool contains(const QRegularExpression &re, QRegularExpressionMatch *rmatch = nullptr) const; int count(const QRegularExpression &re) const; #endif