forked from dgcor/DGEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassifier.cpp
More file actions
executable file
·72 lines (70 loc) · 1.56 KB
/
Copy pathClassifier.cpp
File metadata and controls
executable file
·72 lines (70 loc) · 1.56 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "Classifier.h"
Variable Classifier::get(const Queryable& obj, uint16_t skipFirst) const
{
Variable returnVar;
bool hasResult = false;
for (const auto& classVal : classifierValues)
{
bool hasValue = false;
Variable value;
if (classVal.property.empty() == true)
{
hasValue = true;
}
else if (obj.getProperty(classVal.property, value) == true)
{
hasValue = true;
}
if (hasValue == true)
{
for (const auto& itemElem : classVal.values)
{
bool compareResult = false;
if (std::holds_alternative<ClassifierValue::ValuePair>(itemElem.compare) == true)
{
const auto& minMax = std::get<ClassifierValue::ValuePair>(itemElem.compare);
LevelObjValue intVal = 0;
if (std::holds_alternative<int64_t>(value) == true)
{
intVal = (LevelObjValue)std::get<int64_t>(value);
}
else if (std::holds_alternative<bool>(value) == true)
{
intVal = (LevelObjValue)std::get<bool>(value);
}
if (intVal >= minMax.first && intVal <= minMax.second)
{
compareResult = true;
}
}
else
{
const auto& str = std::get<std::string>(value);
if (std::holds_alternative<std::string>(itemElem.compare) == true &&
std::get<std::string>(itemElem.compare) == str)
{
compareResult = true;
}
}
if (compareResult == true)
{
if (skipFirst > 0)
{
skipFirst--;
}
else
{
returnVar = itemElem.value;
hasResult = true;
}
break;
}
}
if (hasResult == true)
{
break;
}
}
}
return returnVar;
}