Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsettings.cpp File Reference
#include <qdebug.h>
#include "qplatformdefs.h"
#include "qsettings.h"
#include "qsettings_p.h"
#include "qcache.h"
#include "qfile.h"
#include "qdir.h"
#include "qfileinfo.h"
#include "qmutex.h"
#include "private/qlocking_p.h"
#include "private/qtools_p.h"
#include "qlibraryinfo.h"
#include "qtemporaryfile.h"
#include "qstandardpaths.h"
#include <qdatastream.h>
#include "private/qstringconverter_p.h"
#include "qsize.h"
#include "qpoint.h"
#include "qrect.h"
#include "qcoreapplication.h"
#include "qsavefile.h"
#include "qlockfile.h"
#include <algorithm>
#include <stdlib.h>
#include "moc_qsettings.cpp"
+ Include dependency graph for qsettings.cpp:

Go to the source code of this file.

Classes

struct  QConfFileCustomFormat
 
class  QSettingsIniKey
 
struct  QSettingsIniSection
 

Macros

#define FLUSH_CURRENT_SECTION()
 

Typedefs

typedef QHash< QString, QConfFile * > ConfFileHash
 
typedef QCache< QString, QConfFileConfFileCache
 
typedef QHash< int, Path > PathHash
 
typedef QList< QConfFileCustomFormatCustomFormatVector
 
typedef QMap< QSettingsIniKey, QVariantIniKeyMap
 
typedef QMap< QString, QSettingsIniSectionIniMap
 

Enumerations

enum  { Space = 0x1 , Special = 0x2 }
 

Functions

 Q_DECLARE_TYPEINFO (QConfFileCustomFormat, Q_RELOCATABLE_TYPE)
 
static void iniChopTrailingSpaces (QString &str, qsizetype limit)
 
static int pathHashKey (QSettings::Format format, QSettings::Scope scope)
 
static QString make_user_path_without_qstandard_paths ()
 
static QString make_user_path ()
 
static std::unique_lock< QBasicMutexinitDefaultPaths (std::unique_lock< QBasicMutex > locker)
 
static Path getPath (QSettings::Format format, QSettings::Scope scope)
 
 Q_DECLARE_TYPEINFO (QSettingsIniKey, Q_RELOCATABLE_TYPE)
 
static bool operator< (const QSettingsIniKey &k1, const QSettingsIniKey &k2)
 
 Q_DECLARE_TYPEINFO (QSettingsIniSection, Q_RELOCATABLE_TYPE)
 

Variables

static Q_CONSTINIT QBasicMutex settingsGlobalMutex
 
static Q_CONSTINIT QSettings::Format globalDefaultFormat = QSettings::NativeFormat
 
static constexpr QChar sep = u'/'
 
static const char charTraits [256]
 

Macro Definition Documentation

◆ FLUSH_CURRENT_SECTION

#define FLUSH_CURRENT_SECTION ( )
Value:
{ \
QByteArray &sectionData = (*unparsedIniSections)[QSettingsKey(currentSection, \
sectionPosition)]; \
if (!sectionData.isEmpty()) \
sectionData.append('\n'); \
sectionData += data.first(lineStart).sliced(currentSectionStart); \
sectionPosition = ++position; \
}
\inmodule QtCore
Definition qbytearray.h:57
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:106
QByteArray sliced(qsizetype pos) const
Definition qbytearray.h:163
QByteArray first(qsizetype n) const
Definition qbytearray.h:159
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static const Qt::CaseSensitivity IniCaseSensitivity
Definition qsettings_p.h:42

Typedef Documentation

◆ ConfFileCache

Definition at line 81 of file qsettings.cpp.

◆ ConfFileHash

Definition at line 80 of file qsettings.cpp.

◆ CustomFormatVector

Definition at line 94 of file qsettings.cpp.

◆ IniKeyMap

Definition at line 1728 of file qsettings.cpp.

◆ IniMap

Definition at line 1740 of file qsettings.cpp.

◆ PathHash

typedef QHash<int, Path> PathHash

Definition at line 93 of file qsettings.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
Space 
Special 

Definition at line 1493 of file qsettings.cpp.

Function Documentation

◆ getPath()

static Path getPath ( QSettings::Format  format,
QSettings::Scope  scope 
)
static

Definition at line 1028 of file qsettings.cpp.

References QSettings::IniFormat, initDefaultPaths(), QHash< Key, T >::isEmpty(), QSettings::NativeFormat, pathHashKey(), Q_ASSERT, settingsGlobalMutex, and QHash< Key, T >::value().

Referenced by QConfFileSettingsPrivate::QConfFileSettingsPrivate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iniChopTrailingSpaces()

static void iniChopTrailingSpaces ( QString str,
qsizetype  limit 
)
inlinestatic

Definition at line 668 of file qsettings.cpp.

References QString::at(), ch, QString::size(), str, and QString::truncate().

Referenced by QSettingsPrivate::iniUnescapedStringList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDefaultPaths()

static std::unique_lock< QBasicMutex > initDefaultPaths ( std::unique_lock< QBasicMutex locker)
static

Definition at line 986 of file qsettings.cpp.

References QSettings::IniFormat, QHash< Key, T >::insert(), QHash< Key, T >::isEmpty(), make_user_path(), QSettings::NativeFormat, QLibraryInfo::path(), pathHashKey(), QDir::separator(), QLibraryInfo::SettingsPath, QSettings::SystemScope, and QSettings::UserScope.

Referenced by getPath(), and QSettings::setPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_user_path()

static QString make_user_path ( )
static

Definition at line 962 of file qsettings.cpp.

References QStandardPaths::GenericConfigLocation, make_user_path_without_qstandard_paths(), ret, sep, and QStandardPaths::writableLocation().

Referenced by initDefaultPaths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_user_path_without_qstandard_paths()

static QString make_user_path_without_qstandard_paths ( )
static

Definition at line 949 of file qsettings.cpp.

References QFile::decodeName(), QDir::homePath(), QByteArray::isEmpty(), qgetenv(), sep, and QByteArray::startsWith().

Referenced by make_user_path().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<()

static bool operator< ( const QSettingsIniKey k1,
const QSettingsIniKey k2 
)
static

Definition at line 1721 of file qsettings.cpp.

References k1, and QSettingsIniKey::position.

Referenced by QT6_ONLY().

+ Here is the caller graph for this function:

◆ pathHashKey()

static int pathHashKey ( QSettings::Format  format,
QSettings::Scope  scope 
)
inlinestatic

Definition at line 940 of file qsettings.cpp.

References QSettings::SystemScope.

Referenced by getPath(), initDefaultPaths(), and QSettings::setPath().

+ Here is the caller graph for this function:

◆ Q_DECLARE_TYPEINFO() [1/3]

Q_DECLARE_TYPEINFO ( QConfFileCustomFormat  ,
Q_RELOCATABLE_TYPE   
)

◆ Q_DECLARE_TYPEINFO() [2/3]

Q_DECLARE_TYPEINFO ( QSettingsIniKey  ,
Q_RELOCATABLE_TYPE   
)

◆ Q_DECLARE_TYPEINFO() [3/3]

Q_DECLARE_TYPEINFO ( QSettingsIniSection  ,
Q_RELOCATABLE_TYPE   
)

Variable Documentation

◆ charTraits

const char charTraits[256]
static
Initial value:
=
{
0, 0, 0, 0, 0, 0, 0, 0, 0, Space, Space | Special, 0, 0, Space | Special, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Space, 0, Special, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Special, 0, Special, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Special, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
@ Space
@ Special

Definition at line 1495 of file qsettings.cpp.

Referenced by QConfFileSettingsPrivate::readIniLine().

◆ globalDefaultFormat

Q_CONSTINIT QSettings::Format globalDefaultFormat = QSettings::NativeFormat
static

Definition at line 103 of file qsettings.cpp.

Referenced by QSettings::defaultFormat(), and QSettings::setDefaultFormat().

◆ sep

◆ settingsGlobalMutex