summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Buhr <andreas@andreasbuhr.de>2021-03-02 13:58:17 +0100
committerAndreas Buhr <andreas@andreasbuhr.de>2021-03-12 19:17:09 +0100
commit9c59558afc71f36a82a1cab9ca0841119892e26a (patch)
tree1bf93e363f1c65abffc82a4c92f93dd1428374fb
parenta2be117fe1a8dbcd00686e4c71db8a2cfdfa7326 (diff)
Make comparison operators hidden friends in QtBluetooth
This patch changes all comparison operators in QtBluetooth to hidden friends. Thereby, they are symmetric and can only be found through ADL, not polluting the global namespace. Fixes: QTBUG-91553 Change-Id: I4357dd3fee51beb86e68a9c7a01ea6b6c93f135f Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
-rw-r--r--src/bluetooth/qbluetoothaddress.cpp49
-rw-r--r--src/bluetooth/qbluetoothaddress.h14
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp55
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h11
-rw-r--r--src/bluetooth/qbluetoothhostinfo.cpp29
-rw-r--r--src/bluetooth/qbluetoothhostinfo.h12
-rw-r--r--src/bluetooth/qbluetoothuuid.cpp12
-rw-r--r--src/bluetooth/qbluetoothuuid.h11
-rw-r--r--src/bluetooth/qlowenergyadvertisingdata.cpp37
-rw-r--r--src/bluetooth/qlowenergyadvertisingdata.h19
-rw-r--r--src/bluetooth/qlowenergyadvertisingparameters.cpp60
-rw-r--r--src/bluetooth/qlowenergyadvertisingparameters.h39
-rw-r--r--src/bluetooth/qlowenergycharacteristic.cpp48
-rw-r--r--src/bluetooth/qlowenergycharacteristic.h13
-rw-r--r--src/bluetooth/qlowenergycharacteristicdata.cpp39
-rw-r--r--src/bluetooth/qlowenergycharacteristicdata.h22
-rw-r--r--src/bluetooth/qlowenergyconnectionparameters.cpp33
-rw-r--r--src/bluetooth/qlowenergyconnectionparameters.h22
-rw-r--r--src/bluetooth/qlowenergydescriptor.cpp47
-rw-r--r--src/bluetooth/qlowenergydescriptor.h13
-rw-r--r--src/bluetooth/qlowenergydescriptordata.cpp40
-rw-r--r--src/bluetooth/qlowenergydescriptordata.h20
-rw-r--r--src/bluetooth/qlowenergyservicedata.cpp34
-rw-r--r--src/bluetooth/qlowenergyservicedata.h18
24 files changed, 418 insertions, 279 deletions
diff --git a/src/bluetooth/qbluetoothaddress.cpp b/src/bluetooth/qbluetoothaddress.cpp
index d2915373..83c2dcce 100644
--- a/src/bluetooth/qbluetoothaddress.cpp
+++ b/src/bluetooth/qbluetoothaddress.cpp
@@ -55,15 +55,6 @@ QT_BEGIN_NAMESPACE
This class holds a Bluetooth address in a platform- and protocol-independent manner.
*/
-/*!
- \fn inline bool QBluetoothAddress::operator!=(const QBluetoothAddress &other) const
-
-
- Compares this Bluetooth address with \a other.
-
- Returns true if the Bluetooth addresses are not equal, otherwise returns false.
-*/
-
void registerQBluetoothAddress()
{
qRegisterMetaType<QBluetoothAddress>();
@@ -147,25 +138,6 @@ bool QBluetoothAddress::isNull() const
}
/*!
- Returns true if the Bluetooth address is less than \a other, otherwise
- returns false.
-*/
-bool QBluetoothAddress::operator<(const QBluetoothAddress &other) const
-{
- return m_address < other.m_address;
-}
-
-/*!
- Compares this Bluetooth address to \a other.
-
- Returns true if the two Bluetooth addresses are equal, otherwise returns false.
-*/
-bool QBluetoothAddress::operator==(const QBluetoothAddress &other) const
-{
- return m_address == other.m_address;
-}
-
-/*!
Returns this Bluetooth address as a quint64.
*/
quint64 QBluetoothAddress::toUInt64() const
@@ -188,6 +160,27 @@ QString QBluetoothAddress::toString() const
return s.toUpper();
}
+/*!
+ \fn bool QBluetoothAddress::operator<(const QBluetoothAddress &a,
+ const QBluetoothAddress &b)
+ \brief Returns true if the Bluetooth address \a a is less than \a b, otherwise
+ returns false.
+*/
+
+/*!
+ \fn bool QBluetoothAddress::operator==(const QBluetoothAddress &a,
+ const QBluetoothAddress &b)
+ \brief Returns \c true if the two Bluetooth addresses \a a and \a b are equal,
+ otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QBluetoothAddress::operator!=(const QBluetoothAddress &a,
+ const QBluetoothAddress &b)
+ \brief Returns \c true if the two Bluetooth addresses \a a and \a b are not equal,
+ otherwise returns \c false.
+*/
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QBluetoothAddress &address)
{
diff --git a/src/bluetooth/qbluetoothaddress.h b/src/bluetooth/qbluetoothaddress.h
index 414d1f31..8d0bac0a 100644
--- a/src/bluetooth/qbluetoothaddress.h
+++ b/src/bluetooth/qbluetoothaddress.h
@@ -63,11 +63,17 @@ public:
void clear();
- bool operator<(const QBluetoothAddress &other) const;
- bool operator==(const QBluetoothAddress &other) const;
- inline bool operator!=(const QBluetoothAddress &other) const
+ friend bool operator<(const QBluetoothAddress &a, const QBluetoothAddress &b)
{
- return !operator==(other);
+ return a.m_address < b.m_address;
+ }
+ friend bool operator==(const QBluetoothAddress &a, const QBluetoothAddress &b)
+ {
+ return a.m_address == b.m_address;
+ }
+ inline friend bool operator!=(const QBluetoothAddress &a, const QBluetoothAddress &b)
+ {
+ return a.m_address != b.m_address;
}
quint64 toUInt64() const;
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index dc65674e..36d24b91 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -404,51 +404,52 @@ QBluetoothDeviceInfo &QBluetoothDeviceInfo::operator=(const QBluetoothDeviceInfo
}
/*!
- Returns true if the \a other QBluetoothDeviceInfo object and this are identical.
- */
-bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &other) const
-{
- Q_D(const QBluetoothDeviceInfo);
+ \fn bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
+ \brief Returns \c true if the two QBluetoothDeviceInfo objects \a a and \a b are equal.
+*/
- if (d->cached != other.d_func()->cached)
+/*!
+ \fn bool QBluetoothDeviceInfo::operator!=(const QBluetoothDeviceInfo &a,
+ const QBluetoothDeviceInfo &b)
+ \brief Returns \c true if the two QBluetoothDeviceInfo objects \a a and \a b are not equal.
+*/
+
+/*!
+ \brief Returns true if the \a other QBluetoothDeviceInfo object and this are identical.
+ \internal
+*/
+
+bool QBluetoothDeviceInfo::equals(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
+{
+ if (a.d_func()->cached != b.d_func()->cached)
return false;
- if (d->valid != other.d_func()->valid)
+ if (a.d_func()->valid != b.d_func()->valid)
return false;
- if (d->majorDeviceClass != other.d_func()->majorDeviceClass)
+ if (a.d_func()->majorDeviceClass != b.d_func()->majorDeviceClass)
return false;
- if (d->minorDeviceClass != other.d_func()->minorDeviceClass)
+ if (a.d_func()->minorDeviceClass != b.d_func()->minorDeviceClass)
return false;
- if (d->serviceClasses != other.d_func()->serviceClasses)
+ if (a.d_func()->serviceClasses != b.d_func()->serviceClasses)
return false;
- if (d->name != other.d_func()->name)
+ if (a.d_func()->name != b.d_func()->name)
return false;
- if (d->address != other.d_func()->address)
+ if (a.d_func()->address != b.d_func()->address)
return false;
- if (d->serviceUuids.count() != other.d_func()->serviceUuids.count())
+ if (a.d_func()->serviceUuids.count() != b.d_func()->serviceUuids.count())
return false;
- if (d->serviceUuids != other.d_func()->serviceUuids)
+ if (a.d_func()->serviceUuids != b.d_func()->serviceUuids)
return false;
- if (d->manufacturerData != other.d_func()->manufacturerData)
+ if (a.d_func()->manufacturerData != b.d_func()->manufacturerData)
return false;
- if (d->deviceCoreConfiguration != other.d_func()->deviceCoreConfiguration)
+ if (a.d_func()->deviceCoreConfiguration != b.d_func()->deviceCoreConfiguration)
return false;
- if (d->deviceUuid != other.d_func()->deviceUuid)
+ if (a.d_func()->deviceUuid != b.d_func()->deviceUuid)
return false;
return true;
}
/*!
- Returns true if this object is different from \a other, or false otherwise.
-
- \sa operator==()
-*/
-bool QBluetoothDeviceInfo::operator!=(const QBluetoothDeviceInfo &other) const
-{
- return !(*this == other);
-}
-
-/*!
Returns the address of the device.
\note On iOS and \macos this address is invalid. Instead \l deviceUuid() should be used.
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index 8b51dd13..3219e629 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -221,8 +221,14 @@ public:
void setCached(bool cached);
QBluetoothDeviceInfo &operator=(const QBluetoothDeviceInfo &other);
- bool operator==(const QBluetoothDeviceInfo &other) const;
- bool operator!=(const QBluetoothDeviceInfo &other) const;
+ friend bool operator==(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
+ {
+ return !equals(a, b);
+ }
QBluetoothAddress address() const;
QString name() const;
@@ -253,6 +259,7 @@ protected:
QBluetoothDeviceInfoPrivate *d_ptr;
private:
+ static bool equals(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b);
Q_DECLARE_PRIVATE(QBluetoothDeviceInfo)
};
diff --git a/src/bluetooth/qbluetoothhostinfo.cpp b/src/bluetooth/qbluetoothhostinfo.cpp
index ca48fd23..d28cadb9 100644
--- a/src/bluetooth/qbluetoothhostinfo.cpp
+++ b/src/bluetooth/qbluetoothhostinfo.cpp
@@ -95,26 +95,27 @@ QBluetoothHostInfo &QBluetoothHostInfo::operator=(const QBluetoothHostInfo &othe
}
/*!
- \since 5.5
-
- Returns true if \a other is equal to this QBluetoothHostInfo, otherwise false.
+ \fn bool QBluetoothHostInfo::operator==(const QBluetoothHostInfo &a,
+ const QBluetoothHostInfo &b)
+ \brief Returns \c true if \a a and \a b are equal, otherwise \c false.
*/
-bool QBluetoothHostInfo::operator==(const QBluetoothHostInfo &other) const
-{
- if (d_ptr == other.d_ptr)
- return true;
-
- return d_ptr->m_address == other.d_ptr->m_address && d_ptr->m_name == other.d_ptr->m_name;
-}
/*!
- \since 5.5
+ \fn bool QBluetoothHostInfo::operator!=(const QBluetoothHostInfo &a,
+ const QBluetoothHostInfo &b)
+ \brief Returns \c true if \a a and \a b are not equal, otherwise \c false.
+*/
- Returns true if \a other is not equal to this QBluetoothHostInfo, otherwise false.
+/*!
+ \brief Returns \c true if \a a and \a b are equal, otherwise \c false.
+ \internal
*/
-bool QBluetoothHostInfo::operator!=(const QBluetoothHostInfo &other) const
+bool QBluetoothHostInfo::equals(const QBluetoothHostInfo &a, const QBluetoothHostInfo &b)
{
- return !operator==(other);
+ if (a.d_ptr == b.d_ptr)
+ return true;
+
+ return a.d_ptr->m_address == b.d_ptr->m_address && a.d_ptr->m_name == b.d_ptr->m_name;
}
/*!
diff --git a/src/bluetooth/qbluetoothhostinfo.h b/src/bluetooth/qbluetoothhostinfo.h
index 42dfcaab..9330cba7 100644
--- a/src/bluetooth/qbluetoothhostinfo.h
+++ b/src/bluetooth/qbluetoothhostinfo.h
@@ -54,9 +54,14 @@ public:
~QBluetoothHostInfo();
QBluetoothHostInfo &operator=(const QBluetoothHostInfo &other);
-
- bool operator==(const QBluetoothHostInfo &other) const;
- bool operator!=(const QBluetoothHostInfo &other) const;
+ friend bool operator==(const QBluetoothHostInfo &a, const QBluetoothHostInfo &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QBluetoothHostInfo &a, const QBluetoothHostInfo &b)
+ {
+ return !equals(a, b);
+ }
QBluetoothAddress address() const;
void setAddress(const QBluetoothAddress &address);
@@ -65,6 +70,7 @@ public:
void setName(const QString &name);
private:
+ static bool equals(const QBluetoothHostInfo &a, const QBluetoothHostInfo &b);
Q_DECLARE_PRIVATE(QBluetoothHostInfo)
QBluetoothHostInfoPrivate *d_ptr;
};
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp
index 95cc0b0f..e0639a68 100644
--- a/src/bluetooth/qbluetoothuuid.cpp
+++ b/src/bluetooth/qbluetoothuuid.cpp
@@ -1086,17 +1086,13 @@ QString QBluetoothUuid::descriptorToString(QBluetoothUuid::DescriptorType uuid)
}
/*!
- Returns \c true if \a other is equal to this Bluetooth UUID, otherwise \c false.
+ \fn bool QBluetoothUuid::operator==(const QBluetoothUuid &a, const QBluetoothUuid &b)
+ \brief Returns \c true if \a a is equal to \a b, otherwise \c false.
*/
-bool QBluetoothUuid::operator==(const QBluetoothUuid &other) const
-{
- return QUuid::operator==(other);
-}
/*!
- \fn bool QBluetoothUuid::operator!=(const QBluetoothUuid &other) const
- Returns \c true if \a other is not equal to this Bluetooth UUID, otherwise \c false.
- \since 5.7
+ \fn bool QBluetoothUuid::operator!=(const QBluetoothUuid &a, const QBluetoothUuid &b)
+ \brief Returns \c true if \a a is not equal to \a b, otherwise \c false.
*/
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h
index 0dc44b59..e1970475 100644
--- a/src/bluetooth/qbluetoothuuid.h
+++ b/src/bluetooth/qbluetoothuuid.h
@@ -387,10 +387,12 @@ public:
QBluetoothUuid(const QUuid &uuid);
~QBluetoothUuid() = default;
- bool operator==(const QBluetoothUuid &other) const;
- bool operator!=(const QBluetoothUuid &other) const { return !operator==(other); }
-
QBluetoothUuid &operator=(const QBluetoothUuid &other) = default;
+ friend bool operator==(const QBluetoothUuid &a, const QBluetoothUuid &b)
+ {
+ return static_cast<QUuid>(a) == static_cast<QUuid>(b);
+ }
+ friend bool operator!=(const QBluetoothUuid &a, const QBluetoothUuid &b) { return !(a == b); }
int minimumSize() const;
@@ -402,6 +404,9 @@ public:
static QString protocolToString(ProtocolUuid uuid);
static QString characteristicToString(CharacteristicType uuid);
static QString descriptorToString(DescriptorType uuid);
+
+private:
+ static bool equals(const QBluetoothUuid &a, const QBluetoothUuid &b);
};
#ifndef QT_NO_DATASTREAM
diff --git a/src/bluetooth/qlowenergyadvertisingdata.cpp b/src/bluetooth/qlowenergyadvertisingdata.cpp
index 3837025b..880539a1 100644
--- a/src/bluetooth/qlowenergyadvertisingdata.cpp
+++ b/src/bluetooth/qlowenergyadvertisingdata.cpp
@@ -263,27 +263,34 @@ QByteArray QLowEnergyAdvertisingData::rawData() const
*/
/*!
- Returns \c true if \a data1 and \a data2 are equal with respect to their public state,
- otherwise returns \c false.
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
+ \internal
*/
-bool operator==(const QLowEnergyAdvertisingData &data1, const QLowEnergyAdvertisingData &data2)
+bool QLowEnergyAdvertisingData::equals(const QLowEnergyAdvertisingData &a,
+ const QLowEnergyAdvertisingData &b)
{
- if (data1.d == data2.d)
+ if (a.d == b.d)
return true;
- return data1.discoverability() == data2.discoverability()
- && data1.includePowerLevel() == data2.includePowerLevel()
- && data1.localName() == data2.localName()
- && data1.manufacturerData() == data2.manufacturerData()
- && data1.manufacturerId() == data2.manufacturerId()
- && data1.services() == data2.services()
- && data1.rawData() == data2.rawData();
+ return a.discoverability() == b.discoverability()
+ && a.includePowerLevel() == b.includePowerLevel() && a.localName() == b.localName()
+ && a.manufacturerData() == b.manufacturerData()
+ && a.manufacturerId() == b.manufacturerId() && a.services() == b.services()
+ && a.rawData() == b.rawData();
}
/*!
- \fn bool operator!=(const QLowEnergyAdvertisingData &data1,
- const QLowEnergyAdvertisingData &data2)
- Returns \c true if \a data1 and \a data2 are not equal with respect to their public state,
- otherwise returns \c false.
+ \fn bool QLowEnergyAdvertisingData::operator!=(const QLowEnergyAdvertisingData &data1,
+ const QLowEnergyAdvertisingData &data2)
+ \brief Returns \c true if \a data1 and \a data2 are not equal with respect to their
+ public state, otherwise returns \c false.
+ */
+
+/*!
+ \fn bool QLowEnergyAdvertisingData::operator==(const QLowEnergyAdvertisingData &data1,
+ const QLowEnergyAdvertisingData &data2)
+ \brief Returns \c true if \a data1 and \a data2 are equal with respect to their public
+ state, otherwise returns \c false.
*/
/*!
diff --git a/src/bluetooth/qlowenergyadvertisingdata.h b/src/bluetooth/qlowenergyadvertisingdata.h
index 0fc55adb..11edd632 100644
--- a/src/bluetooth/qlowenergyadvertisingdata.h
+++ b/src/bluetooth/qlowenergyadvertisingdata.h
@@ -50,14 +50,20 @@ class QLowEnergyAdvertisingDataPrivate;
class Q_BLUETOOTH_EXPORT QLowEnergyAdvertisingData
{
- friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyAdvertisingData &data1,
- const QLowEnergyAdvertisingData &data2);
public:
QLowEnergyAdvertisingData();
QLowEnergyAdvertisingData(const QLowEnergyAdvertisingData &other);
~QLowEnergyAdvertisingData();
QLowEnergyAdvertisingData &operator=(const QLowEnergyAdvertisingData &other);
+ friend bool operator==(const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b)
+ {
+ return !equals(a, b);
+ }
void setLocalName(const QString &name);
QString localName() const;
@@ -87,17 +93,10 @@ public:
void swap(QLowEnergyAdvertisingData &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
private:
+ static bool equals(const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b);
QSharedDataPointer<QLowEnergyAdvertisingDataPrivate> d;
};
-Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyAdvertisingData &data1,
- const QLowEnergyAdvertisingData &data2);
-inline bool operator!=(const QLowEnergyAdvertisingData &data1,
- const QLowEnergyAdvertisingData &data2)
-{
- return !(data1 == data2);
-}
-
Q_DECLARE_SHARED(QLowEnergyAdvertisingData)
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyadvertisingparameters.cpp b/src/bluetooth/qlowenergyadvertisingparameters.cpp
index 31111da6..e63ef8c2 100644
--- a/src/bluetooth/qlowenergyadvertisingparameters.cpp
+++ b/src/bluetooth/qlowenergyadvertisingparameters.cpp
@@ -269,26 +269,58 @@ int QLowEnergyAdvertisingParameters::maximumInterval() const
*/
/*!
- Returns \a true if \a p1 and \a p2 are equal with respect to their public state,
- otherwise returns false.
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
+ \internal
*/
-bool operator==(const QLowEnergyAdvertisingParameters &p1,
- const QLowEnergyAdvertisingParameters &p2)
+bool QLowEnergyAdvertisingParameters::equals(const QLowEnergyAdvertisingParameters &a,
+ const QLowEnergyAdvertisingParameters &b)
{
- if (p1.d == p2.d)
+ if (a.d == b.d)
return true;
- return p1.filterPolicy() == p2.filterPolicy()
- && p1.minimumInterval() == p2.minimumInterval()
- && p1.maximumInterval() == p2.maximumInterval()
- && p1.mode() == p2.mode()
- && p1.whiteList() == p2.whiteList();
+ return a.filterPolicy() == b.filterPolicy() && a.minimumInterval() == b.minimumInterval()
+ && a.maximumInterval() == b.maximumInterval() && a.mode() == b.mode()
+ && a.whiteList() == b.whiteList();
}
+bool QLowEnergyAdvertisingParameters::AddressInfo::equals(
+ const QLowEnergyAdvertisingParameters::AddressInfo &ai1,
+ const QLowEnergyAdvertisingParameters::AddressInfo &ai2)
+{
+ return ai1.address == ai2.address && ai1.type == ai2.type;
+}
+
+/*!
+ \fn bool QLowEnergyAdvertisingParameters::operator!=(
+ const QLowEnergyAdvertisingParameters &a,
+ const QLowEnergyAdvertisingParameters &b)
+ \brief Returns \c true if \a a and \a b are not equal with respect to their public state,
+ otherwise returns \c false.
+ */
+
+/*!
+ \fn bool QLowEnergyAdvertisingParameters::operator==(
+ const QLowEnergyAdvertisingParameters &a,
+ const QLowEnergyAdvertisingParameters &b)
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
+ */
+
+/*!
+ \fn bool QLowEnergyAdvertisingParameters::AddressInfo::operator!=(const
+ QLowEnergyAdvertisingParameters::AddressInfo &a, const
+ QLowEnergyAdvertisingParameters::AddressInfo &b)
+
+ \brief Returns \c true if \a a and \a b are not equal with respect to their public state,
+ otherwise returns \c false.
+ */
+
/*!
- \fn bool operator!=(const QLowEnergyAdvertisingParameters &p1,
- const QLowEnergyAdvertisingParameters &p2)
- Returns \a true if \a p1 and \a p2 are not equal with respect to their public state,
- otherwise returns false.
+ \fn bool QLowEnergyAdvertisingParameters::AddressInfo::operator==(
+ const QLowEnergyAdvertisingParameters::AddressInfo &a,
+ const QLowEnergyAdvertisingParameters::AddressInfo &b)
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
*/
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyadvertisingparameters.h b/src/bluetooth/qlowenergyadvertisingparameters.h
index 055026e6..ce24e781 100644
--- a/src/bluetooth/qlowenergyadvertisingparameters.h
+++ b/src/bluetooth/qlowenergyadvertisingparameters.h
@@ -52,27 +52,44 @@ class QLowEnergyAdvertisingParametersPrivate;
class Q_BLUETOOTH_EXPORT QLowEnergyAdvertisingParameters
{
- friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyAdvertisingParameters &p1,
- const QLowEnergyAdvertisingParameters &p2);
public:
QLowEnergyAdvertisingParameters();
QLowEnergyAdvertisingParameters(const QLowEnergyAdvertisingParameters &other);
~QLowEnergyAdvertisingParameters();
QLowEnergyAdvertisingParameters &operator=(const QLowEnergyAdvertisingParameters &other);
+ friend bool operator==(const QLowEnergyAdvertisingParameters &a,
+ const QLowEnergyAdvertisingParameters &b)
+ {
+ return equals(a, b);
+ }
+
+ friend bool operator!=(const QLowEnergyAdvertisingParameters &a,
+ const QLowEnergyAdvertisingParameters &b)
+ {
+ return !equals(a, b);
+ }
enum Mode { AdvInd = 0x0, AdvScanInd = 0x2, AdvNonConnInd = 0x3 };
void setMode(Mode mode);
Mode mode() const;
- struct AddressInfo {
+ class Q_BLUETOOTH_EXPORT AddressInfo
+ {
+ public:
AddressInfo(const QBluetoothAddress &addr, QLowEnergyController::RemoteAddressType t)
: address(addr), type(t) {}
AddressInfo() : type(QLowEnergyController::PublicAddress) {}
QBluetoothAddress address;
QLowEnergyController::RemoteAddressType type;
+ friend bool operator==(const AddressInfo &a, const AddressInfo &b) { return equals(a, b); }
+ friend bool operator!=(const AddressInfo &a, const AddressInfo &b) { return !equals(a, b); }
+
+ private:
+ static bool equals(const AddressInfo &a, const AddressInfo &b);
};
+
enum FilterPolicy {
IgnoreWhiteList = 0x00,
UseWhiteListForScanning = 0x01,
@@ -93,23 +110,11 @@ public:
void swap(QLowEnergyAdvertisingParameters &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
private:
+ static bool equals(const QLowEnergyAdvertisingParameters &a,
+ const QLowEnergyAdvertisingParameters &b);
QSharedDataPointer<QLowEnergyAdvertisingParametersPrivate> d;
};
-inline bool operator==(const QLowEnergyAdvertisingParameters::AddressInfo &ai1,
- const QLowEnergyAdvertisingParameters::AddressInfo &ai2)
-{
- return ai1.address == ai2.address && ai1.type == ai2.type;
-}
-
-Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyAdvertisingParameters &p1,
- const QLowEnergyAdvertisingParameters &p2);
-inline bool operator!=(const QLowEnergyAdvertisingParameters &p1,
- const QLowEnergyAdvertisingParameters &p2)
-{
- return !(p1 == p2);
-}
-
Q_DECLARE_SHARED(QLowEnergyAdvertisingParameters)
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycharacteristic.cpp b/src/bluetooth/qlowenergycharacteristic.cpp
index 1419fa7c..4f8e0fd0 100644
--- a/src/bluetooth/qlowenergycharacteristic.cpp
+++ b/src/bluetooth/qlowenergycharacteristic.cpp
@@ -253,43 +253,53 @@ QLowEnergyCharacteristic &QLowEnergyCharacteristic::operator=(const QLowEnergyCh
}
/*!
- Returns \c true if \a other is equal to this QLowEnergyCharacteristic; otherwise \c false.
+ \fn bool QLowEnergyCharacteristic::operator==(const QLowEnergyCharacteristic &a,
+ const QLowEnergyCharacteristic &b)
+ \brief Returns \c true if \a a is equal to \a b, otherwise \c false.
Two \l QLowEnergyCharacteristic instances are considered to be equal if they refer to
the same characteristic on the same remote Bluetooth Low Energy device or both instances
have been default-constructed.
*/
-bool QLowEnergyCharacteristic::operator==(const QLowEnergyCharacteristic &other) const
+
+/*!
+ \fn bool QLowEnergyCharacteristic::operator!=(const QLowEnergyCharacteristic &a,
+ const QLowEnergyCharacteristic &b)
+ \brief Returns \c true if \a a and \a b are not equal; otherwise \c
+ false.
+
+ Two QLowEnergyCharcteristic instances are considered to be equal if they refer to
+ the same characteristic on the same remote Bluetooth Low Energy device or both instances
+ have been default-constructed.
+ */
+
+/*!
+ \brief Returns \c true if \a a is equal to \a b; otherwise \c false.
+ \internal
+
+ Two \l QLowEnergyCharacteristic instances are considered to be equal if they refer to
+ the same characteristic on the same remote Bluetooth Low Energy device or both instances
+ have been default-constructed.
+ */
+bool QLowEnergyCharacteristic::equals(const QLowEnergyCharacteristic &a,
+ const QLowEnergyCharacteristic &b)
{
- if (d_ptr != other.d_ptr)
+ if (a.d_ptr != b.d_ptr)
return false;
- if ((data && !other.data) || (!data && other.data))
+ if ((a.data && !b.data) || (!a.data && b.data))
return false;
- if (!data)
+ if (!a.data)
return true;
- if (data->handle != other.data->handle)
+ if (a.data->handle != b.data->handle)
return false;
return true;
}
/*!
- Returns \c true if \a other is not equal to this QLowEnergyCharacteristic; otherwise \c false.
-
- Two QLowEnergyCharcteristic instances are considered to be equal if they refer to
- the same characteristic on the same remote Bluetooth Low Energy device or both instances
- have been default-constructed.
- */
-
-bool QLowEnergyCharacteristic::operator!=(const QLowEnergyCharacteristic &other) const
-{
- return !(*this == other);
-}
-
-/*!
Returns \c true if the QLowEnergyCharacteristic object is valid, otherwise returns \c false.
An invalid characteristic object is not associated with any service (default-constructed)
diff --git a/src/bluetooth/qlowenergycharacteristic.h b/src/bluetooth/qlowenergycharacteristic.h
index fe9b73fa..0ba08d35 100644
--- a/src/bluetooth/qlowenergycharacteristic.h
+++ b/src/bluetooth/qlowenergycharacteristic.h
@@ -73,8 +73,14 @@ public:
~QLowEnergyCharacteristic();
QLowEnergyCharacteristic &operator=(const QLowEnergyCharacteristic &other);
- bool operator==(const QLowEnergyCharacteristic &other) const;
- bool operator!=(const QLowEnergyCharacteristic &other) const;
+ friend bool operator==(const QLowEnergyCharacteristic &a, const QLowEnergyCharacteristic &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QLowEnergyCharacteristic &a, const QLowEnergyCharacteristic &b)
+ {
+ return !equals(a, b);
+ }
QString name() const;
@@ -108,6 +114,9 @@ protected:
QLowEnergyCharacteristicPrivate *data = nullptr;
QLowEnergyCharacteristic(QSharedPointer<QLowEnergyServicePrivate> p,
QLowEnergyHandle handle);
+
+private:
+ static bool equals(const QLowEnergyCharacteristic &a, const QLowEnergyCharacteristic &b);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QLowEnergyCharacteristic::PropertyTypes)
diff --git a/src/bluetooth/qlowenergycharacteristicdata.cpp b/src/bluetooth/qlowenergycharacteristicdata.cpp
index 700566a6..a677f54a 100644
--- a/src/bluetooth/qlowenergycharacteristicdata.cpp
+++ b/src/bluetooth/qlowenergycharacteristicdata.cpp
@@ -254,27 +254,34 @@ bool QLowEnergyCharacteristicData::isValid() const
*/
/*!
- Returns \c true if \a cd1 and \a cd2 are equal with respect to their public state,
- otherwise returns \c false.
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
+ \internal
*/
-bool operator==(const QLowEnergyCharacteristicData &cd1, const QLowEnergyCharacteristicData &cd2)
+bool QLowEnergyCharacteristicData::equals(const QLowEnergyCharacteristicData &a,
+ const QLowEnergyCharacteristicData &b)
{
- return cd1.d == cd2.d || (
- cd1.uuid() == cd2.uuid()
- && cd1.properties() == cd2.properties()
- && cd1.descriptors() == cd2.descriptors()
- && cd1.value() == cd2.value()
- && cd1.readConstraints() == cd2.readConstraints()
- && cd1.writeConstraints() == cd2.writeConstraints()
- && cd1.minimumValueLength() == cd2.maximumValueLength()
- && cd1.maximumValueLength() == cd2.maximumValueLength());
+ return a.d == b.d
+ || (a.uuid() == b.uuid() && a.properties() == b.properties()
+ && a.descriptors() == b.descriptors() && a.value() == b.value()
+ && a.readConstraints() == b.readConstraints()
+ && a.writeConstraints() == b.writeConstraints()
+ && a.minimumValueLength() == b.maximumValueLength()
+ && a.maximumValueLength() == b.maximumValueLength());
}
/*!
- \fn bool operator!=(const QLowEnergyCharacteristicData &cd1,
- const QLowEnergyCharacteristicData &cd2)
- Returns \c true if \a cd1 and \a cd2 are not equal with respect to their public state,
- otherwise returns \c false.
+ \fn bool QLowEnergyCharacteristicData::operator==(const QLowEnergyCharacteristicData &a,
+ const QLowEnergyCharacteristicData &b)
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
+ */
+
+/*!
+ \fn bool QLowEnergyCharacteristicData::operator!=(const QLowEnergyCharacteristicData &a,
+ const QLowEnergyCharacteristicData &b)
+ \brief Returns \c true if \a a and \a b are not equal with respect to their public state,
+ otherwise returns \c false.
*/
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycharacteristicdata.h b/src/bluetooth/qlowenergycharacteristicdata.h
index cf5de703..d482f787 100644
--- a/src/bluetooth/qlowenergycharacteristicdata.h
+++ b/src/bluetooth/qlowenergycharacteristicdata.h
@@ -48,14 +48,22 @@ class QLowEnergyDescriptorData;
struct QLowEnergyCharacteristicDataPrivate;
class Q_BLUETOOTH_EXPORT QLowEnergyCharacteristicData
{
- friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyCharacteristicData &cd1,
- const QLowEnergyCharacteristicData &cd2);
public:
QLowEnergyCharacteristicData();
QLowEnergyCharacteristicData(const QLowEnergyCharacteristicData &other);
~QLowEnergyCharacteristicData();
QLowEnergyCharacteristicData &operator=(const QLowEnergyCharacteristicData &other);
+ friend bool operator==(const QLowEnergyCharacteristicData &a,
+ const QLowEnergyCharacteristicData &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QLowEnergyCharacteristicData &a,
+ const QLowEnergyCharacteristicData &b)
+ {
+ return !equals(a, b);
+ }
QBluetoothUuid uuid() const;
void setUuid(const QBluetoothUuid &uuid);
@@ -85,17 +93,11 @@ public:
void swap(QLowEnergyCharacteristicData &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
private:
+ static bool equals(const QLowEnergyCharacteristicData &a,
+ const QLowEnergyCharacteristicData &b);
QSharedDataPointer<QLowEnergyCharacteristicDataPrivate> d;
};
-Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyCharacteristicData &cd1,
- const QLowEnergyCharacteristicData &cd2);
-inline bool operator!=(const QLowEnergyCharacteristicData &cd1,
- const QLowEnergyCharacteristicData &cd2)
-{
- return !(cd1 == cd2);
-}
-
Q_DECLARE_SHARED(QLowEnergyCharacteristicData)
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyconnectionparameters.cpp b/src/bluetooth/qlowenergyconnectionparameters.cpp
index 95256402..5d3719dc 100644
--- a/src/bluetooth/qlowenergyconnectionparameters.cpp
+++ b/src/bluetooth/qlowenergyconnectionparameters.cpp
@@ -214,24 +214,33 @@ int QLowEnergyConnectionParameters::supervisionTimeout() const
*/
/*!
- Returns \a true if \a p1 and \a p2 are equal with respect to their public state,
- otherwise returns false.
+ \brief Returns \a true if \a a and \a b are equal with respect to their public state,
+ otherwise returns false.
+ \internal
*/
-bool operator==(const QLowEnergyConnectionParameters &p1, const QLowEnergyConnectionParameters &p2)
+bool QLowEnergyConnectionParameters::equals(const QLowEnergyConnectionParameters &a,
+ const QLowEnergyConnectionParameters &b)
{
- if (p1.d == p2.d)
+ if (a.d == b.d)
return true;
- return p1.minimumInterval() == p2.minimumInterval()
- && p1.maximumInterval() == p2.maximumInterval()
- && p1.latency() == p2.latency()
- && p1.supervisionTimeout() == p2.supervisionTimeout();
+ return a.minimumInterval() == b.minimumInterval() && a.maximumInterval() == b.maximumInterval()
+ && a.latency() == b.latency() && a.supervisionTimeout() == b.supervisionTimeout();
}
/*!
- \fn bool operator!=(const QLowEnergyConnectionParameters &p1,
- const QLowEnergyConnectionParameters &p2)
- Returns \a true if \a p1 and \a p2 are not equal with respect to their public state,
- otherwise returns false.
+ \fn bool QLowEnergyConnectionParameters::operator!=(
+ const QLowEnergyConnectionParameters &p1,
+ const QLowEnergyConnectionParameters &p2)
+ \brief Returns \c true if \a p1 and \a p2 are not equal with respect to their public state,
+ otherwise returns \c false.
+ */
+
+/*!
+ \fn bool QLowEnergyConnectionParameters::operator==(
+ const QLowEnergyConnectionParameters &p1,
+ const QLowEnergyConnectionParameters &p2)
+ \brief Returns \c true if \a p1 and \a p2 are equal with respect to their public state,
+ otherwise returns \c false.
*/
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyconnectionparameters.h b/src/bluetooth/qlowenergyconnectionparameters.h
index c765763f..81e453aa 100644
--- a/src/bluetooth/qlowenergyconnectionparameters.h
+++ b/src/bluetooth/qlowenergyconnectionparameters.h
@@ -50,14 +50,22 @@ class QLowEnergyConnectionParametersPrivate;
class Q_BLUETOOTH_EXPORT QLowEnergyConnectionParameters
{
- friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyConnectionParameters &p1,
- const QLowEnergyConnectionParameters &p2);
public:
QLowEnergyConnectionParameters();
QLowEnergyConnectionParameters(const QLowEnergyConnectionParameters &other);
~QLowEnergyConnectionParameters();
QLowEnergyConnectionParameters &operator=(const QLowEnergyConnectionParameters &other);
+ friend bool operator==(const QLowEnergyConnectionParameters &a,
+ const QLowEnergyConnectionParameters &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QLowEnergyConnectionParameters &a,
+ const QLowEnergyConnectionParameters &b)
+ {
+ return !equals(a, b);
+ }
void setIntervalRange(double minimum, double maximum);
double minimumInterval() const;
@@ -72,17 +80,11 @@ public:
void swap(QLowEnergyConnectionParameters &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
private:
+ static bool equals(const QLowEnergyConnectionParameters &a,
+ const QLowEnergyConnectionParameters &b);
QSharedDataPointer<QLowEnergyConnectionParametersPrivate> d;
};
-Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyConnectionParameters &p1,
- const QLowEnergyConnectionParameters &p2);
-inline bool operator!=(const QLowEnergyConnectionParameters &p1,
- const QLowEnergyConnectionParameters &p2)
-{
- return !(p1 == p2);
-}
-
Q_DECLARE_SHARED(QLowEnergyConnectionParameters)
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergydescriptor.cpp b/src/bluetooth/qlowenergydescriptor.cpp
index 994c17a8..0d6c7c62 100644
--- a/src/bluetooth/qlowenergydescriptor.cpp
+++ b/src/bluetooth/qlowenergydescriptor.cpp
@@ -145,25 +145,46 @@ QLowEnergyDescriptor &QLowEnergyDescriptor::operator=(const QLowEnergyDescriptor
}
/*!
- Returns \c true if \a other is equal to this QLowEnergyCharacteristic; otherwise \c false.
+ \fn bool QLowEnergyDescriptor::operator==(const QLowEnergyDescriptor &a,
+ const QLowEnergyDescriptor &b)
+ \brief Returns \c true if \a a is equal to \a b; otherwise \c false.
+
+ Two QLowEnergyDescriptor instances are considered to be equal if they refer to
+ the same descriptor on the same remote Bluetooth Low Energy device or both
+ instances have been default-constructed.
+ */
+
+/*!
+ \fn bool QLowEnergyDescriptor::operator!=(const QLowEnergyDescriptor &a,
+ const QLowEnergyDescriptor &b)
+ \brief Returns \c true if \a a is not equal to \a b; otherwise \c false.
+
+ Two QLowEnergyDescriptor instances are considered to be equal if they refer to
+ the same descriptor on the same remote Bluetooth Low Energy device or both
+ instances have been default-constructed.
+ */
+
+/*!
+ \brief Returns \c true if \a other is equal to this QLowEnergyCharacteristic,
+ otherwise \c false.
+ \internal
Two QLowEnergyDescriptor instances are considered to be equal if they refer to
the same descriptor on the same remote Bluetooth Low Energy device or both
instances have been default-constructed.
*/
-bool QLowEnergyDescriptor::operator==(const QLowEnergyDescriptor &other) const
+bool QLowEnergyDescriptor::equals(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)
{
- if (d_ptr != other.d_ptr)
+ if (a.d_ptr != b.d_ptr)
return false;
- if ((data && !other.data) || (!data && other.data))
+ if ((a.data && !b.data) || (!a.data && b.data))
return false;
- if (!data)
+ if (!a.data)
return true;
- if (data->charHandle != other.data->charHandle
- || data->descHandle != other.data->descHandle) {
+ if (a.data->charHandle != b.data->charHandle || a.data->descHandle != b.data->descHandle) {
return false;
}
@@ -171,18 +192,6 @@ bool QLowEnergyDescriptor::operator==(const QLowEnergyDescriptor &other) const
}
/*!
- Returns \c true if \a other is not equal to this QLowEnergyCharacteristic; otherwise \c false.
-
- Two QLowEnergyDescriptor instances are considered to be equal if they refer to
- the same descriptor on the same remote Bluetooth Low Energy device or both
- instances have been default-constructed.
- */
-bool QLowEnergyDescriptor::operator!=(const QLowEnergyDescriptor &other) const
-{
- return !(*this == other);
-}
-
-/*!
Returns \c true if the QLowEnergyDescriptor object is valid, otherwise returns \c false.
An invalid descriptor instance is not associated with any service (default-constructed)
diff --git a/src/bluetooth/qlowenergydescriptor.h b/src/bluetooth/qlowenergydescriptor.h
index 18bb53c0..eee23f17 100644
--- a/src/bluetooth/qlowenergydescriptor.h
+++ b/src/bluetooth/qlowenergydescriptor.h
@@ -59,8 +59,14 @@ public:
~QLowEnergyDescriptor();
QLowEnergyDescriptor &operator=(const QLowEnergyDescriptor &other);
- bool operator==(const QLowEnergyDescriptor &other) const;
- bool operator!=(const QLowEnergyDescriptor &other) const;
+ friend bool operator==(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)
+ {
+ return !equals(a, b);
+ }
bool isValid() const;
@@ -92,6 +98,9 @@ protected:
QLowEnergyDescriptor(QSharedPointer<QLowEnergyServicePrivate> p,
QLowEnergyHandle charHandle,
QLowEnergyHandle descHandle);
+
+private:
+ static bool equals(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b);
};
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergydescriptordata.cpp b/src/bluetooth/qlowenergydescriptordata.cpp
index f5836cdc..ad4070cb 100644
--- a/src/bluetooth/qlowenergydescriptordata.cpp
+++ b/src/bluetooth/qlowenergydescriptordata.cpp
@@ -202,24 +202,36 @@ QBluetooth::AttAccessConstraints QLowEnergyDescriptorData::writeConstraints() co
*/
/*!
- Returns \c true if \a d1 and \a d2 are equal with respect to their public state,
+ \fn bool QLowEnergyDescriptorData::operator==(const QLowEnergyDescriptorData &a,
+ const QLowEnergyDescriptorData &b)
+
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
otherwise returns \c false.
*/
-bool operator==(const QLowEnergyDescriptorData &d1, const QLowEnergyDescriptorData &d2)
-{
- return d1.d == d2.d || (
- d1.uuid() == d2.uuid()
- && d1.value() == d2.value()
- && d1.isReadable() == d2.isReadable()
- && d1.isWritable() == d2.isWritable()
- && d1.readConstraints() == d2.readConstraints()
- && d1.writeConstraints() == d2.writeConstraints());
-}
/*!
- \fn bool operator!=(const QLowEnergyDescriptorData &d1, const QLowEnergyDescriptorData &d2)
- Returns \c true if \a d1 and \a d2 are not equal with respect to their public state,
- otherwise returns \c false.
+ \fn bool QLowEnergyDescriptorData::operator!=(const QLowEnergyDescriptorData &a,
+ const QLowEnergyDescriptorData &b)
+
+ \brief Returns \c true if \a a and \a b are unequal with respect to their public state,
+ otherwise returns \c false.
*/
+/*!
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
+ \internal
+ */
+bool QLowEnergyDescriptorData::equals(const QLowEnergyDescriptorData &a,
+ const QLowEnergyDescriptorData &b)
+{
+ return a.d == b.d || (
+ a.uuid() == b.uuid()
+ && a.value() == b.value()
+ && a.isReadable() == b.isReadable()
+ && a.isWritable() == b.isWritable()
+ && a.readConstraints() == b.readConstraints()
+ && a.writeConstraints() == b.writeConstraints());
+}
+
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergydescriptordata.h b/src/bluetooth/qlowenergydescriptordata.h
index 856acf53..cafb95fb 100644
--- a/src/bluetooth/qlowenergydescriptordata.h
+++ b/src/bluetooth/qlowenergydescriptordata.h
@@ -51,8 +51,6 @@ struct QLowEnergyDescriptorDataPrivate;
class Q_BLUETOOTH_EXPORT QLowEnergyDescriptorData
{
- friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyDescriptorData &d1,
- const QLowEnergyDescriptorData &d12);
public:
QLowEnergyDescriptorData();
QLowEnergyDescriptorData(const QBluetoothUuid &uuid,
@@ -61,6 +59,15 @@ public:
~QLowEnergyDescriptorData();
QLowEnergyDescriptorData &operator=(const QLowEnergyDescriptorData &other);
+ friend bool operator==(const QLowEnergyDescriptorData &a, const QLowEnergyDescriptorData &b)
+ {
+ return equals(a, b);
+ }
+
+ friend bool operator!=(const QLowEnergyDescriptorData &a, const QLowEnergyDescriptorData &b)
+ {
+ return !equals(a, b);
+ }
QByteArray value() const;
void setValue(const QByteArray &value);
@@ -83,17 +90,10 @@ public:
void swap(QLowEnergyDescriptorData &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
private:
+ static bool equals(const QLowEnergyDescriptorData &a, const QLowEnergyDescriptorData &b);
QSharedDataPointer<QLowEnergyDescriptorDataPrivate> d;
};
-Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyDescriptorData &d1,
- const QLowEnergyDescriptorData &d2);
-
-inline bool operator!=(const QLowEnergyDescriptorData &d1, const QLowEnergyDescriptorData &d2)
-{
- return !(d1 == d2);
-}
-
Q_DECLARE_SHARED(QLowEnergyDescriptorData)
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyservicedata.cpp b/src/bluetooth/qlowenergyservicedata.cpp
index c536da14..6bc9bf51 100644
--- a/src/bluetooth/qlowenergyservicedata.cpp
+++ b/src/bluetooth/qlowenergyservicedata.cpp
@@ -198,21 +198,33 @@ bool QLowEnergyServiceData::isValid() const
*/
/*!
- Returns \c true if \a sd1 and \a sd2 are equal with respect to their public state,
+ \fn bool QLowEnergyServiceData::operator==(const QLowEnergyServiceData &a,
+ const QLowEnergyServiceData &b)
+
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
otherwise returns \c false.
*/
-bool operator==(const QLowEnergyServiceData &sd1, const QLowEnergyServiceData &sd2)
-{
- return sd1.d == sd2.d || (sd1.type() == sd2.type() && sd1.uuid() == sd2.uuid()
- && sd1.includedServices() == sd2.includedServices()
- && sd1.characteristics() == sd2.characteristics());
-}
/*!
- \fn bool operator!=(const QLowEnergyServiceData &sd1,
- const QLowEnergyServiceData &sd2)
- Returns \c true if \a sd1 and \a sd2 are not equal with respect to their public state,
- otherwise returns \c false.
+ \fn bool QLowEnergyServiceData::operator!=(const QLowEnergyServiceData &a,
+ const QLowEnergyServiceData &b)
+
+ \brief Returns \c true if \a a and \a b are unequal with respect to their public state,
+ otherwise returns \c false.
*/
+/*!
+ \brief Returns \c true if \a a and \a b are equal with respect to their public state,
+ otherwise returns \c false.
+ \internal
+ */
+bool QLowEnergyServiceData::equals(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)
+{
+ return a.d == b.d || (
+ a.type() == b.type()
+ && a.uuid() == b.uuid()
+ && a.includedServices() == b.includedServices()
+ && a.characteristics() == b.characteristics());
+}
+
QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyservicedata.h b/src/bluetooth/qlowenergyservicedata.h
index 4d553267..2586900d 100644
--- a/src/bluetooth/qlowenergyservicedata.h
+++ b/src/bluetooth/qlowenergyservicedata.h
@@ -52,14 +52,20 @@ struct QLowEnergyServiceDataPrivate;
class Q_BLUETOOTH_EXPORT QLowEnergyServiceData
{
- friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData &sd1,
- const QLowEnergyServiceData &sd2);
public:
QLowEnergyServiceData();
QLowEnergyServiceData(const QLowEnergyServiceData &other);
~QLowEnergyServiceData();
QLowEnergyServiceData &operator=(const QLowEnergyServiceData &other);
+ friend bool operator==(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)
+ {
+ return equals(a, b);
+ }
+ friend bool operator!=(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)
+ {
+ return !equals(a, b);
+ }
enum ServiceType { ServiceTypePrimary = 0x2800, ServiceTypeSecondary = 0x2801 };
ServiceType type() const;
@@ -81,16 +87,10 @@ public:
void swap(QLowEnergyServiceData &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
private:
+ static bool equals(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b);
QSharedDataPointer<QLowEnergyServiceDataPrivate> d;
};
-Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData &sd1,
- const QLowEnergyServiceData &sd2);
-inline bool operator!=(const QLowEnergyServiceData &sd1, const QLowEnergyServiceData &sd2)
-{
- return !(sd1 == sd2);
-}
-
Q_DECLARE_SHARED(QLowEnergyServiceData)
QT_END_NAMESPACE