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
4#ifndef QUNIQUEHANDLE_TYPES_P_H
5#define QUNIQUEHANDLE_TYPES_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 <QtCore/qnamespace.h>
19#include <QtCore/private/quniquehandle_p.h>
20
21#include <cstdio>
22
23QT_BEGIN_NAMESPACE
24
25namespace QtUniqueHandleTraits {
26
27#ifdef Q_OS_WIN
28
30{
31 using Type = Qt::HANDLE;
32 static Type invalidValue() noexcept
33 {
34 return Qt::HANDLE(-1); // AKA INVALID_HANDLE_VALUE
35 }
36 Q_CORE_EXPORT static bool close(Type handle) noexcept;
37};
38
40{
41 using Type = Qt::HANDLE;
42 static Type invalidValue() noexcept { return nullptr; }
43 Q_CORE_EXPORT static bool close(Type handle) noexcept;
44};
45
46#endif
47
49{
50 using Type = int;
51 static constexpr Type invalidValue() noexcept { return -1; }
52 Q_CORE_EXPORT static bool close(Type handle);
53};
54
56{
57 using Type = FILE *;
58 static constexpr Type invalidValue() noexcept { return nullptr; }
59 Q_CORE_EXPORT static bool close(Type handle);
60};
61
62} // namespace QtUniqueHandleTraits
63
64#ifdef Q_OS_WIN
65
66using QUniqueWin32Handle = QUniqueHandle<QtUniqueHandleTraits::InvalidHandleTraits>;
67using QUniqueWin32NullHandle = QUniqueHandle<QtUniqueHandleTraits::NullHandleTraits>;
68
69#endif
70
71#ifdef Q_OS_UNIX
72
73using QUniqueFileDescriptorHandle = QUniqueHandle<QtUniqueHandleTraits::FileDescriptorHandleTraits>;
74
75#endif
76
77using QUniqueFILEHandle = QUniqueHandle<QtUniqueHandleTraits::FILEHandleTraits>;
78
79QT_END_NAMESPACE
80
81#endif
static Q_CORE_EXPORT bool close(Type handle)
static constexpr Type invalidValue() noexcept
static Q_CORE_EXPORT bool close(Type handle)