5#include "qplatformdefs.h"
14#include "private/qlocking_p.h"
15#include "private/qtools_p.h"
20#include "private/qstringconverter_p.h"
22#ifndef QT_NO_GEOM_VARIANT
30#ifndef QT_BOOTSTRAPPED
47#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID)
51#if !defined(QT_NO_STANDARDPATHS) \
52 && (defined(Q_XDG_PLATFORM) || defined(QT_PLATFORM_UIKIT) || defined(Q_OS_ANDROID))
53# define QSETTINGS_USE_QSTANDARDPATHS
90 bool userDefined =
false;
108 usedHashFunc()->insert(
name,
this);
114 usedHashFunc()->remove(
name);
132#ifndef QT_NO_TEMPORARYFILE
137#ifndef QT_NO_TEMPORARYFILE
142 if (!
dir.mkpath(
dir.absolutePath()))
163 if (!(confFile = usedHash->
value(absPath))) {
164 if ((confFile = unusedCache->
take(absPath)))
165 usedHash->
insert(absPath, confFile);
171 return new QConfFile(absPath, _userPerms);
177 unusedCacheFunc()->clear();
191 :
format(
format), scope(scope), organizationName(organization), applicationName(application),
203 Q_ASSERT_X(!
n.isEmpty(),
"QSettings",
"empty key");
219 memcpy(
out,
v.data(),
v.size() *
sizeof(
QChar));
220 return out +
v.size();
237 const bool maybeEndsInSlash =
key.visit([&
out](
auto key) {
238 using View =
decltype(
key);
241 const auto end =
key.end();
244 while (*
it == u
'/') {
250 while (*
it != u
'/') {
265 if (maybeEndsInSlash &&
out !=
result.constData())
273#if !defined(Q_OS_WIN) && !defined(Q_OS_DARWIN) && !defined(Q_OS_WASM)
281#if !defined(Q_OS_WIN)
292 if (slashPos == -1) {
298 key.truncate(slashPos);
361 for (
const auto &
s : l)
365 outStringList[
i].remove(0, 1);
368 return outStringList;
375 switch (
v.metaType().id()) {
380 case QMetaType::QByteArray: {
386#if QT_CONFIG(shortcut)
387 case QMetaType::QKeySequence:
389 case QMetaType::QString:
390 case QMetaType::LongLong:
391 case QMetaType::ULongLong:
393 case QMetaType::UInt:
394 case QMetaType::Bool:
395 case QMetaType::Float:
396 case QMetaType::Double: {
400 else if (
result.startsWith(u
'@'))
404#ifndef QT_NO_GEOM_VARIANT
405 case QMetaType::QRect: {
406 QRect r = qvariant_cast<QRect>(
v);
410 case QMetaType::QSize: {
411 QSize s = qvariant_cast<QSize>(
v);
415 case QMetaType::QPoint: {
416 QPoint p = qvariant_cast<QPoint>(
v);
423#ifndef QT_NO_DATASTREAM
425 const char *typeSpec;
426 if (
v.userType() == QMetaType::QDateTime) {
428 typeSpec =
"@DateTime(";
431 typeSpec =
"@Variant(";
436 s.setVersion(version);
444 Q_ASSERT(!
"QSettings: Cannot save custom types without QDataStream support");
456 if (
s.startsWith(u
'@')) {
457 if (
s.endsWith(u
')')) {
458 if (
s.startsWith(
"@ByteArray("_L1)) {
460 }
else if (
s.startsWith(
"@String("_L1)) {
462 }
else if (
s.startsWith(
"@Variant("_L1)
463 ||
s.startsWith(
"@DateTime("_L1)) {
464#ifndef QT_NO_DATASTREAM
467 if (
s.at(1) == u
'D') {
476 stream.setVersion(version);
481 Q_ASSERT(!
"QSettings: Cannot load custom types without QDataStream support");
483#ifndef QT_NO_GEOM_VARIANT
484 }
else if (
s.startsWith(
"@Rect("_L1)) {
488 }
else if (
s.startsWith(
"@Size("_L1)) {
492 }
else if (
s.startsWith(
"@Point("_L1)) {
497 }
else if (
s ==
"@Invalid()"_L1) {
502 if (
s.startsWith(
"@@"_L1))
519 }
else if (
ch <= 0xFF) {
526 for (
int j = 0;
j < 4; ++
j) {
541 bool lowercaseOnly =
true;
551 if (
ch !=
'%' ||
i ==
size - 1) {
554 lowercaseOnly =
false;
585 lowercaseOnly =
false;
589 return lowercaseOnly;
594 bool needsQuotes =
false;
595 bool escapeNextIfDigit =
false;
606 if (
ch ==
';' ||
ch ==
',' ||
ch ==
'=')
614 escapeNextIfDigit =
false;
619 escapeNextIfDigit =
true;
648 if (
ch <= 0x1F || (
ch >= 0x7F && !useCodec)) {
650 escapeNextIfDigit =
true;
651 }
else if (useCodec) {
661 || (startPos <
result.size() && (
result.at(startPos) ==
' '
663 result.insert(startPos,
'"');
678 if (strs.isEmpty()) {
700 static const char escapeCodes[][2] =
715 bool isStringList =
false;
716 bool inQuotedString =
false;
717 bool currentValueIsQuoted =
false;
718 char16_t escapeVal = 0;
738 for (
const auto &escapeCode : escapeCodes) {
739 if (
ch == escapeCode[0]) {
757 }
else if (
ch ==
'\n' ||
ch ==
'\r') {
761 if ((ch2 ==
'\n' || ch2 ==
'\r') && ch2 !=
ch)
767 chopLimit = stringResult.
size();
771 currentValueIsQuoted =
true;
772 inQuotedString = !inQuotedString;
777 if (!inQuotedString) {
778 if (!currentValueIsQuoted)
782 stringListResult.clear();
785 stringListResult.append(stringResult);
786 stringResult.
clear();
787 currentValueIsQuoted =
false;
796 if (
ch ==
'\\' ||
ch ==
'"' ||
ch ==
',')
806 if (!currentValueIsQuoted)
812 stringResult += escapeVal;
823 stringResult += escapeVal;
829 stringResult += escapeVal;
840 stringResult += escapeVal;
846 stringListResult.append(stringResult);
860 for (++idx; idx < l; ++idx) {
865 }
else if (
c == u
' ') {
879void QConfFileSettingsPrivate::initFormat()
884#if defined(Q_OS_DARWIN)
895 if (
i >= 0 && i < customFormatVector->
size()) {
897 extension =
info.extension;
898 readFunc =
info.readFunc;
899 writeFunc =
info.writeFunc;
900 caseSensitivity =
info.caseSensitivity;
918static QString windowsConfigPath(
const KNOWNFOLDERID &
type)
922 PWSTR
path =
nullptr;
923 if (SHGetKnownFolderPath(
type, KF_FLAG_DONT_VERIFY, NULL, &
path) == S_OK) {
929 if (
type == FOLDERID_ProgramData) {
930 result =
"C:\\temp\\qt-common"_L1;
931 }
else if (
type == FOLDERID_RoamingAppData) {
932 result =
"C:\\temp\\qt-user"_L1;
948#if !defined(QSETTINGS_USE_QSTANDARDPATHS) || defined(Q_OS_ANDROID)
964#ifndef QSETTINGS_USE_QSTANDARDPATHS
988 PathHash *pathHash = pathHashFunc();
1008 const QString roamingAppDataFolder = windowsConfigPath(FOLDERID_RoamingAppData);
1009 const QString programDataFolder = windowsConfigPath(FOLDERID_ProgramData);
1034 PathHash *pathHash = pathHashFunc();
1039 if (!
result.path.isEmpty())
1046#if defined(QT_BUILD_INTERNAL) && defined(Q_XDG_PLATFORM) && !defined(QT_NO_STANDARDPATHS)
1051 pathHashFunc()->clear();
1060 nextPosition(0x40000000)
1065 if (
org.isEmpty()) {
1067 org =
"Unknown Organization"_L1;
1081#if defined(Q_XDG_PLATFORM) && !defined(QT_NO_STANDARDPATHS)
1083 if (!systemPath.userDefined) {
1089 if (!dirs.isEmpty())
1093 paths.reserve(dirs.size() * 2);
1094 for (
const auto &
dir : std::as_const(dirs))
1095 paths.append(
dir + u
'/' + appFile);
1097 paths.reserve(dirs.size());
1099 for (
const auto &
dir : std::as_const(dirs))
1100 paths.append(
dir + u
'/' + orgFile);
1103 for (
const auto &
path : std::as_const(
paths))
1121 nextPosition(0x40000000)
1136 for (
auto conf_file : std::as_const(confFiles)) {
1137 if (!conf_file->ref.deref()) {
1138 if (conf_file->size == 0) {
1142 usedHash->
remove(conf_file->name);
1146 unusedCache->
insert(conf_file->name, conf_file,
1147 10 + (conf_file->originalKeys.size() / 4));
1171 const auto locker = qt_scoped_lock(confFile->
mutex);
1173 ensureSectionParsed(confFile, theKey);
1174 ensureSectionParsed(confFile, prefix);
1177 while (
i != confFile->
addedKeys.
end() &&
i.key().startsWith(prefix))
1199 const auto locker = qt_scoped_lock(confFile->
mutex);
1207 ParsedSettingsMap::const_iterator
j;
1210 for (
auto confFile : std::as_const(confFiles)) {
1211 const auto locker = qt_scoped_lock(confFile->mutex);
1213 if (!confFile->addedKeys.isEmpty()) {
1214 j = confFile->addedKeys.constFind(theKey);
1215 found = (
j != confFile->addedKeys.constEnd());
1218 ensureSectionParsed(confFile, theKey);
1219 j = confFile->originalKeys.constFind(theKey);
1220 found = (
j != confFile->originalKeys.constEnd()
1221 && !confFile->removedKeys.contains(theKey));
1229 return std::nullopt;
1239 for (
auto confFile : std::as_const(confFiles)) {
1240 const auto locker = qt_scoped_lock(confFile->mutex);
1243 ensureAllSectionsParsed(confFile);
1245 ensureSectionParsed(confFile, thePrefix);
1248 &confFile->originalKeys)->lowerBound( thePrefix);
1249 while (
j != confFile->originalKeys.constEnd() &&
j.key().startsWith(thePrefix)) {
1250 if (!confFile->removedKeys.contains(
j.key()))
1256 &confFile->addedKeys)->lowerBound(thePrefix);
1257 while (
j != confFile->addedKeys.constEnd() &&
j.key().startsWith(thePrefix)) {
1279 const auto locker = qt_scoped_lock(confFile->
mutex);
1280 ensureAllSectionsParsed(confFile);
1290 for (
auto confFile : std::as_const(confFiles)) {
1291 const auto locker = qt_scoped_lock(confFile->mutex);
1292 syncConfFile(confFile);
1307 return confFiles.
at(0)->
name;
1321void QConfFileSettingsPrivate::syncConfFile(
QConfFile *confFile)
1330 if (readOnly && confFile->
size > 0) {
1340#ifndef QT_BOOTSTRAPPED
1343# if defined(Q_OS_ANDROID) && defined(QSETTINGS_USE_QSTANDARDPATHS)
1368 bool mustReadFile =
true;
1369 bool createFile = !fileInfo.exists();
1372 mustReadFile = (confFile->
size != fileInfo.size()
1400 }
else if (readFunc) {
1402 ok = readFunc(
file, tempNewKeys);
1418 confFile->
size = fileInfo.size();
1428 ensureAllSectionsParsed(confFile);
1431#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile)
1437 sf.setDirectWriteFallback(
true);
1449 ok = writePlistFile(sf, mergedKeys);
1453 ok = writeIniFile(sf, mergedKeys);
1454 }
else if (writeFunc) {
1459 tempOriginalKeys.
insert(
i.key(),
i.value());
1462 ok = writeFunc(sf, tempOriginalKeys);
1465#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile)
1477 confFile->
size = fileInfo.size();
1500 0, 0, 0, 0, 0, 0, 0, 0, 0,
Space,
Space |
Special, 0, 0,
Space |
Special, 0, 0,
1501 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1502 Space, 0,
Special, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1503 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Special, 0,
Special, 0, 0,
1504 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1505 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Special, 0, 0, 0,
1506 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1507 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1509 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1512 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1513 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1514 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1515 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1516 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1524 bool inQuotes =
false;
1528 lineStart = dataPos;
1533 while (
i < dataLen) {
1537 goto break_out_of_outer_loop;
1543 if (!inQuotes && equalsPos == -1)
1545 }
else if (
ch ==
'\n' ||
ch ==
'\r') {
1546 if (
i == lineStart + 1) {
1548 }
else if (!inQuotes) {
1550 goto break_out_of_outer_loop;
1552 }
else if (
ch ==
'\\') {
1556 char ch2 =
data.at(
i);
1558 if ((
ch ==
'\n' && ch2 ==
'\r') || (
ch ==
'\r' && ch2 ==
'\n'))
1562 }
else if (
ch ==
'"') {
1563 inQuotes = !inQuotes;
1567 if (
i == lineStart + 1) {
1568 while (
i < dataLen && (((
ch =
data.at(
i)) !=
'\n') &&
ch !=
'\r'))
1573 }
else if (!inQuotes) {
1575 goto break_out_of_outer_loop;
1580break_out_of_outer_loop:
1582 lineLen =
i - lineStart;
1594#define FLUSH_CURRENT_SECTION() \
1596 QByteArray §ionData = (*unparsedIniSections)[QSettingsKey(currentSection, \
1597 IniCaseSensitivity, \
1598 sectionPosition)]; \
1599 if (!sectionData.isEmpty()) \
1600 sectionData.append('\n'); \
1601 sectionData += data.first(lineStart).sliced(currentSectionStart); \
1602 sectionPosition = ++position; \
1616 if (
data.startsWith(
"\xef\xbb\xbf"))
1635 currentSection.
clear();
1640 currentSection.
clear();
1643 currentSection += u
'/';
1645 currentSectionStart = dataPos;
1655#undef FLUSH_CURRENT_SECTION
1675 if (equalsPos == -1) {
1681 equalsPos -= lineStart;
1683 Q_ASSERT(equalsPos >= 0 && equalsPos < lineLen);
1725 return static_cast<const QString &
>(
k1) <
static_cast<const QString &
>(k2);
1751 const char *
const eol =
"\r\n";
1753 const char eol =
'\n';
1761 if ((slashPos =
key.indexOf(u
'/')) != -1) {
1769 if (
size_t(
key.position) <
size_t(iniSection.
position))
1776 sections.
reserve(sectionCount);
1779 std::sort(sections.
begin(), sections.
end());
1781 bool writeError =
false;
1782 for (
qsizetype j = 0; !writeError &&
j < sectionCount; ++
j) {
1791 realSection =
"[General]";
1793 realSection =
"[%General]";
1803 device.write(realSection);
1818 if (
value.metaType().id() == QMetaType::QStringList
1819 || (
value.metaType().id() == QMetaType::QVariantList &&
value.toList().size() != 1)) {
1825 if (
device.write(block) == -1) {
1834void QConfFileSettingsPrivate::ensureAllSectionsParsed(
QConfFile *confFile)
const
1839 for (;
i !=
end; ++
i) {
1846void QConfFileSettingsPrivate::ensureSectionParsed(
QConfFile *confFile,
1852 UnparsedSettingsMap::iterator
i;
1855 if (indexOfSlash != -1) {
1860 if (
i.key().isEmpty() || !
key.startsWith(
i.key()))
2474#ifndef QT_NO_QOBJECT
2698 if (
d->pendingChanges) {
2741 d->pendingChanges =
false;
2756 return d->fileName();
2795 return d->organizationName;
2808 return d->applicationName;
2841 return d->atomicSyncOnly;
2919 if (
d->groupStack.isEmpty()) {
2920 qWarning(
"QSettings::endGroup: No matching beginGroup()");
2927 d->groupPrefix.truncate(
d->groupPrefix.size() - (
len + 1));
2929 if (
group.isArray())
2930 qWarning(
"QSettings::endGroup: Expected endArray() instead");
2941 return d->groupPrefix.left(
d->groupPrefix.size() - 1);
2963 return value(
"size"_L1).toInt();
3018 if (
d->groupStack.isEmpty()) {
3019 qWarning(
"QSettings::endArray: No matching beginArray()");
3025 d->groupStack.pop();
3027 d->groupPrefix.truncate(
d->groupPrefix.size() - (
len + 1));
3029 if (
group.arraySizeGuess() != -1)
3032 if (!
group.isArray())
3033 qWarning(
"QSettings::endArray: Expected endGroup() instead");
3047 if (
d->groupStack.isEmpty() || !
d->groupStack.top().isArray()) {
3048 qWarning(
"QSettings::setArrayIndex: Missing beginArray()");
3055 d->groupPrefix.replace(
d->groupPrefix.size() -
len - 1,
len,
top.toString());
3142 return d->isWritable();
3167 if (
key.isEmpty()) {
3168 qWarning(
"QSettings::setValue: Empty key passed");
3242 return d->get(
d->actualKey(
key)) != std::nullopt;
3268 return d->fallbacks;
3271#ifndef QT_NO_QOBJECT
3313 return d->value(
key,
nullptr);
3319 return d->value(
key, &defaultValue);
3324 if (
key.isEmpty()) {
3325 qWarning(
"QSettings::value: Empty key passed");
3329 return std::move(*
r);
3331 return *defaultValue;
3402 PathHash *pathHash = pathHashFunc();
3477 WriteFunc writeFunc,
3480#ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
3492 info.readFunc = readFunc;
3493 info.writeFunc = writeFunc;
3494 info.caseSensitivity = caseSensitivity;
3502#ifndef QT_BOOTSTRAPPED
3503#include "moc_qsettings.cpp"
IOBluetoothDevice * device
constexpr qsizetype size() const noexcept
int compare(QByteArrayView a, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr const_pointer constData() const noexcept
QByteArray & prepend(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool startsWith(QByteArrayView bv) const
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
int compare(QByteArrayView a, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
T * take(const Key &key) noexcept(std::is_nothrow_destructible_v< Key >)
bool insert(const Key &key, T *object, qsizetype cost=1)
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
constexpr bool isUpper() const noexcept
Returns true if the character is an uppercase letter, for example category() is Letter_Uppercase.
static bool readIniSection(const QSettingsKey §ion, QByteArrayView data, ParsedSettingsMap *settingsMap)
void set(const QString &key, const QVariant &value) override
~QConfFileSettingsPrivate()
virtual void initAccess()
bool readIniFile(QByteArrayView data, UnparsedSettingsMap *unparsedIniSections)
bool isWritable() const override
QString fileName() const override
QConfFileSettingsPrivate(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application)
void remove(const QString &key) override
static bool readIniLine(QByteArrayView data, qsizetype &dataPos, qsizetype &lineStart, qsizetype &lineLen, qsizetype &equalsPos)
std::optional< QVariant > get(const QString &key) const override
UnparsedSettingsMap unparsedIniSections
ParsedSettingsMap originalKeys
static Q_AUTOTEST_EXPORT void clearCache()
ParsedSettingsMap removedKeys
ParsedSettingsMap mergedKeyMap() const
static QConfFile * fromName(const QString &name, bool _userPerms)
ParsedSettingsMap addedKeys
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
\inmodule QtCore\reentrant
Version
This enum provides symbolic synonyms for the data serialization format version numbers.
static QChar separator()
Returns the native directory separator: "/" under Unix and "\\" under Windows.
static QString homePath()
Returns the absolute path of the user's home directory.
\inmodule QtCore \reentrant
QString fileName() const
Returns the name of the file, excluding the path.
QString absoluteFilePath() const
Returns an absolute path including the file name.
QString absolutePath() const
Returns a file's path absolute path.
bool exists() const
Returns true if the file exists; otherwise returns false.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool setPermissions(Permissions permissionSpec) override
Sets the permissions for the file to the permissions specified.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
qint64 size() const override
\reimp
bool remove(const Key &key)
Removes the item that has the key from the hash.
T value(const Key &key) const noexcept
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
\inmodule QtCore \reentrant
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
bool isReadable() const
Returns true if data can be read from the device; otherwise returns false.
static QString path(LibraryPath p)
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
iterator erase(const_iterator it)
bool contains(const Key &key) const
size_type remove(const Key &key)
const_iterator constFind(const Key &key) const
iterator lowerBound(const Key &key)
iterator upperBound(const Key &key)
const_iterator constBegin() const
const_iterator constEnd() const
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
QScopedPointer< QObjectData > d_ptr
\inmodule QtCore\reentrant
Represents an immutable JsonPath like path in the Qml code model (from a DomItem to another DomItem)
\inmodule QtCore\reentrant
QSettingsIniKey(const QString &str, qsizetype pos=-1)
QString originalCaseKey() const
qsizetype originalKeyPosition() const
static void iniEscapedKey(const QString &key, QByteArray &result)
virtual std::optional< QVariant > get(const QString &key) const =0
virtual QString fileName() const =0
QVariant value(QAnyStringView key, const QVariant *defaultValue) const
static bool iniUnescapedStringList(QByteArrayView str, QString &stringResult, QStringList &stringListResult)
QSettingsPrivate(QSettings::Format format)
static QStringList variantListToStringList(const QVariantList &l)
static QSettingsPrivate * create(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application)
static void iniEscapedString(const QString &str, QByteArray &result)
void beginGroupOrArray(const QSettingsGroup &group)
void setStatus(QSettings::Status status) const
static QVariant stringListToVariantList(const QStringList &l)
static QVariant stringToVariant(const QString &s)
virtual ~QSettingsPrivate()
static void iniEscapedStringList(const QStringList &strs, QByteArray &result)
QString actualKey(QAnyStringView key) const
static QString variantToString(const QVariant &v)
static bool iniUnescapedKey(QByteArrayView key, QString &result)
static QString normalizedKey(QAnyStringView key)
static QStringList splitArgs(const QString &s, qsizetype idx)
QStack< QSettingsGroup > groupStack
static void processChild(QStringView key, ChildSpec spec, QStringList &result)
static void setDefaultFormat(Format format)
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
void beginWriteArray(QAnyStringView prefix, int size=-1)
Adds prefix to the current group and starts writing an array of size size.
void endArray()
Closes the array that was started using beginReadArray() or beginWriteArray().
QSettings(const QString &organization, const QString &application=QString(), QObject *parent=nullptr)
Constructs a QSettings object for accessing settings of the application called application from the o...
static Format defaultFormat()
Format
This enum type specifies the storage format used by QSettings.
Scope
This enum specifies whether settings are user-specific or shared by all users of the same system.
void clear()
Removes all entries in the primary location associated to this QSettings object.
QString fileName() const
Returns the path where settings written using this QSettings object are stored.
bool contains(QAnyStringView key) const
Returns true if there exists a setting called key; returns false otherwise.
~QSettings()
Destroys the QSettings object.
void setAtomicSyncRequired(bool enable)
bool event(QEvent *event) override
\reimp
QString organizationName() const
void setValue(QAnyStringView key, const QVariant &value)
Sets the value of setting key to value.
void remove(QAnyStringView key)
Removes the setting key and any sub-settings of key.
QVariant value(QAnyStringView key, const QVariant &defaultValue) const
Returns the value for setting key.
int beginReadArray(QAnyStringView prefix)
Adds prefix to the current group and starts reading from an array.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object.
bool(* WriteFunc)(QIODevice &device, const SettingsMap &map)
Typedef for a pointer to a function with the following signature:
static Format registerFormat(const QString &extension, ReadFunc readFunc, WriteFunc writeFunc, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)
QString applicationName() const
QStringList allKeys() const
Returns a list of all keys, including subkeys, that can be read using the QSettings object.
void sync()
Writes any unsaved changes to permanent storage, and reloads any settings that have been changed in t...
Status
The following status values are possible:
bool isWritable() const
Returns true if settings can be written using this QSettings object; returns false otherwise.
bool(* ReadFunc)(QIODevice &device, SettingsMap &map)
Typedef for a pointer to a function with the following signature:
static void setPath(Format format, Scope scope, const QString &path)
bool isAtomicSyncRequired() const
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
void beginGroup(QAnyStringView prefix)
Appends prefix to the current group.
void setArrayIndex(int i)
Sets the current array index to i.
QString group() const
Returns the current group.
Status status() const
Returns a status code indicating the first error that was met by QSettings, or QSettings::NoError if ...
bool fallbacksEnabled() const
Returns true if fallbacks are enabled; returns false otherwise.
void setFallbacksEnabled(bool b)
Sets whether fallbacks are enabled to b.
void push(const T &t)
Adds element t to the top of the stack.
static QStringList standardLocations(StandardLocation type)
static QString writableLocation(StandardLocation type)
ushort toUShort(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned short} using base base, which is 10 by default and ...
QByteArray toLatin1() const
Returns a Latin-1 representation of the string as a QByteArray.
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
void truncate(qsizetype pos)
Truncates the string at the given position index.
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString first(qsizetype n) const
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
QString sliced(qsizetype pos) const
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
void squeeze()
Releases any memory not required to store the character data.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString trimmed() const &
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QString & prepend(QChar c)
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
\inmodule QtCore \reentrant
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
Lock qt_scoped_lock(Mutex &mutex)
constexpr int fromOct(char32_t c) noexcept
constexpr bool isAsciiLetterOrNumber(char32_t c) noexcept
constexpr char toHexUpper(char32_t value) noexcept
constexpr bool isHexDigit(char32_t c) noexcept
constexpr int fromHex(char32_t c) noexcept
constexpr Initialization Uninitialized
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLsizei const GLuint * paths
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
static QString lockFileName(const QString &name)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT_X(cond, x, msg)
static Q_CONSTINIT QSettings::Format globalDefaultFormat
QHash< int, Path > PathHash
QList< QConfFileCustomFormat > CustomFormatVector
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
static Path getPath(QSettings::Format format, QSettings::Scope scope)
static int pathHashKey(QSettings::Format format, QSettings::Scope scope)
static QString make_user_path()
static std::unique_lock< QBasicMutex > initDefaultPaths(std::unique_lock< QBasicMutex > locker)
static QString make_user_path_without_qstandard_paths()
static const char charTraits[256]
static Q_CONSTINIT QBasicMutex settingsGlobalMutex
QMap< QSettingsIniKey, QVariant > IniKeyMap
static constexpr QChar sep
QHash< QString, QConfFile * > ConfFileHash
#define FLUSH_CURRENT_SECTION()
QMap< QString, QSettingsIniSection > IniMap
static void iniChopTrailingSpaces(QString &str, qsizetype limit)
QCache< QString, QConfFile > ConfFileCache
static const Qt::CaseSensitivity IniCaseSensitivity
#define Q_AUTOTEST_EXPORT
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
static int toInt(const QChar &qc, int R)
static int numDigits(qlonglong n)
QFileInfo info(fileName)
[8]
gzip write("uncompressed data")
QTextStream out(stdout)
[7]
char * toString(const MyType &t)
[31]
\inmodule QtCore \reentrant
static char16_t * convertToUnicode(char16_t *dst, QLatin1StringView in) noexcept
static QChar * convertToUnicode(QChar *buffer, QByteArrayView in) noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent