7#include <QtCore/qhash.h>
12template <
class Key,
class T>
19 Value()
noexcept =
default;
20 Value(T *tt, qsizetype c)
noexcept
23 Value(Value &&other)
noexcept
29 Value &operator=(Value &&other)
noexcept
31 qt_ptr_swap(t, other.t);
32 std::swap(cost, other.cost);
35 ~Value() {
delete t; }
43 Chain()
noexcept : prev(
this), next(
this) { }
48 struct Node :
public Chain
51 using ValueType = Value;
56 Node(
const Key &k, Value &&t)
noexcept(std::is_nothrow_move_assignable_v<Key>)
62 Node(Key &&k, Value &&t)
noexcept(std::is_nothrow_move_assignable_v<Key>)
68 static void createInPlace(Node *n,
const Key &k, T *o, qsizetype cost)
70 new (n) Node{ Key(k), Value(o, cost) };
72 void emplace(T *o, qsizetype cost)
74 value = Value(o, cost);
79 key(std::move(other.key)),
80 value(std::move(other.value))
84 this->prev->next =
this;
85 this->next->prev =
this;
91 using Data = QHashPrivate::Data<Node>;
98 void unlink(Node *n)
noexcept(std::is_nothrow_destructible_v<Node>)
102 n->prev->next = n->next;
103 n->next->prev = n->prev;
104 total -= n->value.cost;
105 auto it = d.findBucket(n->key);
108 T *relink(
const Key &key)
const noexcept
112 Node *n = d.findNode(key);
116 if (chain.next != n) {
119 n->prev->next = n->next;
120 n->next->prev = n->prev;
121 n->next = chain.next;
122 chain.next->prev = n;
129 void trim(qsizetype m)
noexcept(std::is_nothrow_destructible_v<Node>)
131 while (chain.prev != &chain && total > m) {
132 Node *n =
static_cast<Node *>(chain.prev);
138 Q_DISABLE_COPY(QCache)
141 inline explicit QCache(qsizetype maxCost = 100)
noexcept
147 static_assert(std::is_nothrow_destructible_v<Key>,
"Types with throwing destructors are not supported in Qt containers.");
148 static_assert(std::is_nothrow_destructible_v<T>,
"Types with throwing destructors are not supported in Qt containers.");
153 inline qsizetype maxCost()
const noexcept {
return mx; }
154 void setMaxCost(qsizetype m)
noexcept(std::is_nothrow_destructible_v<Node>)
159 inline qsizetype totalCost()
const noexcept {
return total; }
161 inline qsizetype size()
const noexcept {
return qsizetype(d.size); }
162 inline qsizetype count()
const noexcept {
return qsizetype(d.size); }
163 inline bool isEmpty()
const noexcept {
return !d.size; }
164 inline QList<Key> keys()
const
169 for (
auto it = d.begin(); it != d.end(); ++it)
172 Q_ASSERT(k.size() == size());
176 void clear()
noexcept(std::is_nothrow_destructible_v<Node>)
184 bool insert(
const Key &key, T *object, qsizetype cost = 1)
192 auto result = d.findOrInsert(key);
193 Node *n = result.it.node();
194 if (result.initialized) {
195 auto prevCost = n->value.cost;
196 result.it.node()->emplace(object, cost);
200 Node::createInPlace(n, key, object, cost);
202 n->next = chain.next;
203 chain.next->prev = n;
209 T *object(
const Key &key)
const noexcept
213 T *operator[](
const Key &key)
const noexcept
217 inline bool contains(
const Key &key)
const noexcept
219 return !isEmpty() && d.findNode(key) !=
nullptr;
222 bool remove(
const Key &key)
noexcept(std::is_nothrow_destructible_v<Node>)
226 Node *n = d.findNode(key);
235 T *take(
const Key &key)
noexcept(std::is_nothrow_destructible_v<Key>)
239 Node *n = d.findNode(key);
244 n->value.t =
nullptr;
static bool readIniSection(const QSettingsKey §ion, QByteArrayView data, ParsedSettingsMap *settingsMap)
void set(const QString &key, const QVariant &value) override
QStringList children(const QString &prefix, ChildSpec spec) const 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
QConfFileSettingsPrivate(const QString &fileName, QSettings::Format format)
const QList< QConfFile * > & getConfFiles() const
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
QSettingsGroup(const QString &s, bool guessArraySize)
qsizetype arraySizeGuess() const
QSettingsGroup(const QString &s)
void setArrayIndex(qsizetype i)
QSettingsIniKey(const QString &str, qsizetype pos=-1)
QSettingsKey(const QString &key, Qt::CaseSensitivity cs, qsizetype=-1)
QString originalCaseKey() const
qsizetype originalKeyPosition() const
Combined button and popup list for selecting options.
static const char charTraits[256]
QMap< QString, QSettingsIniSection > IniMap
QList< QConfFileCustomFormat > CustomFormatVector
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
static constexpr QChar sep
static Path getPath(QSettings::Format format, QSettings::Scope scope)
QMap< QSettingsIniKey, QVariant > IniKeyMap
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()
QHash< QString, QConfFile * > ConfFileHash
QHash< int, Path > PathHash
Q_DECLARE_TYPEINFO(QSettingsIniSection, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QConfFileCustomFormat, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QSettingsIniKey, Q_RELOCATABLE_TYPE)
QCache< QString, QConfFile > ConfFileCache
#define FLUSH_CURRENT_SECTION()
static void iniChopTrailingSpaces(QString &str, qsizetype limit)
Q_DECLARE_TYPEINFO(QSettingsGroup, Q_RELOCATABLE_TYPE)
static const Qt::CaseSensitivity IniCaseSensitivity
Q_DECLARE_TYPEINFO(QSettingsKey, Q_RELOCATABLE_TYPE)
QMap< QSettingsKey, QByteArray > UnparsedSettingsMap
QMap< QSettingsKey, QVariant > ParsedSettingsMap
#define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
QSettings settings("MySoft", "Star Runner")
[0]