aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dicealias.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dicealias.cpp')
-rw-r--r--dicealias.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/dicealias.cpp b/dicealias.cpp
new file mode 100644
index 0000000..2a09206
--- /dev/null
+++ b/dicealias.cpp
@@ -0,0 +1,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;
+}
+
+