1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton <kde.braxton@gmail.com>
4 SPDX-FileCopyrightText: 1999 Preston Brown <pbrown@kde.org>
5 SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <kalle@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef KCONFIGINI_P_H
11#define KCONFIGINI_P_H
12
13#include <kconfigbackend_p.h>
14#include <kconfigcore_export.h>
15#include <QMutex>
16
17class QLockFile;
18class QIODevice;
19
20class KConfigIniBackend : public KConfigBackend
21{
22 Q_OBJECT
23private:
24 QLockFile *lockFile;
25 QMutex m_mutex;
26
27public:
28 class BufferFragment;
29
30 KConfigIniBackend();
31 ~KConfigIniBackend() override;
32
33 ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options) override;
34 ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options, bool merging);
35 bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) override;
36
37 bool isWritable() const override;
38 QString nonWritableErrorMessage() const override;
39 KConfigBase::AccessMode accessMode() const override;
40 void createEnclosing() override;
41 void setFilePath(const QString &path) override;
42 bool lock() override;
43 void unlock() override;
44 bool isLocked() const override;
45
46protected:
47 enum StringType {
48 GroupString = 0,
49 KeyString = 1,
50 ValueString = 2,
51 };
52 // Warning: this modifies data in-place. Other BufferFragment objects referencing the same buffer
53 // fragment will get their data modified too.
54 static void printableToString(BufferFragment *aString, const QFile &file, int line);
55 static QByteArray stringToPrintable(const QByteArray &aString, StringType type);
56 static char charFromHex(const char *str, const QFile &file, int line);
57 static QString warningProlog(const QFile &file, int line);
58
59 void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map);
60 void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry);
61};
62
63#endif // KCONFIGINI_P_H
64

source code of kconfig/src/core/kconfigini_p.h