Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qbluetoothaddress.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qbluetoothaddress.h"
5
6#ifndef QT_NO_DEBUG_STREAM
7#include <QDebug>
8#endif
9
11
12static_assert(QT6_ONLY(!)std::is_trivially_copyable_v<QBluetoothAddress>,
13 "Must stay this way until Qt 7 because of BC reasons.");
14
16
28{
29 qRegisterMetaType<QBluetoothAddress>();
30}
32
33
51QBluetoothAddress::QBluetoothAddress(const QString &address)
52{
54
55 if (a.size() == 17)
56 a.remove(QLatin1Char(':'));
57
58 if (a.size() == 12) {
59 bool ok;
60 m_address = a.toULongLong(&ok, 16);
61 if (!ok)
62 clear();
63 } else {
64 m_address = 0;
65 }
66}
67
97QString QBluetoothAddress::toString() const
98{
99 QString s(QStringLiteral("%1:%2:%3:%4:%5:%6"));
100
101 for (int i = 5; i >= 0; --i) {
102 const quint8 a = (m_address >> (i*8)) & 0xff;
103 s = s.arg(a, 2, 16, QLatin1Char('0'));
104 }
105
106 return s.toUpper();
107}
108
130#ifndef QT_NO_DEBUG_STREAM
131QDebug QBluetoothAddress::streamingOperator(QDebug debug, const QBluetoothAddress &address)
132{
133 debug << address.toString();
134 return debug;
135}
136#endif
137
\inmodule QtBluetooth
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
#define this
Definition dialogs.cpp:9
b clear()
Combined button and popup list for selecting options.
void registerQBluetoothAddress()
Q_CONSTRUCTOR_FUNCTION(initializeStandardUserDefaults)
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1369
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLuint64EXT address
GLdouble s
[6]
Definition qopenglext.h:235
QT_BEGIN_NAMESPACE class QT6_ONLY(Q_CORE_EXPORT) QReadWriteLock
#define QStringLiteral(str)
unsigned char quint8
Definition qtypes.h:41
\inmodule QtCore \reentrant
Definition qchar.h:17