added empty operator additionally to isset to check in a condition if a string token is set

This commit is contained in:
louis 2015-01-18 15:54:41 +01:00
parent 06af6390e3
commit bab251a7a1
3 changed files with 18 additions and 0 deletions

View File

@ -156,3 +156,5 @@ Version 0.1.3
Version 0.1.4 Version 0.1.4
- fixed token volpercent in nopacity and metrixhd - fixed token volpercent in nopacity and metrixhd
- added "empty" operator additionally to "isset" to check in a condition
if a string token is set

View File

@ -295,6 +295,19 @@ bool cConditionalParameter::Evaluate(map < string, int > *intTokens, map < strin
tokenTrue = true; tokenTrue = true;
} }
} }
} else if (cond->type == ctStringEmpty) {
if (stringTokens) {
map < string, string >::iterator hit = stringTokens->find(cond->tokenName);
if (hit != stringTokens->end()) {
string value = hit->second;
if (value.size() == 0)
tokenTrue = true;
} else {
tokenTrue = true;
}
} else {
tokenTrue = true;
}
} else { } else {
int tokenValue = EvaluateParameter(cond->tokenName, intTokens, stringTokens); int tokenValue = EvaluateParameter(cond->tokenName, intTokens, stringTokens);
if (cond->type == ctBool) { if (cond->type == ctBool) {
@ -387,6 +400,8 @@ void cConditionalParameter::InsertCondition(string cond) {
sCond.isNegated = true; sCond.isNegated = true;
} else if (!rest.compare("isset")) { } else if (!rest.compare("isset")) {
sCond.type = ctStringSet; sCond.type = ctStringSet;
} else if (!rest.compare("empty")) {
sCond.type = ctStringEmpty;
} else if (startswith(rest.c_str(), "gt(")) { } else if (startswith(rest.c_str(), "gt(")) {
string compVal = rest.substr(4, rest.size() - 5); string compVal = rest.substr(4, rest.size() - 5);
sCond.compareValue = atoi(compVal.c_str()); sCond.compareValue = atoi(compVal.c_str());

View File

@ -109,6 +109,7 @@ enum eCondType {
ctEquals, ctEquals,
ctBool, ctBool,
ctStringSet, ctStringSet,
ctStringEmpty,
ctNone ctNone
}; };