Use QList instead of QVector in qtcoap

And fix dependencies.

Task-number: QTBUG-84469
Change-Id: Ic68bcf0229b516a04ba3d9e515dfb992e12d1f49
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Sona Kurazyan 2020-06-23 17:04:59 +02:00
parent 0407987296
commit a0ab76a6f5
25 changed files with 74 additions and 74 deletions

View File

@ -1,4 +1,4 @@
dependencies:
../qtbase:
ref: 56f40cdca6b589beec5c2cb803633985ca4c59d1
ref: bcc3472aa231d0a65351b73ce9c75f7688be6623
required: true

View File

@ -105,7 +105,7 @@ void CoapHandler::onNotified(QCoapReply *reply, QCoapMessage message)
qCInfo(lcCoapClient) << "Received Observe notification with payload:" << reply->readAll();
}
void CoapHandler::onDiscovered(QCoapResourceDiscoveryReply *reply, QVector<QCoapResource> resources)
void CoapHandler::onDiscovered(QCoapResourceDiscoveryReply *reply, QList<QCoapResource> resources)
{
Q_UNUSED(reply)

View File

@ -61,7 +61,7 @@ public:
public Q_SLOTS:
void onFinished(QCoapReply *reply);
void onNotified(QCoapReply *reply, QCoapMessage message);
void onDiscovered(QCoapResourceDiscoveryReply *reply, QVector<QCoapResource> resources);
void onDiscovered(QCoapResourceDiscoveryReply *reply, QList<QCoapResource> resources);
void onResponseToMulticast(QCoapReply *reply, const QCoapMessage& message,
const QHostAddress &sender);
void onError(QCoapReply *reply, QtCoap::Error error);

View File

@ -95,7 +95,7 @@ void QmlCoapMulticastClient::discover(QtCoap::MulticastGroup group, int port,
}
void QmlCoapMulticastClient::onDiscovered(QCoapResourceDiscoveryReply *reply,
const QVector<QCoapResource> &resources)
const QList<QCoapResource> &resources)
{
Q_UNUSED(reply)
for (auto resource : resources)

View File

@ -85,7 +85,7 @@ Q_SIGNALS:
void finished(int error);
public slots:
void onDiscovered(QCoapResourceDiscoveryReply *reply, const QVector<QCoapResource> &resources);
void onDiscovered(QCoapResourceDiscoveryReply *reply, const QList<QCoapResource> &resources);
};
#endif // QMLCOAPMULTICASTCLIENT_H

View File

@ -122,7 +122,7 @@ void MainWindow::onError(QCoapReply *reply, QtCoap::Error error)
addMessage(errorMessage(errorCode), true);
}
void MainWindow::onDiscovered(QCoapResourceDiscoveryReply *reply, QVector<QCoapResource> resources)
void MainWindow::onDiscovered(QCoapResourceDiscoveryReply *reply, QList<QCoapResource> resources)
{
if (reply->errorReceived() != QtCoap::Error::Ok)
return;

View File

@ -78,7 +78,7 @@ private:
private slots:
void onFinished(QCoapReply *reply);
void onError(QCoapReply *reply, QtCoap::Error error);
void onDiscovered(QCoapResourceDiscoveryReply *reply, QVector<QCoapResource> resources);
void onDiscovered(QCoapResourceDiscoveryReply *reply, QList<QCoapResource> resources);
void onNotified(QCoapReply *reply, const QCoapMessage &message);
void on_runButton_clicked();
@ -92,7 +92,7 @@ private slots:
private:
Ui::MainWindow *ui;
QCoapClient *m_client;
QVector<QCoapOption> m_options;
QList<QCoapOption> m_options;
QByteArray m_currentData;
};

View File

@ -68,7 +68,7 @@ OptionDialog::~OptionDialog()
delete ui;
}
QVector<QCoapOption> OptionDialog::options() const
QList<QCoapOption> OptionDialog::options() const
{
return m_options;
}

View File

@ -68,7 +68,7 @@ public:
explicit OptionDialog(QWidget *parent = nullptr);
~OptionDialog();
QVector<QCoapOption> options() const;
QList<QCoapOption> options() const;
private slots:
void on_addButton_clicked();
@ -78,7 +78,7 @@ private:
void fillOptions();
Ui::OptionDialog *ui;
QVector<QCoapOption> m_options;
QList<QCoapOption> m_options;
};
#endif // OPTIONDIALOG_H

View File

@ -184,7 +184,7 @@
And in certificate mode:
\code
QCoapClient *client = new QCoapClient(this, QtCoap::Certificate);
QVector<QSslCertificate> localCertificates, caCertificates;
QList<QSslCertificate> localCertificates, caCertificates;
QCoapPrivateKey key;
// Initialize the key and certificates
QCoapSecurityConfiguration config;

View File

@ -183,7 +183,7 @@ QByteArray QCoapInternalRequest::toQByteArray() const
// Insert Options
if (!d->message.options().isEmpty()) {
QVector<QCoapOption> options = d->message.options();
const auto options = d->message.options();
// Options should be sorted in order of their option numbers
Q_ASSERT(std::is_sorted(d->message.options().cbegin(), d->message.options().cend(),

View File

@ -277,7 +277,7 @@ QCoapOption QCoapMessage::option(QCoapOption::OptionName name) const
with the given \a name.
If there is no such option, returns \c d->options.end().
*/
QVector<QCoapOption>::const_iterator
QList<QCoapOption>::const_iterator
QCoapMessagePrivate::findOption(QCoapOption::OptionName name) const
{
return std::find_if(options.begin(), options.end(), [name](const QCoapOption &option) {
@ -298,7 +298,7 @@ bool QCoapMessage::hasOption(QCoapOption::OptionName name) const
/*!
Returns the list of options.
*/
const QVector<QCoapOption> &QCoapMessage::options() const
const QList<QCoapOption> &QCoapMessage::options() const
{
Q_D(const QCoapMessage);
return d->options;
@ -307,11 +307,11 @@ const QVector<QCoapOption> &QCoapMessage::options() const
/*!
Finds and returns the list of options with the given \a name.
*/
QVector<QCoapOption> QCoapMessage::options(QCoapOption::OptionName name) const
QList<QCoapOption> QCoapMessage::options(QCoapOption::OptionName name) const
{
Q_D(const QCoapMessage);
QVector<QCoapOption> result;
QList<QCoapOption> result;
std::copy_if(d->options.cbegin(), d->options.cend(), std::back_inserter(result),
[name](const QCoapOption &option) {
return option.name() == name;
@ -392,7 +392,7 @@ void QCoapMessage::setPayload(const QByteArray &payload)
/*!
Sets the message options to \a options.
*/
void QCoapMessage::setOptions(const QVector<QCoapOption> &options)
void QCoapMessage::setOptions(const QList<QCoapOption> &options)
{
Q_D(QCoapMessage);
d->options = options;

View File

@ -34,8 +34,8 @@
#include <QtCore/qglobal.h>
#include <QtCoap/qcoapglobal.h>
#include <QtCoap/qcoapoption.h>
#include <QtCore/qlist.h>
#include <QtCore/qobject.h>
#include <QtCore/qvector.h>
#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
@ -70,13 +70,13 @@ public:
void setToken(const QByteArray &token);
void setMessageId(quint16);
void setPayload(const QByteArray &payload);
void setOptions(const QVector<QCoapOption> &options);
void setOptions(const QList<QCoapOption> &options);
QCoapOption optionAt(int index) const;
QCoapOption option(QCoapOption::OptionName name) const;
bool hasOption(QCoapOption::OptionName name) const;
const QVector<QCoapOption> &options() const;
QVector<QCoapOption> options(QCoapOption::OptionName name) const;
const QList<QCoapOption> &options() const;
QList<QCoapOption> options(QCoapOption::OptionName name) const;
int optionCount() const;
void addOption(QCoapOption::OptionName name, const QByteArray &value = QByteArray());
void addOption(const QCoapOption &option);

View File

@ -55,13 +55,13 @@ public:
QCoapMessagePrivate(const QCoapMessagePrivate &other);
~QCoapMessagePrivate();
QVector<QCoapOption>::const_iterator findOption(QCoapOption::OptionName name) const;
QList<QCoapOption>::const_iterator findOption(QCoapOption::OptionName name) const;
quint8 version = 1;
QCoapMessage::Type type = QCoapMessage::Type::NonConfirmable;
quint16 messageId = 0;
QByteArray token;
QVector<QCoapOption> options;
QList<QCoapOption> options;
QByteArray payload;
};

View File

@ -440,7 +440,7 @@ QPointer<QCoapReply> QCoapProtocolPrivate::userReplyForToken(const QCoapToken &t
Returns the replies for the exchange identified by \a token.
*/
QVector<QSharedPointer<QCoapInternalReply>>
QList<QSharedPointer<QCoapInternalReply>>
QCoapProtocolPrivate::repliesForToken(const QCoapToken &token) const
{
auto it = exchangeMap.find(token);
@ -772,7 +772,7 @@ void QCoapProtocolPrivate::registerExchange(const QCoapToken &token, QCoapReply
QSharedPointer<QCoapInternalRequest> request)
{
CoapExchangeData data = { reply, request,
QVector<QSharedPointer<QCoapInternalReply> >()
QList<QSharedPointer<QCoapInternalReply> >()
};
exchangeMap.insert(token, data);

View File

@ -34,7 +34,7 @@
#include <QtCoap/qcoapglobal.h>
#include <QtCoap/qcoapreply.h>
#include <QtCoap/qcoapresource.h>
#include <QtCore/qvector.h>
#include <QtCore/qlist.h>
#include <QtCore/qqueue.h>
#include <QtCore/qpointer.h>
#include <QtCore/qobject.h>
@ -107,7 +107,7 @@ private:
struct CoapExchangeData {
QPointer<QCoapReply> userReply;
QSharedPointer<QCoapInternalRequest> request;
QVector<QSharedPointer<QCoapInternalReply> > replies;
QList<QSharedPointer<QCoapInternalReply> > replies;
};
typedef QMap<QByteArray, CoapExchangeData> CoapExchangeMap;
@ -144,7 +144,7 @@ public:
QCoapInternalRequest *requestForToken(const QCoapToken &token) const;
QPointer<QCoapReply> userReplyForToken(const QCoapToken &token) const;
QVector<QSharedPointer<QCoapInternalReply>> repliesForToken(const QCoapToken &token) const;
QList<QSharedPointer<QCoapInternalReply>> repliesForToken(const QCoapToken &token) const;
QCoapInternalReply *lastReplyForToken(const QCoapToken &token) const;
QCoapInternalRequest *findRequestByMessageId(quint16 messageId) const;
QCoapInternalRequest *findRequestByUserReply(const QCoapReply *reply) const;

View File

@ -89,7 +89,7 @@ void QCoapResourceDiscoveryReplyPrivate::_q_setContent(const QHostAddress &sende
/*!
\fn void QCoapResourceDiscoveryReply::discovered(QCoapResourceDiscoveryReply *reply,
QVector<QCoapResource> resources);
QList<QCoapResource> resources);
This signal is emitted whenever a CoAP resource is discovered.
@ -113,7 +113,7 @@ QCoapResourceDiscoveryReply::QCoapResourceDiscoveryReply(const QCoapRequest &req
/*!
Returns the list of resources.
*/
QVector<QCoapResource> QCoapResourceDiscoveryReply::resources() const
QList<QCoapResource> QCoapResourceDiscoveryReply::resources() const
{
Q_D(const QCoapResourceDiscoveryReply);
return d->resources;
@ -126,11 +126,11 @@ QVector<QCoapResource> QCoapResourceDiscoveryReply::resources() const
objects. The \a data byte array contains the frame returned by the
discovery request.
*/
QVector<QCoapResource>
QList<QCoapResource>
QCoapResourceDiscoveryReplyPrivate::resourcesFromCoreLinkList(const QHostAddress &sender,
const QByteArray &data)
{
QVector<QCoapResource> resourceList;
QList<QCoapResource> resourceList;
QLatin1String quote = QLatin1String("\"");
const QList<QByteArray> links = data.split(',');

View File

@ -43,10 +43,10 @@ class Q_COAP_EXPORT QCoapResourceDiscoveryReply : public QCoapReply
Q_OBJECT
public:
QVector<QCoapResource> resources() const;
QList<QCoapResource> resources() const;
Q_SIGNALS:
void discovered(QCoapResourceDiscoveryReply *reply, QVector<QCoapResource> resources);
void discovered(QCoapResourceDiscoveryReply *reply, QList<QCoapResource> resources);
private:
explicit QCoapResourceDiscoveryReply(const QCoapRequest &request, QObject *parent = nullptr);

View File

@ -56,10 +56,10 @@ public:
void _q_setContent(const QHostAddress &sender, const QCoapMessage &, QtCoap::ResponseCode) override;
static QVector<QCoapResource> resourcesFromCoreLinkList(
static QList<QCoapResource> resourcesFromCoreLinkList(
const QHostAddress &sender, const QByteArray &data);
QVector<QCoapResource> resources;
QList<QCoapResource> resources;
Q_DECLARE_PUBLIC(QCoapResourceDiscoveryReply)
};

View File

@ -29,9 +29,9 @@
#include "qcoapsecurityconfiguration.h"
#include <QtCore/QVector>
#include <QtCore/QByteArray>
#include <QtCore/QIODevice>
#include <QtCore/QList>
#include <QtNetwork/QSslCertificate>
QT_BEGIN_NAMESPACE
@ -52,8 +52,8 @@ public:
QByteArray identity;
QByteArray preSharedKey;
QString defaultCipherString;
QVector<QSslCertificate> caCertificates;
QVector<QSslCertificate> localCertificateChain;
QList<QSslCertificate> caCertificates;
QList<QSslCertificate> localCertificateChain;
QCoapPrivateKey privateKey;
};
@ -333,7 +333,7 @@ QString QCoapSecurityConfiguration::defaultCipherString() const
\sa caCertificates()
*/
void QCoapSecurityConfiguration::setCaCertificates(const QVector<QSslCertificate> &certificates)
void QCoapSecurityConfiguration::setCaCertificates(const QList<QSslCertificate> &certificates)
{
d->caCertificates = certificates;
}
@ -343,7 +343,7 @@ void QCoapSecurityConfiguration::setCaCertificates(const QVector<QSslCertificate
\sa setCaCertificates()
*/
QVector<QSslCertificate> QCoapSecurityConfiguration::caCertificates() const
QList<QSslCertificate> QCoapSecurityConfiguration::caCertificates() const
{
return d->caCertificates;
}
@ -354,7 +354,7 @@ QVector<QSslCertificate> QCoapSecurityConfiguration::caCertificates() const
\sa localCertificateChain()
*/
void QCoapSecurityConfiguration::setLocalCertificateChain(const QVector<QSslCertificate> &localChain)
void QCoapSecurityConfiguration::setLocalCertificateChain(const QList<QSslCertificate> &localChain)
{
d->localCertificateChain = localChain;
}
@ -364,7 +364,7 @@ void QCoapSecurityConfiguration::setLocalCertificateChain(const QVector<QSslCert
\sa setLocalCertificateChain()
*/
QVector<QSslCertificate> QCoapSecurityConfiguration::localCertificateChain() const
QList<QSslCertificate> QCoapSecurityConfiguration::localCertificateChain() const
{
return d->localCertificateChain;
}

View File

@ -95,11 +95,11 @@ public:
void setDefaultCipherString(const QString &cipherString);
QString defaultCipherString() const;
void setCaCertificates(const QVector<QSslCertificate> &certificates);
QVector<QSslCertificate> caCertificates() const;
void setCaCertificates(const QList<QSslCertificate> &certificates);
QList<QSslCertificate> caCertificates() const;
void setLocalCertificateChain(const QVector<QSslCertificate> &localChain);
QVector<QSslCertificate> localCertificateChain() const;
void setLocalCertificateChain(const QList<QSslCertificate> &localChain);
QList<QSslCertificate> localCertificateChain() const;
void setPrivateKey(const QCoapPrivateKey &key);
QCoapPrivateKey privateKey() const;

View File

@ -545,8 +545,8 @@ void tst_QCoapClient::multipleRequests()
QSignalSpy spyClientFinished(&client, &QCoapClient::finished);
const uint8_t requestCount = 4;
QVector<QSharedPointer<QCoapReply>> replies;
QVector<QSharedPointer<QSignalSpy>> signalSpies;
QList<QSharedPointer<QCoapReply>> replies;
QList<QSharedPointer<QSignalSpy>> signalSpies;
for (uint8_t i = 0; i < requestCount; ++i) {
QCoapRequest request;
const auto token = "token" + QByteArray::number(i);

View File

@ -169,15 +169,15 @@ void tst_QCoapInternalRequest::requestToFrame()
void tst_QCoapInternalRequest::parseUri_data()
{
qRegisterMetaType<QVector<QCoapOption>>();
qRegisterMetaType<QList<QCoapOption>>();
QTest::addColumn<QUrl>("uri");
QTest::addColumn<QUrl>("proxyUri");
QTest::addColumn<QVector<QCoapOption>>("options");
QTest::addColumn<QList<QCoapOption>>("options");
QTest::newRow("port_path")
<< QUrl("coap://10.20.30.40:1234/test/path1")
<< QUrl()
<< QVector<QCoapOption>({
<< QList<QCoapOption>({
QCoapOption(QCoapOption::UriPort, 1234),
QCoapOption(QCoapOption::UriPath, QByteArray("test")),
QCoapOption(QCoapOption::UriPath, QByteArray("path1")) });
@ -185,7 +185,7 @@ void tst_QCoapInternalRequest::parseUri_data()
QTest::newRow("path_query")
<< QUrl("coap://10.20.30.40/test/path1/?rd=25&nd=4")
<< QUrl()
<< QVector<QCoapOption>({
<< QList<QCoapOption>({
QCoapOption(QCoapOption::UriPath, QByteArray("test")),
QCoapOption(QCoapOption::UriPath, QByteArray("path1")),
QCoapOption(QCoapOption::UriQuery, QByteArray("rd=25")),
@ -194,7 +194,7 @@ void tst_QCoapInternalRequest::parseUri_data()
QTest::newRow("host_path_query")
<< QUrl("coap://aa.bb.cc.com:5683/test/path1/?rd=25&nd=4")
<< QUrl()
<< QVector<QCoapOption>({
<< QList<QCoapOption>({
QCoapOption(QCoapOption::UriHost, QByteArray("aa.bb.cc.com")),
QCoapOption(QCoapOption::UriPath, QByteArray("test")),
QCoapOption(QCoapOption::UriPath, QByteArray("path1")),
@ -204,7 +204,7 @@ void tst_QCoapInternalRequest::parseUri_data()
QTest::newRow("proxy_url")
<< QUrl("coap://aa.bb.cc.com:5683/test/path1/?rd=25&nd=4")
<< QUrl("coap://10.20.30.40/test:5684/othertest/path")
<< QVector<QCoapOption>({
<< QList<QCoapOption>({
QCoapOption(QCoapOption::ProxyUri,
QByteArray("coap://10.20.30.40/test:5684/othertest/path")) });
}
@ -213,7 +213,7 @@ void tst_QCoapInternalRequest::parseUri()
{
QFETCH(QUrl, uri);
QFETCH(QUrl, proxyUri);
QFETCH(QVector<QCoapOption>, options);
QFETCH(QList<QCoapOption>, options);
QCoapRequest request(uri, QCoapMessage::Type::NonConfirmable, proxyUri);
QCoapInternalRequest internalRequest(request);
@ -227,9 +227,9 @@ void tst_QCoapInternalRequest::parseUri()
void tst_QCoapInternalRequest::urlOptions_data()
{
QTest::addColumn<QString>("url");
QTest::addColumn<QVector<QCoapOption>>("options");
QTest::addColumn<QList<QCoapOption>>("options");
QVector<QCoapOption> options = {
QList<QCoapOption> options = {
{ QCoapOption::UriHost, QByteArray("example.com") },
{ QCoapOption::UriPath, QByteArray("~sensors") },
{ QCoapOption::UriPath, QByteArray("temp.xml") }
@ -257,7 +257,7 @@ void tst_QCoapInternalRequest::urlOptions_data()
void tst_QCoapInternalRequest::urlOptions()
{
QFETCH(QString, url);
QFETCH(QVector<QCoapOption>, options);
QFETCH(QList<QCoapOption>, options);
const QCoapRequest request(url);
const QCoapInternalRequest internalRequest(request);

View File

@ -129,13 +129,13 @@ void tst_QCoapMessage::addOption()
void tst_QCoapMessage::addOption_string_data()
{
QTest::addColumn<QVector<QCoapOption>>("options");
QTest::addColumn<QList<QCoapOption>>("options");
QVector<QCoapOption> single_string_option = { { QCoapOption::LocationPath, QString("path1") } };
QVector<QCoapOption> single_ba_option = {
QList<QCoapOption> single_string_option = { { QCoapOption::LocationPath, QString("path1") } };
QList<QCoapOption> single_ba_option = {
{ QCoapOption::LocationPath, QByteArray("\xAF\x01\xC2") }
};
QVector<QCoapOption> multiple_string_options = {
QList<QCoapOption> multiple_string_options = {
{ QCoapOption::LocationPath, QString("str_path2") },
{ QCoapOption::LocationPath, QString("str_path3") }
};
@ -147,7 +147,7 @@ void tst_QCoapMessage::addOption_string_data()
void tst_QCoapMessage::addOption_string()
{
QFETCH(QVector<QCoapOption>, options);
QFETCH(QList<QCoapOption>, options);
QCoapMessage message;
for (const auto& option : options)
@ -190,10 +190,10 @@ void tst_QCoapMessage::addOption_uint()
void tst_QCoapMessage::removeOption_data()
{
QTest::addColumn<QVector<QCoapOption>>("options");
QTest::addColumn<QList<QCoapOption>>("options");
QVector<QCoapOption> single_option = { { QCoapOption::LocationPath, QByteArray("path1") } };
QVector<QCoapOption> multiple_options = {
QList<QCoapOption> single_option = { { QCoapOption::LocationPath, QByteArray("path1") } };
QList<QCoapOption> multiple_options = {
{ QCoapOption::LocationPath, QByteArray("path2") },
{ QCoapOption::LocationPath, QByteArray("path3") }
};
@ -204,7 +204,7 @@ void tst_QCoapMessage::removeOption_data()
void tst_QCoapMessage::removeOption()
{
QFETCH(QVector<QCoapOption>, options);
QFETCH(QList<QCoapOption>, options);
QCoapMessage message;
for (const auto& option : options)
@ -224,11 +224,11 @@ void tst_QCoapMessage::removeOption()
void tst_QCoapMessage::removeOptionByName_data()
{
QTest::addColumn<QVector<QCoapOption>>("options");
QTest::addColumn<QList<QCoapOption>>("options");
QTest::addColumn<QCoapOption::OptionName>("name");
QVector<QCoapOption> single_option = { { QCoapOption::LocationPath, QByteArray("path1") } };
QVector<QCoapOption> multiple_options = {
QList<QCoapOption> single_option = { { QCoapOption::LocationPath, QByteArray("path1") } };
QList<QCoapOption> multiple_options = {
{ QCoapOption::LocationPath, QByteArray("path2") },
{ QCoapOption::LocationPath, QByteArray("path3") }
};
@ -239,7 +239,7 @@ void tst_QCoapMessage::removeOptionByName_data()
void tst_QCoapMessage::removeOptionByName()
{
QFETCH(QVector<QCoapOption>, options);
QFETCH(QList<QCoapOption>, options);
QFETCH(QCoapOption::OptionName, name);
QCoapMessage message;

View File

@ -146,7 +146,7 @@ void tst_QCoapResource::parseCoreLink()
QFETCH(QList<bool>, observableList);
QFETCH(QByteArray, coreLinkList);
const QVector<QCoapResource> resourceList =
const auto resourceList =
QCoapResourceDiscoveryReplyPrivate::resourcesFromCoreLinkList(
QHostAddress(senderAddress), coreLinkList);