-
Notifications
You must be signed in to change notification settings - Fork 21
/
Config.cpp
57 lines (46 loc) · 1.46 KB
/
Config.cpp
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
55
56
57
#include "stdafx.h"
#include "Config.h"
#include "path.h"
static CConfig cfg;
//////////////////////////////////////////////////////////////////////////
CConfig::CConfig()
{
RegisterEvent(evCfgSetBOOLVal, this, &CConfig::SetBOOLValue);
RegisterEvent(evCfgGetBOOLVal, this, &CConfig::GetBOOLValue);
RegisterEvent(evCfgSetINTVal, this, &CConfig::SetINTValue);
RegisterEvent(evCfgGetINTVal, this, &CConfig::GetINTValue);
RegisterEvent(evCfgSetSTRVal, this, &CConfig::SetSTRTValue);
RegisterEvent(evCfgGetSTRVal, this, &CConfig::GetSTRValue);
CString cfgFileName = CPath::GetAppPath() + _T("wtlbuilder.cfg");
cfgFile.SetPathName(cfgFileName);
}
CConfig::~CConfig()
{
}
void CConfig::SetBOOLValue(LPCTSTR section, LPCTSTR key, BOOL val)
{
cfgFile.WriteBool(section, key, val);
}
void CConfig::GetBOOLValue(LPCTSTR section, LPCTSTR key, BOOL *val)
{
if(val != NULL)
*val = cfgFile.GetBool(section, key, FALSE);
}
void CConfig::SetINTValue(LPCTSTR section, LPCTSTR key, BOOL val)
{
cfgFile.WriteInt(section, key, val);
}
void CConfig::GetINTValue(LPCTSTR section, LPCTSTR key, BOOL *val)
{
if (val != NULL)
*val = cfgFile.GetInt(section, key, 0);
}
void CConfig::SetSTRTValue(LPCTSTR section, LPCTSTR key, LPCTSTR val)
{
cfgFile.WriteString(section, key, val);
}
void CConfig::GetSTRValue(LPCTSTR section, LPCTSTR key, LPTSTR val, int sz)
{
if (val != NULL)
cfgFile.GetString(section, key, val, sz, "");
}