summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-14 21:51:24 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-18 13:36:34 +0000
commita336f293eeb62f4ae839870317f2b44cea40ca38 (patch)
tree91feb738d5e9211f1276bfa304a651db4a235fb8
parent246dfef3efc6fc931c73743f9569e89cb599f558 (diff)
QBluetoothUuid: magic_numbers -= 50
Prevent code readers from having to compare the long lists of magic numbers in the various bluetooth-specific UUID constructors; they're all the same as the ones used in the quint32 ctor, so use C++11 ctor delegation to make all ctors call the quint32 one. This calls into question the need of the quint16 ctor, seeing as the quint32 ctor could just do the former's job with an implicit conversion. But removing it would allow users to pass any integral type to the QBluetoothUuid ctor, which is not the case atm, because the two integral ctors make each other ambiguous unless the arguments match either parameter types exactly. So leave it in. Change-Id: I40ddc47149cbb0526ad6488f32cc7f203e70a6b3 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 08a0f404f60e5c02dfb3cf7b224feae7e93359b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/bluetooth/qbluetoothuuid.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h
index b0a7dcc2..c19928ce 100644
--- a/src/bluetooth/qbluetoothuuid.h
+++ b/src/bluetooth/qbluetoothuuid.h
@@ -339,15 +339,15 @@ public:
// values below are based on Bluetooth BASE_UUID
constexpr QBluetoothUuid(ProtocolUuid uuid) noexcept
- : QUuid(static_cast<uint>(uuid), 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ : QBluetoothUuid(static_cast<quint32>(uuid)) {};
constexpr QBluetoothUuid(ServiceClassUuid uuid) noexcept
- : QUuid(static_cast<uint>(uuid), 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ : QBluetoothUuid(static_cast<quint32>(uuid)) {};
constexpr QBluetoothUuid(CharacteristicType uuid) noexcept
- : QUuid(static_cast<uint>(uuid), 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ : QBluetoothUuid(static_cast<quint32>(uuid)) {};
constexpr QBluetoothUuid(DescriptorType uuid) noexcept
- : QUuid(static_cast<uint>(uuid), 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ : QBluetoothUuid(static_cast<quint32>(uuid)) {};
explicit constexpr QBluetoothUuid(quint16 uuid) noexcept
- : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ : QBluetoothUuid(quint32{uuid}) {};
explicit constexpr QBluetoothUuid(quint32 uuid) noexcept
: QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
// end of bluetooth-specific constructors; rest is essentially `using QUuid::QUuid;`