blob: 87e9765c439ebf27c1d59fa2d0069eac9d523826 (
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
44
45
46
47
48
|
#ifndef CONFIG_H
#define CONFIG_H
#include <string>
#include <map>
//! Utility class for handling configuration file
//! Supported format in config file is:
//! keyword = value
//! example: nick = xyz
class Config{
private:
//! Map in the format <id, value>
std::map<std::string, std::string> config;
//! The path to the configuration file
std::string path;
//! Loads configuration from file
void load_conf();
//! Saves configuration to file
void save_conf();
public:
//! Constructs a object with the default configuration path
Config();
//! Constructs a object with a custom configuration path
Config(std::string path);
//! Deletes the object, saving the configuration to a file
~Config();
//! Adds a std::string value to the configuration
//! \param keyword Keyword associated with the value inserted
//! \param value The value for the associated keyword
void add_element(std::string keyword, std::string value);
//! Adds a int value to the configuration
//! \param keyword Keyword associated with the value inserted
//! \param value The value for the associated keyword
void add_element(std::string keyword, const int value);
//! Gets a element from the configuration
//! \param keyword The keyword you want the value from
std::string get_element(std::string keyword);
};
#endif
|