summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearraymatcher.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-09-28 18:58:25 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-10-01 14:23:15 -0700
commitf6fa78fd600d0b78d279993f02d86b14aeb6fc22 (patch)
tree2dda0d730ab724d67fc2308dccc57c2a941301d3 /src/corelib/text/qbytearraymatcher.h
parent90c54b02f83961b1c66f10fe57bcfcf4523ebba1 (diff)
QByteArrayMatcher: add QByteArrayView overloads
The modification to the existing constructor was necessary to avoid ambiguous overloads from plain strings. They'd previously only match QByteArray, but now they match QByteArrayView too. The QByteArray constructor must stay even in Qt 7 because the pattern is stored. The QByteArray indexIn also stays in because of ambiguous overloads. Unless we want to remove the const char* overloads. Change-Id: I2bbf422288924c198645fffd16a92859b67f3978 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearraymatcher.h')
-rw-r--r--src/corelib/text/qbytearraymatcher.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/corelib/text/qbytearraymatcher.h b/src/corelib/text/qbytearraymatcher.h
index db6c06128c..d9ea638500 100644
--- a/src/corelib/text/qbytearraymatcher.h
+++ b/src/corelib/text/qbytearraymatcher.h
@@ -54,7 +54,10 @@ class Q_CORE_EXPORT QByteArrayMatcher
public:
QByteArrayMatcher();
explicit QByteArrayMatcher(const QByteArray &pattern);
- explicit QByteArrayMatcher(const char *pattern, qsizetype length);
+ explicit QByteArrayMatcher(QByteArrayView pattern)
+ : QByteArrayMatcher(pattern.data(), pattern.size())
+ {}
+ explicit QByteArrayMatcher(const char *pattern, qsizetype length = -1);
QByteArrayMatcher(const QByteArrayMatcher &other);
~QByteArrayMatcher();
@@ -64,6 +67,10 @@ public:
qsizetype indexIn(const QByteArray &ba, qsizetype from = 0) const;
qsizetype indexIn(const char *str, qsizetype len, qsizetype from = 0) const;
+ qsizetype indexIn(QByteArrayView data, qsizetype from = 0) const
+ {
+ return indexIn(data.data(), data.size(), from);
+ }
inline QByteArray pattern() const
{
if (q_pattern.isNull())