summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-05-25 13:12:51 +0200
committerLars Knoll <lars.knoll@qt.io>2020-06-10 09:09:36 +0200
commit122d66f69fa44e11202fccdab076fe1ec368f971 (patch)
tree07d6c3bca6a3be5f246fef74c9efd61e2fe18d8e /src/network/access
parent4ab3089a2cbcc3b0656a36e9c22ca2d72e150c7e (diff)
Port QtNetwork from QStringRef to QStringView
Task-number: QTBUG-84319 Change-Id: I0f4e83c282b58ab4cc5e397b21981978f79d92cf Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qftp.cpp20
-rw-r--r--src/network/access/qhsts.cpp2
-rw-r--r--src/network/access/qhsts_p.h8
-rw-r--r--src/network/access/qnetworkcookiejar.cpp2
4 files changed, 16 insertions, 16 deletions
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 048c272780..ffe0ae7b6b 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -580,10 +580,10 @@ static void _q_parseDosDir(const QStringList &tokens, const QString &userName, Q
int permissions = QUrlInfo::ReadOwner | QUrlInfo::WriteOwner
| QUrlInfo::ReadGroup | QUrlInfo::WriteGroup
| QUrlInfo::ReadOther | QUrlInfo::WriteOther;
- QStringRef ext;
+ QStringView ext;
int extIndex = name.lastIndexOf(QLatin1Char('.'));
if (extIndex != -1)
- ext = name.midRef(extIndex + 1);
+ ext = QStringView{name}.mid(extIndex + 1);
if (ext == QLatin1String("exe") || ext == QLatin1String("bat") || ext == QLatin1String("com"))
permissions |= QUrlInfo::ExeOwner | QUrlInfo::ExeGroup | QUrlInfo::ExeOther;
info->setPermissions(permissions);
@@ -949,19 +949,19 @@ void QFtpPI::readyRead()
QString endOfMultiLine(QLatin1String(count, 4));
QString lineCont(endOfMultiLine);
lineCont[3] = QLatin1Char('-');
- QStringRef lineLeft4 = line.leftRef(4);
+ QStringView lineLeft4 = QStringView{line}.left(4);
while (lineLeft4 != endOfMultiLine) {
if (lineLeft4 == lineCont)
- replyText += line.midRef(4); // strip 'xyz-'
+ replyText += QStringView{line}.mid(4); // strip 'xyz-'
else
replyText += line;
if (!commandSocket.canReadLine())
return;
line = QString::fromUtf8(commandSocket.readLine());
- lineLeft4 = line.leftRef(4);
+ lineLeft4 = QStringView{line}.left(4);
}
- replyText += line.midRef(4); // strip reply code 'xyz '
+ replyText += QStringView{line}.mid(4); // strip reply code 'xyz '
if (replyText.endsWith(QLatin1String("\r\n")))
replyText.chop(2);
@@ -1078,7 +1078,7 @@ bool QFtpPI::processReply()
} else {
++portPos;
QChar delimiter = replyText.at(portPos);
- const auto epsvParameters = replyText.midRef(portPos).split(delimiter);
+ const auto epsvParameters = QStringView{replyText}.mid(portPos).split(delimiter);
waitForDtpToConnect = true;
dtp.connectToHost(commandSocket.peerAddress().toString(),
@@ -1207,7 +1207,7 @@ bool QFtpPI::startNextCmd()
pendingCommands.pop_front();
#if defined(QFTPPI_DEBUG)
- qDebug("QFtpPI send: %s", currentCmd.leftRef(currentCmd.length() - 2).toLatin1().constData());
+ qDebug("QFtpPI send: %s", QStringView{currentCmd}.left(currentCmd.length() - 2).toLatin1().constData());
#endif
state = Waiting;
commandSocket.write(currentCmd.toUtf8());
@@ -2031,7 +2031,7 @@ int QFtp::rename(const QString &oldname, const QString &newname)
*/
int QFtp::rawCommand(const QString &command)
{
- const QString cmd = QStringRef(&command).trimmed() + QLatin1String("\r\n");
+ const QString cmd = QStringView{command}.trimmed() + QLatin1String("\r\n");
return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));
}
@@ -2262,7 +2262,7 @@ void QFtpPrivate::_q_startNextCommand()
// through.
if (c->command == QFtp::Login && !proxyHost.isEmpty()) {
QString loginString;
- loginString += QStringRef(&c->rawCmds.constFirst()).trimmed() + QLatin1Char('@') + host;
+ loginString += QStringView{c->rawCmds.constFirst()}.trimmed() + QLatin1Char('@') + host;
if (port && port != 21)
loginString += QLatin1Char(':') + QString::number(port);
loginString += QLatin1String("\r\n");
diff --git a/src/network/access/qhsts.cpp b/src/network/access/qhsts.cpp
index 0cef0ad3dc..e473008305 100644
--- a/src/network/access/qhsts.cpp
+++ b/src/network/access/qhsts.cpp
@@ -194,7 +194,7 @@ bool QHstsCache::isKnownHost(const QUrl &url) const
bool superDomainMatch = false;
const QString hostNameAsString(url.host());
- HostName nameToTest(static_cast<QStringRef>(&hostNameAsString));
+ HostName nameToTest(QStringView{hostNameAsString});
while (nameToTest.fragment.size()) {
auto const pos = knownHosts.find(nameToTest);
if (pos != knownHosts.end()) {
diff --git a/src/network/access/qhsts_p.h b/src/network/access/qhsts_p.h
index b5be4ff455..8ebf7294dd 100644
--- a/src/network/access/qhsts_p.h
+++ b/src/network/access/qhsts_p.h
@@ -94,18 +94,18 @@ private:
struct HostName
{
explicit HostName(const QString &n) : name(n) { }
- explicit HostName(const QStringRef &r) : fragment(r) { }
+ explicit HostName(QStringView r) : fragment(r) { }
bool operator < (const HostName &rhs) const
{
if (fragment.size()) {
if (rhs.fragment.size())
return fragment < rhs.fragment;
- return fragment < QStringRef(&rhs.name);
+ return fragment < QStringView{rhs.name};
}
if (rhs.fragment.size())
- return QStringRef(&name) < rhs.fragment;
+ return QStringView{name} < rhs.fragment;
return name < rhs.name;
}
@@ -114,7 +114,7 @@ private:
// name, removing subdomain names (such HostName object is 'transient', it
// must not outlive the original QString object.
QString name;
- QStringRef fragment;
+ QStringView fragment;
};
mutable std::map<HostName, QHstsPolicy> knownHosts;
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp
index 62225b28d1..c01bd339ca 100644
--- a/src/network/access/qnetworkcookiejar.cpp
+++ b/src/network/access/qnetworkcookiejar.cpp
@@ -170,7 +170,7 @@ static inline bool isParentDomain(const QString &domain, const QString &referenc
if (!reference.startsWith(QLatin1Char('.')))
return domain == reference;
- return domain.endsWith(reference) || domain == reference.midRef(1);
+ return domain.endsWith(reference) || domain == QStringView{reference}.mid(1);
}
/*!