-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoolBox.cpp
84 lines (74 loc) · 2.13 KB
/
toolBox.cpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "headerFiles/toolBox.h"
double ToolBox::getStatus(string var)
{
double ret;
if (var == "h0")
{
string strVal = SymbolPathMap::getinstance().umap.at(var);
// convert from string to double
ret = stod(strVal);
}
else
{
string path = SymbolPathMap::getinstance().umap.at(var);
ret = PathValueMap::getinstance().umap.at(path);
}
return ret;
};
bool ToolBox::operatorInterp(double x, string op, string yStr)
{
// converting the string to an int
int y = stoi(yStr);
if ((op == "==") && (x == y))
return true;
else if ((op == "!=") && (x != y))
return true;
else if ((op == "<") && (x < y))
return true;
else if ((op == ">") && (x > y))
return true;
else if ((op == "<=") && (x <= y))
return true;
else if ((op == ">=") && (x >= y))
return true;
else
return false;
};
void ToolBox::systemRun()
{
system("fgfs --telnet=socket,in,10,127.0.0.1,5402,tcp --generic=socket,out,10,127.0.0.1,5400,tcp,generic_small");
};
pair<vector<vector<string>>, vector<vector<string>>> ToolBox::combine(const vector<vector<string>> &vec1, const vector<vector<string>> &vec2)
{
return std::make_pair(vec2, vec1);
};
vector<string> ToolBox::replaceByStatus(vector<string> line)
{
for (int i = 2; i < line.size(); i++)
{
string word = line[i];
// checking if the word is a var type that i need to get its status
if (SymbolPathMap::getinstance().umap.find(word) != SymbolPathMap::getinstance().umap.end())
{
// getting its status
double dValue = ToolBox::getStatus(word);
// converting the status from double to string
string strValue = to_string(dValue);
// replacing the original word by its status as a string
line[i] = strValue;
}
}
return line;
};
// dose not work!!!
/*
bool ToolBox::isFound(string element, class claasName)
{
if(claasName::getinstance()->umap.find(line[1]) == claasName::getinstance()->umap.end())
{
return false;
}
else{
return true;
}
*/