forked from leonmaxx/asus_fanmode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.hpp
50 lines (40 loc) · 1.07 KB
/
config.hpp
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
/*
* config.hpp
*
* Created on: Sep 4, 2019
* Author: Leonid Maksymchuk
*/
#ifndef CONFIG_HPP_
#define CONFIG_HPP_
#include <string>
#include <vector>
class ConfigParser {
public:
ConfigParser();
~ConfigParser();
void addOption(int& rnInt, const std::string& rsName);
void addOption(unsigned& rnUint, const std::string& rsName);
void addOption(bool& rbBool, const std::string& rsName);
void addOption(float& rfFloat, const std::string& rsName);
void addOption(std::string& rsStr, const std::string& rsName);
bool loadConfig(const std::string& rsFileName);
private:
enum OptionType {
OPT_INT = 0,
OPT_UNSIGNED = 1,
OPT_BOOL = 2,
OPT_FLOAT = 3,
OPT_STRING = 4
};
struct ConfigOption {
std::string sName;
OptionType otType;
void* pvPtr;
};
std::vector<ConfigOption> m_voOptions;
void trimString(std::string& rsStr);
bool splitString(std::string& rsName, std::string& rsVal);
bool getLine(char** ppcBuf, std::string& rsLine);
ConfigOption* findOption(const std::string& rsName);
};
#endif /* CONFIG_HPP_ */