summaryrefslogtreecommitdiff
path: root/src/common/fqterm_config.h
blob: 4884920c64c2fe53d8abb994e6701206dada5b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: GPL-2.0-or-later

#ifndef FQTERM_CFG_H
#define FQTERM_CFG_H

#include <QTextStream>
#include <QMap>
#include <QObject>

namespace FQTerm {
typedef QMap<QString, QString> Section;
typedef QMap<QString, Section> StrSecMap;

class FQTermConfig {
 private:
  StrSecMap data;
  bool loadFromStream(QTextStream &);
  bool saveToStream(QTextStream &);

  bool addSection(const QString &sectionName);
 public:
  FQTermConfig(const QString &fileName);
  ~FQTermConfig();

  bool load(const QString &filename);
  bool save(const QString &fileName);

  bool setItemValue(const QString &sectionName, const QString &itemName,
                    const QString &itemValue);
  
  QString getItemValue(const QString &sectionName,
                       const QString &itemName) const;

  bool deleteItem(const QString &sectionName, const QString &itemName);
  bool deleteSection(const QString &sectionName);

  bool renameSection(const QString &sectionName, const QString &newName);
  bool hasSection(const QString &sectionName) const;
};

}  // namespace FQTerm

#endif  // FQTERM_CFG_H