Minor tweak to ConfigUtility
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user