From c5be11a789837095f587fadd684584b767e33ee9 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 15 Mar 2017 13:11:08 +0100 Subject: Now that kconfigbackend.h isn't installed anymore, rename it to _p.h for clarity. --- src/core/kconfig.cpp | 2 +- src/core/kconfig_p.h | 2 +- src/core/kconfigbackend.cpp | 2 +- src/core/kconfigbackend.h | 214 -------------------------------------------- src/core/kconfigbackend_p.h | 214 ++++++++++++++++++++++++++++++++++++++++++++ src/core/kconfigini.cpp | 2 +- src/core/kconfigini_p.h | 2 +- src/core/ksharedconfig.cpp | 2 +- 8 files changed, 220 insertions(+), 220 deletions(-) delete mode 100644 src/core/kconfigbackend.h create mode 100644 src/core/kconfigbackend_p.h (limited to 'src') diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index be09ca0a..aced218d 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -39,7 +39,7 @@ static inline int pclose(FILE *stream) #include #endif -#include "kconfigbackend.h" +#include "kconfigbackend_p.h" #include "kconfiggroup.h" #include diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h index beda6e4b..080adadb 100644 --- a/src/core/kconfig_p.h +++ b/src/core/kconfig_p.h @@ -25,7 +25,7 @@ #define KCONFIG_P_H #include "kconfigdata.h" -#include "kconfigbackend.h" +#include "kconfigbackend_p.h" #include "kconfiggroup.h" #include diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp index 32b43194..9d9fa47e 100644 --- a/src/core/kconfigbackend.cpp +++ b/src/core/kconfigbackend.cpp @@ -20,7 +20,7 @@ Boston, MA 02110-1301, USA. */ -#include "kconfigbackend.h" +#include "kconfigbackend_p.h" #include #include diff --git a/src/core/kconfigbackend.h b/src/core/kconfigbackend.h deleted file mode 100644 index 332a0b4e..00000000 --- a/src/core/kconfigbackend.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Portions copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KCONFIGBACKEND_H -#define KCONFIGBACKEND_H - -#include -#include -#include - -#include -#include -class KConfigBackendPrivate; - -class KEntryMap; -class QFile; -class QByteArray; -class QDateTime; - -/** - * \class KConfigBackend kconfigbackend.h - * - * Provides the implementation for accessing configuration sources. - * - * KConfig only provides an INI backend, but this class can be used - * to create plugins that allow access to other file formats and - * configuration systems. - * - * \internal - */ -class KConfigBackend : public QObject, public QSharedData -{ - Q_OBJECT - -public: - /** - * Creates a new KConfig backend. - * - * If no @p system is given, or the given @p system is unknown, this method tries - * to determine the correct backend to use. - * - * @param fileName the absolute file name of the configuration file - * @param system the configuration system to use - * @return a KConfigBackend object to be used with KConfig - */ - static QExplicitlySharedDataPointer create(const QString &fileName = QString(), - const QString &system = QString()); - - /** - * Registers mappings from directories/files to configuration systems - * - * Allows you to tell KConfigBackend that create() should use a particular - * backend for a particular file or directory. - * - * @warning currently does nothing - * - * @param entryMap the KEntryMap to build the mappings from - */ - static void registerMappings(const KEntryMap &entryMap); - - /** Destroys the backend */ - virtual ~KConfigBackend(); - - /** Allows the behaviour of parseConfig() to be tuned */ - enum ParseOption { - ParseGlobal = 1, /// entries should be marked as @em global - ParseDefaults = 2, /// entries should be marked as @em default - ParseExpansions = 4 /// entries are allowed to be marked as @em expandable - }; - Q_FLAG(ParseOption) - /// @typedef typedef QFlags ParseOptions - Q_DECLARE_FLAGS(ParseOptions, ParseOption) - - /** Allows the behaviour of writeConfig() to be tuned */ - enum WriteOption { - WriteGlobal = 1 /// only write entries marked as "global" - }; - Q_FLAG(WriteOption) - /// @typedef typedef QFlags WriteOptions - Q_DECLARE_FLAGS(WriteOptions, WriteOption) - - /** Return value from parseConfig() */ - enum ParseInfo { - ParseOk, /// the configuration was opened read/write - ParseImmutable, /// the configuration is @em immutable - ParseOpenError /// the configuration could not be opened - }; - - /** - * Read persistent storage - * - * @param locale the locale to read entries for (if the backend supports localized entries) - * @param pWriteBackMap the KEntryMap where the entries are placed - * @param options See ParseOptions - * @return See ParseInfo - */ - virtual ParseInfo parseConfig(const QByteArray &locale, - KEntryMap &pWriteBackMap, - ParseOptions options = ParseOptions()) = 0; - - /** - * Write the @em dirty entries to permanent storage - * - * @param locale the locale to write entries for (if the backend supports localized entries) - * @param entryMap the KEntryMap containing the config object's entries. - * @param options See WriteOptions - * - * @return @c true if the write was successful, @c false if writing the configuration failed - */ - virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, - WriteOptions options) = 0; - - /** - * If isWritable() returns false, writeConfig() will always fail. - * - * @return @c true if the configuration is writable, @c false if it is immutable - */ - virtual bool isWritable() const = 0; - /** - * When isWritable() returns @c false, return an error message to - * explain to the user why saving configuration will not work. - * - * The return value when isWritable() returns @c true is undefined. - * - * @returns a translated user-visible explanation for the configuration - * object not being writable - */ - virtual QString nonWritableErrorMessage() const = 0; - /** - * @return the read/write status of the configuration object - * - * @see KConfigBase::AccessMode - */ - virtual KConfigBase::AccessMode accessMode() const = 0; - /** - * Create the enclosing object of the configuration object - * - * For example, if the configuration object is a file, this should create - * the parent directory. - */ - virtual void createEnclosing() = 0; - - /** - * Set the file path. - * - * @note @p path @b MUST be @em absolute. - * - * @param path the absolute file path - */ - virtual void setFilePath(const QString &path) = 0; - - /** - * Lock the file - */ - virtual bool lock() = 0; - /** - * Release the lock on the file - */ - virtual void unlock() = 0; - /** - * @return @c true if the file is locked, @c false if it is not locked - */ - virtual bool isLocked() const = 0; - - /** - * @return the date and time when the object was last modified - */ - QDateTime lastModified() const; - /** @return the absolute path to the object */ - QString filePath() const; - /** @return the size of the object */ - qint64 size() const; - -protected: - KConfigBackend(); - void setLastModified(const QDateTime &dt); - void setSize(qint64 sz); - void setLocalFilePath(const QString &file); - -private: - KConfigBackendPrivate *const d; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::ParseOptions) -Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::WriteOptions) - -#if 0 // TODO re-enable if the plugin loading code is re-enabled -/** - * Register a KConfig backend when it is contained in a loadable module - */ -#define K_EXPORT_KCONFIGBACKEND(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) -#endif - -#endif // KCONFIGBACKEND_H diff --git a/src/core/kconfigbackend_p.h b/src/core/kconfigbackend_p.h new file mode 100644 index 00000000..0a63a687 --- /dev/null +++ b/src/core/kconfigbackend_p.h @@ -0,0 +1,214 @@ +/* + This file is part of the KDE libraries + Copyright (c) 2006, 2007 Thomas Braxton + Copyright (c) 1999 Preston Brown + Portions copyright (c) 1997 Matthias Kalle Dalheimer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KCONFIGBACKEND_H +#define KCONFIGBACKEND_H + +#include +#include +#include + +#include +#include +class KConfigBackendPrivate; + +class KEntryMap; +class QFile; +class QByteArray; +class QDateTime; + +/** + * \class KConfigBackend kconfigbackend_p.h + * + * Provides the implementation for accessing configuration sources. + * + * KConfig only provides an INI backend, but this class can be used + * to create plugins that allow access to other file formats and + * configuration systems. + * + * \internal + */ +class KConfigBackend : public QObject, public QSharedData +{ + Q_OBJECT + +public: + /** + * Creates a new KConfig backend. + * + * If no @p system is given, or the given @p system is unknown, this method tries + * to determine the correct backend to use. + * + * @param fileName the absolute file name of the configuration file + * @param system the configuration system to use + * @return a KConfigBackend object to be used with KConfig + */ + static QExplicitlySharedDataPointer create(const QString &fileName = QString(), + const QString &system = QString()); + + /** + * Registers mappings from directories/files to configuration systems + * + * Allows you to tell KConfigBackend that create() should use a particular + * backend for a particular file or directory. + * + * @warning currently does nothing + * + * @param entryMap the KEntryMap to build the mappings from + */ + static void registerMappings(const KEntryMap &entryMap); + + /** Destroys the backend */ + virtual ~KConfigBackend(); + + /** Allows the behaviour of parseConfig() to be tuned */ + enum ParseOption { + ParseGlobal = 1, /// entries should be marked as @em global + ParseDefaults = 2, /// entries should be marked as @em default + ParseExpansions = 4 /// entries are allowed to be marked as @em expandable + }; + Q_FLAG(ParseOption) + /// @typedef typedef QFlags ParseOptions + Q_DECLARE_FLAGS(ParseOptions, ParseOption) + + /** Allows the behaviour of writeConfig() to be tuned */ + enum WriteOption { + WriteGlobal = 1 /// only write entries marked as "global" + }; + Q_FLAG(WriteOption) + /// @typedef typedef QFlags WriteOptions + Q_DECLARE_FLAGS(WriteOptions, WriteOption) + + /** Return value from parseConfig() */ + enum ParseInfo { + ParseOk, /// the configuration was opened read/write + ParseImmutable, /// the configuration is @em immutable + ParseOpenError /// the configuration could not be opened + }; + + /** + * Read persistent storage + * + * @param locale the locale to read entries for (if the backend supports localized entries) + * @param pWriteBackMap the KEntryMap where the entries are placed + * @param options See ParseOptions + * @return See ParseInfo + */ + virtual ParseInfo parseConfig(const QByteArray &locale, + KEntryMap &pWriteBackMap, + ParseOptions options = ParseOptions()) = 0; + + /** + * Write the @em dirty entries to permanent storage + * + * @param locale the locale to write entries for (if the backend supports localized entries) + * @param entryMap the KEntryMap containing the config object's entries. + * @param options See WriteOptions + * + * @return @c true if the write was successful, @c false if writing the configuration failed + */ + virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, + WriteOptions options) = 0; + + /** + * If isWritable() returns false, writeConfig() will always fail. + * + * @return @c true if the configuration is writable, @c false if it is immutable + */ + virtual bool isWritable() const = 0; + /** + * When isWritable() returns @c false, return an error message to + * explain to the user why saving configuration will not work. + * + * The return value when isWritable() returns @c true is undefined. + * + * @returns a translated user-visible explanation for the configuration + * object not being writable + */ + virtual QString nonWritableErrorMessage() const = 0; + /** + * @return the read/write status of the configuration object + * + * @see KConfigBase::AccessMode + */ + virtual KConfigBase::AccessMode accessMode() const = 0; + /** + * Create the enclosing object of the configuration object + * + * For example, if the configuration object is a file, this should create + * the parent directory. + */ + virtual void createEnclosing() = 0; + + /** + * Set the file path. + * + * @note @p path @b MUST be @em absolute. + * + * @param path the absolute file path + */ + virtual void setFilePath(const QString &path) = 0; + + /** + * Lock the file + */ + virtual bool lock() = 0; + /** + * Release the lock on the file + */ + virtual void unlock() = 0; + /** + * @return @c true if the file is locked, @c false if it is not locked + */ + virtual bool isLocked() const = 0; + + /** + * @return the date and time when the object was last modified + */ + QDateTime lastModified() const; + /** @return the absolute path to the object */ + QString filePath() const; + /** @return the size of the object */ + qint64 size() const; + +protected: + KConfigBackend(); + void setLastModified(const QDateTime &dt); + void setSize(qint64 sz); + void setLocalFilePath(const QString &file); + +private: + KConfigBackendPrivate *const d; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::ParseOptions) +Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::WriteOptions) + +#if 0 // TODO re-enable if the plugin loading code is re-enabled +/** + * Register a KConfig backend when it is contained in a loadable module + */ +#define K_EXPORT_KCONFIGBACKEND(libname, classname) \ + K_PLUGIN_FACTORY(factory, registerPlugin();) +#endif + +#endif // KCONFIGBACKEND_H diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 85ece838..49ec150f 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -23,7 +23,7 @@ #include "kconfigini_p.h" #include "kconfig.h" -#include "kconfigbackend.h" +#include "kconfigbackend_p.h" #include "bufferfragment_p.h" #include "kconfigdata.h" diff --git a/src/core/kconfigini_p.h b/src/core/kconfigini_p.h index 47aa6fea..d633c048 100644 --- a/src/core/kconfigini_p.h +++ b/src/core/kconfigini_p.h @@ -24,7 +24,7 @@ #define KCONFIGINI_P_H #include -#include +#include class QLockFile; class QIODevice; diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index 8c9cad8d..52a2d23d 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -20,7 +20,7 @@ */ #include "ksharedconfig.h" -#include "kconfigbackend.h" +#include "kconfigbackend_p.h" #include "kconfiggroup.h" #include "kconfig_p.h" #include -- cgit v1.2.1