QUrlQuery: s/QPair/std::pair/
They're literally the same, QPair is an alias for std::pair, so this is both SC and BC. Also port from qMakePair to std::make_pair, so we can later drop the qpair.h include (not done here to avoid breaking 6.6/6.5 users relying on this transitive include for qMakePair(). Pick-to: 6.6 6.5 Change-Id: I593ca3fee5f330992b46170bb660b1b33a663427 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
9d54b5c57e
commit
8f44ec2e48
@ -123,14 +123,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QUrlQuery::QUrlQuery(std::initializer_list<QPair<QString, QString>> list)
|
\fn QUrlQuery::QUrlQuery(std::initializer_list<std::pair<QString, QString>> list)
|
||||||
|
|
||||||
\since 5.13
|
\since 5.13
|
||||||
|
|
||||||
Constructs a QUrlQuery object from the \a list of key/value pair.
|
Constructs a QUrlQuery object from the \a list of key/value pair.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef QList<QPair<QString, QString> > Map;
|
typedef QList<std::pair<QString, QString> > Map;
|
||||||
|
|
||||||
class QUrlQueryPrivate : public QSharedData
|
class QUrlQueryPrivate : public QSharedData
|
||||||
{
|
{
|
||||||
@ -146,7 +146,7 @@ public:
|
|||||||
void setQuery(const QString &query);
|
void setQuery(const QString &query);
|
||||||
|
|
||||||
void addQueryItem(const QString &key, const QString &value)
|
void addQueryItem(const QString &key, const QString &value)
|
||||||
{ itemList.append(qMakePair(recodeFromUser(key), recodeFromUser(value))); }
|
{ itemList.append(std::make_pair(recodeFromUser(key), recodeFromUser(value))); }
|
||||||
int findRecodedKey(const QString &key, int from = 0) const
|
int findRecodedKey(const QString &key, int from = 0) const
|
||||||
{
|
{
|
||||||
for (int i = from; i < itemList.size(); ++i)
|
for (int i = from; i < itemList.size(); ++i)
|
||||||
@ -290,17 +290,17 @@ void QUrlQueryPrivate::setQuery(const QString &query)
|
|||||||
|
|
||||||
if (delimiter == pos) {
|
if (delimiter == pos) {
|
||||||
// the value delimiter wasn't found, store a null value
|
// the value delimiter wasn't found, store a null value
|
||||||
itemList.append(qMakePair(key, QString()));
|
itemList.append(std::make_pair(key, QString()));
|
||||||
} else if (delimiter + 1 == pos) {
|
} else if (delimiter + 1 == pos) {
|
||||||
// if the delimiter was found but the value is empty, store empty-but-not-null
|
// if the delimiter was found but the value is empty, store empty-but-not-null
|
||||||
itemList.append(qMakePair(key, QString(0, Qt::Uninitialized)));
|
itemList.append(std::make_pair(key, QString(0, Qt::Uninitialized)));
|
||||||
} else {
|
} else {
|
||||||
QString value;
|
QString value;
|
||||||
if (!qt_urlRecode(value, QStringView{delimiter + 1, pos},
|
if (!qt_urlRecode(value, QStringView{delimiter + 1, pos},
|
||||||
QUrl::DecodeReserved,
|
QUrl::DecodeReserved,
|
||||||
prettyDecodedActions))
|
prettyDecodedActions))
|
||||||
value = QString(delimiter + 1, pos - delimiter - 1);
|
value = QString(delimiter + 1, pos - delimiter - 1);
|
||||||
itemList.append(qMakePair(key, value));
|
itemList.append(std::make_pair(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos != end)
|
if (pos != end)
|
||||||
@ -613,14 +613,14 @@ QChar QUrlQuery::queryPairDelimiter() const
|
|||||||
|
|
||||||
\sa queryItems(), isEmpty()
|
\sa queryItems(), isEmpty()
|
||||||
*/
|
*/
|
||||||
void QUrlQuery::setQueryItems(const QList<QPair<QString, QString> > &query)
|
void QUrlQuery::setQueryItems(const QList<std::pair<QString, QString> > &query)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
if (query.isEmpty())
|
if (query.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QUrlQueryPrivate *dd = d;
|
QUrlQueryPrivate *dd = d;
|
||||||
QList<QPair<QString, QString> >::const_iterator it = query.constBegin(),
|
QList<std::pair<QString, QString> >::const_iterator it = query.constBegin(),
|
||||||
end = query.constEnd();
|
end = query.constEnd();
|
||||||
for ( ; it != end; ++it)
|
for ( ; it != end; ++it)
|
||||||
dd->addQueryItem(it->first, it->second);
|
dd->addQueryItem(it->first, it->second);
|
||||||
@ -634,20 +634,20 @@ void QUrlQuery::setQueryItems(const QList<QPair<QString, QString> > &query)
|
|||||||
|
|
||||||
\sa setQueryItems(), {encoding}{Encoding}
|
\sa setQueryItems(), {encoding}{Encoding}
|
||||||
*/
|
*/
|
||||||
QList<QPair<QString, QString> > QUrlQuery::queryItems(QUrl::ComponentFormattingOptions encoding) const
|
QList<std::pair<QString, QString> > QUrlQuery::queryItems(QUrl::ComponentFormattingOptions encoding) const
|
||||||
{
|
{
|
||||||
if (!d)
|
if (!d)
|
||||||
return QList<QPair<QString, QString> >();
|
return QList<std::pair<QString, QString> >();
|
||||||
if (idempotentRecodeToUser(encoding))
|
if (idempotentRecodeToUser(encoding))
|
||||||
return d->itemList;
|
return d->itemList;
|
||||||
|
|
||||||
QList<QPair<QString, QString> > result;
|
QList<std::pair<QString, QString> > result;
|
||||||
Map::const_iterator it = d->itemList.constBegin();
|
Map::const_iterator it = d->itemList.constBegin();
|
||||||
Map::const_iterator end = d->itemList.constEnd();
|
Map::const_iterator end = d->itemList.constEnd();
|
||||||
result.reserve(d->itemList.size());
|
result.reserve(d->itemList.size());
|
||||||
for ( ; it != end; ++it)
|
for ( ; it != end; ++it)
|
||||||
result << qMakePair(d->recodeToUser(it->first, encoding),
|
result << std::make_pair(d->recodeToUser(it->first, encoding),
|
||||||
d->recodeToUser(it->second, encoding));
|
d->recodeToUser(it->second, encoding));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ void QUrlQuery::removeAllQueryItems(const QString &key)
|
|||||||
if (d.constData()) {
|
if (d.constData()) {
|
||||||
auto *p = d.data();
|
auto *p = d.data();
|
||||||
const QString encodedKey = p->recodeFromUser(key);
|
const QString encodedKey = p->recodeFromUser(key);
|
||||||
auto firstEqualsEncodedKey = [&encodedKey](const QPair<QString, QString> &item) {
|
auto firstEqualsEncodedKey = [&encodedKey](const std::pair<QString, QString> &item) {
|
||||||
return item.first == encodedKey;
|
return item.first == encodedKey;
|
||||||
};
|
};
|
||||||
p->itemList.removeIf(firstEqualsEncodedKey);
|
p->itemList.removeIf(firstEqualsEncodedKey);
|
||||||
|
@ -22,10 +22,10 @@ public:
|
|||||||
QUrlQuery();
|
QUrlQuery();
|
||||||
explicit QUrlQuery(const QUrl &url);
|
explicit QUrlQuery(const QUrl &url);
|
||||||
explicit QUrlQuery(const QString &queryString);
|
explicit QUrlQuery(const QString &queryString);
|
||||||
QUrlQuery(std::initializer_list<QPair<QString, QString>> list)
|
QUrlQuery(std::initializer_list<std::pair<QString, QString>> list)
|
||||||
: QUrlQuery()
|
: QUrlQuery()
|
||||||
{
|
{
|
||||||
for (const QPair<QString, QString> &item : list)
|
for (const std::pair<QString, QString> &item : list)
|
||||||
addQueryItem(item.first, item.second);
|
addQueryItem(item.first, item.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ public:
|
|||||||
QChar queryValueDelimiter() const;
|
QChar queryValueDelimiter() const;
|
||||||
QChar queryPairDelimiter() const;
|
QChar queryPairDelimiter() const;
|
||||||
|
|
||||||
void setQueryItems(const QList<QPair<QString, QString> > &query);
|
void setQueryItems(const QList<std::pair<QString, QString> > &query);
|
||||||
QList<QPair<QString, QString> > queryItems(QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const;
|
QList<std::pair<QString, QString> > queryItems(QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const;
|
||||||
|
|
||||||
bool hasQueryItem(const QString &key) const;
|
bool hasQueryItem(const QString &key) const;
|
||||||
void addQueryItem(const QString &key, const QString &value);
|
void addQueryItem(const QString &key, const QString &value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user