summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringview.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-12-02 12:31:41 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-12-10 02:15:18 +0100
commitce0b76731042412a0fa5a5f633fc48a52f79ef81 (patch)
treeb0e697beba8c24158a6312341417b82b6a561d2c /src/corelib/text/qstringview.h
parentbe83ff65c424cff1036e7da19d6175826d9f7ed9 (diff)
QStringView: add some QRegularExpression-related overloads
[ChangeLog][QtCore][QStringView] Added the indexOf(), contains(), lastIndexOf() and count() methods taking a QRegularExpression. Fixes: QTBUG-89050 Change-Id: Ic726754f67e06b3764302d2fad252e0378a77afc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstringview.h')
-rw-r--r--src/corelib/text/qstringview.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h
index df05fce252..42935440f3 100644
--- a/src/corelib/text/qstringview.h
+++ b/src/corelib/text/qstringview.h
@@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE
class QString;
class QStringView;
class QRegularExpression;
+class QRegularExpressionMatch;
namespace QtPrivate {
template <typename Char>
@@ -347,6 +348,25 @@ public:
{ return QtPrivate::lastIndexOf(*this, from, s, cs); }
[[nodiscard]] inline qsizetype lastIndexOf(QLatin1String s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
+#if QT_CONFIG(regularexpression)
+ [[nodiscard]] qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0, QRegularExpressionMatch *rmatch = nullptr) const
+ {
+ return QtPrivate::indexOf(*this, re, from, rmatch);
+ }
+ [[nodiscard]] qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1, QRegularExpressionMatch *rmatch = nullptr) const
+ {
+ return QtPrivate::lastIndexOf(*this, re, from, rmatch);
+ }
+ [[nodiscard]] bool contains(const QRegularExpression &re, QRegularExpressionMatch *rmatch = nullptr) const
+ {
+ return QtPrivate::contains(*this, re, rmatch);
+ }
+ [[nodiscard]] qsizetype count(const QRegularExpression &re) const
+ {
+ return QtPrivate::count(*this, re);
+ }
+#endif
+
[[nodiscard]] bool isRightToLeft() const noexcept
{ return QtPrivate::isRightToLeft(*this); }
[[nodiscard]] bool isValidUtf16() const noexcept