-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditionParser.cpp
More file actions
48 lines (43 loc) · 1.49 KB
/
Copy pathConditionParser.cpp
File metadata and controls
48 lines (43 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Created by roy on 12/22/18.
//
#include "ConditionParser.h"
/**
* This method return true if the condition is met, else false.
* @return boolean - is condition met.
*/
bool ConditionParser::conditionIsMet() {
vector<string> valueVector1, valueVector2;
string address1, address2;
double value1, value2;
valueVector1 = this->smallLexer.lexer(this->exp1String);
address1 = valueVector1.at(0);
if (this->dataReaderServer->isInBindMap(address1)) {
address1 = this->dataReaderServer->getBindAddress(address1);
valueVector1.clear();
valueVector1.push_back(address1);
}
value1 = stod(this->util.shuntingYard(valueVector1));
// calculate expression 2.
valueVector2 = this->smallLexer.lexer(this->exp2String);
address2 = valueVector2.at(0);
if (this->dataReaderServer->isInBindMap(address2)) {
address2 = this->dataReaderServer->getBindAddress(address2);
valueVector2.clear();
valueVector2.push_back(address2);
}
value2 = stod(this->util.shuntingYard(valueVector2));
if (this->condition == "<") {
return value1 < value2;
} else if (this->condition == ">") {
return value1 > value2;
} else if (this->condition == "==") {
return value1 == value2;
} else if (this->condition == "!=") {
return value1 != value2;
} else if (this->condition == "<=") {
return value1 <= value2;
} else if (this->condition == ">=") {
return value1 >= value2;
}
}