Config debugged
This commit is contained in:
parent
5b7a673b6f
commit
53f0785fee
@ -9,8 +9,8 @@
|
|||||||
# maxFPS: 30
|
# maxFPS: 30
|
||||||
#
|
#
|
||||||
general:
|
general:
|
||||||
maxFPS: 30
|
maxFPS: 30
|
||||||
theme: bad
|
theme: bad
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# #
|
# #
|
||||||
|
@ -45,12 +45,14 @@ void ConfigBuilder::parseFile(const string& fname) {
|
|||||||
|
|
||||||
vector<string> keyParts;
|
vector<string> keyParts;
|
||||||
unsigned listIndex;
|
unsigned listIndex;
|
||||||
|
unsigned lineno = 0; // for error handling purposes
|
||||||
while (!file.eof()) {
|
while (!file.eof()) {
|
||||||
string line;
|
string line;
|
||||||
getline(file, line);
|
getline(file, line);
|
||||||
|
++lineno;
|
||||||
auto match = line.find('#');
|
auto match = line.find('#');
|
||||||
if (match != string::npos)line.erase(match);
|
if (match != string::npos)line.erase(match);
|
||||||
if (line.empty())continue;
|
if (line.find_first_not_of(' ')==string::npos)continue;
|
||||||
|
|
||||||
unsigned currentIndent = 0;
|
unsigned currentIndent = 0;
|
||||||
while (line[currentIndent] == ' ')++currentIndent;
|
while (line[currentIndent] == ' ')++currentIndent;
|
||||||
@ -71,7 +73,7 @@ void ConfigBuilder::parseFile(const string& fname) {
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
match = line.find(':');
|
match = line.find(':');
|
||||||
if (match == string::npos)throw config_error("Line "+ to_string(currentIndent)+" invalid : |"+line+"|");
|
if (match == string::npos)throw config_error("Line "+ to_string(lineno)+" invalid : |"+line+"|");
|
||||||
string key = line.substr(0, match);
|
string key = line.substr(0, match);
|
||||||
string value = line.substr(match + 1);
|
string value = line.substr(match + 1);
|
||||||
trimSpaces(key);
|
trimSpaces(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user