Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qapple_utils_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists purely as an
9// implementation detail. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QAPPLE_UTILS_P_H
16#define QAPPLE_UTILS_P_H
17
18#include <QtCore/qdebug.h>
19#include <QtCore/qendian.h>
20#include <QtCore/qglobal.h>
21#include <QtCore/private/qcore_mac_p.h>
22
23#include <QtMultimedia/private/qiteratorfacade_p.h>
24
25#ifdef Q_OS_MACOS
26# include <CoreAudioTypes/CoreAudioTypes.h>
27#endif
28
29#include <CoreFoundation/CFArray.h>
30
31QT_BEGIN_NAMESPACE
32
33namespace QtMultimediaPrivate {
34
36{
38 explicit QOSStatus(OSStatus s) : status(s) {}
39
40 friend QDebug operator<<(QDebug dbg, const QOSStatus &qos)
41 {
42 QDebugStateSaver saver(dbg);
43 dbg.noquote();
44
45 if (qos.status == noErr) {
46 dbg << "noErr";
47 return dbg;
48 }
49
50 std::array<char, 4> buf;
51 qToBigEndian(qos.status, buf.data());
52
53 bool isPrintable = std::all_of(buf.begin(), buf.end(), [](unsigned char c) {
54 return std::isprint(c);
55 });
56
57 if (isPrintable)
58 return dbg << QLatin1String(buf.data(), buf.size());
59 else
60 return dbg << qos.status;
61 }
62};
63
64template <typename T>
67{
68public:
69 static_assert(std::is_pointer_v<T>, "CFArrayIterator must be instantiated with a pointer type");
70
72
73 CFArrayIterator() = default;
74 CFArrayIterator(QCFType<CFArrayRef> array, CFIndex index)
75 : m_array(std::move(array)), m_index(index)
76 {
77 }
78
79 T dereference() const { return static_cast<T>(CFArrayGetValueAtIndex(m_array, m_index)); }
80
82
87
88private:
91};
92
93template <typename T = CFTypeRef>
95{
96public:
97 static_assert(std::is_pointer_v<T>, "CFArrayRange must be instantiated with a pointer type");
98
100
101 CFArrayRange() = default;
102 explicit CFArrayRange(QCFType<CFArrayRef> array) : m_array(std::move(array)) {}
103
104 iterator begin() const { return iterator(m_array, 0); }
106
107 bool empty() const { return m_array == nullptr || CFArrayGetCount(m_array) == 0; }
108
109 std::size_t size() const
110 {
111 return m_array ? static_cast<std::size_t>(CFArrayGetCount(m_array)) : 0;
112 }
113
114private:
116};
117
118} // namespace QtMultimediaPrivate
119
120QT_END_NAMESPACE
121
122#endif // QAPPLE_UTILS_P_H
friend QDebug operator<<(QDebug dbg, const QOSStatus &qos)