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
btutility_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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#ifndef BTUTILITY_P_H
5#define BTUTILITY_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "btraii_p.h"
19
20#include <QtCore/qloggingcategory.h>
21#include <QtCore/qglobal.h>
22
23#include <QtCore/private/qcore_mac_p.h>
24
25#include <Foundation/Foundation.h>
26
27#include <CoreBluetooth/CoreBluetooth.h>
28
29#ifdef Q_OS_MACOS
30#include <IOBluetooth/IOBluetooth.h>
31#endif // Q_OS_MACOS
32
34
37class QBluetoothUuid;
38class QString;
39
40namespace DarwinBluetooth {
41
42template<class T>
44{
45public:
46 ObjCScopedPointer() = default;
48 : m_ptr(ptr, policy)
49 {
50 }
52 {
53 m_ptr.swap(other.m_ptr);
54 }
55 void reset()
56 {
57 m_ptr.reset();
58 }
60 {
61 m_ptr.reset(ptr, policy);
62 }
63 operator T*() const
64 {
65 return m_ptr.getAs<T>();
66 }
67 T *get() const
68 {
69 // operator T * above does not work when accessing
70 // properties using '.' syntax.
71 return m_ptr.getAs<T>();
72 }
73private:
74 // Copy and move disabled by m_ptr:
75 ScopedPointer m_ptr;
76};
77
78#define QT_BT_MAC_AUTORELEASEPOOL const QMacAutoReleasePool pool;
79
80template<class T>
82public:
84
85 operator T *() const
86 {
87 return this->getAs<T>();
88 }
89
90 T *data() const
91 {
92 return this->getAs<T>();
93 }
94};
95
96QString qt_address(NSString *address);
97
98#ifndef QT_IOS_BLUETOOTH
99
100QBluetoothAddress qt_address(const BluetoothDeviceAddress *address);
101BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &address);
102
103ObjCStrongReference<IOBluetoothSDPUUID> iobluetooth_uuid(const QBluetoothUuid &uuid);
104QBluetoothUuid qt_uuid(IOBluetoothSDPUUID *uuid);
105QString qt_error_string(IOReturn errorCode);
107
108#endif // !QT_IOS_BLUETOOTH
109
110QBluetoothUuid qt_uuid(CBUUID *uuid);
111ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid);
112bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid);
113bool equal_uuids(CBUUID *cbUuid, const QBluetoothUuid &qtUuid);
115QByteArray qt_bytearray(NSObject *data);
116
117ObjCStrongReference<NSData> data_from_bytearray(const QByteArray &qtData);
118ObjCStrongReference<NSMutableData> mutable_data_from_bytearray(const QByteArray &qtData);
119
120dispatch_queue_t qt_LE_queue();
121
122extern const int defaultLEScanTimeoutMS;
123extern const int maxValueLength;
124extern const int defaultMtu;
125
126} // namespace DarwinBluetooth
127
128Q_DECLARE_LOGGING_CATEGORY(QT_BT_DARWIN)
129
131
132#endif // BTUTILITY_P_H
ObjCScopedPointer(T *ptr, RetainPolicy policy)
Definition btutility_p.h:47
void reset(T *ptr, RetainPolicy policy)
Definition btutility_p.h:59
void swap(ObjCScopedPointer &other)
Definition btutility_p.h:51
ObjCType * getAs() const
Definition btraii_p.h:67
void swap(StrongReference &other) noexcept
Definition btraii_p.h:56
\inmodule QtBluetooth
\inmodule QtBluetooth
\inmodule QtCore
Definition qbytearray.h:57
The QLowEnergyCharacteristicData class is used to set up GATT service data. \inmodule QtBluetooth.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
ObjCStrongReference< CBUUID > cb_uuid(const QBluetoothUuid &qtUuid)
Definition btutility.mm:174
const int defaultLEScanTimeoutMS
Definition btutility.mm:30
bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid)
Definition btutility.mm:190
ObjCStrongReference< NSMutableData > mutable_data_from_bytearray(const QByteArray &qtData)
Definition btutility.mm:281
BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &qAddress)
Definition btutility.mm:65
QByteArray qt_bytearray(NSData *data)
Definition btutility.mm:201
QBluetoothUuid qt_uuid(NSUUID *nsUuid)
QString qt_address(NSString *address)
Definition btutility.mm:36
void qt_test_iobluetooth_runloop()
Definition btutility.mm:125
QString qt_error_string(IOReturn errorCode)
Definition btutility.mm:104
const int maxValueLength
Definition btutility.mm:32
ObjCStrongReference< NSData > data_from_bytearray(const QByteArray &qtData)
Definition btutility.mm:272
ObjCStrongReference< IOBluetoothSDPUUID > iobluetooth_uuid(const QBluetoothUuid &uuid)
Definition btutility.mm:81
dispatch_queue_t qt_LE_queue()
Definition btutility.mm:324
const int defaultMtu
Definition btutility.mm:34
Combined button and popup list for selecting options.
#define Q_DECLARE_LOGGING_CATEGORY(name)
static ControlElement< T > * ptr(QWidget *widget)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLuint64EXT address
QSharedPointer< T > other(t)
[5]
QSizePolicy policy