-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.h
52 lines (48 loc) · 996 Bytes
/
Config.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
#pragma once
#include <string>
#include <sstream>
#include <fstream>
namespace Spyder
{
class ConfigVarBase
{
protected:
virtual void ReadVar(std::string &dat) = 0;
public:
static void ReadConfigFile(std::istream &file);
ConfigVarBase(const std::string &strName);
};
template <class T>
class ConfigVar : ConfigVarBase
{
private:
T m_val;
public:
ConfigVar(const std::string &strName, T default_val) : ConfigVarBase(strName),
m_val(default_val)
{
}
inline T GetVal()
{
return m_val;
}
protected:
virtual void ReadVar(std::string &dat)
{
std::stringstream ss(dat);
ss >> m_val;
}
};
class TwoIntConfig : ConfigVarBase
{
private:
int m_val1;
int m_val2;
public:
//TwoIntConfig::TwoIntConfig(const std::string &strName, int val1, int val2);
TwoIntConfig(const std::string &strName, int val1, int val2);
int GetVar(const unsigned char val);
protected:
virtual void ReadVar(std::string &dat);
};
};