Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwinregistry_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 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 QWINREGISTRY_H
5#define QWINREGISTRY_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/qpair.h>
19#include <QtCore/qstring.h>
20#include <QtCore/qstringview.h>
21#include <QtCore/qt_windows.h>
22#include <QtCore/qvariant.h>
23
25
26class Q_CORE_EXPORT QWinRegistryKey
27{
28 Q_DISABLE_COPY(QWinRegistryKey)
29
30public:
32 explicit QWinRegistryKey(HKEY parentHandle, QStringView subKey,
33 REGSAM permissions = KEY_READ, REGSAM access = 0);
35
37 : m_key(std::exchange(other.m_key, nullptr)) {}
38 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWinRegistryKey)
39 void swap(QWinRegistryKey &other) noexcept { qSwap(m_key, other.m_key); }
40
41 [[nodiscard]] bool isValid() const { return m_key != nullptr; }
42
43 [[nodiscard]] HKEY handle() const { return m_key; }
44
45 operator HKEY() const { return handle(); }
46
47 void close();
48
49 [[nodiscard]] QVariant value(QStringView subKey) const;
50 template<typename T>
51 [[nodiscard]] std::optional<T> value(QStringView subKey) const
52 {
53 const QVariant var = value(subKey);
54 if (var.isValid())
55 return qvariant_cast<T>(var);
56 return std::nullopt;
57 }
58
59 // ### TODO: Remove once all usages are migrated to new interface.
60 QString stringValue(QStringView subKey) const;
61 std::pair<DWORD, bool> dwordValue(QStringView subKey) const;
62
63private:
64 HKEY m_key = nullptr;
65};
66
68
69#endif // QWINREGISTRY_H
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
std::optional< T > value(QStringView subKey) const
QWinRegistryKey(QWinRegistryKey &&other) noexcept
HKEY handle() const
bool isValid() const
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint64 GLenum void * handle
GLenum access
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
Definition qswap.h:20
QSharedPointer< T > other(t)
[5]
this swap(other)