summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qwinregistry_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qwinregistry_p.h')
-rw-r--r--src/corelib/kernel/qwinregistry_p.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/corelib/kernel/qwinregistry_p.h b/src/corelib/kernel/qwinregistry_p.h
index 0dfa6c70fb..20b2d10dd7 100644
--- a/src/corelib/kernel/qwinregistry_p.h
+++ b/src/corelib/kernel/qwinregistry_p.h
@@ -19,34 +19,49 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringview.h>
#include <QtCore/qt_windows.h>
-#include <QtCore/private/qglobal_p.h>
+#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QWinRegistryKey
{
-public:
Q_DISABLE_COPY(QWinRegistryKey)
+public:
QWinRegistryKey();
explicit QWinRegistryKey(HKEY parentHandle, QStringView subKey,
REGSAM permissions = KEY_READ, REGSAM access = 0);
~QWinRegistryKey();
QWinRegistryKey(QWinRegistryKey &&other) noexcept
- : m_key(qExchange(other.m_key, nullptr)) {}
+ : m_key(std::exchange(other.m_key, nullptr)) {}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWinRegistryKey)
void swap(QWinRegistryKey &other) noexcept { qSwap(m_key, other.m_key); }
- bool isValid() const { return m_key != nullptr; }
- operator HKEY() const { return m_key; }
+ [[nodiscard]] bool isValid() const { return m_key != nullptr; }
+
+ [[nodiscard]] HKEY handle() const { return m_key; }
+
+ operator HKEY() const { return handle(); }
+
void close();
+ [[nodiscard]] QVariant value(QStringView subKey) const;
+ template<typename T>
+ [[nodiscard]] std::optional<T> value(QStringView subKey) const
+ {
+ const QVariant var = value(subKey);
+ if (var.isValid())
+ return qvariant_cast<T>(var);
+ return std::nullopt;
+ }
+
+ // ### TODO: Remove once all usages are migrated to new interface.
QString stringValue(QStringView subKey) const;
- QPair<DWORD, bool> dwordValue(QStringView subKey) const;
+ std::pair<DWORD, bool> dwordValue(QStringView subKey) const;
private:
- HKEY m_key;
+ HKEY m_key = nullptr;
};
QT_END_NAMESPACE