blob: 2a09206832c039162c18220b278d57938fbeaad0 (
plain) (
blame)
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
|
#include "dicealias.h"
#include <QRegularExpression>
DiceAlias::DiceAlias(QString cmd, QString key, bool isReplace)
: m_command(cmd),m_value(key)
{
if(isReplace)
{
m_type = REPLACE;
}
else
{
m_type = REGEXP;
}
}
DiceAlias::~DiceAlias()
{
}
bool DiceAlias::resolved(QString & str)
{
if((m_type == REPLACE)&&(str.contains(m_command)))
{
str.replace(m_command,m_value);
return true;
}
else if(m_type == REGEXP)
{
QRegularExpression exp(m_command);
str.replace(exp,m_value);
return true;
}
return false;
}
void DiceAlias::setCommand(QString key)
{
m_command = key;
}
void DiceAlias::setValue(QString value)
{
m_value = value;
}
void DiceAlias::setType(RESOLUTION_TYPE type)
{
m_type = type;
}
QString DiceAlias::getCommand()
{
return m_command;
}
QString DiceAlias::getValue()
{
return m_value;
}
bool DiceAlias::isReplace()
{
return (m_type == REPLACE) ? true : false;
}
|