File indexing completed on 2024-05-12 03:54:26
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton <kde.braxton@gmail.com> 0004 SPDX-FileCopyrightText: 1999 Preston Brown <pbrown@kde.org> 0005 SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <kalle@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef KCONFIGINI_P_H 0011 #define KCONFIGINI_P_H 0012 0013 #include <kconfigbackend_p.h> 0014 #include <kconfigcore_export.h> 0015 #include <QMutex> 0016 0017 class QLockFile; 0018 class QIODevice; 0019 0020 class KConfigIniBackend : public KConfigBackend 0021 { 0022 Q_OBJECT 0023 private: 0024 QLockFile *lockFile; 0025 QMutex m_mutex; 0026 0027 public: 0028 class BufferFragment; 0029 0030 KConfigIniBackend(); 0031 ~KConfigIniBackend() override; 0032 0033 ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options) override; 0034 ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options, bool merging); 0035 bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) override; 0036 0037 bool isWritable() const override; 0038 QString nonWritableErrorMessage() const override; 0039 KConfigBase::AccessMode accessMode() const override; 0040 void createEnclosing() override; 0041 void setFilePath(const QString &path) override; 0042 bool lock() override; 0043 void unlock() override; 0044 bool isLocked() const override; 0045 0046 protected: 0047 enum StringType { 0048 GroupString = 0, 0049 KeyString = 1, 0050 ValueString = 2, 0051 }; 0052 // Warning: this modifies data in-place. Other BufferFragment objects referencing the same buffer 0053 // fragment will get their data modified too. 0054 static void printableToString(BufferFragment *aString, const QFile &file, int line); 0055 static QByteArray stringToPrintable(const QByteArray &aString, StringType type); 0056 static char charFromHex(const char *str, const QFile &file, int line); 0057 static QString warningProlog(const QFile &file, int line); 0058 0059 void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map); 0060 void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry); 0061 }; 0062 0063 #endif // KCONFIGINI_P_H