ini.h
1 //------------------------------------------------------------------------------
2 // ini.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __INI_H_
24 #define __INI_H_
25 
26 #include "dptr.h"
27 #include "global.h"
28 #include "ini/inisection.h"
29 #include "ini/inivariable.h"
30 #include <QString>
31 #include <QStringList>
32 #include <QVector>
33 
34 class SettingsProvider;
35 
69 class MAIN_EXPORT Ini : public QObject
70 {
71  Q_OBJECT
72 
73 public:
74  Ini(SettingsProvider *provider);
75  virtual ~Ini() override;
76 
82  IniVariable createSetting(const QString &sectionname, const QString &name, const QVariant &data);
83 
87  void deleteSection(const QString &sectionname);
88 
93  void deleteSetting(const QString &sectionname, const QString &settingname);
94 
101  bool hasSetting(const QString &sectionname, const QString &settingname) const;
102 
103  void removeKey(const QString &key);
104 
111  IniVariable retrieveSetting(const QString &sectionname, const QString &variablename);
112 
124  IniSection section(const QString &name);
125 
131  QVector<IniSection> sectionsArray(const QString &regexPattern);
132 
139  IniVariable setting(const QString &sectionname, const QString &variablename);
140 
141  void setValue(const QString &key, const QVariant &value);
142  QVariant value(const QString &key) const;
143 
144 private:
145  DPtr<Ini> d;
146 };
147 
148 #endif