wasm: use matchView() instead of match()

QRegularExpression::match() is deprecated.

Change-Id: I66c7b3043a3805614fedcdb081c7e704e9925e5e
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Morten Sørvig 2022-08-19 09:37:53 +02:00
parent d2e9d70ec1
commit 407a39d3ca

View File

@ -46,7 +46,7 @@ std::optional<Type> Type::fromQt(QStringView type)
// Group 1 is treated as the description, whereas group 2 or 3 are treated as the filter list. // Group 1 is treated as the description, whereas group 2 or 3 are treated as the filter list.
static QRegularExpression regex( static QRegularExpression regex(
QString(QStringLiteral("(?:(?:([^(]*)\\(([^()]+)\\)[^)]*)|([^()]+))"))); QString(QStringLiteral("(?:(?:([^(]*)\\(([^()]+)\\)[^)]*)|([^()]+))")));
const auto match = regex.match(type); const auto match = regex.matchView(type);
if (!match.hasMatch()) if (!match.hasMatch())
return std::nullopt; return std::nullopt;
@ -86,7 +86,7 @@ std::optional<Type::Accept> Type::Accept::fromQt(QStringView qtRepresentation)
// The next group of non-empty characters. // The next group of non-empty characters.
static QRegularExpression internalRegex(QString(QStringLiteral("([^\\s]+)\\s*"))); static QRegularExpression internalRegex(QString(QStringLiteral("([^\\s]+)\\s*")));
int offset = 0; int offset = 0;
auto internalMatch = internalRegex.match(qtRepresentation, offset); auto internalMatch = internalRegex.matchView(qtRepresentation, offset);
MimeType mimeType; MimeType mimeType;
while (internalMatch.hasMatch()) { while (internalMatch.hasMatch()) {
@ -97,7 +97,7 @@ std::optional<Type::Accept> Type::Accept::fromQt(QStringView qtRepresentation)
mimeType.addExtension(*webExtension); mimeType.addExtension(*webExtension);
internalMatch = internalRegex.match(qtRepresentation, internalMatch.capturedEnd()); internalMatch = internalRegex.matchView(qtRepresentation, internalMatch.capturedEnd());
} }
accept.addMimeType(mimeType); accept.addMimeType(mimeType);
@ -144,7 +144,7 @@ Type::Accept::MimeType::Extension::fromQt(QStringView qtRepresentation)
// The web filter does not support wildcards. // The web filter does not support wildcards.
static QRegularExpression qtAcceptAllRegex( static QRegularExpression qtAcceptAllRegex(
QRegularExpression::anchoredPattern(QString(QStringLiteral("[*]+|[*]+\\.[*]+")))); QRegularExpression::anchoredPattern(QString(QStringLiteral("[*]+|[*]+\\.[*]+"))));
if (qtAcceptAllRegex.match(qtRepresentation).hasMatch()) if (qtAcceptAllRegex.matchView(qtRepresentation).hasMatch())
return std::nullopt; return std::nullopt;
// Checks for correctness. The web filter only allows filename extensions and does not filter // Checks for correctness. The web filter only allows filename extensions and does not filter
@ -153,7 +153,7 @@ Type::Accept::MimeType::Extension::fromQt(QStringView qtRepresentation)
static QRegularExpression qtFilenameMatcherRegex( static QRegularExpression qtFilenameMatcherRegex(
QRegularExpression::anchoredPattern(QString(QStringLiteral("(\\*?)(\\.[^*]+)")))); QRegularExpression::anchoredPattern(QString(QStringLiteral("(\\*?)(\\.[^*]+)"))));
auto extensionMatch = qtFilenameMatcherRegex.match(qtRepresentation); auto extensionMatch = qtFilenameMatcherRegex.matchView(qtRepresentation);
if (extensionMatch.hasMatch()) if (extensionMatch.hasMatch())
return Extension(extensionMatch.capturedView(2)); return Extension(extensionMatch.capturedView(2));