fixed bug that global double vars are not working

This commit is contained in:
louis 2014-11-29 16:00:42 +01:00
parent da25976325
commit 714ee26b1b
4 changed files with 18 additions and 6 deletions

View File

@ -100,3 +100,5 @@ Version 0.0.6
Version 0.0.7
- fixed bug that global double vars are not working

View File

@ -71,6 +71,9 @@ void cGlobals::Debug(void) {
for (map <string, int>::iterator myInt = intVars.begin(); myInt != intVars.end(); myInt++) {
dsyslog("skindesigner: Integer Variable \"%s\": %d", (myInt->first).c_str(), myInt->second);
}
for (map <string, double>::iterator myDouble = doubleVars.begin(); myDouble != doubleVars.end(); myDouble++) {
dsyslog("skindesigner: Double Variable \"%s\": %f", (myDouble->first).c_str(), myDouble->second);
}
for (map <string, string>::iterator myStr = stringVars.begin(); myStr != stringVars.end(); myStr++) {
dsyslog("skindesigner: String Variable \"%s\": \"%s\"", (myStr->first).c_str(), (myStr->second).c_str());
}

View File

@ -1,3 +1,4 @@
#include "../config.h"
#include "parameter.h"
using namespace std;
@ -164,7 +165,13 @@ bool cNumericParameter::CheckExpression(int &val, string &parsedVal) {
if (foundToken != string::npos) {
stringstream st;
st << globDouble->second;
parsedValue = parsedValue.replace(foundToken, token.size(), st.str());
string doubleVal = st.str();
if (config.replaceDecPoint) {
if (doubleVal.find_first_of('.') != string::npos) {
std::replace( doubleVal.begin(), doubleVal.end(), '.', config.decPoint);
}
}
parsedValue = parsedValue.replace(foundToken, token.size(), doubleVal);
}
}
}

View File

@ -145,11 +145,6 @@ bool cXmlParser::ParseView(void) {
xmlAttrPtr attr = node->properties;
vector<pair<string, string> > attribs;
ParseAttributes(attr, node, attribs);
/*
for (vector<pair<string, string> >::iterator it = attribs.begin(); it != attribs.end(); it++) {
esyslog("skindesigner: attribute %s value %s", (it->first).c_str(), (it->second).c_str());
}
*/
ParseViewElement(node->name, node->xmlChildrenNode, attribs);
} else if (view->ValidViewList((const char*)node->name)) {
ParseViewList(node);
@ -360,6 +355,11 @@ void cXmlParser::InsertVariable(string name, string type, string value) {
int val = atoi(value.c_str());
globals->intVars.insert(pair<string, int>(name, val));
} else if (!type.compare("double")) {
if (config.replaceDecPoint) {
if (value.find_first_of('.') != string::npos) {
std::replace( value.begin(), value.end(), '.', config.decPoint);
}
}
double val = atof(value.c_str());
globals->doubleVars.insert(pair<string, double>(name, val));
} else if (!type.compare("string")) {