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
88 Path(
const QString &
p,
bool ud) :
path(
p), userDefined(ud) {}
90 bool userDefined =
false;
108 usedHashFunc()->insert(
name,
this);
114 usedHashFunc()->remove(
name);
132#if QT_CONFIG(temporaryfile)
137#if QT_CONFIG(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: {
398 if (
result.contains(QChar::Null))
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
424 QDataStream::Version version;
425 const char *typeSpec;
426 if (
v.userType() == QMetaType::QDateTime) {
427 version = QDataStream::Qt_5_6;
428 typeSpec =
"@DateTime(";
430 version = QDataStream::Qt_4_0;
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
465 QDataStream::Version version;
467 if (
s.at(1) == u
'D') {
468 version = QDataStream::Qt_5_6;
471 version = QDataStream::Qt_4_0;
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;
543 char16_t ch = decoded.
at(
i).unicode();
551 if (
ch !=
'%' ||
i ==
size - 1) {
554 lowercaseOnly =
false;
563 ch = decoded.
at(
i + 1).unicode();
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;
729 qsizetype chopLimit = stringResult.size();
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();
783 stringResult.squeeze();
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()
881#if defined(Q_OS_WASM)
890#if defined(Q_OS_DARWIN)
905 if (
i >= 0 && i < customFormatVector->
size()) {
907 extension =
info.extension;
908 readFunc =
info.readFunc;
909 writeFunc =
info.writeFunc;
910 caseSensitivity =
info.caseSensitivity;
932static QString windowsConfigPath(
const KNOWNFOLDERID &
type)
936 PWSTR
path =
nullptr;
937 if (SHGetKnownFolderPath(
type, KF_FLAG_DONT_VERIFY, NULL, &
path) == S_OK) {
943 if (
type == FOLDERID_ProgramData) {
944 result =
"C:\\temp\\qt-common"_L1;
945 }
else if (
type == FOLDERID_RoamingAppData) {
946 result =
"C:\\temp\\qt-user"_L1;
962#if !defined(QSETTINGS_USE_QSTANDARDPATHS) || defined(Q_OS_ANDROID)
978#ifndef QSETTINGS_USE_QSTANDARDPATHS
1002 PathHash *pathHash = pathHashFunc();
1014 if (pathHash->isEmpty()) {
1022 const QString roamingAppDataFolder = windowsConfigPath(FOLDERID_RoamingAppData);
1023 const QString programDataFolder = windowsConfigPath(FOLDERID_ProgramData);
1048 PathHash *pathHash = pathHashFunc();
1049 if (pathHash->isEmpty())
1053 if (!
result.path.isEmpty())
1060#if defined(QT_BUILD_INTERNAL) && defined(Q_XDG_PLATFORM) && !defined(QT_NO_STANDARDPATHS)
1065 pathHashFunc()->clear();
1074 nextPosition(0x40000000)
1079 if (
org.isEmpty()) {
1081 org =
"Unknown Organization"_L1;
1095#if defined(Q_XDG_PLATFORM) && !defined(QT_NO_STANDARDPATHS)
1097 if (!systemPath.userDefined) {
1103 if (!dirs.isEmpty())
1107 paths.reserve(dirs.size() * 2);
1108 for (
const auto &
dir : std::as_const(dirs))
1109 paths.append(
dir + u
'/' + appFile);
1111 paths.reserve(dirs.size());
1113 for (
const auto &
dir : std::as_const(dirs))
1114 paths.append(
dir + u
'/' + orgFile);
1117 for (
const auto &
path : std::as_const(
paths))
1133 nextPosition(0x40000000)
1148 for (
auto conf_file : std::as_const(confFiles)) {
1149 if (!conf_file->ref.deref()) {
1150 if (conf_file->size == 0) {
1154 usedHash->remove(conf_file->name);
1158 unusedCache->insert(conf_file->name, conf_file,
1159 10 + (conf_file->originalKeys.size() / 4));
1183 const auto locker = qt_scoped_lock(confFile->mutex);
1185 ensureSectionParsed(confFile, theKey);
1186 ensureSectionParsed(confFile, prefix);
1188 auto i = confFile->addedKeys.lowerBound(prefix);
1189 while (
i != confFile->addedKeys.end() &&
i.key().startsWith(prefix))
1190 i = confFile->addedKeys.erase(
i);
1191 confFile->addedKeys.remove(theKey);
1193 auto j =
const_cast<const ParsedSettingsMap *
>(&confFile->originalKeys)->lowerBound(prefix);
1194 while (
j != confFile->originalKeys.constEnd() &&
j.key().startsWith(prefix)) {
1198 if (confFile->originalKeys.contains(theKey))
1199 confFile->removedKeys.insert(theKey,
QVariant());
1211 const auto locker = qt_scoped_lock(confFile->mutex);
1212 confFile->removedKeys.remove(theKey);
1213 confFile->addedKeys.insert(theKey,
value);
1219 ParsedSettingsMap::const_iterator
j;
1222 for (
auto confFile : std::as_const(confFiles)) {
1223 const auto locker = qt_scoped_lock(confFile->mutex);
1225 if (!confFile->addedKeys.isEmpty()) {
1226 j = confFile->addedKeys.constFind(theKey);
1227 found = (
j != confFile->addedKeys.constEnd());
1230 ensureSectionParsed(confFile, theKey);
1231 j = confFile->originalKeys.constFind(theKey);
1232 found = (
j != confFile->originalKeys.constEnd()
1233 && !confFile->removedKeys.contains(theKey));
1241 return std::nullopt;
1251 for (
auto confFile : std::as_const(confFiles)) {
1252 const auto locker = qt_scoped_lock(confFile->mutex);
1254 if (thePrefix.isEmpty())
1255 ensureAllSectionsParsed(confFile);
1257 ensureSectionParsed(confFile, thePrefix);
1259 const auto &originalKeys = confFile->originalKeys;
1260 auto i = originalKeys.lowerBound(thePrefix);
1261 while (
i != originalKeys.end() &&
i.key().startsWith(thePrefix)) {
1262 if (!confFile->removedKeys.contains(
i.key()))
1267 const auto &addedKeys = confFile->addedKeys;
1268 auto j = addedKeys.lowerBound(thePrefix);
1269 while (
j != addedKeys.end() &&
j.key().startsWith(thePrefix)) {
1291 const auto locker = qt_scoped_lock(confFile->mutex);
1292 ensureAllSectionsParsed(confFile);
1293 confFile->addedKeys.clear();
1294 confFile->removedKeys = confFile->originalKeys;
1302 for (
auto confFile : std::as_const(confFiles)) {
1303 const auto locker = qt_scoped_lock(confFile->mutex);
1304 syncConfFile(confFile);
1319 return confFiles.
at(0)->
name;
1324#if defined(Q_OS_WASM)
1337void QConfFileSettingsPrivate::syncConfFile(
QConfFile *confFile)
1339 bool readOnly = confFile->addedKeys.isEmpty() && confFile->removedKeys.isEmpty();
1346 if (readOnly && confFile->size > 0) {
1347 if (confFile->size == fileInfo.size() && confFile->timeStamp == fileInfo.lastModified(
QTimeZone::UTC))
1351 if (!readOnly && !confFile->isWritable()) {
1356#ifndef QT_BOOTSTRAPPED
1359# if defined(Q_OS_ANDROID) && defined(QSETTINGS_USE_QSTANDARDPATHS)
1362 if (confFile->name.startsWith(
"content:"_L1))
1384 bool mustReadFile =
true;
1385 bool createFile = !fileInfo.exists();
1388 mustReadFile = (confFile->size != fileInfo.size()
1389 || (confFile->size != 0 && confFile->timeStamp != fileInfo.lastModified(
QTimeZone::UTC)));
1392 confFile->unparsedIniSections.clear();
1393 confFile->originalKeys.clear();
1409 if (
format == QSettings::WebIndexedDBFormat) {
1417 ok = readPlistFile(
data, &confFile->originalKeys);
1423 }
else if (readFunc) {
1425 ok = readFunc(
file, tempNewKeys);
1428 auto i = tempNewKeys.constBegin();
1429 while (
i != tempNewKeys.constEnd()) {
1430 confFile->originalKeys.insert(
QSettingsKey(
i.key(), caseSensitivity),
1441 confFile->size = fileInfo.size();
1451 ensureAllSectionsParsed(confFile);
1454#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile)
1455 QSaveFile sf(confFile->name);
1459 if (confFile->name.startsWith(
"content:"_L1))
1460 sf.setDirectWriteFallback(
true);
1463 QFile sf(confFile->name);
1471 if (
format == QSettings::WebIndexedDBFormat) {
1472 ok = writeIniFile(sf, mergedKeys);
1477 ok = writePlistFile(sf, mergedKeys);
1481 ok = writeIniFile(sf, mergedKeys);
1482 }
else if (writeFunc) {
1486 while (
i != mergedKeys.constEnd()) {
1487 tempOriginalKeys.insert(
i.key(),
i.value());
1490 ok = writeFunc(sf, tempOriginalKeys);
1493#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile)
1499 confFile->unparsedIniSections.clear();
1500 confFile->originalKeys = mergedKeys;
1501 confFile->addedKeys.clear();
1502 confFile->removedKeys.clear();
1505 confFile->size = fileInfo.size();
1511 if (!confFile->userPerms)
1525static const char charTraits[256] =
1530 0, 0, 0, 0, 0, 0, 0, 0, 0,
Space,
Space |
Special, 0, 0,
Space |
Special, 0, 0,
1531 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1532 Space, 0,
Special, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1533 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Special, 0,
Special, 0, 0,
1534 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1535 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Special, 0, 0, 0,
1536 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1537 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1539 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1540 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1541 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1542 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1543 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1544 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1545 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1546 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1559 bool inQuotes =
false;
1563 lineStart = dataPos;
1568 while (
i < dataLen) {
1570 while (!(charTraits[
uchar(
ch)] & Special)) {
1572 goto break_out_of_outer_loop;
1578 if (!inQuotes && equalsPos == -1)
1580 }
else if (
ch ==
'\n' ||
ch ==
'\r') {
1581 if (
i == lineStart + 1) {
1583 }
else if (!inQuotes) {
1585 goto break_out_of_outer_loop;
1587 }
else if (
ch ==
'\\') {
1591 char ch2 =
data.at(
i);
1593 if ((
ch ==
'\n' && ch2 ==
'\r') || (
ch ==
'\r' && ch2 ==
'\n'))
1597 }
else if (
ch ==
'"') {
1598 inQuotes = !inQuotes;
1602 if (
i == lineStart + 1) {
1603 while (
i < dataLen && (((
ch =
data.at(
i)) !=
'\n') &&
ch !=
'\r'))
1608 }
else if (!inQuotes) {
1610 goto break_out_of_outer_loop;
1615break_out_of_outer_loop:
1617 lineLen =
i - lineStart;
1629#define FLUSH_CURRENT_SECTION() \
1631 QByteArray §ionData = (*unparsedIniSections)[QSettingsKey(currentSection, \
1632 IniCaseSensitivity, \
1633 sectionPosition)]; \
1634 if (!sectionData.isEmpty()) \
1635 sectionData.append('\n'); \
1636 sectionData += data.first(lineStart).sliced(currentSectionStart); \
1637 sectionPosition = ++position; \
1651 if (
data.startsWith(
"\xef\xbb\xbf"))
1670 currentSection.
clear();
1673 currentSection =
QLatin1StringView(iniSection.constData() + 1, iniSection.size() - 1);
1675 currentSection.
clear();
1678 currentSection += u
'/';
1680 currentSectionStart = dataPos;
1690#undef FLUSH_CURRENT_SECTION
1710 if (equalsPos == -1) {
1716 equalsPos -= lineStart;
1718 Q_ASSERT(equalsPos >= 0 && equalsPos < lineLen);
1758 if (
k1.position != k2.position)
1759 return k1.position < k2.position;
1760 return static_cast<const QString &
>(
k1) <
static_cast<const QString &
>(k2);
1775typedef QMap<QString, QSettingsIniSection>
IniMap;
1786 const char *
const eol =
"\r\n";
1788 const char eol =
'\n';
1796 if ((slashPos =
key.indexOf(u
'/')) != -1) {
1804 if (
size_t(
key.position) <
size_t(iniSection.position))
1806 iniSection.keyMap[
key] =
j.value();
1809 const qsizetype sectionCount = iniMap.size();
1810 QList<QSettingsIniKey> sections;
1811 sections.reserve(sectionCount);
1812 for (
auto i = iniMap.constBegin();
i != iniMap.constEnd(); ++
i)
1814 std::sort(sections.begin(), sections.end());
1816 bool writeError =
false;
1817 for (
qsizetype j = 0; !writeError &&
j < sectionCount; ++
j) {
1818 auto i = iniMap.constFind(sections.at(
j));
1825 if (realSection.isEmpty()) {
1826 realSection =
"[General]";
1828 realSection =
"[%General]";
1830 realSection.prepend(
'[');
1831 realSection.append(
']');
1835 realSection.prepend(eol);
1838 device.write(realSection);
1841 for (
auto j = ents.constBegin();
j != ents.constEnd(); ++
j) {
1853 if (
value.metaType().id() == QMetaType::QStringList
1854 || (
value.metaType().id() == QMetaType::QVariantList &&
value.toList().size() != 1)) {
1860 if (
device.write(block) == -1) {
1869void QConfFileSettingsPrivate::ensureAllSectionsParsed(
QConfFile *confFile)
const
1871 auto i = confFile->unparsedIniSections.constBegin();
1872 const auto end = confFile->unparsedIniSections.constEnd();
1874 for (;
i !=
end; ++
i) {
1878 confFile->unparsedIniSections.clear();
1881void QConfFileSettingsPrivate::ensureSectionParsed(
QConfFile *confFile,
1884 if (confFile->unparsedIniSections.isEmpty())
1887 UnparsedSettingsMap::iterator
i;
1890 if (indexOfSlash != -1) {
1891 i = confFile->unparsedIniSections.upperBound(
key);
1892 if (
i == confFile->unparsedIniSections.begin())
1895 if (
i.key().isEmpty() || !
key.startsWith(
i.key()))
1898 i = confFile->unparsedIniSections.begin();
1899 if (
i == confFile->unparsedIniSections.end() || !
i.key().isEmpty())
1905 confFile->unparsedIniSections.erase(
i);
2512#ifndef QT_NO_QOBJECT
2736 if (
d->pendingChanges) {
2779 d->pendingChanges =
false;
2794 return d->fileName();
2833 return d->organizationName;
2846 return d->applicationName;
2879 return d->atomicSyncOnly;
2957 if (
d->groupStack.isEmpty()) {
2958 qWarning(
"QSettings::endGroup: No matching beginGroup()");
2965 d->groupPrefix.truncate(
d->groupPrefix.size() - (
len + 1));
2967 if (
group.isArray())
2968 qWarning(
"QSettings::endGroup: Expected endArray() instead");
2979 return d->groupPrefix.left(
d->groupPrefix.size() - 1);
3001 return value(
"size"_L1).toInt();
3056 if (
d->groupStack.isEmpty()) {
3057 qWarning(
"QSettings::endArray: No matching beginArray()");
3063 d->groupStack.pop();
3065 d->groupPrefix.truncate(
d->groupPrefix.size() - (
len + 1));
3067 if (
group.arraySizeGuess() != -1)
3070 if (!
group.isArray())
3071 qWarning(
"QSettings::endArray: Expected endGroup() instead");
3085 if (
d->groupStack.isEmpty() || !
d->groupStack.top().isArray()) {
3086 qWarning(
"QSettings::setArrayIndex: Missing beginArray()");
3093 d->groupPrefix.replace(
d->groupPrefix.size() -
len - 1,
len,
top.toString());
3180 return d->isWritable();
3205 if (
key.isEmpty()) {
3206 qWarning(
"QSettings::setValue: Empty key passed");
3247 if (theKey.isEmpty())
3250 theKey.prepend(
d->groupPrefix);
3252 if (theKey.isEmpty()) {
3280 return d->get(
d->actualKey(
key)) != std::nullopt;
3306 return d->fallbacks;
3309#ifndef QT_NO_QOBJECT
3351 return d->value(
key,
nullptr);
3357 return d->value(
key, &defaultValue);
3362 if (
key.isEmpty()) {
3363 qWarning(
"QSettings::value: Empty key passed");
3367 return std::move(*
r);
3369 return *defaultValue;
3438 PathHash *pathHash = pathHashFunc();
3439 if (pathHash->isEmpty())
3513 WriteFunc writeFunc,
3516#ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
3528 info.readFunc = readFunc;
3529 info.writeFunc = writeFunc;
3530 info.caseSensitivity = caseSensitivity;
3531 customFormatVector->append(
info);
3538#ifndef QT_BOOTSTRAPPED
3539#include "moc_qsettings.cpp"
IOBluetoothDevice * device
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.
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
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
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.
QString absoluteFilePath() const
QString absolutePath() const
Returns the absolute path of the file system entry this QFileInfo refers to, excluding the entry's na...
bool exists() const
Returns true if the file system entry this QFileInfo refers to exists; otherwise returns false.
QFILE_MAYBE_NODISCARD 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
\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)
T value(const Key &key, const T &defaultValue=T()) const
size_type remove(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)
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
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.
QString sliced(qsizetype pos) const &
void truncate(qsizetype pos)
Truncates the string at the given position index.
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const noexcept
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.
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
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
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
static const char charTraits[256]
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
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLuint * paths
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 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)
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