-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigs.cpp
57 lines (45 loc) · 1.29 KB
/
configs.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 "configs.h"
Config* Config::_instance = NULL;
//GenericConverter<bool>* GenericConverter<bool>::_instance = NULL;
ConfigException::ConfigException(std::string message)
: tError(message) {}
template<> std::string default_tostring<const char *>(const char * const &val) {
return ((std::string) val);
}
template<> const char * default_fromstring<const char *>(const std::string &s) {
return s.c_str();
}
/*
void Config::add(const std::string &name, IOption* option) {
if(!isValidName(name)) {
throw ConfigException("`" + name + "' is not a valid option name");
}
if(hasOption(name)) { throw DuplicateOptionException(name); }
keyValue_[name] = option;
}
IOption& Config::getIOption(const std::string& name) {
KeyValueMap::iterator i = keyValue_.find(name);
if(i == keyValue_.end())
throw NoSuchOptionException(name);
return *(i->second);
}
*/
/*
void Config::setString(const std::string& entry, const std::string& value,
int prio) {
try {
getIOption(entry).setString(value, prio);
}
catch(std::bad_cast) {
throw WrongTypeException(entry);
}
}
std::string Config::getString(const std::string& entry) {
try {
return getIOption(entry).getString();
}
catch(std::bad_cast) {
throw WrongTypeException(entry);
}
}
*/