-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.cpp
70 lines (55 loc) · 1.35 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
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// Created by rege on 09.03.17.
//
#include <kaguya.hpp>
#include "Config.hpp"
using namespace std;
// state of lua script config
kaguya::State state;
Config::Config (string configPath)
{
state.dofile(configPath);
}
string Config::filePath = DEFAULT_CONFIG_PATH;
void Config::setFilePath (string s)
{
filePath = s;
}
#if false
int Config::getInt (string varName) throw(NotFoundException)
{
state("__t__ = type("+varName+")");
string realVarType = state["__t__"];
if (realVarType == "nil") throw NotFoundException();
assert(state["__t__"] == "number");
return state[varName];
}
bool Config::getBool (string varName) throw(NotFoundException)
{
state("__t__ = type("+varName+")");
string realVarType = state["__t__"];
if (realVarType == "nil") throw NotFoundException();
assert(state["__t__"] == "boolean");
return state[varName];
}
string Config::getString (string varName) throw(NotFoundException)
{
state("__t__ = type("+varName+")");
string realVarType = state["__t__"];
if (realVarType == "nil") throw NotFoundException();
assert(state["__t__"] == "string");
return state[varName];
}
#endif
int Config::getInt (string varName)
{
return state[varName];
}
bool Config::getBool (string varName)
{
return state[varName];
}
string Config::getString (string varName)
{
return state[varName];
}