summaryrefslogtreecommitdiff
path: root/src/bluetooth/qbluetoothuuid_darwin.mm
blob: 056a26668181f0c5601d8c4fb2f68ac043d68ce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "darwin/btutility_p.h"

#include "qbluetoothuuid.h"

QT_BEGIN_NAMESPACE

/*!
    \brief Constructs a new QBluetoothUuid, containing a copy of the \a cbUuid CBUUID.

    \note this function is only available on Apple platforms.

    \since 6.6
    \ingroup platform-type-conversions
*/
QBluetoothUuid QBluetoothUuid::fromCBUUID(CBUUID *cbUuid)
{
    if (!cbUuid)
        return {};

    return DarwinBluetooth::qt_uuid(cbUuid);
}

/*!
    \brief Creates a CBUUID from a QBluetoothUuid.

    The resulting CBUUID is autoreleased.

    \note this function is only available on Apple platforms.

    \since 6.6
    \ingroup platform-type-conversions
*/

CBUUID *QBluetoothUuid::toCBUUID() const
{
    const auto cbUuidGuard = DarwinBluetooth::cb_uuid(*this);
    // cb_uuid returns a strong reference (RAII object). Let
    // it do its job and release, but we return auto-released
    // CBUUID, as documented.
    return [[cbUuidGuard.data() retain] autorelease];
}

QT_END_NAMESPACE