summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qregularexpression.h
diff options
context:
space:
mode:
authorMatthias Rauter <matthias.rauter@qt.io>2024-02-09 13:29:57 +0100
committerMarc Mutz <marc.mutz@qt.io>2024-04-29 07:40:29 +0000
commit737c6680b48d1e02832d9b71be5e9620f26ec484 (patch)
treea747aaccaea27079a12158683ea042e50771c623 /src/corelib/text/qregularexpression.h
parentab0b2a490eb98f3216403e87e4ea108a10fbeed2 (diff)
QRegularExpressionMatch: port API from QString to QAnyStringView keys
The QRegularExpression capture-by-name keys are currently QStringViews, but are only ever used to compare them against a const char16_t*, so this API is a perfect candidate for replacing all of these overload sets with a single QAnyStringView function. [ChangeLog][QtCore][QRegularExpression] Keys can now be passed as QAnyStringView (was QStringView). Fixes: QTBUG-103097 Change-Id: I1a80e85f301cc08370d70b3b5eb0ae10c6a51f33 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qregularexpression.h')
-rw-r--r--src/corelib/text/qregularexpression.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/corelib/text/qregularexpression.h b/src/corelib/text/qregularexpression.h
index ed838327ef..2b51b94b15 100644
--- a/src/corelib/text/qregularexpression.h
+++ b/src/corelib/text/qregularexpression.h
@@ -213,18 +213,26 @@ public:
int lastCapturedIndex() const;
+#if QT_CORE_REMOVED_SINCE(6, 8)
bool hasCaptured(const QString &name) const
- { return hasCaptured(QStringView(name)); }
+ { return hasCaptured(qToAnyStringViewIgnoringNull(name)); }
bool hasCaptured(QStringView name) const;
+#endif
+ bool hasCaptured(QAnyStringView name) const;
bool hasCaptured(int nth) const;
QString captured(int nth = 0) const;
QStringView capturedView(int nth = 0) const;
+#if QT_CORE_REMOVED_SINCE(6, 8)
QString captured(const QString &name) const
- { return captured(QStringView(name)); }
+ { return captured(qToAnyStringViewIgnoringNull(name)); }
+
QString captured(QStringView name) const;
QStringView capturedView(QStringView name) const;
+#endif
+ QString captured(QAnyStringView name) const;
+ QStringView capturedView(QAnyStringView name) const;
QStringList capturedTexts() const;
@@ -232,16 +240,21 @@ public:
qsizetype capturedLength(int nth = 0) const;
qsizetype capturedEnd(int nth = 0) const;
+#if QT_CORE_REMOVED_SINCE(6, 8)
qsizetype capturedStart(const QString &name) const
- { return capturedStart(QStringView(name)); }
+ { return capturedStart(qToAnyStringViewIgnoringNull(name)); }
qsizetype capturedLength(const QString &name) const
- { return capturedLength(QStringView(name)); }
+ { return capturedLength(qToAnyStringViewIgnoringNull(name)); }
qsizetype capturedEnd(const QString &name) const
- { return capturedEnd(QStringView(name)); }
+ { return capturedEnd(qToAnyStringViewIgnoringNull(name)); }
qsizetype capturedStart(QStringView name) const;
qsizetype capturedLength(QStringView name) const;
qsizetype capturedEnd(QStringView name) const;
+#endif
+ qsizetype capturedStart(QAnyStringView name) const;
+ qsizetype capturedLength(QAnyStringView name) const;
+ qsizetype capturedEnd(QAnyStringView name) const;
private:
friend class QRegularExpression;