Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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:129
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned long long} using base base, which is 10 by default and m...
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition qstring.cpp:3466
#define this
Definition dialogs.cpp:9
b clear()
Combined button and popup list for selecting options.
Definition qcompare.h:63
void registerQBluetoothAddress()
class QT6_ONLY(Q_CORE_EXPORT) QChar
Definition qchar.h:44
Q_CONSTRUCTOR_FUNCTION(qt_apple_check_os_version)
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1390
GLboolean GLboolean GLboolean GLboolean a
[7]
GLdouble s
[6]
Definition qopenglext.h:235
GLuint GLuint64EXT address
#define QStringLiteral(str)
unsigned char quint8
Definition qtypes.h:46
\inmodule QtCore \reentrant
Definition qchar.h:18