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
quniquehandle_types_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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// Qt-Security score:significant reason:default
4
5#ifndef QUNIQUEHANDLE_TYPES_P_H
6#define QUNIQUEHANDLE_TYPES_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qnamespace.h>
20#include <QtCore/private/quniquehandle_p.h>
21
22#include <cstdio>
23
24QT_BEGIN_NAMESPACE
25
26namespace QtUniqueHandleTraits {
27
28#ifdef Q_OS_WIN
29
31{
32 using Type = Qt::HANDLE;
33 static Type invalidValue() noexcept
34 {
35 return Qt::HANDLE(-1); // AKA INVALID_HANDLE_VALUE
36 }
37 Q_CORE_EXPORT static bool close(Type handle) noexcept;
38};
39
41{
42 using Type = Qt::HANDLE;
43 static Type invalidValue() noexcept { return nullptr; }
44 Q_CORE_EXPORT static bool close(Type handle) noexcept;
45};
46
47#endif
48
50{
51 using Type = int;
52 static constexpr Type invalidValue() noexcept { return -1; }
53 Q_CORE_EXPORT static bool close(Type handle);
54};
55
57{
58 using Type = FILE *;
59 static constexpr Type invalidValue() noexcept { return nullptr; }
60 Q_CORE_EXPORT static bool close(Type handle);
61};
62
63} // namespace QtUniqueHandleTraits
64
65#ifdef Q_OS_WIN
66
67using QUniqueWin32Handle = QUniqueHandle<QtUniqueHandleTraits::InvalidHandleTraits>;
68using QUniqueWin32NullHandle = QUniqueHandle<QtUniqueHandleTraits::NullHandleTraits>;
69
70#endif
71
72#ifdef Q_OS_UNIX
73
74using QUniqueFileDescriptorHandle = QUniqueHandle<QtUniqueHandleTraits::FileDescriptorHandleTraits>;
75
76#endif
77
78using QUniqueFILEHandle = QUniqueHandle<QtUniqueHandleTraits::FILEHandleTraits>;
79
80QT_END_NAMESPACE
81
82#endif
static Q_CORE_EXPORT bool close(Type handle)
static constexpr Type invalidValue() noexcept
static Q_CORE_EXPORT bool close(Type handle)