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
|
#include "CristallDetectRules.h"
using namespace std;
CristallDetectRules::Types CristallDetectRules::detectInvoke(char Val)
{
if (Val == OPTION_SEPARATEDFLOAT)
return Types::Coma;
if (Val == '-')
return Types::Minus;
if (isdigit(Val))
return Types::Digit;
if (isalpha(Val))
return Types::Alpha;
return Types::None;
}
bool CristallDetectRules::checkAlfanum(const std::string & str)
{
bool alpha {false};
bool numerical {false};
for (auto const c : str)
{
if (!alpha && isalpha(c))
alpha = true;
else if (!numerical && isdigit(c))
numerical = true;
}
return numerical && alpha;
}
bool CristallDetectRules::checkFloatnum(const std::string& str)
{
bool digit {false};
for (auto const c : str)
{
if (isdigit(c) && digit == false)
digit = true;
if (OPTION_SEPARATEDFLOAT == c && digit == true && isdigit(str[str.length()-1]) )
return true;
}
return false;
}
bool CristallDetectRules::isSingleRule(CristallGrammarModel element, const std::string& RawData, int pos)
{
return (element.RuleTypes == Cristall::RuleType::SingleRule && RawData.substr(pos, element.StartChar.length()) == element.StartChar);
}
bool CristallDetectRules::isMultiRule(CristallGrammarModel element, const std::string& RawData, int pos)
{
return (element.RuleTypes == Cristall::RuleType::MultiRule && RawData.substr(pos, element.StartChar.length()) == element.StartChar);
}
bool CristallDetectRules::isAnyNumbers(Cristall::Rules Rule)
{
return (Rule == Cristall::Rules::Numbers || Rule== Cristall::Rules::FloatNumbers);
}
|