From 163cebc7065cd85650f45e93203b3ea8dd82f652 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 15 Apr 2021 12:02:09 +0200 Subject: KConfig: rename kconfigdata.h to kconfigdata_p.h It's internal, the symbols are not exported, the header is not installed. The _p.h naming makes this more obvious, when grepping for stuff in public API. --- src/core/kconfig_p.h | 2 +- src/core/kconfigbackend.cpp | 2 +- src/core/kconfigdata.cpp | 2 +- src/core/kconfigdata.h | 253 -------------------------------------------- src/core/kconfigdata_p.h | 253 ++++++++++++++++++++++++++++++++++++++++++++ src/core/kconfiggroup.cpp | 2 +- src/core/kconfigini.cpp | 2 +- 7 files changed, 258 insertions(+), 258 deletions(-) delete mode 100644 src/core/kconfigdata.h create mode 100644 src/core/kconfigdata_p.h (limited to 'src') diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h index b201df17..e5c9d869 100644 --- a/src/core/kconfig_p.h +++ b/src/core/kconfig_p.h @@ -12,7 +12,7 @@ #define KCONFIG_P_H #include "kconfigbackend_p.h" -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include "kconfiggroup.h" #include diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp index 13455dbd..6a5984a3 100644 --- a/src/core/kconfigbackend.cpp +++ b/src/core/kconfigbackend.cpp @@ -16,7 +16,7 @@ #include #include -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include "kconfigini_p.h" typedef QExplicitlySharedDataPointer BackendPtr; diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index ada7125f..b479a598 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -7,7 +7,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include +#include "kconfigdata_p.h" QDebug operator<<(QDebug dbg, const KEntryKey &key) { diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h deleted file mode 100644 index 0ca228fe..00000000 --- a/src/core/kconfigdata.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - This file is part of the KDE libraries - SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton - SPDX-FileCopyrightText: 1999-2000 Preston Brown - SPDX-FileCopyrightText: 1996-2000 Matthias Kalle Dalheimer - - SPDX-License-Identifier: LGPL-2.0-or-later -*/ - -#ifndef KCONFIGDATA_H -#define KCONFIGDATA_H - -#include -#include -#include -#include - -/** - * map/dict/list config node entry. - * @internal - */ -struct KEntry { - /** Constructor. @internal */ - KEntry() - : mValue() - , bDirty(false) - , bGlobal(false) - , bImmutable(false) - , bDeleted(false) - , bExpand(false) - , bReverted(false) - , bLocalizedCountry(false) - , bNotify(false) - , bOverridesGlobal(false) - { - } - /** @internal */ - QByteArray mValue; - /** - * Must the entry be written back to disk? - */ - bool bDirty : 1; - /** - * Entry should be written to the global config file - */ - bool bGlobal : 1; - /** - * Entry can not be modified. - */ - bool bImmutable : 1; - /** - * Entry has been deleted. - */ - bool bDeleted : 1; - /** - * Whether to apply dollar expansion or not. - */ - bool bExpand : 1; - /** - * Entry has been reverted to its default value (from a more global file). - */ - bool bReverted : 1; - /** - * Entry is for a localized key. If @c false the value references just language e.g. "de", - * if @c true the value references language and country, e.g. "de_DE". - **/ - bool bLocalizedCountry : 1; - - bool bNotify : 1; - - /** - * Entry will need to be written on a non global file even if it matches default value - */ - bool bOverridesGlobal : 1; -}; - -// These operators are used to check whether an entry which is about -// to be written equals the previous value. As such, this intentionally -// omits the dirty/notify flag from the comparison. -inline bool operator==(const KEntry &k1, const KEntry &k2) -{ - /* clang-format off */ - return k1.bGlobal == k2.bGlobal - && k1.bImmutable == k2.bImmutable - && k1.bDeleted == k2.bDeleted - && k1.bExpand == k2.bExpand - && k1.mValue == k2.mValue; - /* clang-format on */ -} - -inline bool operator!=(const KEntry &k1, const KEntry &k2) -{ - return !(k1 == k2); -} - -/** - * key structure holding both the actual key and the group - * to which it belongs. - * @internal - */ -struct KEntryKey { - /** Constructor. @internal */ - KEntryKey(const QByteArray &_group = QByteArray(), const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false) - : mGroup(_group) - , mKey(_key) - , bLocal(isLocalized) - , bDefault(isDefault) - , bRaw(false) - { - ; - } - /** - * The "group" to which this EntryKey belongs - */ - QByteArray mGroup; - /** - * The _actual_ key of the entry in question - */ - QByteArray mKey; - /** - * Entry is localised or not - */ - bool bLocal : 1; - /** - * Entry indicates if this is a default value. - */ - bool bDefault : 1; - /** @internal - * Key is a raw unprocessed key. - * @warning this should only be set during merging, never for normal use. - */ - bool bRaw : 1; -}; - -/** - * Compares two KEntryKeys (needed for QMap). The order is localized, localized-default, - * non-localized, non-localized-default - * @internal - */ -inline bool operator<(const KEntryKey &k1, const KEntryKey &k2) -{ - int result = qstrcmp(k1.mGroup.data(), k2.mGroup.data()); - if (result != 0) { - return result < 0; - } - - result = qstrcmp(k1.mKey.data(), k2.mKey.data()); - if (result != 0) { - return result < 0; - } - - if (k1.bLocal != k2.bLocal) { - return k1.bLocal; - } - return (!k1.bDefault && k2.bDefault); -} - -QDebug operator<<(QDebug dbg, const KEntryKey &key); -QDebug operator<<(QDebug dbg, const KEntry &entry); - -/** - * \relates KEntry - * type specifying a map of entries (key,value pairs). - * The keys are actually a key in a particular config file group together - * with the group name. - * @internal - */ -class KEntryMap : public QMap -{ -public: - enum SearchFlag { - SearchDefaults = 1, - SearchLocalized = 2, - }; - Q_DECLARE_FLAGS(SearchFlags, SearchFlag) - - enum EntryOption { - EntryDirty = 1, - EntryGlobal = 2, - EntryImmutable = 4, - EntryDeleted = 8, - EntryExpansion = 16, - EntryRawKey = 32, - EntryLocalizedCountry = 64, - EntryNotify = 128, - EntryDefault = (SearchDefaults << 16), - EntryLocalized = (SearchLocalized << 16), - }; - Q_DECLARE_FLAGS(EntryOptions, EntryOption) - - Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); - - Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); - - ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const - { - return constFindEntry(group, key, flags); - } - - ConstIterator constFindEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; - - /** - * Returns true if the entry gets dirtied or false in other case - */ - bool setEntry(const QByteArray &group, const QByteArray &key, const QByteArray &value, EntryOptions options); - - void setEntry(const QByteArray &group, const QByteArray &key, const QString &value, EntryOptions options) - { - setEntry(group, key, value.toUtf8(), options); - } - - QString getEntry(const QByteArray &group, - const QByteArray &key, - const QString &defaultValue = QString(), - SearchFlags flags = SearchFlags(), - bool *expand = nullptr) const; - - bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; - - bool getEntryOption(const ConstIterator &it, EntryOption option) const; - bool getEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option) const - { - return getEntryOption(findEntry(group, key, flags), option); - } - - void setEntryOption(Iterator it, EntryOption option, bool bf); - void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option, bool bf) - { - setEntryOption(findEntry(group, key, flags), option, bf); - } - - bool revertEntry(const QByteArray &group, const QByteArray &key, EntryOptions options, SearchFlags flags = SearchFlags()); -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::SearchFlags) -Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::EntryOptions) - -/** - * \relates KEntry - * type for iterating over keys in a KEntryMap in sorted order. - * @internal - */ -typedef QMap::Iterator KEntryMapIterator; - -/** - * \relates KEntry - * type for iterating over keys in a KEntryMap in sorted order. - * It is const, thus you cannot change the entries in the iterator, - * only examine them. - * @internal - */ -typedef QMap::ConstIterator KEntryMapConstIterator; - -#endif diff --git a/src/core/kconfigdata_p.h b/src/core/kconfigdata_p.h new file mode 100644 index 00000000..3554568e --- /dev/null +++ b/src/core/kconfigdata_p.h @@ -0,0 +1,253 @@ +/* + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999-2000 Preston Brown + SPDX-FileCopyrightText: 1996-2000 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#ifndef KCONFIGDATA_P_H +#define KCONFIGDATA_P_H + +#include +#include +#include +#include + +/** + * map/dict/list config node entry. + * @internal + */ +struct KEntry { + /** Constructor. @internal */ + KEntry() + : mValue() + , bDirty(false) + , bGlobal(false) + , bImmutable(false) + , bDeleted(false) + , bExpand(false) + , bReverted(false) + , bLocalizedCountry(false) + , bNotify(false) + , bOverridesGlobal(false) + { + } + /** @internal */ + QByteArray mValue; + /** + * Must the entry be written back to disk? + */ + bool bDirty : 1; + /** + * Entry should be written to the global config file + */ + bool bGlobal : 1; + /** + * Entry can not be modified. + */ + bool bImmutable : 1; + /** + * Entry has been deleted. + */ + bool bDeleted : 1; + /** + * Whether to apply dollar expansion or not. + */ + bool bExpand : 1; + /** + * Entry has been reverted to its default value (from a more global file). + */ + bool bReverted : 1; + /** + * Entry is for a localized key. If @c false the value references just language e.g. "de", + * if @c true the value references language and country, e.g. "de_DE". + **/ + bool bLocalizedCountry : 1; + + bool bNotify : 1; + + /** + * Entry will need to be written on a non global file even if it matches default value + */ + bool bOverridesGlobal : 1; +}; + +// These operators are used to check whether an entry which is about +// to be written equals the previous value. As such, this intentionally +// omits the dirty/notify flag from the comparison. +inline bool operator==(const KEntry &k1, const KEntry &k2) +{ + /* clang-format off */ + return k1.bGlobal == k2.bGlobal + && k1.bImmutable == k2.bImmutable + && k1.bDeleted == k2.bDeleted + && k1.bExpand == k2.bExpand + && k1.mValue == k2.mValue; + /* clang-format on */ +} + +inline bool operator!=(const KEntry &k1, const KEntry &k2) +{ + return !(k1 == k2); +} + +/** + * key structure holding both the actual key and the group + * to which it belongs. + * @internal + */ +struct KEntryKey { + /** Constructor. @internal */ + KEntryKey(const QByteArray &_group = QByteArray(), const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false) + : mGroup(_group) + , mKey(_key) + , bLocal(isLocalized) + , bDefault(isDefault) + , bRaw(false) + { + ; + } + /** + * The "group" to which this EntryKey belongs + */ + QByteArray mGroup; + /** + * The _actual_ key of the entry in question + */ + QByteArray mKey; + /** + * Entry is localised or not + */ + bool bLocal : 1; + /** + * Entry indicates if this is a default value. + */ + bool bDefault : 1; + /** @internal + * Key is a raw unprocessed key. + * @warning this should only be set during merging, never for normal use. + */ + bool bRaw : 1; +}; + +/** + * Compares two KEntryKeys (needed for QMap). The order is localized, localized-default, + * non-localized, non-localized-default + * @internal + */ +inline bool operator<(const KEntryKey &k1, const KEntryKey &k2) +{ + int result = qstrcmp(k1.mGroup.data(), k2.mGroup.data()); + if (result != 0) { + return result < 0; + } + + result = qstrcmp(k1.mKey.data(), k2.mKey.data()); + if (result != 0) { + return result < 0; + } + + if (k1.bLocal != k2.bLocal) { + return k1.bLocal; + } + return (!k1.bDefault && k2.bDefault); +} + +QDebug operator<<(QDebug dbg, const KEntryKey &key); +QDebug operator<<(QDebug dbg, const KEntry &entry); + +/** + * \relates KEntry + * type specifying a map of entries (key,value pairs). + * The keys are actually a key in a particular config file group together + * with the group name. + * @internal + */ +class KEntryMap : public QMap +{ +public: + enum SearchFlag { + SearchDefaults = 1, + SearchLocalized = 2, + }; + Q_DECLARE_FLAGS(SearchFlags, SearchFlag) + + enum EntryOption { + EntryDirty = 1, + EntryGlobal = 2, + EntryImmutable = 4, + EntryDeleted = 8, + EntryExpansion = 16, + EntryRawKey = 32, + EntryLocalizedCountry = 64, + EntryNotify = 128, + EntryDefault = (SearchDefaults << 16), + EntryLocalized = (SearchLocalized << 16), + }; + Q_DECLARE_FLAGS(EntryOptions, EntryOption) + + Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); + + Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); + + ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const + { + return constFindEntry(group, key, flags); + } + + ConstIterator constFindEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; + + /** + * Returns true if the entry gets dirtied or false in other case + */ + bool setEntry(const QByteArray &group, const QByteArray &key, const QByteArray &value, EntryOptions options); + + void setEntry(const QByteArray &group, const QByteArray &key, const QString &value, EntryOptions options) + { + setEntry(group, key, value.toUtf8(), options); + } + + QString getEntry(const QByteArray &group, + const QByteArray &key, + const QString &defaultValue = QString(), + SearchFlags flags = SearchFlags(), + bool *expand = nullptr) const; + + bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; + + bool getEntryOption(const ConstIterator &it, EntryOption option) const; + bool getEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option) const + { + return getEntryOption(findEntry(group, key, flags), option); + } + + void setEntryOption(Iterator it, EntryOption option, bool bf); + void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option, bool bf) + { + setEntryOption(findEntry(group, key, flags), option, bf); + } + + bool revertEntry(const QByteArray &group, const QByteArray &key, EntryOptions options, SearchFlags flags = SearchFlags()); +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::SearchFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::EntryOptions) + +/** + * \relates KEntry + * type for iterating over keys in a KEntryMap in sorted order. + * @internal + */ +typedef QMap::Iterator KEntryMapIterator; + +/** + * \relates KEntry + * type for iterating over keys in a KEntryMap in sorted order. + * It is const, thus you cannot change the entries in the iterator, + * only examine them. + * @internal + */ +typedef QMap::ConstIterator KEntryMapConstIterator; + +#endif diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index c065be81..5ee9f6ab 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -13,7 +13,7 @@ #include "kconfig.h" #include "kconfig_core_log_settings.h" #include "kconfig_p.h" -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include "ksharedconfig.h" #include diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 8c81db8f..c7861f66 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -13,7 +13,7 @@ #include "kconfig.h" #include "kconfig_core_log_settings.h" #include "kconfigbackend_p.h" -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include #include -- cgit v1.2.1