forked from hrkfdn/hrktorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.h
36 lines (28 loc) · 860 Bytes
/
settings.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
#ifndef _SETTINGS_H
#define _SETTINGS_H
enum { TYPE_INT = 0, TYPE_STRING };
typedef struct
{
int type;
int ival;
std::string sval;
} setting_t;
class CSettings
{
public:
CSettings();
~CSettings();
void LoadConfig();
void ParseLine(std::string line);
void Set(std::string name, int ival) { settings[name].type = TYPE_INT; settings[name].ival = ival; }
void Set(std::string name, std::string sval) { settings[name].type = TYPE_STRING; settings[name].sval = sval; }
int GetI(std::string name) { return settings[name].ival; }
std::string GetS(std::string name) { return settings[name].sval; }
inline std::string* getDir() { return &_dir; }
inline std::map<std::string, setting_t>* getSettingMap() { return &settings; }
private:
std::map<std::string, setting_t> settings;
std::string _dir;
};
extern CSettings* Settings;
#endif