summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsettings.h
blob: 5d0356e8906400e3a6e4e99bdedfc7a5aade52f8 (plain)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
// Copyright (C) 2020 The Qt Company Ltd.// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only#ifndef QSETTINGS_H#define QSETTINGS_H#include <QtCore/qobject.h>#include <QtCore/qvariant.h>#include <QtCore/qstring.h>#include <QtCore/qscopedpointer.h>QT_REQUIRE_CONFIG(settings);#include <ctype.h> QT_BEGIN_NAMESPACE #ifdef Status// we seem to pick up a macro Status --> int somewhere#undef Status#endifclass QIODevice;class QSettingsPrivate;#ifndef QT_NO_QOBJECTclass Q_CORE_EXPORT QSettings :public QObject #elseclass Q_CORE_EXPORT QSettings #endif{#ifndef QT_NO_QOBJECT Q_OBJECT #elsestd::unique_ptr<QSettingsPrivate> d_ptr;#endifQ_DECLARE_PRIVATE(QSettings)public:enum Status { NoError =0, AccessError, FormatError };#ifndef QT_NO_QOBJECTQ_ENUM(Status)#endifenum Format { NativeFormat =0, IniFormat =1,#if defined(Q_OS_WIN) || defined(Q_QDOC) Registry32Format =2, Registry64Format =3,#endif#if defined(Q_OS_WASM) || defined(Q_QDOC) WebLocalStorageFormat =4, WebIndexedDBFormat =5,#endif InvalidFormat =16, CustomFormat1, CustomFormat2, CustomFormat3, CustomFormat4, CustomFormat5, CustomFormat6, CustomFormat7, CustomFormat8, CustomFormat9, CustomFormat10, CustomFormat11, CustomFormat12, CustomFormat13, CustomFormat14, CustomFormat15, CustomFormat16 };#ifndef QT_NO_QOBJECTQ_ENUM(Format)#endifenum Scope { UserScope, SystemScope };#ifndef QT_NO_QOBJECTQ_ENUM(Scope)#endif#ifndef QT_NO_QOBJECTexplicitQSettings(const QString &organization,const QString &application =QString(), QObject *parent =nullptr);QSettings(Scope scope,const QString &organization,const QString &application =QString(), QObject *parent =nullptr);QSettings(Format format, Scope scope,const QString &organization,const QString &application =QString(), QObject *parent =nullptr);QSettings(const QString &fileName, Format format, QObject *parent =nullptr);explicitQSettings(QObject *parent =nullptr);explicitQSettings(Scope scope, QObject *parent =nullptr);#elseexplicitQSettings(const QString &organization,const QString &application =QString());QSettings(Scope scope,const QString &organization,const QString &application =QString());QSettings(Format format, Scope scope,const QString &organization,const QString &application =QString());QSettings(const QString &fileName, Format format);explicitQSettings(Scope scope = UserScope);#endif~QSettings();voidclear();voidsync(); Status status()const;boolisAtomicSyncRequired()const;voidsetAtomicSyncRequired(bool enable);#if QT_CORE_REMOVED_SINCE(6, 4)voidbeginGroup(const QString &prefix);#endifvoidbeginGroup(QAnyStringView prefix);voidendGroup(); QString group()const;#if QT_CORE_REMOVED_SINCE(6, 4)intbeginReadArray(const QString &prefix);voidbeginWriteArray(const QString &prefix,int size = -1);#endifintbeginReadArray(QAnyStringView prefix);voidbeginWriteArray(QAnyStringView prefix,int size = -1);voidendArray();voidsetArrayIndex(int i); QStringList allKeys()const; QStringList childKeys()const; QStringList childGroups()const;boolisWritable()const;#if QT_CORE_REMOVED_SINCE(6, 4)voidsetValue(const QString &key,const QVariant &value); QVariant value(const QString &key,const QVariant &defaultValue)const; QVariant value(const QString &key)const;#endifvoidsetValue(QAnyStringView key,const QVariant &value); QVariant value(QAnyStringView key,const QVariant &defaultValue)const; QVariant value(QAnyStringView key)const;#if QT_CORE_REMOVED_SINCE(6, 4)voidremove(const QString &key);boolcontains(const QString &key)const;#endifvoidremove(QAnyStringView key);boolcontains(QAnyStringView key)const;voidsetFallbacksEnabled(bool b);boolfallbacksEnabled()const; QString fileName()const; Format format()const; Scope scope()const; QString organizationName()const; QString applicationName()const;static voidsetDefaultFormat(Format format);static Format defaultFormat();static voidsetPath(Format format, Scope scope,const QString &path);typedef QMap<QString, QVariant> SettingsMap;typedefbool(*ReadFunc)(QIODevice &device, SettingsMap &map);typedefbool(*WriteFunc)(QIODevice &device,const SettingsMap &map);static Format registerFormat(const QString &extension, ReadFunc readFunc, WriteFunc writeFunc,Qt::CaseSensitivity caseSensitivity =Qt::CaseSensitive);protected:#ifndef QT_NO_QOBJECTboolevent(QEvent *event) override;#endifprivate:Q_DISABLE_COPY(QSettings)}; QT_END_NAMESPACE #endif// QSETTINGS_H
close