fixed bug that global tokens were not parsed correctly

This commit is contained in:
louis 2015-01-27 17:36:29 +01:00
parent 15ad84bccf
commit 17497de3c3
2 changed files with 23 additions and 16 deletions

View File

@ -190,3 +190,4 @@ Version 0.2.0
Version 0.2.1 Version 0.2.1
- fixed bug that global tokens were not parsed correctly

View File

@ -73,12 +73,15 @@ void cGlobals::ReplaceIntVars(string &value) {
stringstream sToken; stringstream sToken;
sToken << "{" << it->first << "}"; sToken << "{" << it->first << "}";
string token = sToken.str(); string token = sToken.str();
size_t foundToken = value.find(token); size_t foundToken = string::npos;
if (foundToken != string::npos) { do {
stringstream st; foundToken = value.find(token);
st << it->second; if (foundToken != string::npos) {
value = value.replace(foundToken, token.size(), st.str()); stringstream st;
} st << it->second;
value = value.replace(foundToken, token.size(), st.str());
}
} while (foundToken != string::npos);
} }
} }
@ -107,18 +110,21 @@ void cGlobals::ReplaceDoubleVars(string &value) {
stringstream sToken; stringstream sToken;
sToken << "{" << it->first << "}"; sToken << "{" << it->first << "}";
string token = sToken.str(); string token = sToken.str();
size_t foundToken = value.find(token); size_t foundToken = string::npos;
if (foundToken != string::npos) { do {
stringstream st; foundToken = value.find(token);
st << it->second; if (foundToken != string::npos) {
string doubleVal = st.str(); stringstream st;
if (config.replaceDecPoint) { st << it->second;
if (doubleVal.find_first_of('.') != string::npos) { string doubleVal = st.str();
std::replace( doubleVal.begin(), doubleVal.end(), '.', config.decPoint); if (config.replaceDecPoint) {
if (doubleVal.find_first_of('.') != string::npos) {
std::replace( doubleVal.begin(), doubleVal.end(), '.', config.decPoint);
}
} }
value = value.replace(foundToken, token.size(), doubleVal);
} }
value = value.replace(foundToken, token.size(), doubleVal); } while (foundToken != string::npos);
}
} }
} }