/
Config.h
54 lines (47 loc) · 933 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
53
54
#pragma once
template< typename T >
class ConfigItem
{
std::string category, name;
T* value;
public:
ConfigItem( std::string category, std::string name, T* value )
{
this->category = category;
this->name = name;
this->value = value;
}
};
template< typename T >
class ConfigValue
{
public:
ConfigValue( std::string category_, std::string name_, T* value_ )
{
category = category_;
name = name_;
value = value_;
}
std::string category, name;
T* value;
};
class CConfig
{
protected:
std::vector< ConfigValue< int >* > ints;
std::vector< ConfigValue< bool >* > bools;
std::vector< ConfigValue< float >* > floats;
private:
void SetupValue( int&, int, std::string, std::string );
void SetupValue( bool&, bool, std::string, std::string );
void SetupValue( float&, float, std::string, std::string );
public:
CConfig()
{
Setup();
}
void Setup();
void Save();
void Load();
};
extern CConfig* Config;