Minor tweak to ConfigUtility

This commit is contained in:
Kayne Ruse
2014-07-31 17:14:40 +10:00
parent 414a0896c9
commit 46f02dcfdd
2 changed files with 13 additions and 19 deletions
+10 -10
View File
@@ -25,25 +25,25 @@
#include <fstream>
#include <stdexcept>
using namespace std;
void ConfigUtility::Load(string fname) {
ifstream is(fname);
void ConfigUtility::Load(std::string fname) {
std::ifstream is(fname);
if (!is.is_open()) {
throw(runtime_error("Failed to open config file"));
throw(std::runtime_error("Failed to open config file"));
}
string key, val;
std::string key, val;
for (;;) { //forever
while(true) { //forever
//eat whitespace
while(isspace(is.peek()))
while(isspace(is.peek())) {
is.ignore();
}
//end of file
if (is.eof())
if (is.eof()) {
break;
}
//skip comment lines
if (is.peek() == '#') {
@@ -64,7 +64,7 @@ void ConfigUtility::Load(string fname) {
while(key.size() && isspace(*(key.end()-1))) key.erase(key.end() - 1);
while(val.size() && isspace(*(val.end()-1))) val.erase(val.end() - 1);
//allow empty/wiped values
//disallow empty/wiped values
if (key.size() == 0) {
continue;
}
+3 -9
View File
@@ -39,15 +39,9 @@ public:
bool Boolean(std::string);
//shorthand
std::string& operator[](std::string s) {
return String(s);
}
int Int(std::string s) {
return Integer(s);
}
bool Bool(std::string s) {
return Boolean(s);
}
inline std::string& operator[](std::string s) { return String(s); }
inline int Int(std::string s) { return Integer(s); }
inline bool Bool(std::string s) { return Boolean(s); }
//OO breaker
std::map<std::string, std::string>* GetMap() {