Skip to content

Commit

Permalink
Remove redundant overloads in QString
Browse files Browse the repository at this point in the history
These were added since we couldn't add default parameters in the Qt 5 lifetime.

Change-Id: Idf04df78cc7f56c6c1dc1fe6c07e30003350ed0d
Reviewed-by: Edward Welbourne <[email protected]>
Reviewed-by: Vitaly Fanaskov <[email protected]>
  • Loading branch information
gladhorn committed Nov 13, 2019
1 parent a5f474b commit 36fcfd9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 62 deletions.
8 changes: 2 additions & 6 deletions src/corelib/doc/snippets/qstring/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
52 changes: 2 additions & 50 deletions src/corelib/text/qstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
{
Expand All @@ -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
Expand All @@ -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
{
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/corelib/text/qstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,11 @@ class Q_CORE_EXPORT QString
#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

Expand Down

0 comments on commit 36fcfd9

Please sign in to comment.