blob: 8deff51dc7f35b0e7ca9ae085541ecc08a04bdea (
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
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <QString>
#include <CoreFoundation/CoreFoundation.h>
namespace Ios {
template<typename CFType>
struct CFRefDeleter
{
using pointer = CFType;
void operator()(CFType ref) { CFRelease(ref); }
};
inline QString toQStringRelease(CFStringRef str)
{
QString result = QString::fromCFString(str);
CFRelease(str);
return result;
}
using CFString_t = std::unique_ptr<CFStringRef, CFRefDeleter<CFStringRef>>;
using CFUrl_t = std::unique_ptr<CFURLRef, CFRefDeleter<CFURLRef>>;
using CFPropertyList_t = std::unique_ptr<CFPropertyListRef, CFRefDeleter<CFPropertyListRef>>;
using CFBundle_t = std::unique_ptr<CFBundleRef, CFRefDeleter<CFBundleRef>>;
using CFDictionary_t = std::unique_ptr<CFDictionaryRef, CFRefDeleter<CFDictionaryRef>>;
using CFArray_t = std::unique_ptr<CFArrayRef, CFRefDeleter<CFArrayRef>>;
} // namespace Ios
|