Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationFilterStringCondition.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CReasonerEvaluationFilterStringCondition.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28 namespace Evaluation {
29
30
31
32 CReasonerEvaluationFilterStringCondition::CReasonerEvaluationFilterStringCondition(const QString& statisticNameString, const QString& statisticComperator, const QString& statisticCompareValueString) : CReasonerEvaluationFilterCondition(statisticNameString) {
33 mStatisticCompareValue = statisticCompareValueString;
34 mStatisticComperator = statisticComperator;
35 }
36
37
38
39
40 bool CReasonerEvaluationFilterStringCondition::isStatisticConditionSatisfied(const QString& statisticString, const QString& statisticValueString) {
41 if (mStatisticComperator == "=" || mStatisticComperator == "==") {
42 if (statisticValueString == mStatisticCompareValue) {
43 return true;
44 }
45 } else if (mStatisticComperator == "!=" || mStatisticComperator == "!") {
46 if (statisticValueString != mStatisticCompareValue) {
47 return true;
48 }
49 } else if (mStatisticComperator == "contains") {
50 if (statisticValueString.contains(mStatisticCompareValue)) {
51 return true;
52 }
53 } else if (mStatisticComperator == "CONTAINS") {
54 if (statisticValueString.toUpper().contains(mStatisticCompareValue)) {
55 return true;
56 }
57 } else if (mStatisticComperator == "startsWith") {
58 if (statisticValueString.startsWith(mStatisticCompareValue)) {
59 return true;
60 }
61 } else if (mStatisticComperator == "STARTSWITH") {
62 if (statisticValueString.toUpper().startsWith(mStatisticCompareValue)) {
63 return true;
64 }
65 } else if (mStatisticComperator == "endsWith") {
66 if (statisticValueString.endsWith(mStatisticCompareValue)) {
67 return true;
68 }
69 } else if (mStatisticComperator == "ENDSWITH") {
70 if (statisticValueString.toUpper().endsWith(mStatisticCompareValue)) {
71 return true;
72 }
73 }
74 return false;
75 }
76
77
78
79 }; // end namespace Evaluation
80
81 }; // end namespace Test
82
83 }; // end namespace Konclude