-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigFile.h
62 lines (47 loc) · 1.61 KB
/
ConfigFile.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef CONFIGFILE_H
#define CONFIGFILE_H
#include <QString>
#include <QMap>
#include <QFile>
using namespace std;
class ConfigFile {
public:
/** Constructor for the configuration file class.
* Creates a new instance of a configuration. If the file exists, it is
* opened and read.
* @param filename the pathname of the configuration file.
*/
ConfigFile(QString filename);
/** Destruktor.
*/
~ConfigFile();
/** Write the file.
* Write the configuration to the file.
*/
void writeFile();
/** Read the file.
* Read the configuration from the file.
*/
void readFile();
/** Set value.
* Set a configuration value in the configuration.
* @param key the key to write the value in the configuration.
* @param value the value for that key.
*/
void setValue(QString key, QString value);
/** Get value.
* Get a configuration value from the configuration.
* @param key the key to read the value from the configuration.
*/
QString getValue(QString key);
/** Automatic file writing on settings change.
* @param autosave Setting this to true enables atomatic file
* writing on every settings change.
*/
void autoWrite(bool autosave);
private:
QMap<QString, QString> m_config; /**< the map to hold the key value pairs */
bool m_auto; /**< autoSave enabled? */
QString m_file; /**< the file to read and write */
};
#endif // CONFIGFILE_H