I'm going to do shit
This commit is contained in:
parent
51866120f2
commit
ff258e6aeb
@ -41,6 +41,6 @@ points:
|
||||
invader1: 600
|
||||
|
||||
grid:
|
||||
- AAAAAAAAAA
|
||||
- BBBB BBBBB
|
||||
- CCCCCCCCCC
|
||||
- "AAAAAAAAAA"
|
||||
- " BBB BBB "
|
||||
- "CCCCCCCCCC"
|
||||
@ -26,8 +26,20 @@ void trimSpaces(string& str){
|
||||
str.erase(0, str.find_first_not_of(' '));
|
||||
}
|
||||
|
||||
void sanitizeValue(string& val) {
|
||||
trimSpaces(val);
|
||||
for (char c: {'\'', '"'}) {
|
||||
if (val[0] == c && val[val.size() - 1] == c) {
|
||||
val.erase(val.begin());
|
||||
val.pop_back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING : This implementation of YAML is not meant to detect and report errors in a non YAML-compliant file
|
||||
* WARNING : This implementation of YAML is not meant to be complete, but to work with our specific needs
|
||||
* It also can't detect and report errors in a non YAML-compliant file
|
||||
*/
|
||||
|
||||
void ConfigBuilder::parseFile(const string& fname) {
|
||||
@ -48,7 +60,7 @@ void ConfigBuilder::parseFile(const string& fname) {
|
||||
|
||||
if(line[currentIndent]=='-'){
|
||||
string value = line.substr(currentIndent+1);
|
||||
trimSpaces(value);
|
||||
sanitizeValue(value);
|
||||
|
||||
string fullKey;
|
||||
for (unsigned i = 0; i < currentIndent; ++i) {
|
||||
@ -66,7 +78,7 @@ void ConfigBuilder::parseFile(const string& fname) {
|
||||
string key = line.substr(0, match);
|
||||
string value = line.substr(match + 1);
|
||||
trimSpaces(key);
|
||||
trimSpaces(value);
|
||||
sanitizeValue(value);
|
||||
if (value.empty()) {
|
||||
keyParts.resize(currentIndent);
|
||||
keyParts.push_back(key);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user