Replace all QPair/qMakePair with std::pair in qtbase/network
Task-number: QTBUG-115841 Change-Id: I34f3106e4b50a18cc19c4cda597205c346e7561e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
This commit is contained in:
parent
95c70bbc5b
commit
a41c860c7d
@ -16,12 +16,12 @@
|
||||
//
|
||||
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qpair.h>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -49,7 +49,7 @@ struct Q_AUTOTEST_EXPORT HeaderField
|
||||
QByteArray value;
|
||||
};
|
||||
|
||||
using HeaderSize = QPair<bool, quint32>;
|
||||
using HeaderSize = std::pair<bool, quint32>;
|
||||
|
||||
HeaderSize entry_size(QByteArrayView name, QByteArrayView value);
|
||||
|
||||
|
@ -64,7 +64,7 @@ Q_GLOBAL_STATIC(QNetworkCacheMetaDataPrivate, metadata_shared_invalid)
|
||||
/*!
|
||||
\typedef QNetworkCacheMetaData::RawHeader
|
||||
|
||||
Synonym for QPair<QByteArray, QByteArray>
|
||||
Synonym for std::pair<QByteArray, QByteArray>
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -7,9 +7,10 @@
|
||||
#include <QtNetwork/qtnetworkglobal.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qshareddata.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtNetwork/qnetworkrequest.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
@ -22,7 +23,7 @@ class Q_NETWORK_EXPORT QNetworkCacheMetaData
|
||||
{
|
||||
|
||||
public:
|
||||
typedef QPair<QByteArray, QByteArray> RawHeader;
|
||||
typedef std::pair<QByteArray, QByteArray> RawHeader;
|
||||
typedef QList<RawHeader> RawHeaderList;
|
||||
typedef QHash<QNetworkRequest::Attribute, QVariant> AttributesMap;
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -630,7 +630,7 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor
|
||||
reply->setRequest(request);
|
||||
reply->d_func()->connection = q;
|
||||
reply->d_func()->connectionChannel = &channels[0]; // will have the correct one set later
|
||||
HttpMessagePair pair = qMakePair(request, reply);
|
||||
HttpMessagePair pair = std::pair(request, reply);
|
||||
|
||||
if (request.isPreConnect())
|
||||
preConnectRequests++;
|
||||
|
@ -37,6 +37,8 @@
|
||||
|
||||
#include <private/qhttpnetworkconnectionchannel_p.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
QT_REQUIRE_CONFIG(http);
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -129,7 +131,7 @@ private:
|
||||
|
||||
|
||||
// private classes
|
||||
typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
|
||||
typedef std::pair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
|
||||
|
||||
|
||||
class QHttpNetworkConnectionPrivate : public QObjectPrivate
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
QT_REQUIRE_CONFIG(http);
|
||||
|
||||
@ -58,7 +59,7 @@ class QHttpNetworkReply;
|
||||
class QByteArray;
|
||||
|
||||
#ifndef HttpMessagePair
|
||||
typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
|
||||
typedef std::pair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
|
||||
#endif
|
||||
|
||||
class QHttpNetworkConnectionChannel : public QObject {
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "qnetconmonitor_p.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -415,7 +416,7 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent)
|
||||
qRegisterMetaType<QSslConfiguration>();
|
||||
qRegisterMetaType<QSslPreSharedKeyAuthenticator *>();
|
||||
#endif
|
||||
qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >();
|
||||
qRegisterMetaType<QList<std::pair<QByteArray, QByteArray>>>();
|
||||
#if QT_CONFIG(http)
|
||||
qRegisterMetaType<QHttpNetworkRequest>();
|
||||
#endif
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "QtNetwork/qhostaddress.h"
|
||||
#include "private/qobject_p.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
@ -376,7 +378,7 @@ void QNetworkCookie::setValue(const QByteArray &value)
|
||||
}
|
||||
|
||||
// ### move this to qnetworkcookie_p.h and share with qnetworkaccesshttpbackend
|
||||
static QPair<QByteArray, QByteArray> nextField(QByteArrayView text, int &position, bool isNameValue)
|
||||
static std::pair<QByteArray, QByteArray> nextField(QByteArrayView text, int &position, bool isNameValue)
|
||||
{
|
||||
// format is one of:
|
||||
// (1) token
|
||||
@ -392,7 +394,7 @@ static QPair<QByteArray, QByteArray> nextField(QByteArrayView text, int &positio
|
||||
int equalsPosition = text.indexOf('=', position);
|
||||
if (equalsPosition < 0 || equalsPosition > semiColonPosition) {
|
||||
if (isNameValue)
|
||||
return qMakePair(QByteArray(), QByteArray()); //'=' is required for name-value-pair (RFC6265 section 5.2, rule 2)
|
||||
return std::pair(QByteArray(), QByteArray()); //'=' is required for name-value-pair (RFC6265 section 5.2, rule 2)
|
||||
equalsPosition = semiColonPosition; //no '=' means there is an attribute-name but no attribute-value
|
||||
}
|
||||
|
||||
@ -403,7 +405,7 @@ static QPair<QByteArray, QByteArray> nextField(QByteArrayView text, int &positio
|
||||
second = text.mid(equalsPosition + 1, secondLength).trimmed().toByteArray();
|
||||
|
||||
position = semiColonPosition;
|
||||
return qMakePair(first, second);
|
||||
return std::pair(first, second);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -964,7 +966,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(QByteArray
|
||||
QNetworkCookie cookie;
|
||||
|
||||
// The first part is always the "NAME=VALUE" part
|
||||
QPair<QByteArray,QByteArray> field = nextField(cookieString, position, true);
|
||||
std::pair<QByteArray,QByteArray> field = nextField(cookieString, position, true);
|
||||
if (field.first.isEmpty())
|
||||
// parsing error
|
||||
break;
|
||||
|
@ -638,7 +638,7 @@ QByteArray QNetworkReply::rawHeader(QAnyStringView headerName) const
|
||||
|
||||
/*! \typedef QNetworkReply::RawHeaderPair
|
||||
|
||||
RawHeaderPair is a QPair<QByteArray, QByteArray> where the first
|
||||
RawHeaderPair is a std::pair<QByteArray, QByteArray> where the first
|
||||
QByteArray is the header name and the second is the header.
|
||||
*/
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
|
||||
#include <utility>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
@ -107,7 +109,7 @@ public:
|
||||
#endif
|
||||
QByteArray rawHeader(QAnyStringView headerName) const;
|
||||
|
||||
typedef QPair<QByteArray, QByteArray> RawHeaderPair;
|
||||
typedef std::pair<QByteArray, QByteArray> RawHeaderPair;
|
||||
const QList<RawHeaderPair>& rawHeaderPairs() const;
|
||||
QHttpHeaders headers() const;
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "QtCore/qsharedpointer.h"
|
||||
#include "QtCore/qpointer.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkCookie;
|
||||
@ -33,7 +35,7 @@ class QNetworkCookie;
|
||||
class QNetworkHeadersPrivate
|
||||
{
|
||||
public:
|
||||
typedef QPair<QByteArray, QByteArray> RawHeaderPair;
|
||||
typedef std::pair<QByteArray, QByteArray> RawHeaderPair;
|
||||
typedef QList<RawHeaderPair> RawHeadersList;
|
||||
typedef QHash<QNetworkRequest::KnownHeaders, QVariant> CookedHeadersMap;
|
||||
typedef QHash<QNetworkRequest::Attribute, QVariant> AttributesMap;
|
||||
|
@ -974,7 +974,7 @@ bool QHostAddress::isInSubnet(const QHostAddress &subnet, int netmask) const
|
||||
prefix and the int (second) member contains the netmask (prefix
|
||||
length).
|
||||
*/
|
||||
bool QHostAddress::isInSubnet(const QPair<QHostAddress, int> &subnet) const
|
||||
bool QHostAddress::isInSubnet(const std::pair<QHostAddress, int> &subnet) const
|
||||
{
|
||||
return isInSubnet(subnet.first, subnet.second);
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ bool QHostAddress::isInSubnet(const QPair<QHostAddress, int> &subnet) const
|
||||
|
||||
\sa isInSubnet()
|
||||
*/
|
||||
QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
|
||||
std::pair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
|
||||
{
|
||||
// We support subnets in the form:
|
||||
// ddd.ddd.ddd.ddd/nn
|
||||
@ -1021,7 +1021,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
|
||||
//
|
||||
// where nn can be an IPv4-style netmask for the IPv4 forms
|
||||
|
||||
const QPair<QHostAddress, int> invalid = qMakePair(QHostAddress(), -1);
|
||||
const std::pair<QHostAddress, int> invalid = std::pair(QHostAddress(), -1);
|
||||
if (subnet.isEmpty())
|
||||
return invalid;
|
||||
|
||||
@ -1064,7 +1064,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
|
||||
return invalid; // failed to parse the IP
|
||||
|
||||
clearBits(net.d->a6.c, netmask, 128);
|
||||
return qMakePair(net, netmask);
|
||||
return std::pair(net, netmask);
|
||||
}
|
||||
|
||||
if (netmask > 32)
|
||||
@ -1102,7 +1102,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
|
||||
addr &= mask;
|
||||
}
|
||||
|
||||
return qMakePair(QHostAddress(addr), netmask);
|
||||
return std::pair(QHostAddress(addr), netmask);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -6,13 +6,14 @@
|
||||
#define QHOSTADDRESS_H
|
||||
|
||||
#include <QtNetwork/qtnetworkglobal.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qshareddata.h>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
|
||||
#include <QtNetwork/qabstractsocket.h>
|
||||
#endif
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct sockaddr;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -120,7 +121,7 @@ public:
|
||||
void clear();
|
||||
|
||||
bool isInSubnet(const QHostAddress &subnet, int netmask) const;
|
||||
bool isInSubnet(const QPair<QHostAddress, int> &subnet) const;
|
||||
bool isInSubnet(const std::pair<QHostAddress, int> &subnet) const;
|
||||
|
||||
bool isLoopback() const;
|
||||
bool isGlobal() const;
|
||||
@ -131,7 +132,7 @@ public:
|
||||
bool isBroadcast() const;
|
||||
bool isPrivateUse() const;
|
||||
|
||||
static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
|
||||
static std::pair<QHostAddress, int> parseSubnet(const QString &subnet);
|
||||
|
||||
friend Q_NETWORK_EXPORT size_t qHash(const QHostAddress &key, size_t seed) noexcept;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user