43 #include "qplatformdefs.h" 46 #ifndef QT_NO_SETTINGS 57 #ifndef QT_NO_TEXTCODEC 61 #ifndef QT_NO_GEOM_VARIANT 65 #endif // !QT_NO_GEOM_VARIANT 71 #ifdef Q_OS_WIN // for homedirpath reading from registry 73 #include <private/qsystemlibrary_p.h> 82 #ifndef CSIDL_COMMON_APPDATA 83 #define CSIDL_COMMON_APPDATA 0x0023 // All Users\Application Data 87 #define CSIDL_APPDATA 0x001a // <username>\Application Data 90 #ifdef Q_AUTOTEST_EXPORT 91 # define Q_AUTOTEST_EXPORT_HELPER Q_AUTOTEST_EXPORT 93 # define Q_AUTOTEST_EXPORT_HELPER static 129 inline bool qt_isEvilFsTypeName(
const char *
name)
131 return (
qstrncmp(name,
"nfs", 3) == 0
133 ||
qstrncmp(name,
"cachefs", 7) == 0);
136 #if defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD) 138 # include <sys/param.h> 139 # include <sys/mount.h> 145 if (fstatfs(handle, &buf) != 0)
147 return qt_isEvilFsTypeName(buf.f_fstypename);
150 #elif defined(Q_OS_LINUX) || defined(Q_OS_HURD) 152 # include <sys/vfs.h> 155 # include <sys/statfs.h> 158 # ifndef NFS_SUPER_MAGIC 159 # define NFS_SUPER_MAGIC 0x00006969 161 # ifndef AUTOFS_SUPER_MAGIC 162 # define AUTOFS_SUPER_MAGIC 0x00000187 164 # ifndef AUTOFSNG_SUPER_MAGIC 165 # define AUTOFSNG_SUPER_MAGIC 0x7d92b1a0 171 if (fstatfs(handle, &buf) != 0)
173 return buf.f_type == NFS_SUPER_MAGIC
174 || buf.f_type == AUTOFS_SUPER_MAGIC
175 || buf.f_type == AUTOFSNG_SUPER_MAGIC;
178 #elif defined(Q_OS_SOLARIS) || defined(Q_OS_IRIX) || defined(Q_OS_AIX) || defined(Q_OS_HPUX) \ 179 || defined(Q_OS_OSF) || defined(Q_OS_QNX) || defined(Q_OS_SCO) \ 180 || defined(Q_OS_UNIXWARE) || defined(Q_OS_RELIANT) || defined(Q_OS_NETBSD) 182 # include <sys/statvfs.h> 188 if (fstatvfs(handle, &buf) != 0)
190 #if defined(Q_OS_NETBSD) 191 return qt_isEvilFsTypeName(buf.f_fstypename);
193 return qt_isEvilFsTypeName(buf.f_basetype);
203 static bool unixLock(
int handle,
int lockType)
211 if (qIsLikelyToBeNfs(handle))
215 fl.l_whence = SEEK_SET;
218 fl.l_type = lockType;
219 return fcntl(handle, F_SETLKW, &fl) == 0;
224 :
name(fileName), size(0), ref(1), userPerms(_userPerms)
226 usedHashFunc()->insert(
name,
this);
232 usedHashFunc()->remove(
name);
243 result.
insert(i.key(), i.value());
251 #ifndef QT_NO_TEMPORARYFILE 256 #ifndef QT_NO_TEMPORARYFILE 261 if (!dir.mkpath(dir.absolutePath()))
282 if (!(confFile = usedHash->
value(absPath))) {
283 if ((confFile = unusedCache->
take(absPath)))
284 usedHash->
insert(absPath, confFile);
290 return new QConfFile(absPath, _userPerms);
296 unusedCacheFunc()->clear();
303 : format(format), scope(
QSettings::UserScope ), iniCodec(0), spec(0), fallbacks(true),
343 while (i < result.
size()) {
346 if (i == result.
size())
351 if (i == result.
size())
365 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 373 #if !defined(Q_OS_WIN) 384 if (slashPos == -1) {
426 #ifndef QT_NO_QOBJECT 447 for (
int i = 0; i < outStringList.
count(); ++i) {
448 const QString &str = outStringList.
at(i);
452 outStringList[i].remove(0, 1);
455 for (
int j = 0; j < l.
count(); ++j)
461 return outStringList;
494 #ifndef QT_NO_GEOM_VARIANT 526 #endif // !QT_NO_GEOM_VARIANT 529 #ifndef QT_NO_DATASTREAM 541 Q_ASSERT(!
"QSettings: Cannot save custom types without QDataStream support");
558 #ifndef QT_NO_DATASTREAM 566 Q_ASSERT(!
"QSettings: Cannot load custom types without QDataStream support");
568 #ifndef QT_NO_GEOM_VARIANT 571 if (args.
size() == 4)
575 if (args.
size() == 2)
579 if (args.
size() == 2)
599 for (
int i = 0; i < key.
size(); ++i) {
604 }
else if ((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z') || (ch >=
'0' && ch <=
'9')
605 || ch ==
'_' || ch ==
'-' || ch ==
'.') {
607 }
else if (ch <= 0xFF) {
609 result += hexDigits[ch / 16];
610 result += hexDigits[ch % 16];
614 for (
int i = 0; i < 4; ++i) {
615 hexCode.
prepend(hexDigits[ch % 16]);
625 bool lowercaseOnly =
true;
637 if (ch !=
'%' || i == to - 1) {
638 if (
uint(ch -
'A') <=
'Z' -
'A')
639 lowercaseOnly =
false;
646 int firstDigitPos = i + 1;
654 if (firstDigitPos + numDigits > to) {
662 ch = key.
mid(firstDigitPos, numDigits).
toInt(&ok, 16);
672 lowercaseOnly =
false;
676 return lowercaseOnly;
681 bool needsQuotes =
false;
682 bool escapeNextIfDigit =
false;
684 int startPos = result.
size();
687 for (i = 0; i < str.
size(); ++i) {
689 if (ch ==
';' || ch ==
',' || ch ==
'=')
692 if (escapeNextIfDigit
693 && ((ch >=
'0' && ch <=
'9')
694 || (ch >=
'a' && ch <=
'f')
695 || (ch >=
'A' && ch <=
'F'))) {
701 escapeNextIfDigit =
false;
706 escapeNextIfDigit =
true;
735 if (ch <= 0x1F || (ch >= 0x7F && !codec)) {
738 escapeNextIfDigit =
true;
739 #ifndef QT_NO_TEXTCODEC 751 || (startPos < result.
size() && (result.
at(startPos) ==
' ' 752 || result.
at(result.
size() - 1) ==
' '))) {
753 result.
insert(startPos,
'"');
760 int n = str.
size() - 1;
779 result +=
"@Invalid()";
781 for (
int i = 0; i < strs.
size(); ++i) {
793 #ifdef QT_NO_TEXTCODE 796 static const char escapeCodes[][2] =
810 static const int numEscapeCodes =
sizeof(escapeCodes) /
sizeof(escapeCodes[0]);
812 bool isStringList =
false;
813 bool inQuotedString =
false;
814 bool currentValueIsQuoted =
false;
820 while (i < to && ((ch = str.
at(i)) ==
' ' || ch ==
'\t'))
833 for (
int j = 0; j < numEscapeCodes; ++j) {
834 if (ch == escapeCodes[j][0]) {
847 if ((ch >=
'0' && ch <=
'9') || (ch >=
'A' && ch <=
'F') || (ch >=
'a' && ch <=
'f'))
849 }
else if (ch >=
'0' && ch <=
'7') {
850 escapeVal = ch -
'0';
852 }
else if (ch ==
'\n' || ch ==
'\r') {
854 char ch2 = str.
at(i);
856 if ((ch2 ==
'\n' || ch2 ==
'\r') && ch2 != ch)
865 currentValueIsQuoted =
true;
866 inQuotedString = !inQuotedString;
871 if (!inQuotedString) {
872 if (!currentValueIsQuoted)
876 stringListResult.
clear();
879 stringListResult.
append(stringResult);
880 stringResult.
clear();
881 currentValueIsQuoted =
false;
890 if (ch ==
'\\' || ch ==
'"' || ch ==
',')
895 #ifndef QT_NO_TEXTCODEC 901 int n = stringResult.
size();
902 stringResult.
resize(n + (j - i));
903 QChar *resultData = stringResult.
data() + n;
904 for (
int k = i; k < j; ++k)
915 stringResult +=
QChar(escapeVal);
922 if ((ch >=
'0' && ch <=
'9') || (ch >=
'A' && ch <=
'F')) {
924 escapeVal += strchr(hexDigits, ch) -
hexDigits;
928 stringResult +=
QChar(escapeVal);
934 stringResult +=
QChar(escapeVal);
939 if (ch >=
'0' && ch <=
'7') {
941 escapeVal += ch -
'0';
945 stringResult +=
QChar(escapeVal);
950 if (!currentValueIsQuoted)
953 stringListResult.
append(stringResult);
967 for (++idx; idx <
l; ++idx) {
991 #if defined(Q_OS_MAC) 1002 if (i >= 0 && i < customFormatVector->size()) {
1014 if (confFiles[
spec]) {
1033 #endif // Q_OS_WINCE 1034 typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
1035 GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.
resolve(
"SHGetSpecialFolderPathW");
1036 if (SHGetSpecialFolderPath) {
1037 wchar_t path[MAX_PATH];
1038 SHGetSpecialFolderPath(0, path, type,
FALSE);
1075 PathHash *pathHash = pathHashFunc();
1104 char *env = getenv(
"XDG_CONFIG_HOME");
1106 userPath = homePath;
1108 #if defined(Q_WS_QWS) || defined(Q_WS_QPA) 1113 }
else if (*env ==
'/') {
1116 userPath = homePath;
1138 PathHash *pathHash = pathHashFunc();
1155 nextPosition(0x40000000)
1166 #if !defined(Q_OS_BLACKBERRY) 1228 10 + (
confFiles[i]->originalKeys.size() / 4));
1259 while (i != confFile->
addedKeys.
end() && i.key().startsWith(prefix))
1294 if (!confFile->addedKeys.isEmpty()) {
1295 j = confFile->addedKeys.constFind(theKey);
1296 found = (j != confFile->addedKeys.constEnd());
1300 j = confFile->originalKeys.constFind(theKey);
1301 found = (j != confFile->originalKeys.constEnd()
1302 && !confFile->removedKeys.contains(theKey));
1323 int startPos = prefix.
size();
1336 &confFile->originalKeys)->lowerBound( thePrefix);
1337 while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) {
1338 if (!confFile->removedKeys.contains(j.key()))
1344 &confFile->addedKeys)->lowerBound(thePrefix);
1345 while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) {
1354 return result.
keys();
1393 return confFile->
name;
1418 if (readOnly && confFile->
size > 0) {
1435 bool createFile = !file.
exists();
1441 if (!createFile && !file.
isOpen())
1445 HANDLE readSemaphore = 0;
1446 HANDLE writeSemaphore = 0;
1447 static const int FileLockSemMax = 50;
1448 int numReadLocks = readOnly ? 1 : FileLockSemMax;
1456 writeSemaphore = CreateSemaphore(0, 1, 1, reinterpret_cast<const wchar_t *>(writeSemName.
utf16()));
1458 if (writeSemaphore) {
1459 WaitForSingleObject(writeSemaphore, INFINITE);
1472 readSemaphore = CreateSemaphore(0, FileLockSemMax, FileLockSemMax, reinterpret_cast<const wchar_t *>(readSemName.
utf16()));
1474 if (readSemaphore) {
1475 for (
int i = 0; i < numReadLocks; ++i)
1476 WaitForSingleObject(readSemaphore, INFINITE);
1479 if (writeSemaphore != 0) {
1480 ReleaseSemaphore(writeSemaphore, 1, 0);
1481 CloseHandle(writeSemaphore);
1488 unixLock(file.
handle(), readOnly ? F_RDLCK : F_WRLCK);
1506 bool mustReadFile =
true;
1509 mustReadFile = (confFile->
size != fileInfo.
size()
1537 while (i != tempNewKeys.
constEnd()) {
1590 while (i != mergedKeys.
constEnd()) {
1591 tempOriginalKeys.
insert(i.key(), i.value());
1622 if (readSemaphore != 0) {
1623 ReleaseSemaphore(readSemaphore, numReadLocks, 0);
1624 CloseHandle(readSemaphore);
1626 if (writeSemaphore != 0) {
1627 ReleaseSemaphore(writeSemaphore, 1, 0);
1628 CloseHandle(writeSemaphore);
1640 0, 0, 0, 0, 0, 0, 0, 0, 0,
Space,
Space |
Special, 0, 0,
Space |
Special, 0, 0,
1641 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1642 Space, 0,
Special, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1643 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Special, 0,
Special, 0, 0,
1644 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1645 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Special, 0, 0, 0,
1646 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1647 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1649 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1650 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1651 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1652 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1653 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1655 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1656 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1660 int &lineStart,
int &lineLen,
int &equalsPos)
1662 int dataLen = data.
length();
1663 bool inQuotes =
false;
1667 lineStart = dataPos;
1668 while (lineStart < dataLen && (charTraits[
uint(
uchar(data.
at(lineStart)))] &
Space))
1672 while (i < dataLen) {
1675 goto break_out_of_outer_loop;
1678 char ch = data.
at(i++);
1680 if (!inQuotes && equalsPos == -1)
1682 }
else if (ch ==
'\n' || ch ==
'\r') {
1683 if (i == lineStart + 1) {
1685 }
else if (!inQuotes) {
1687 goto break_out_of_outer_loop;
1689 }
else if (ch ==
'\\') {
1691 char ch = data.
at(i++);
1693 char ch2 = data.
at(i);
1695 if ((ch ==
'\n' && ch2 ==
'\r') || (ch ==
'\r' && ch2 ==
'\n'))
1699 }
else if (ch ==
'"') {
1700 inQuotes = !inQuotes;
1704 if (i == lineStart + 1) {
1706 while (i < dataLen && ((ch = data.
at(i) !=
'\n') && ch !=
'\r'))
1709 }
else if (!inQuotes) {
1711 goto break_out_of_outer_loop;
1716 break_out_of_outer_loop:
1718 lineLen = i - lineStart;
1730 #define FLUSH_CURRENT_SECTION() \ 1732 QByteArray §ionData = (*unparsedIniSections)[QSettingsKey(currentSection, \ 1733 IniCaseSensitivity, \ 1734 sectionPosition)]; \ 1735 if (!sectionData.isEmpty()) \ 1736 sectionData.append('\n'); \ 1737 sectionData += data.mid(currentSectionStart, lineStart - currentSectionStart); \ 1738 sectionPosition = ++position; \ 1742 int currentSectionStart = 0;
1748 int sectionPosition = 0;
1751 while (
readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
1752 char ch = data.
at(lineStart);
1758 int idx = data.
indexOf(
']', lineStart);
1759 if (idx == -1 || idx >= lineStart + lineLen) {
1761 iniSection = data.
mid(lineStart + 1, lineLen - 1);
1763 iniSection = data.
mid(lineStart + 1, idx - lineStart - 1);
1766 iniSection = iniSection.
trimmed();
1768 if (
qstricmp(iniSection,
"general") == 0) {
1769 currentSection.
clear();
1771 if (
qstricmp(iniSection,
"%general") == 0) {
1774 currentSection.
clear();
1779 currentSectionStart = dataPos;
1789 #undef FLUSH_CURRENT_SECTION 1805 while (
readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
1806 char ch = data.
at(lineStart);
1809 if (equalsPos == -1) {
1815 int keyEnd = equalsPos;
1816 while (keyEnd > lineStart && ((ch = data.
at(keyEnd - 1)) ==
' ' || ch ==
'\t'))
1818 int valueStart = equalsPos + 1;
1821 bool keyIsLowercase = (
iniUnescapedKey(data, lineStart, keyEnd, key) && sectionIsLowercase);
1824 strValue.
reserve(lineLen - (valueStart - lineStart));
1826 strValue, strListValue, codec);
1862 return static_cast<const QString &
>(k1) < static_cast<const QString &>(k2);
1887 const char *
const eol =
"\r\n";
1889 const char eol =
'\n';
1898 section =
key.left(slashPos);
1899 key.remove(0, slashPos + 1);
1910 const int sectionCount = iniMap.
size();
1912 sections.
reserve(sectionCount);
1917 bool writeError =
false;
1918 for (
int j = 0; !writeError && j < sectionCount; ++j) {
1926 if (realSection.isEmpty()) {
1927 realSection =
"[General]";
1928 }
else if (
qstricmp(realSection,
"general") == 0) {
1929 realSection =
"[%General]";
1931 realSection.prepend(
'[');
1932 realSection.append(
']');
1936 realSection.prepend(eol);
1939 device.
write(realSection);
1941 const IniKeyMap &ents = i.
value().keyMap;
1961 if (device.
write(block) == -1) {
1975 for (; i !=
end; ++i) {
1991 if (indexOfSlash != -1) {
1996 if (i.key().isEmpty() || !key.
startsWith(i.key()))
2651 #ifndef QT_NO_QOBJECT 2844 if (
d->pendingChanges) {
2900 return d->fileName();
2948 return d->organizationName;
2964 return d->applicationName;
2967 #ifndef QT_NO_TEXTCODEC 3029 #endif // QT_NO_TEXTCODEC 3092 if (
d->groupStack.isEmpty()) {
3093 qWarning(
"QSettings::endGroup: No matching beginGroup()");
3100 d->groupPrefix.truncate(
d->groupPrefix.size() - (len + 1));
3103 qWarning(
"QSettings::endGroup: Expected endArray() instead");
3114 return d->groupPrefix.left(
d->groupPrefix.size() - 1);
3185 if (
d->groupStack.isEmpty()) {
3186 qWarning(
"QSettings::endArray: No matching beginArray()");
3192 d->groupStack.pop();
3194 d->groupPrefix.truncate(
d->groupPrefix.size() - (len + 1));
3200 qWarning(
"QSettings::endArray: Expected endGroup() instead");
3214 if (
d->groupStack.isEmpty() || !
d->groupStack.top().isArray()) {
3215 qWarning(
"QSettings::setArrayIndex: Missing beginArray()");
3222 d->groupPrefix.replace(
d->groupPrefix.size() - len - 1, len, top.
toString());
3309 return d->isWritable();
3366 QString theKey =
d->normalizedKey(key);
3398 return d->get(k, 0);
3424 return d->fallbacks;
3427 #ifndef QT_NO_QOBJECT 3517 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 3534 #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) 3581 PathHash *pathHash = pathHashFunc();
3667 #ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER 3683 customFormatVector->
append(info);
3689 void QSettings::setPath_helper(
Scope scope,
const QString &organization,
const QString &application)
3692 if (
d->pendingChanges)
3990 #endif // QT_NO_SETTINGS static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QVariant class acts like a union for the most common Qt data types.
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
The QDir class provides access to directory structures and their contents.
static QStringList splitArgs(const QString &s, int idx)
void setStatus(QSettings::Status status) const
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
QString originalCaseKey() const
Status
The following status values are possible:
static const char charTraits[256]
void setValue(const QString &key, const QVariant &value)
Sets the value of setting key to value.
Qt::CaseSensitivity caseSensitivity
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
QMap< QString, QSettingsIniSection > IniMap
Scope scope() const
Returns the scope used for storing the settings.
bool readPlistFile(const QString &fileName, ParsedSettingsMap *map) const
static Format defaultFormat()
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
The QMutex class provides access serialization between threads.
QHash< int, QString > PathHash
QHash< QString, QConfFile * > ConfFileHash
ParsedSettingsMap mergedKeyMap() const
QMap< QSettingsIniKey, QVariant > IniKeyMap
static void initDefaultPaths(QMutexLocker *locker)
int remove(const Key &key)
Removes all the items that have the key from the hash.
const QChar at(int i) const
Returns the character at the given index position in the string.
bool isReadable() const
Returns true if data can be read from the device; otherwise returns false.
bool isWritable() const
Returns true if data can be written to the device; otherwise returns false.
bool isWritable() const
Returns true if settings can be written using this QSettings object; returns false otherwise...
QSettingsPrivate(QSettings::Format format)
QConfFile(const QConfFile &)
T * data() const
Returns the value of the pointer referenced by this object.
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
#define it(className, varName)
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
int beginReadArray(const QString &prefix)
Adds prefix to the current group and starts reading from an array.
The QSettings class provides persistent platform-independent application settings.
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
static bool iniUnescapedStringList(const QByteArray &str, int from, int to, QString &stringResult, QStringList &stringListResult, QTextCodec *codec)
The QByteArray class provides an array of bytes.
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
int length() const
Returns the number of characters in this string.
The QTemporaryFile class is an I/O device that operates on temporary files.
QSettings::WriteFunc writeFunc
Format
This enum type specifies the storage format used by QSettings.
QString & prepend(QChar c)
T * take()
Returns the value of the pointer referenced by this object.
bool(* WriteFunc)(QIODevice &device, const SettingsMap &map)
Typedef for a pointer to a function with the following signature:
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
void beginGroup(const QString &prefix)
Appends prefix to the current group.
void unlock()
Unlocks this mutex locker.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
int size() const
Returns the number of (key, value) pairs in the map.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
bool writePlistFile(const QString &fileName, const ParsedSettingsMap &map) const
int width() const
Returns the width of the rectangle.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
static LibLoadStatus status
bool open()
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the d...
void setIniCodec(QTextCodec *codec)
Sets the codec for accessing INI files (including .
QString absoluteFilePath() const
Returns an absolute path including the file name.
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool exists() const
Returns true if the file exists; otherwise returns false.
static QConfFile * fromName(const QString &name, bool _userPerms)
const Key & key() const
Returns the current item's key.
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
bool ref()
Atomically increments the value of this QAtomicInt.
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
QByteArray & prepend(char c)
Prepends the character ch to this byte array.
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
static QSettingsPrivate * create(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application)
static QStringList variantListToStringList(const QVariantList &l)
The QHash class is a template class that provides a hash-table-based dictionary.
Format format() const
Returns the format used for storing the settings.
bool resize(qint64 sz)
Sets the file size (in bytes) sz.
The QVector class is a template class that provides a dynamic array.
bool event(QEvent *event)
Reimplemented Function
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
QStringList allKeys() const
Returns a list of all keys, including subkeys, that can be read using the QSettings object...
QString actualKey(const QString &key) const
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
static void setPath(Format format, Scope scope, const QString &path)
Sets the path used for storing settings for the given format and scope, to path.
void sync()
Writes any unsaved changes to permanent storage, and reloads any settings that have been changed in t...
void endArray()
Closes the array that was started using beginReadArray() or beginWriteArray().
int arraySizeGuess() const
The QChar class provides a 16-bit Unicode character.
QChar * data()
Returns a pointer to the data stored in the QString.
virtual QString fileName() const =0
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
const T value(const Key &key) const
Returns the value associated with the key.
static void iniChopTrailingSpaces(QString &str)
QTextCodec * iniCodec() const
Returns the codec that is used for accessing INI files.
QString group() const
Returns the current group.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
bool isEmpty() const
Returns true if the list 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.
void setVersion(int)
Sets the version number of the data serialization format to v.
void set(const QString &key, const QVariant &value)
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
void relock()
Relocks an unlocked mutex locker.
void reserve(int size)
Attempts to allocate memory for at least size characters.
#define Q_OS_MAC
Defined on MAC OS (synonym for Darwin).
friend class const_iterator
int width() const
Returns the width.
void append(const T &t)
Inserts value at the end of the list.
void syncConfFile(int confFileNo)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QStringList children(const QString &prefix, ChildSpec spec) const
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
bool isOpen() const
Returns true if the device is open; otherwise returns false.
Status status() const
Returns a status code indicating the first error that was met by QSettings, or QSettings::NoError if ...
static bool isEmpty(const char *str)
virtual ~QSettingsPrivate()
void truncate(int pos)
Truncates the string at the given position index.
QSettings::ReadFunc readFunc
int size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static int numDigits(qlonglong n)
void beginGroupOrArray(const QSettingsGroup &group)
static void setUserIniPath(const QString &dir)
Use setPath() instead.
QByteArray trimmed() const
Returns a byte array that has whitespace removed from the start and the end.
const T value(const Key &key) const
Returns the value associated with the key key.
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
ParsedSettingsMap addedKeys
static int toInt(const QByteArray &str)
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
void append(const T &t)
Inserts value at the end of the vector.
Q_CORE_EXPORT void qWarning(const char *,...)
#define FLUSH_CURRENT_SECTION()
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
static const char hexDigits[]
static QTextCodec * codec(MYSQL *mysql)
#define FALSE
Synonym for false.
bool(* ReadFunc)(QIODevice &device, SettingsMap &map)
Typedef for a pointer to a function with the following signature:
void ensureSectionParsed(QConfFile *confFile, const QSettingsKey &key) const
QString organizationName() const
Returns the organization name used for storing the settings.
void ensureAllSectionsParsed(QConfFile *confFile) const
~QConfFileSettingsPrivate()
QList< Key > keys() const
Returns a list containing all the keys in the map in ascending order.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
void clear()
Removes all items from the list.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object. ...
static QString variantToString(const QVariant &v)
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
static const Qt::CaseSensitivity IniCaseSensitivity
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
QString fileName() const
Returns the path where settings written using this QSettings object are stored.
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
void push(const T &t)
Adds element t to the top of the stack.
void squeeze()
Releases any memory not required to store the character data.
int handle() const
Returns the file handle of the file.
void qSort(RandomAccessIterator start, RandomAccessIterator end)
int originalKeyPosition() const
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
void setArrayIndex(int i)
Sets the current array index to i.
const T & at(int i) const
Returns the item at index position i in the vector.
bool isUpper() const
Returns true if the character is an uppercase letter, i.
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
static void iniEscapedKey(const QString &key, QByteArray &result)
bool insert(const Key &key, T *object, int cost=1)
int length() const
Same as size().
void resize(int size)
Sets the size of the string to size characters.
QConfFileSettingsPrivate(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application)
static QVariant stringListToVariantList(const QStringList &l)
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
int remove(const Key &key)
Removes all the items that have the key key from the map.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
ParsedSettingsMap originalKeys
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
The QCoreApplication class provides an event loop for console Qt applications.
#define Q_ASSERT_X(cond, where, what)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
void setArrayIndex(int i)
void * resolve(const char *symbol)
QString & append(QChar c)
qint64 size() const
Returns the file size in bytes.
The QFile class provides an interface for reading from and writing to files.
~QSettings()
Destroys the QSettings object.
static bool readIniSection(const QSettingsKey §ion, const QByteArray &data, ParsedSettingsMap *settingsMap, QTextCodec *codec)
void remove(const QString &key)
Removes the setting key and any sub-settings of key.
ParsedSettingsMap removedKeys
static QString getPath(QSettings::Format format, QSettings::Scope scope)
int y() const
Returns the y-coordinate of the rectangle's top edge.
void clear()
Clears the contents of the string and makes it empty.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
int x() const
Returns the x-coordinate of the rectangle's left edge.
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
static QString location(LibraryLocation)
Returns the location specified by loc.
static QSettings::Format globalDefaultFormat
QObject * parent() const
Returns a pointer to the parent object.
The QPoint class defines a point in the plane using integer precision.
int size() const
Returns the number of items in the list.
bool contains(const QString &key) const
Returns true if there exists a setting called key; returns false otherwise.
QVector< QConfFileCustomFormat > CustomFormatVector
QSettings(const QString &organization, const QString &application=QString(), QObject *parent=0)
Constructs a QSettings object for accessing settings of the application called application from the o...
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
int qstrncmp(const char *str1, const char *str2, uint len)
UnparsedSettingsMap unparsedIniSections
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
bool setPermissions(Permissions permissionSpec)
Sets the permissions for the file to the permissions specified.
const T & value() const
Returns the current item's value.
void clear()
Removes all entries in the primary location associated to this QSettings object.
QCache< QString, QConfFile > ConfFileCache
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
T qvariant_cast(const QVariant &)
const_iterator constFind(const Key &key) const
Returns an const iterator pointing to the item with key key in the map.
int size() const
Returns the number of bytes in this byte array.
int y() const
Returns the y coordinate of this point.
static Format registerFormat(const QString &extension, ReadFunc readFunc, WriteFunc writeFunc, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)
Registers a custom storage format.
static int pathHashKey(QSettings::Format format, QSettings::Scope scope)
void remove(const QString &key)
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permission for the file.
QScopedPointer< QObjectData > d_ptr
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
iterator upperBound(const Key &key)
Returns an iterator pointing to the item that immediately follows the last item with key key in the m...
QSettingsIniKey(const QString &str, int pos=-1)
static bool readIniLine(const QByteArray &data, int &dataPos, int &lineStart, int &lineLen, int &equalsPos)
#define CSIDL_COMMON_APPDATA
The QSize class defines the size of a two-dimensional object using integer point precision.
static void iniEscapedString(const QString &str, QByteArray &result, QTextCodec *codec)
The QDataStream class provides serialization of binary data to a QIODevice.
QStack< QSettingsGroup > groupStack
bool writeIniFile(QIODevice &device, const ParsedSettingsMap &map)
iterator lowerBound(const Key &key)
Returns an iterator pointing to the first item with key key in the map.
void reserve(int size)
Attempts to allocate memory for at least size elements.
int x() const
Returns the x coordinate of this point.
static QVariant stringToVariant(const QString &s)
static void setSystemIniPath(const QString &dir)
Use setPath() instead.
static QString normalizedKey(const QString &key)
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Q_CORE_EXPORT int qstricmp(const char *, const char *)
The QTextCodec class provides conversions between text encodings.
T value() const
Returns the stored value converted to the template type T.
char at(int i) const
Returns the character at index position i in the byte array.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
The QFileInfo class provides system-independent file information.
QString applicationName() const
Returns the application name used for storing the settings.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
static const KeyPair *const end
void beginWriteArray(const QString &prefix, int size=-1)
Adds prefix to the current group and starts writing an array of size size.
The QIODevice class is the base interface class of all I/O devices in Qt.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
bool seek(qint64 offset)
For random-access devices, this function sets the current position to pos, returning true on success...
static QString windowsConfigPath(int type)
#define Q_AUTOTEST_EXPORT_HELPER
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
bool get(const QString &key, QVariant *value) const
static void processChild(QString key, ChildSpec spec, QMap< QString, QString > &result)
int size() const
Returns the number of items in the vector.
QString absolutePath() const
Returns a file's path absolute path.
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static void setDefaultFormat(Format format)
void clear()
Removes all items from the map.
static bool iniUnescapedKey(const QByteArray &key, int from, int to, QString &result)
QScopedSharedPointer< QConfFile > confFiles[NumConfFiles]
static void iniEscapedStringList(const QStringList &strs, QByteArray &result, QTextCodec *codec)
static bool readIniFile(const QByteArray &data, UnparsedSettingsMap *unparsedIniSections)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
friend class const_iterator
void setFallbacksEnabled(bool b)
Sets whether fallbacks are enabled to b.
QByteArray & insert(int i, char c)
Inserts character ch at index position i in the byte array.
static QString homePath()
Returns the absolute path of the user's home directory.
QDateTime lastModified() const
Returns the date and time when the file was last modified.
bool fallbacksEnabled() const
Returns true if fallbacks are enabled; returns false otherwise.