diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-07-06 22:09:05 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-07-09 21:57:59 +0000 |
commit | 503f00eeccb29ec7924db1942d7a211e83ef6754 (patch) | |
tree | 2bf6a35cede32cb5e7daf79659f519392d6b8f85 | |
parent | 734638bcf7d256ee1d4b384fdbd584c6aff37bc9 (diff) |
QBluetoothAddress: inline most functions
This class is supposed to be a _thin_ wrapper around a quint64. It's
not extensible anymore, anyway, because inline functions (e.g. the
relational operators) access m_address, so we might was well inline
all the trivial functions.
Do that. Since the class is exported, we need to us QT_INLINE_SINCE.
As a drive-by, make all newly-inline functions noexcept.
Drop the documentation of the copy SMFs and the destructor. They're
trivial, we're not documenting the SMFs of e.g. QUuid, either.
Change-Id: I7d5207cb24ea637d5b6eefe0ab8ce54a4b123305
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7f248fed3d19ca73580d02f5b4ae3d009b90fadf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/bluetooth/qbluetoothaddress.cpp | 43 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothaddress.h | 37 | ||||
-rw-r--r-- | src/bluetooth/removed_api.cpp | 2 |
3 files changed, 40 insertions, 42 deletions
diff --git a/src/bluetooth/qbluetoothaddress.cpp b/src/bluetooth/qbluetoothaddress.cpp index af85afa7..915b107c 100644 --- a/src/bluetooth/qbluetoothaddress.cpp +++ b/src/bluetooth/qbluetoothaddress.cpp @@ -63,31 +63,6 @@ QBluetoothAddress::QBluetoothAddress(const QString &address) } /*! - Constructs a new Bluetooth address which is a copy of \a other. -*/ -QBluetoothAddress::QBluetoothAddress(const QBluetoothAddress &other) -{ - *this = other; -} - -/*! - Destroys the QBluetoothAddress. -*/ -QBluetoothAddress::~QBluetoothAddress() -{ -} - -/*! - Assigns \a other to this Bluetooth address. -*/ -QBluetoothAddress &QBluetoothAddress::operator=(const QBluetoothAddress &other) -{ - m_address = other.m_address; - - return *this; -} - -/*! \fn QBluetoothAddress::qHash(QBluetoothAddress key, size_t seed) \since 6.6 @@ -96,28 +71,22 @@ QBluetoothAddress &QBluetoothAddress::operator=(const QBluetoothAddress &other) */ /*! + \fn void QBluetoothAddress::clear() + Sets the Bluetooth address to 00:00:00:00:00:00. */ -void QBluetoothAddress::clear() -{ - m_address = 0; -} /*! + \fn bool QBluetoothAddress::isNull() const + Returns true if the Bluetooth address is null, otherwise returns false. */ -bool QBluetoothAddress::isNull() const -{ - return m_address == 0; -} /*! + \fn quint64 QBluetoothAddress::toUInt64() const + Returns this Bluetooth address as a quint64. */ -quint64 QBluetoothAddress::toUInt64() const -{ - return m_address; -} /*! Returns the Bluetooth address as a string of the form, XX:XX:XX:XX:XX:XX. diff --git a/src/bluetooth/qbluetoothaddress.h b/src/bluetooth/qbluetoothaddress.h index 5a9f5793..5b14f224 100644 --- a/src/bluetooth/qbluetoothaddress.h +++ b/src/bluetooth/qbluetoothaddress.h @@ -20,14 +20,19 @@ public: constexpr QBluetoothAddress() noexcept {}; constexpr explicit QBluetoothAddress(quint64 address) noexcept : m_address(address) {}; explicit QBluetoothAddress(const QString &address); - QBluetoothAddress(const QBluetoothAddress &other); + QT_BLUETOOTH_INLINE_SINCE(6, 6) + QBluetoothAddress(const QBluetoothAddress &other) noexcept; + QT_BLUETOOTH_INLINE_SINCE(6, 6) ~QBluetoothAddress(); - QBluetoothAddress &operator=(const QBluetoothAddress &other); + QT_BLUETOOTH_INLINE_SINCE(6, 6) + QBluetoothAddress &operator=(const QBluetoothAddress &other) noexcept; - bool isNull() const; + QT_BLUETOOTH_INLINE_SINCE(6, 6) + bool isNull() const noexcept; - void clear(); + QT_BLUETOOTH_INLINE_SINCE(6, 6) + void clear() noexcept; friend bool operator<(const QBluetoothAddress &a, const QBluetoothAddress &b) { @@ -42,7 +47,8 @@ public: return a.m_address != b.m_address; } - quint64 toUInt64() const; + QT_BLUETOOTH_INLINE_SINCE(6, 6) + quint64 toUInt64() const noexcept; QString toString() const; private: @@ -58,6 +64,27 @@ private: #endif }; +#if QT_BLUETOOTH_INLINE_IMPL_SINCE(6, 6) +QBluetoothAddress::QBluetoothAddress(const QBluetoothAddress &) noexcept = default; +QBluetoothAddress &QBluetoothAddress::operator=(const QBluetoothAddress &) noexcept = default; +QBluetoothAddress::~QBluetoothAddress() = default; + +void QBluetoothAddress::clear() noexcept +{ + m_address = 0; +} + +bool QBluetoothAddress::isNull() const noexcept +{ + return m_address == 0; +} + +quint64 QBluetoothAddress::toUInt64() const noexcept +{ + return m_address; +} +#endif // QT_BLUETOOTH_INLINE_IMPL_SINCE(6, 6) + QT_END_NAMESPACE QT_DECL_METATYPE_EXTERN(QBluetoothAddress, Q_BLUETOOTH_EXPORT) diff --git a/src/bluetooth/removed_api.cpp b/src/bluetooth/removed_api.cpp index 96aa8ef1..a1676c7d 100644 --- a/src/bluetooth/removed_api.cpp +++ b/src/bluetooth/removed_api.cpp @@ -16,6 +16,8 @@ QT_USE_NAMESPACE #if QT_BLUETOOTH_REMOVED_SINCE(6, 6) +#include "qbluetoothaddress.h" // inlined API + #include "qbluetoothuuid.h" static_assert(std::is_aggregate_v<quint128>); |