aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--booleancondition.cpp2
-rw-r--r--cli/main.cpp2
-rw-r--r--compositevalidator.cpp6
-rw-r--r--diceparser.cpp75
-rw-r--r--irc/botircdiceparser.cpp3
-rw-r--r--node/countexecutenode.cpp24
-rw-r--r--node/dicerollernode.cpp12
-rw-r--r--node/executionnode.cpp20
-rw-r--r--node/executionnode.h2
-rw-r--r--node/explosedicenode.cpp24
-rw-r--r--node/explosedicenode.h2
-rw-r--r--node/filternode.cpp18
-rw-r--r--node/helpnode.cpp8
-rw-r--r--node/ifnode.cpp51
-rw-r--r--node/ifnode.h2
-rw-r--r--node/jumpbackwardnode.cpp32
-rw-r--r--node/jumpbackwardnode.h2
-rw-r--r--node/keepdiceexecnode.cpp16
-rw-r--r--node/listaliasnode.cpp12
-rw-r--r--node/listaliasnode.h2
-rw-r--r--node/listsetrollnode.cpp16
-rw-r--r--node/listsetrollnode.h2
-rw-r--r--node/mergenode.cpp4
-rw-r--r--node/numbernode.cpp8
-rw-r--r--node/paintnode.cpp16
-rw-r--r--node/paintnode.h2
-rw-r--r--node/parenthesesnode.cpp20
-rw-r--r--node/parenthesesnode.h2
-rw-r--r--node/rerolldicenode.cpp20
-rw-r--r--node/scalaroperatornode.cpp152
-rw-r--r--node/scalaroperatornode.h5
-rw-r--r--node/sortresult.cpp17
-rw-r--r--node/splitnode.cpp8
-rw-r--r--node/startingnode.cpp9
-rw-r--r--node/stringnode.cpp8
-rw-r--r--operationcondition.cpp2
-rw-r--r--range.cpp2
-rw-r--r--result/diceresult.cpp2
-rw-r--r--result/result.cpp6
39 files changed, 308 insertions, 308 deletions
diff --git a/booleancondition.cpp b/booleancondition.cpp
index 7be9836..907746c 100644
--- a/booleancondition.cpp
+++ b/booleancondition.cpp
@@ -39,7 +39,7 @@ qint64 BooleanCondition::hasValid(Die* b,bool recursive,bool unhighlight) const
}
qint64 sum= 0;
- foreach(qint64 value, listValues)
+ for(qint64 value : listValues)
{
switch(m_operator)
{
diff --git a/cli/main.cpp b/cli/main.cpp
index be02507..6ed6036 100644
--- a/cli/main.cpp
+++ b/cli/main.cpp
@@ -151,7 +151,7 @@ QString diceToText(QList<ExportedDiceResult>& diceList,bool highlight,bool homog
for(auto dice : diceList)
{
QStringList resultGlobal;
- foreach(int face, dice.keys())
+ for(int face : dice.keys())
{
QStringList result;
ListDiceResult diceResult = dice.value(face);
diff --git a/compositevalidator.cpp b/compositevalidator.cpp
index 109ec26..9023460 100644
--- a/compositevalidator.cpp
+++ b/compositevalidator.cpp
@@ -22,14 +22,14 @@
#include "compositevalidator.h"
CompositeValidator::CompositeValidator()
- : m_operators(NULL),m_validatorList(NULL)
+ : m_operators(nullptr),m_validatorList(nullptr)
{
}
CompositeValidator::~CompositeValidator()
{
qDeleteAll(*m_validatorList);
- if(NULL!=m_operators)
+ if(nullptr!=m_operators)
{
delete m_operators;
}
@@ -40,7 +40,7 @@ qint64 CompositeValidator::hasValid(Die* b,bool recursive,bool unhighlight) cons
int i = 0;
qint64 sum = 0;
bool highLight = false;
- foreach(const Validator* validator, *m_validatorList)
+ for(const Validator* validator: *m_validatorList)
{
qint64 val = validator->hasValid(b,recursive,unhighlight);
if(i==0)
diff --git a/diceparser.cpp b/diceparser.cpp
index 42f46ac..8838171 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -50,7 +50,7 @@
#define DEFAULT_FACES_NUMBER 10
DiceParser::DiceParser()
- : m_current(nullptr)//m_start(NULL),
+ : m_current(nullptr)//m_start(nullptr),
{
m_currentTreeHasSeparator =false;
m_parsingToolbox = new ParsingToolBox();
@@ -152,7 +152,6 @@ void DiceParser::insertAlias(DiceAlias* dice, int i)
{
m_aliasList->insert(i, dice);
}
-
}
bool DiceParser::parseLine(QString str)
@@ -190,21 +189,22 @@ bool DiceParser::parseLine(QString str)
{
return true;
}
- else if(!m_errorMap.isEmpty())
+ else
{
- m_errorMap.insert(ExecutionNode::NOTHING_UNDERSTOOD,QObject::tr("Nothing was understood"));
+ m_errorMap.insert(ExecutionNode::NOTHING_UNDERSTOOD,QObject::tr("Nothing was understood. To roll dice: !1d6 - full documation:"
+ "https://github.com/Rolisteam/DiceParser/blob/master/HelpMe.md"));
}
return false;
}
bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
{
- ExecutionNode* operandNode=NULL;
+ ExecutionNode* operandNode=nullptr;
QString result;
QString comment;
if(m_parsingToolbox->readOpenParentheses(str))
{
- ExecutionNode* internalNode=NULL;
+ ExecutionNode* internalNode=nullptr;
if(readExpression(str,internalNode))
{
ParenthesesNode* parentheseNode = new ParenthesesNode();
@@ -213,7 +213,7 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
if(m_parsingToolbox->readCloseParentheses(str))
{
- ExecutionNode* diceNode=NULL;
+ ExecutionNode* diceNode=nullptr;
if(readDice(str,diceNode))
{
parentheseNode->setNextNode(diceNode);
@@ -224,7 +224,7 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
}
else if(readOperand(str,operandNode))
{
- ExecutionNode* diceNode=NULL;
+ ExecutionNode* diceNode=nullptr;
if(readDice(str,diceNode))
{
operandNode->setNextNode(diceNode);
@@ -249,7 +249,7 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
}
else
{
- ExecutionNode* diceNode=NULL;
+ ExecutionNode* diceNode=nullptr;
if(readDice(str,diceNode))
{
NumberNode* numberNode=new NumberNode();
@@ -330,12 +330,12 @@ QString DiceParser::displayResult()
{
DiceResult* myDiceResult = dynamic_cast<DiceResult*>(result);
- if(NULL!=myDiceResult)
+ if(nullptr!=myDiceResult)
{
QString resulStr;
quint64 face=0;
- foreach(Die* die, myDiceResult->getResultList())
+ for(Die* die : myDiceResult->getResultList())
{
if(!die->hasBeenDisplayed())
{
@@ -347,7 +347,7 @@ QString DiceParser::displayResult()
if(die->hasChildrenValue())
{
resulStr+=QStringLiteral(" [");
- foreach(qint64 i, die->getListValue())
+ for(qint64 i : die->getListValue())
{
resulStr+=QStringLiteral("%1 ").arg(i);
}
@@ -392,7 +392,7 @@ QList<qreal> DiceParser::getLastIntegerResults()
ExecutionNode* next = getLeafNode(node);
Result* result=next->getResult();
bool scalarDone = false;
- while((result!=NULL)&&(!scalarDone))
+ while((result!=nullptr)&&(!scalarDone))
{
if(result->hasResultOfType(Result::SCALAR))
{
@@ -465,7 +465,7 @@ QStringList DiceParser::getAllDiceResult(bool& hasAlias)
if(result->hasResultOfType(Result::DICE_LIST))
{
DiceResult* stringResult = dynamic_cast<DiceResult*>(result);
- if(NULL!=stringResult)
+ if(nullptr!=stringResult)
{
for(auto die : stringResult->getResultList())
{
@@ -484,7 +484,7 @@ QStringList DiceParser::getAllDiceResult(bool& hasAlias)
{
if(die->isHighlighted())
{
- foreach (qint64 value, die->getListValue())
+ for(qint64 value : die->getListValue())
{
stringListResult << QString::number(value);
@@ -503,12 +503,12 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo
ExecutionNode* next = getLeafNode(start);
Result* result=next->getResult();
- while(NULL!=result)
+ while(nullptr!=result)
{
if(result->hasResultOfType(Result::DICE_LIST))
{
DiceResult* diceResult = dynamic_cast<DiceResult*>(result);
- if(NULL!=diceResult)
+ if(nullptr!=diceResult)
{
if(homogeneous)
{
@@ -517,7 +517,7 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo
}
quint64 face=0;
ListDiceResult listpair;
- foreach(Die* die, diceResult->getResultList())
+ for(Die* die : diceResult->getResultList())
{
if(!die->hasBeenDisplayed())
{
@@ -527,7 +527,7 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo
face = die->getFaces();
if(die->hasChildrenValue())
{
- foreach(qint64 i, die->getListValue())
+ for(qint64 i : die->getListValue())
{
valuesResult.append(i);
}
@@ -633,6 +633,7 @@ QList<qreal> DiceParser::getSumOfDiceResult()
}
resultValues << resultValue;
}
+ return resultValues;
}
int DiceParser::getStartNodeCount() const
{
@@ -732,7 +733,7 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node)
bool DiceParser::readDiceOperator(QString& str,DiceOperator& op)
{
QStringList listKey = m_mapDiceOp->keys();
- foreach(QString key, listKey)
+ for(const QString& key : listKey)
{
if(str.startsWith(key,Qt::CaseInsensitive))
{
@@ -770,13 +771,13 @@ bool DiceParser::readDiceExpression(QString& str,ExecutionNode* & node)
{
bool returnVal=false;
- ExecutionNode* next = NULL;
+ ExecutionNode* next = nullptr;
if(readDice(str,next))
{
ExecutionNode* latest = next;
while(readOption(str,latest))
{
- while(NULL!=latest->getNextNode())
+ while(nullptr!=latest->getNextNode())
{
latest = latest->getNextNode();
}
@@ -828,8 +829,8 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous)
{
parent = nodeExecOrChild;
nodeExecOrChild = nodeExecOrChild->getNextNode();
+ //qDebug() << node->getPriority() << nodeExecOrChild->getPriority() << "###########";
}
-
// management of operator priority
if((nullptr != nodeExecOrChild)&&(nodeExec != nodeExecOrChild))
{
@@ -920,17 +921,23 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//,
{
str=str.remove(0,tmp.size());
- // option = m_OptionOp->value(tmp);
switch(m_OptionOp->value(tmp))
{
case Keep:
{
+ qDebug() << "keep " << previous->toString(true) << str;
+ if(str == "4+7")
+ {
+ qDebug() << "nauteanuit";
+ }
qint64 myNumber=0;
bool ascending = m_parsingToolbox->readAscending(str);
+
if(m_parsingToolbox->readNumber(str,myNumber))
{
node = m_parsingToolbox->addSort(previous,ascending);
KeepDiceExecNode* nodeK = new KeepDiceExecNode();
+ qDebug() << "nodeK " << previous->toString(true) << str;
nodeK->setDiceKeepNumber(myNumber);
node->setNextNode(nodeK);
node = nodeK;
@@ -949,7 +956,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//,
previous = addRollDiceNode(DEFAULT_FACES_NUMBER,previous);
}*/
DiceRollerNode* nodeTmp = dynamic_cast<DiceRollerNode*>(previous);
- if(NULL!=nodeTmp)
+ if(nullptr!=nodeTmp)
{
previous = addExploseDiceNode(nodeTmp->getFaces(),previous);
@@ -969,7 +976,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//,
case Filter:
{
Validator* validator = m_parsingToolbox->readCompositeValidator(str);
- if(NULL!=validator)
+ if(nullptr!=validator)
{
m_parsingToolbox->isValidValidator(previous,validator);
@@ -996,7 +1003,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//,
case Count:
{
Validator* validator = m_parsingToolbox->readCompositeValidator(str);
- if(NULL!=validator)
+ if(nullptr!=validator)
{
m_parsingToolbox->isValidValidator(previous,validator);
@@ -1017,7 +1024,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//,
case RerollAndAdd:
{
Validator* validator = m_parsingToolbox->readCompositeValidator(str);
- if(NULL!=validator)
+ if(nullptr!=validator)
{
m_parsingToolbox->isValidValidator(previous,validator);
RerollDiceNode* rerollNode = new RerollDiceNode();
@@ -1040,7 +1047,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//,
case Explosing:
{
Validator* validator = m_parsingToolbox->readCompositeValidator(str);
- if(NULL!=validator)
+ if(nullptr!=validator)
{
if(!m_parsingToolbox->isValidValidator(previous,validator))
{
@@ -1083,10 +1090,10 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//,
IfNode* nodeif = new IfNode();
nodeif->setConditionType(m_parsingToolbox->readConditionType(str));
Validator* validator = m_parsingToolbox->readCompositeValidator(str);
- if(NULL!=validator)
+ if(nullptr!=validator)
{
- ExecutionNode* trueNode = NULL;
- ExecutionNode* falseNode = NULL;
+ ExecutionNode* trueNode = nullptr;
+ ExecutionNode* falseNode = nullptr;
if(readIfInstruction(str,trueNode,falseNode))
{
nodeif->setInstructionTrue(trueNode);
@@ -1153,7 +1160,7 @@ bool DiceParser::readBlocInstruction(QString& str,ExecutionNode*& resultnode)
str=str.remove(0,1);
ExecutionNode* node;
Die::ArithmeticOperator op;
- ScalarOperatorNode* scalarNode = NULL;
+ ScalarOperatorNode* scalarNode = nullptr;
if(m_parsingToolbox->readArithmeticOperator(str,op))
{
scalarNode = new ScalarOperatorNode();
@@ -1163,7 +1170,7 @@ bool DiceParser::readBlocInstruction(QString& str,ExecutionNode*& resultnode)
{
if(str.startsWith('}'))
{
- if(NULL==scalarNode)
+ if(nullptr==scalarNode)
{
resultnode = node;
}
diff --git a/irc/botircdiceparser.cpp b/irc/botircdiceparser.cpp
index 44a3224..ce9bf3a 100644
--- a/irc/botircdiceparser.cpp
+++ b/irc/botircdiceparser.cpp
@@ -164,8 +164,7 @@ QString BotIrcDiceParser::diceToText(QList<ExportedDiceResult>& diceList,bool hi
{
QStringList result;
ListDiceResult diceResult = dice.value(face);
- //patternColor = patternColorarg();
- foreach (HighLightDice tmp, diceResult)
+ for (const auto& tmp : diceResult)
{
QStringList diceListStr;
QStringList diceListChildren;
diff --git a/node/countexecutenode.cpp b/node/countexecutenode.cpp
index 1f78fd2..de5e457 100644
--- a/node/countexecutenode.cpp
+++ b/node/countexecutenode.cpp
@@ -4,7 +4,7 @@
CountExecuteNode::CountExecuteNode()
- : m_scalarResult(new ScalarResult()),m_validator(NULL)
+ : m_scalarResult(new ScalarResult()),m_validator(nullptr)
{
m_result = m_scalarResult;
}
@@ -14,7 +14,7 @@ void CountExecuteNode::setValidator(Validator* validator)
}
CountExecuteNode::~CountExecuteNode()
{
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
delete m_validator;
}
@@ -23,19 +23,19 @@ CountExecuteNode::~CountExecuteNode()
void CountExecuteNode::run(ExecutionNode *previous)
{
m_previousNode = previous;
- if(NULL==previous)
+ if(nullptr==previous)
{
return;
}
DiceResult* previousResult = dynamic_cast<DiceResult*>(previous->getResult());
- if(NULL!=previousResult)
+ if(nullptr!=previousResult)
{
m_result->setPrevious(previousResult);
QList<Die*> diceList=previousResult->getResultList();
qint64 sum = 0;
- foreach(Die* dice,diceList)
+ for(Die* dice : diceList)
{
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
sum+=m_validator->hasValid(dice,true,true);
}
@@ -43,7 +43,7 @@ void CountExecuteNode::run(ExecutionNode *previous)
m_scalarResult->setValue(sum);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -63,23 +63,21 @@ QString CountExecuteNode::toString(bool withlabel) const
qint64 CountExecuteNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_previousNode)
{
- priority = m_nextNode->getPriority();
+ priority = m_previousNode->getPriority();
}
-
-
return priority;
}
ExecutionNode* CountExecuteNode::getCopy() const
{
CountExecuteNode* node = new CountExecuteNode();
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
node->setValidator(m_validator->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp
index 89ba24d..25b9d5a 100644
--- a/node/dicerollernode.cpp
+++ b/node/dicerollernode.cpp
@@ -17,10 +17,10 @@ DiceRollerNode::DiceRollerNode(qint64 max,qint64 min)
void DiceRollerNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL!=previous)
+ if(nullptr!=previous)
{
Result* result=previous->getResult();
- if(NULL!=result)
+ if(nullptr!=result)
{
m_diceCount = result->getResult(Result::SCALAR).toReal();
m_result->setPrevious(result);
@@ -40,7 +40,7 @@ void DiceRollerNode::run(ExecutionNode* previous)
//qDebug() << die->getValue() << "value";
m_diceResult->insertResult(die);
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -66,18 +66,16 @@ QString DiceRollerNode::toString(bool wl) const
qint64 DiceRollerNode::getPriority() const
{
qint64 priority=4;
-// if(NULL!=m_nextNode)
+// if(nullptr!=m_nextNode)
// {
// priority = m_nextNode->getPriority();
// }
-
-
return priority;
}
ExecutionNode* DiceRollerNode::getCopy() const
{
DiceRollerNode* node = new DiceRollerNode(m_max,m_min);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/executionnode.cpp b/node/executionnode.cpp
index c8c62f2..94d0d46 100644
--- a/node/executionnode.cpp
+++ b/node/executionnode.cpp
@@ -3,21 +3,21 @@
#include <QUuid>
ExecutionNode::ExecutionNode()
- : m_previousNode(NULL),m_result(NULL),m_nextNode(NULL),m_errors(QMap<ExecutionNode::DICE_ERROR_CODE,QString>()),m_id(QString("\"%1\"").arg(QUuid::createUuid().toString()))
+ : m_previousNode(nullptr),m_result(nullptr),m_nextNode(nullptr),m_errors(QMap<ExecutionNode::DICE_ERROR_CODE,QString>()),m_id(QString("\"%1\"").arg(QUuid::createUuid().toString()))
{
}
ExecutionNode::~ExecutionNode()
{
- if(NULL!=m_result)
+ if(nullptr!=m_result)
{
delete m_result;
- m_result = NULL;
+ m_result = nullptr;
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
delete m_nextNode;
- m_nextNode = NULL;
+ m_nextNode = nullptr;
}
}
@@ -39,9 +39,9 @@ ExecutionNode* ExecutionNode::getNextNode()
}
QMap<ExecutionNode::DICE_ERROR_CODE,QString> ExecutionNode::getExecutionErrorMap()
{
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
- foreach (ExecutionNode::DICE_ERROR_CODE key, m_nextNode->getExecutionErrorMap().keys())
+ for (const auto& key : m_nextNode->getExecutionErrorMap().keys())
{
m_errors.insert(key,m_nextNode->getExecutionErrorMap().value(key));
}
@@ -61,7 +61,7 @@ void ExecutionNode::generateDotTree(QString& s)
s.append(toString(true));
s.append(";\n");
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
s.append(toString(false));
s.append(" -> ");
@@ -74,8 +74,8 @@ void ExecutionNode::generateDotTree(QString& s)
{
s.append(toString(false));
s.append(" -> ");
- s.append("NULL;\n");
- if(NULL!=m_result)
+ s.append("nullptr;\n");
+ if(nullptr!=m_result)
{
s.append(toString(false));
diff --git a/node/executionnode.h b/node/executionnode.h
index c57b8b1..4913b68 100644
--- a/node/executionnode.h
+++ b/node/executionnode.h
@@ -23,7 +23,7 @@ public:
* @brief run
* @param previous
*/
- virtual void run(ExecutionNode* previous = NULL)=0;
+ virtual void run(ExecutionNode* previous = nullptr)=0;
/**
* @brief getResult
* @return
diff --git a/node/explosedicenode.cpp b/node/explosedicenode.cpp
index 51fc37e..bdde83b 100644
--- a/node/explosedicenode.cpp
+++ b/node/explosedicenode.cpp
@@ -1,20 +1,20 @@
#include "explosedicenode.h"
ExploseDiceNode::ExploseDiceNode()
- : m_diceResult(new DiceResult()),m_validator(NULL)
+ : m_diceResult(new DiceResult()),m_validator(nullptr)
{
m_result = m_diceResult;
}
void ExploseDiceNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if((NULL!=previous)&&(NULL!=previous->getResult()))
+ if((nullptr!=previous)&&(nullptr!=previous->getResult()))
{
DiceResult* previous_result = static_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previous_result);
- if(NULL!=previous_result)
+ if(nullptr!=previous_result)
{
- foreach(Die* die,previous_result->getResultList())
+ for(Die* die : previous_result->getResultList())
{
Die* tmpdie = new Die();
*tmpdie=*die;
@@ -25,7 +25,7 @@ void ExploseDiceNode::run(ExecutionNode* previous)
QList<Die*> list = m_diceResult->getResultList();
- foreach(Die* die, list)
+ for(Die* die : list)
{
while(m_validator->hasValid(die,false))
{
@@ -34,7 +34,7 @@ void ExploseDiceNode::run(ExecutionNode* previous)
}
// m_diceResult->setResultList(list);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -43,7 +43,7 @@ void ExploseDiceNode::run(ExecutionNode* previous)
}
ExploseDiceNode::~ExploseDiceNode()
{
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
delete m_validator;
}
@@ -66,23 +66,21 @@ QString ExploseDiceNode::toString(bool withlabel) const
qint64 ExploseDiceNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_previousNode)
{
- priority = m_nextNode->getPriority();
+ priority = m_previousNode->getPriority();
}
-
-
return priority;
}
ExecutionNode* ExploseDiceNode::getCopy() const
{
ExploseDiceNode* node = new ExploseDiceNode();
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
node->setValidator(m_validator->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/explosedicenode.h b/node/explosedicenode.h
index ceb35b8..6b582a3 100644
--- a/node/explosedicenode.h
+++ b/node/explosedicenode.h
@@ -14,7 +14,7 @@ class ExploseDiceNode : public ExecutionNode
public:
ExploseDiceNode();
virtual ~ExploseDiceNode();
- virtual void run(ExecutionNode* previous = NULL);
+ virtual void run(ExecutionNode* previous = nullptr);
virtual void setValidator(Validator* );
virtual QString toString(bool )const;
virtual qint64 getPriority() const;
diff --git a/node/filternode.cpp b/node/filternode.cpp
index 5cee9df..0be2e62 100644
--- a/node/filternode.cpp
+++ b/node/filternode.cpp
@@ -8,7 +8,7 @@ FilterNode::FilterNode()
FilterNode::~FilterNode()
{
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
delete m_validator;
}
@@ -20,13 +20,13 @@ void FilterNode::setValidator(Validator* validator)
void FilterNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL==previous)
+ if(nullptr==previous)
{
return;
}
DiceResult* previousDiceResult = static_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previousDiceResult);
- if(NULL!=previousDiceResult)
+ if(nullptr!=previousDiceResult)
{
QList<Die*> diceList=previousDiceResult->getResultList();
QList<Die*> diceList2;
@@ -48,7 +48,7 @@ void FilterNode::run(ExecutionNode* previous)
}
m_diceResult->setResultList(diceList2);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -69,22 +69,20 @@ QString FilterNode::toString(bool wl) const
qint64 FilterNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_previousNode)
{
- priority = m_nextNode->getPriority();
+ priority = m_previousNode->getPriority();
}
-
-
return priority;
}
ExecutionNode* FilterNode::getCopy() const
{
FilterNode* node = new FilterNode();
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
node->setValidator(m_validator->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/helpnode.cpp b/node/helpnode.cpp
index 4425969..bcd7aaf 100644
--- a/node/helpnode.cpp
+++ b/node/helpnode.cpp
@@ -30,9 +30,9 @@ void HelpNode::run(ExecutionNode* previous)
StringResult* txtResult = dynamic_cast<StringResult*>(m_result);
txtResult->setHighLight(false);
- if(NULL != previous)
+ if(nullptr != previous)
{
- if(previous->getResult() == NULL)
+ if(previous->getResult() == nullptr)
{
txtResult->setText(QObject::tr("Rolisteam Dice Parser:\nFull documentation at: %1").arg(m_path));
}
@@ -43,7 +43,7 @@ void HelpNode::run(ExecutionNode* previous)
m_result->setPrevious(previous->getResult());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -72,7 +72,7 @@ void HelpNode::setHelpPath(QString path)
ExecutionNode* HelpNode::getCopy() const
{
HelpNode* node = new HelpNode();
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/ifnode.cpp b/node/ifnode.cpp
index c32a6a9..b15e203 100644
--- a/node/ifnode.cpp
+++ b/node/ifnode.cpp
@@ -21,14 +21,14 @@
#include "result/diceresult.h"
IfNode::IfNode()
- : m_validator(NULL),m_true(NULL),m_false(NULL),m_conditionType(AllOfThem)
+ : m_validator(nullptr),m_true(nullptr),m_false(nullptr),m_conditionType(AllOfThem)
{
//m_result = new DiceResult();
}
IfNode::~IfNode()
{
- m_result=NULL;
+ m_result=nullptr;
}
void IfNode::run(ExecutionNode *previous)
@@ -60,7 +60,7 @@ void IfNode::run(ExecutionNode *previous)
for(Die* dice : diceList)
{
if(m_validator->hasValid(dice,true,true))
- {
+ {
nextNode = (nullptr==m_true) ? nullptr: m_true->getCopy();
}
else
@@ -104,29 +104,29 @@ void IfNode::run(ExecutionNode *previous)
{
if(oneIsTrue)
{
- nextNode = (NULL==m_true) ? NULL: m_true->getCopy();
+ nextNode = (nullptr==m_true) ? nullptr: m_true->getCopy();
}
else if(oneIsFalse)
{
- nextNode = (NULL==m_false) ? NULL: m_false->getCopy();
+ nextNode = (nullptr==m_false) ? nullptr: m_false->getCopy();
}
}
else if(m_conditionType==AllOfThem)
{
if(trueForAll)
{
- nextNode = (NULL==m_true) ? NULL: m_true->getCopy();
+ nextNode = (nullptr==m_true) ? nullptr: m_true->getCopy();
}
else if(falseForAll)
{
- nextNode = (NULL==m_false) ? NULL: m_false->getCopy();
+ nextNode = (nullptr==m_false) ? nullptr: m_false->getCopy();
}
}
- if(NULL!=nextNode)
+ if(nullptr!=nextNode)
{
- if(NULL==m_nextNode)
+ if(nullptr==m_nextNode)
{
m_nextNode = nextNode;
}
@@ -151,9 +151,9 @@ void IfNode::run(ExecutionNode *previous)
{
nextNode=m_false;
}
- if(NULL!=nextNode)
+ if(nullptr!=nextNode)
{
- if(NULL==m_nextNode)
+ if(nullptr==m_nextNode)
{
m_nextNode = nextNode;
}
@@ -163,7 +163,7 @@ void IfNode::run(ExecutionNode *previous)
}
}
- if((NULL!=m_nextNode)&&(runNext))
+ if((nullptr!=m_nextNode)&&(runNext))
{
m_nextNode->run(previousLoop);
}
@@ -187,7 +187,7 @@ void IfNode::generateDotTree(QString& s)
s.append(toString(true));
s.append(";\n");
- if((NULL!=m_true)&&(m_true != m_nextNode))
+ if((nullptr!=m_true)&&(m_true != m_nextNode))
{
s.append(toString(false));
s.append(" -> ");
@@ -196,7 +196,7 @@ void IfNode::generateDotTree(QString& s)
m_true->generateDotTree(s);
}
- if((NULL!=m_false)&&(m_false != m_nextNode))
+ if((nullptr!=m_false)&&(m_false != m_nextNode))
{
s.append(toString(false));
s.append(" -> ");
@@ -205,7 +205,7 @@ void IfNode::generateDotTree(QString& s)
m_false->generateDotTree(s);
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
s.append(toString(false));
s.append(" -> ");
@@ -217,9 +217,9 @@ void IfNode::generateDotTree(QString& s)
{
s.append(toString(false));
s.append(" -> ");
- s.append("NULL;\n");
+ s.append("nullptr;\n");
- if(NULL!=m_result)
+ if(nullptr!=m_result)
{
s.append(toString(false));
@@ -245,13 +245,18 @@ QString IfNode::toString(bool wl) const
qint64 IfNode::getPriority() const
{
- return 4;
+ qint64 priority=0;
+ if(nullptr != getPreviousNode())
+ {
+ priority=getPreviousNode()->getPriority();
+ }
+ return priority;
}
ExecutionNode* IfNode::getLeafNode(ExecutionNode* node)
{
ExecutionNode* next = node;
- while(NULL != next->getNextNode() )
+ while(nullptr != next->getNextNode() )
{
next = next->getNextNode();
}
@@ -270,19 +275,19 @@ void IfNode::setConditionType(const IfNode::ConditionType &conditionType)
ExecutionNode* IfNode::getCopy() const
{
IfNode* node = new IfNode();
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
node->setValidator(m_validator->getCopy());
}
- if(NULL!=m_false)
+ if(nullptr!=m_false)
{
node->setInstructionFalse(m_false->getCopy());
}
- if(NULL!=m_true)
+ if(nullptr!=m_true)
{
node->setInstructionTrue(m_true->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/ifnode.h b/node/ifnode.h
index 7376101..9205000 100644
--- a/node/ifnode.h
+++ b/node/ifnode.h
@@ -47,7 +47,7 @@ public:
* @brief run
* @param previous
*/
- virtual void run(ExecutionNode* previous = NULL);
+ virtual void run(ExecutionNode* previous = nullptr);
/**
* @brief setValidator
*/
diff --git a/node/jumpbackwardnode.cpp b/node/jumpbackwardnode.cpp
index b7af106..e860f99 100644
--- a/node/jumpbackwardnode.cpp
+++ b/node/jumpbackwardnode.cpp
@@ -23,8 +23,8 @@
JumpBackwardNode::JumpBackwardNode()
{
- m_previousNode=NULL;
- m_backwardNode = NULL;
+ m_previousNode=nullptr;
+ m_backwardNode = nullptr;
m_diceResult =new DiceResult();
m_result = m_diceResult;
}
@@ -51,7 +51,7 @@ void JumpBackwardNode::generateDotTree(QString& s)
s.append(toString(true));
s.append(";\n");
- if(NULL!=m_backwardNode)
+ if(nullptr!=m_backwardNode)
{
s.append(toString(false));
s.append(" -> ");
@@ -60,7 +60,7 @@ void JumpBackwardNode::generateDotTree(QString& s)
//m_backwardNode->generateDotTree(s);
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
s.append(toString(false));
s.append(" -> ");
@@ -72,9 +72,9 @@ void JumpBackwardNode::generateDotTree(QString& s)
{
s.append(toString(false));
s.append(" -> ");
- s.append("NULL;\n");
+ s.append("nullptr;\n");
- if(NULL!=m_result)
+ if(nullptr!=m_result)
{
s.append(toString(false));
s.append(" ->");
@@ -92,12 +92,12 @@ void JumpBackwardNode::run(ExecutionNode* previous)
ExecutionNode* parent = previous;
bool found=false;
//int i = 3;
- Result* result=NULL;
- while((NULL!=parent)&&(!found))
+ Result* result=nullptr;
+ while((nullptr!=parent)&&(!found))
{
result = parent->getResult();
- if(NULL!=result)
+ if(nullptr!=result)
{
//--i;
if(/*(i==0)&&*/(result->hasResultOfType(Result::DICE_LIST)))
@@ -108,7 +108,7 @@ void JumpBackwardNode::run(ExecutionNode* previous)
else
{
JumpBackwardNode* jpNode = dynamic_cast<JumpBackwardNode*>(parent);
- if(NULL!=jpNode)
+ if(nullptr!=jpNode)
{
found = true;
m_backwardNode = parent;
@@ -121,16 +121,16 @@ void JumpBackwardNode::run(ExecutionNode* previous)
}
}
- if(NULL==result)
+ if(nullptr==result)
{
m_errors.insert(DIE_RESULT_EXPECTED,QObject::tr(" The @ operator expects dice result. Please check the documentation to fix your command."));
}
else
{
DiceResult* diceResult = dynamic_cast<DiceResult*>(result);
- if(NULL!=diceResult)
+ if(nullptr!=diceResult)
{
- foreach(Die* die,diceResult->getResultList())
+ for(Die* die : diceResult->getResultList())
{
Die* tmpdie = new Die();
*tmpdie=*die;
@@ -141,11 +141,11 @@ void JumpBackwardNode::run(ExecutionNode* previous)
m_result->setPrevious(previous->getResult());
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
- if(NULL!=diceResult)
+ if(nullptr!=diceResult)
{
for(int i =0;i<diceResult->getResultList().size();++i)
{
@@ -163,7 +163,7 @@ void JumpBackwardNode::run(ExecutionNode* previous)
ExecutionNode* JumpBackwardNode::getCopy() const
{
JumpBackwardNode* node = new JumpBackwardNode();
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/jumpbackwardnode.h b/node/jumpbackwardnode.h
index cb87181..eda71f1 100644
--- a/node/jumpbackwardnode.h
+++ b/node/jumpbackwardnode.h
@@ -37,7 +37,7 @@ public:
* @brief run - performs the actions
* @param previous
*/
- virtual void run(ExecutionNode* previous = NULL);
+ virtual void run(ExecutionNode* previous = nullptr);
/**
* @brief toString
diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp
index d36abec..355a63a 100644
--- a/node/keepdiceexecnode.cpp
+++ b/node/keepdiceexecnode.cpp
@@ -36,20 +36,20 @@ KeepDiceExecNode::~KeepDiceExecNode()
void KeepDiceExecNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL==previous)
+ if(nullptr==previous)
{
return;
}
DiceResult* previousDiceResult = static_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previousDiceResult);
- if(NULL!=previousDiceResult)
+ if(nullptr!=previousDiceResult)
{
QList<Die*> diceList=previousDiceResult->getResultList();
QList<Die*> diceList3= diceList.mid(0,m_numberOfDice);
QList<Die*> diceList2;
- foreach(Die* die,diceList3)
+ for(Die* die:diceList3)
{
Die* tmpdie = new Die();
*tmpdie=*die;
@@ -70,7 +70,7 @@ void KeepDiceExecNode::run(ExecutionNode* previous)
}
m_diceResult->setResultList(diceList2);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -94,12 +94,10 @@ QString KeepDiceExecNode::toString(bool wl) const
qint64 KeepDiceExecNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_previousNode)
{
- priority = m_nextNode->getPriority();
+ priority = m_previousNode->getPriority();
}
-
-
return priority;
}
@@ -107,7 +105,7 @@ ExecutionNode* KeepDiceExecNode::getCopy() const
{
KeepDiceExecNode* node = new KeepDiceExecNode();
node->setDiceKeepNumber(m_numberOfDice);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/listaliasnode.cpp b/node/listaliasnode.cpp
index 91644d4..4c9f9f2 100644
--- a/node/listaliasnode.cpp
+++ b/node/listaliasnode.cpp
@@ -31,9 +31,9 @@ void ListAliasNode::run(ExecutionNode* previous )
StringResult* txtResult = dynamic_cast<StringResult*>(m_result);
txtResult->setHighLight(false);
- if(NULL != previous)
+ if(nullptr != previous)
{
- if(previous->getResult() == NULL)
+ if(previous->getResult() == nullptr)
{
txtResult->setText(buildList());
@@ -45,7 +45,7 @@ void ListAliasNode::run(ExecutionNode* previous )
m_result->setPrevious(previous->getResult());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -53,7 +53,7 @@ void ListAliasNode::run(ExecutionNode* previous )
QString ListAliasNode::buildList() const
{
QString result(QObject::tr("List of Alias:\n"));
- foreach(DiceAlias* key, *m_aliasList)
+ for(DiceAlias* key : *m_aliasList)
{
result+=QString("%1 : %2\n").arg(key->getCommand()).arg(key->getValue());
}
@@ -62,7 +62,7 @@ QString ListAliasNode::buildList() const
QString ListAliasNode::toString(bool wl) const
{
QStringList resultList;
- foreach(DiceAlias* key, *m_aliasList)
+ for(DiceAlias* key : *m_aliasList)
{
resultList << "{" <<key->getCommand() << key->getValue()<< "}";
}
@@ -84,7 +84,7 @@ qint64 ListAliasNode::getPriority() const
ExecutionNode* ListAliasNode::getCopy() const
{
ListAliasNode* node = new ListAliasNode(m_aliasList);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/listaliasnode.h b/node/listaliasnode.h
index 19212cd..493aa1e 100644
--- a/node/listaliasnode.h
+++ b/node/listaliasnode.h
@@ -36,7 +36,7 @@ public:
* @brief run
* @param previous
*/
- virtual void run(ExecutionNode* previous = NULL);
+ virtual void run(ExecutionNode* previous = nullptr);
/**
* @brief toString
diff --git a/node/listsetrollnode.cpp b/node/listsetrollnode.cpp
index 488721a..8f86332 100644
--- a/node/listsetrollnode.cpp
+++ b/node/listsetrollnode.cpp
@@ -28,10 +28,10 @@ ListSetRollNode::ListSetRollNode()
}
ListSetRollNode::~ListSetRollNode()
{
- if(NULL!=m_diceResult)
+ if(nullptr!=m_diceResult)
{
delete m_diceResult;
- m_diceResult =NULL;
+ m_diceResult =nullptr;
}
}
@@ -59,10 +59,10 @@ qint64 ListSetRollNode::getPriority() const
void ListSetRollNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL!=previous)
+ if(nullptr!=previous)
{
Result* result=previous->getResult();
- if(NULL!=result)
+ if(nullptr!=result)
{
quint64 diceCount = result->getResult(Result::SCALAR).toReal();
m_result->setPrevious(result);
@@ -76,7 +76,7 @@ void ListSetRollNode::run(ExecutionNode* previous)
getValueFromDie(die,rollResult);
}
m_stringResult->setText(rollResult.join(","));
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -106,7 +106,7 @@ void ListSetRollNode::computeFacesNumber(Die* die)
Q_ASSERT(m_values.size() == m_rangeList.size());
qint64 max;
int i=0;
- foreach(Range range, m_rangeList)
+ for(Range range: m_rangeList)
{
if(((i==0)||(max<range.getEnd()))&&(range.isFullyDefined()))
{
@@ -133,7 +133,7 @@ void ListSetRollNode::getValueFromDie(Die* die,QStringList& rollResult)
{
Q_ASSERT(m_values.size() == m_rangeList.size());
int i=0;
- foreach (Range range, m_rangeList)
+ for (Range range: m_rangeList)
{
if(range.hasValid(die,false))
{
@@ -150,7 +150,7 @@ ExecutionNode* ListSetRollNode::getCopy() const
node->setRangeList(dataList);
node->setUnique(m_unique);
node->setListValue(m_values);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/listsetrollnode.h b/node/listsetrollnode.h
index c140d8d..2cc36f0 100644
--- a/node/listsetrollnode.h
+++ b/node/listsetrollnode.h
@@ -36,7 +36,7 @@ class ListSetRollNode : public ExecutionNode
public:
ListSetRollNode();
virtual ~ListSetRollNode();
- virtual void run(ExecutionNode* previous = NULL);
+ virtual void run(ExecutionNode* previous = nullptr);
virtual QString toString(bool)const;
virtual qint64 getPriority() const;
QStringList getList() const;
diff --git a/node/mergenode.cpp b/node/mergenode.cpp
index 1cf6062..f2323df 100644
--- a/node/mergenode.cpp
+++ b/node/mergenode.cpp
@@ -99,7 +99,7 @@ QString MergeNode::toString(bool withLabel) const
qint64 MergeNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -108,7 +108,7 @@ qint64 MergeNode::getPriority() const
ExecutionNode* MergeNode::getCopy() const
{
MergeNode* node = new MergeNode();
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/numbernode.cpp b/node/numbernode.cpp
index 5815ad6..26141c5 100644
--- a/node/numbernode.cpp
+++ b/node/numbernode.cpp
@@ -39,11 +39,11 @@ NumberNode::~NumberNode()
void NumberNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL!=previous)
+ if(nullptr!=previous)
{
m_result->setPrevious(previous->getResult());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -68,7 +68,7 @@ QString NumberNode::toString(bool withLabel) const
qint64 NumberNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -80,7 +80,7 @@ ExecutionNode* NumberNode::getCopy() const
{
NumberNode* node = new NumberNode();
node->setNumber(m_number);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/paintnode.cpp b/node/paintnode.cpp
index 5a85590..035334e 100644
--- a/node/paintnode.cpp
+++ b/node/paintnode.cpp
@@ -53,32 +53,32 @@ void ColorItem::setColor(const QString &color)
PainterNode::PainterNode()
: ExecutionNode()
{
- m_result = NULL;
- m_nextNode = NULL;
+ m_result = nullptr;
+ m_nextNode = nullptr;
}
PainterNode::~PainterNode()
{
- m_result = NULL;
+ m_result = nullptr;
}
void PainterNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL==previous)
+ if(nullptr==previous)
{
return;
}
Result* previousResult = previous->getResult();
//m_result = previousResult;
DiceResult* previousDiceResult = dynamic_cast<DiceResult*>(previousResult);
- if(NULL!=previousDiceResult)
+ if(nullptr!=previousDiceResult)
{
QList<Die*> diceList=previousDiceResult->getResultList();
int pastDice=0;
- foreach(ColorItem item, m_colors)
+ for(ColorItem item: m_colors)
{
int current=item.colorNumber();
QList<Die*>::iterator it;
@@ -90,7 +90,7 @@ void PainterNode::run(ExecutionNode* previous)
}
}
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(previous);
}
@@ -127,7 +127,7 @@ void PainterNode::insertColorItem(QString color, int value)
ExecutionNode* PainterNode::getCopy() const
{
PainterNode* node = new PainterNode();
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/paintnode.h b/node/paintnode.h
index ffd8ae1..3d45b9a 100644
--- a/node/paintnode.h
+++ b/node/paintnode.h
@@ -48,7 +48,7 @@ class PainterNode : public ExecutionNode
public:
PainterNode();
virtual ~PainterNode();
- virtual void run(ExecutionNode* previous = NULL);
+ virtual void run(ExecutionNode* previous = nullptr);
Result* getResult();
virtual QString toString(bool )const;
virtual qint64 getPriority() const;
diff --git a/node/parenthesesnode.cpp b/node/parenthesesnode.cpp
index 96c0bb7..5c0379f 100644
--- a/node/parenthesesnode.cpp
+++ b/node/parenthesesnode.cpp
@@ -22,7 +22,7 @@
#include "parenthesesnode.h"
ParenthesesNode::ParenthesesNode()
- : m_internalNode(NULL)
+ : m_internalNode(nullptr)
{
}
@@ -32,12 +32,12 @@ void ParenthesesNode::setInternelNode(ExecutionNode* node)
}
void ParenthesesNode::run(ExecutionNode* /*previous*/)
{
- m_previousNode = NULL;
- if(NULL!=m_internalNode)
+ m_previousNode = nullptr;
+ if(nullptr!=m_internalNode)
{
m_internalNode->run(this);
ExecutionNode* temp=m_internalNode;
- while(NULL!=temp->getNextNode())
+ while(nullptr!=temp->getNextNode())
{
temp=temp->getNextNode();
}
@@ -45,7 +45,7 @@ void ParenthesesNode::run(ExecutionNode* /*previous*/)
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -69,11 +69,11 @@ qint64 ParenthesesNode::getPriority() const
ExecutionNode* ParenthesesNode::getCopy() const
{
ParenthesesNode* node = new ParenthesesNode();
- if(NULL!=m_internalNode)
+ if(nullptr!=m_internalNode)
{
node->setInternelNode(m_internalNode->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
@@ -96,7 +96,7 @@ void ParenthesesNode::generateDotTree(QString & s)
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
s.append(toString(false));
s.append(" -> ");
@@ -109,8 +109,8 @@ void ParenthesesNode::generateDotTree(QString & s)
{
s.append(toString(false));
s.append(" -> ");
- s.append("NULL;\n");
- if(NULL!=m_result)
+ s.append("nullptr;\n");
+ if(nullptr!=m_result)
{
s.append(toString(false));
diff --git a/node/parenthesesnode.h b/node/parenthesesnode.h
index 388f6db..5f841ab 100644
--- a/node/parenthesesnode.h
+++ b/node/parenthesesnode.h
@@ -31,7 +31,7 @@ class ParenthesesNode : public ExecutionNode
{
public:
ParenthesesNode();
- virtual void run(ExecutionNode* previous = NULL);
+ virtual void run(ExecutionNode* previous = nullptr);
void setInternelNode(ExecutionNode* node);
virtual QString toString(bool)const;
diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp
index dcce4aa..8e8be2c 100644
--- a/node/rerolldicenode.cpp
+++ b/node/rerolldicenode.cpp
@@ -2,28 +2,28 @@
RerollDiceNode::RerollDiceNode()
- : m_diceResult(new DiceResult()),m_adding(false),m_validator(NULL)
+ : m_diceResult(new DiceResult()),m_adding(false),m_validator(nullptr)
{
m_result=m_diceResult;
}
RerollDiceNode::~RerollDiceNode()
{
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
delete m_validator;
- m_validator = NULL;
+ m_validator = nullptr;
}
}
void RerollDiceNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if((NULL!=previous)&&(NULL!=previous->getResult()))
+ if((nullptr!=previous)&&(nullptr!=previous->getResult()))
{
DiceResult* previous_result = static_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previous_result);
- if(NULL!=previous_result)
+ if(nullptr!=previous_result)
{
- foreach(Die* die,previous_result->getResultList())
+ for(Die* die : previous_result->getResultList())
{
Die* tmpdie = new Die();
*tmpdie=*die;
@@ -34,7 +34,7 @@ void RerollDiceNode::run(ExecutionNode* previous)
QList<Die*> list = m_diceResult->getResultList();
- foreach(Die* die, list)
+ for(Die* die: list)
{
if(m_validator->hasValid(die,false))
{
@@ -42,7 +42,7 @@ void RerollDiceNode::run(ExecutionNode* previous)
}
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -72,7 +72,7 @@ void RerollDiceNode::setAddingMode(bool b)
qint64 RerollDiceNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -85,7 +85,7 @@ ExecutionNode* RerollDiceNode::getCopy() const
RerollDiceNode* node = new RerollDiceNode();
node->setValidator(m_validator);
node->setAddingMode(m_adding);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index 9c86917..b85f23c 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -26,56 +26,49 @@
ScalarOperatorNode::ScalarOperatorNode()
- : m_internalNode(NULL),m_scalarResult(new ScalarResult()),m_arithmeticOperator(Die::PLUS)
+ : m_internalNode(nullptr),m_scalarResult(new ScalarResult()),m_arithmeticOperator(Die::PLUS)
{
- /*m_scalarOperationList.insert('+',PLUS);
- m_scalarOperationList.insert('-',MINUS);
- m_scalarOperationList.insert('x',MULTIPLICATION);
- m_scalarOperationList.insert('*',MULTIPLICATION);
- m_scalarOperationList.insert('/',DIVIDE);*/
-
m_result = m_scalarResult;
}
ScalarOperatorNode::~ScalarOperatorNode()
{
- if(NULL!=m_internalNode)
- {
- delete m_internalNode;
- m_internalNode = NULL;
- }
+ if(nullptr!=m_internalNode)
+ {
+ delete m_internalNode;
+ m_internalNode = nullptr;
+ }
}
void ScalarOperatorNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL!=m_internalNode)
+ if(nullptr!=m_internalNode)
{
- m_internalNode->run(this);
+ m_internalNode->run(this);
}
- if(NULL!=previous)
+ if(nullptr!=previous)
{
DiceResult* previousResult = static_cast<DiceResult*>(previous->getResult());
- if(NULL!=previousResult)
+ if(nullptr!=previousResult)
{
ExecutionNode* internal = m_internalNode;
- if(NULL != internal)
+ if(nullptr != internal)
{
- while(NULL != internal->getNextNode() )
- {
+ while(nullptr != internal->getNextNode() )
+ {
internal = internal->getNextNode();
- }
-
+ }
- Result* internalResult = internal->getResult();
- m_result->setPrevious(internalResult);
- if(NULL!=m_internalNode->getResult())
- {
- m_internalNode->getResult()->setPrevious(previousResult);
- }
+ Result* internalResult = internal->getResult();
+ m_result->setPrevious(internalResult);
+ if(nullptr!=m_internalNode->getResult())
+ {
+ m_internalNode->getResult()->setPrevious(previousResult);
+ }
- switch(m_arithmeticOperator)
- {
+ switch(m_arithmeticOperator)
+ {
case Die::PLUS:
m_scalarResult->setValue(add(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal()));
break;
@@ -88,13 +81,16 @@ void ScalarOperatorNode::run(ExecutionNode* previous)
case Die::DIVIDE:
m_scalarResult->setValue(divide(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal()));
break;
+ case Die::POWER:
+ m_scalarResult->setValue(power(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal()));
+ break;
default:
break;
- }
+ }
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -102,15 +98,6 @@ void ScalarOperatorNode::run(ExecutionNode* previous)
}
}
-/*bool ScalarOperatorNode::setOperatorChar(QChar c)
-{
- if(m_scalarOperationList.contains(c))
- {
- m_operator = m_scalarOperationList.value(c);
- return true;
- }
- return false;
-}*/
void ScalarOperatorNode::setInternalNode(ExecutionNode* node)
{
@@ -133,10 +120,14 @@ qreal ScalarOperatorNode::divide(qint64 a,qint64 b)
}
return (qreal)a/b;
}
-qint64 ScalarOperatorNode::multiple(qint64 a,qint64 b)
+qint64 ScalarOperatorNode::multiple(qint64 a, qint64 b)
{
return a*b;
}
+qint64 ScalarOperatorNode::power(qint64 a, qint64 b)
+{
+ return std::pow(a,b);
+}
Die::ArithmeticOperator ScalarOperatorNode::getArithmeticOperator() const
{
return m_arithmeticOperator;
@@ -157,64 +148,71 @@ QString ScalarOperatorNode::toString(bool wl) const
break;
case Die::MINUS:
op="-";
- break;
- case Die::MULTIPLICATION:
- op="*";
- break;
- case Die::DIVIDE:
- op="/";
- break;
- default:
- break;
+ break;
+ case Die::MULTIPLICATION:
+ op="*";
+ break;
+ case Die::DIVIDE:
+ op="/";
+ break;
+ case Die::POWER:
+ op="^";
+ break;
+ default:
+ break;
}
- if(wl)
- {
- return QString("%1 [label=\"ScalarOperatorNode %2\"]").arg(m_id).arg(op);
- }
- else
- {
- return m_id;
- }
+ if(wl)
+ {
+ return QString("%1 [label=\"ScalarOperatorNode %2\"]").arg(m_id).arg(op);
+ }
+ else
+ {
+ return m_id;
+ }
}
qint64 ScalarOperatorNode::getPriority() const
{
if((m_arithmeticOperator==Die::PLUS)||(m_arithmeticOperator==Die::MINUS))
- {
+ {
return 1;
- }
- else
- {
+ }
+ else if((m_arithmeticOperator==Die::MULTIPLICATION)||(m_arithmeticOperator==Die::DIVIDE))
+ {
return 2;
- }
+ }
+ else
+ {
+ return 3;
+ }
}
void ScalarOperatorNode::generateDotTree(QString& s)
{
- s.append(toString(true));
- s.append(";\n");
+ s.append(toString(true));
+ s.append(";\n");
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
- s.append(toString(false));
+ s.append(toString(false));
s.append(" -> ");
- s.append(m_nextNode->toString(false));
+ s.append(m_nextNode->toString(false));
s.append("[label=\"nextNode\"];\n");
m_nextNode->generateDotTree(s);
}
else
{
- s.append(toString(false));
+ s.append(toString(false));
s.append(" -> ");
- s.append("NULL");
- s.append(" [label=\"nextNode\"];\n");
+ s.append("nullptr");
+ s.append(" [label=\"nextNode\"];\n");
}
QString str;
str.append("\n");
- if(NULL!=m_internalNode)
+ if(nullptr!=m_internalNode)
{
- str.append(toString(false));
+ str.append(toString(false));
str.append(" -> ");
- str.append(m_internalNode->toString(false));
+ str.append(m_internalNode->toString(false));
str.append(" [label=\"internalNode\"];\n");
m_internalNode->generateDotTree(str);
}
@@ -222,14 +220,14 @@ void ScalarOperatorNode::generateDotTree(QString& s)
}
QMap<ExecutionNode::DICE_ERROR_CODE,QString> ScalarOperatorNode::getExecutionErrorMap()
{
- if(NULL!=m_internalNode)
+ if(nullptr!=m_internalNode)
{
for (ExecutionNode::DICE_ERROR_CODE key: m_internalNode->getExecutionErrorMap().keys())
{
m_errors.insert(key,m_internalNode->getExecutionErrorMap().value(key));
}
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
for (ExecutionNode::DICE_ERROR_CODE key: m_nextNode->getExecutionErrorMap().keys())
{
@@ -243,7 +241,7 @@ ExecutionNode* ScalarOperatorNode::getCopy() const
ScalarOperatorNode* node = new ScalarOperatorNode();
node->setInternalNode(m_internalNode->getCopy());
node->setArithmeticOperator(m_arithmeticOperator);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/scalaroperatornode.h b/node/scalaroperatornode.h
index 0855a4c..7753a6f 100644
--- a/node/scalaroperatornode.h
+++ b/node/scalaroperatornode.h
@@ -115,6 +115,11 @@ private:
* @return
*/
static qint64 multiple(qint64,qint64);
+ /**
+ * @brief power
+ * @return
+ */
+ static qint64 power(qint64,qint64);
private:
ExecutionNode* m_internalNode;
diff --git a/node/sortresult.cpp b/node/sortresult.cpp
index d864aa2..e3d8d1e 100644
--- a/node/sortresult.cpp
+++ b/node/sortresult.cpp
@@ -34,13 +34,13 @@ SortResultNode::SortResultNode()
void SortResultNode::run(ExecutionNode* node)
{
m_previousNode = node;
- if(NULL==node)
+ if(nullptr==node)
{
return;
}
DiceResult* previousDiceResult = dynamic_cast<DiceResult*>(node->getResult());
m_diceResult->setPrevious(previousDiceResult);
- if(NULL!=previousDiceResult)
+ if(nullptr!=previousDiceResult)
{
QList<Die*> diceList=previousDiceResult->getResultList();
QList<Die*> diceList2=m_diceResult->getResultList();
@@ -57,7 +57,7 @@ void SortResultNode::run(ExecutionNode* node)
bool found = false;
int start = 0;
int end = diceList2.size();
- Die* tmp2 = NULL;
+ Die* tmp2 = nullptr;
while(!found)
{
int distance = end-start;
@@ -92,7 +92,7 @@ void SortResultNode::run(ExecutionNode* node)
}
m_diceResult->setResultList(diceList2);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -123,22 +123,19 @@ QString SortResultNode::toString(bool wl) const
qint64 SortResultNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr != m_previousNode)
{
- priority = m_nextNode->getPriority();
+ priority = m_previousNode->getPriority();
}
-
-
return priority;
}
ExecutionNode* SortResultNode::getCopy() const
{
SortResultNode* node = new SortResultNode();
node->setSortAscending(m_ascending);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
return node;
-
}
diff --git a/node/splitnode.cpp b/node/splitnode.cpp
index a074248..ed32fdd 100644
--- a/node/splitnode.cpp
+++ b/node/splitnode.cpp
@@ -29,7 +29,7 @@ SplitNode::SplitNode()
void SplitNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL!=previous)
+ if(nullptr!=previous)
{
m_result->setPrevious(previous->getResult());
@@ -56,7 +56,7 @@ void SplitNode::run(ExecutionNode* previous)
}
}
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -76,7 +76,7 @@ QString SplitNode::toString(bool withLabel) const
qint64 SplitNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -85,7 +85,7 @@ qint64 SplitNode::getPriority() const
ExecutionNode* SplitNode::getCopy() const
{
SplitNode* node = new SplitNode();
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/startingnode.cpp b/node/startingnode.cpp
index 3cd3352..3b0d660 100644
--- a/node/startingnode.cpp
+++ b/node/startingnode.cpp
@@ -22,12 +22,11 @@
StartingNode::StartingNode()
{
-
+ m_previousNode = nullptr;
}
void StartingNode::run(ExecutionNode*)
{
- m_previousNode = NULL;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -48,7 +47,7 @@ QString StartingNode::toString(bool withlabel) const
qint64 StartingNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -57,7 +56,7 @@ qint64 StartingNode::getPriority() const
ExecutionNode* StartingNode::getCopy() const
{
StartingNode* node = new StartingNode();
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/stringnode.cpp b/node/stringnode.cpp
index d427cd6..af2fcda 100644
--- a/node/stringnode.cpp
+++ b/node/stringnode.cpp
@@ -9,11 +9,11 @@ StringNode::StringNode()
void StringNode::run(ExecutionNode *previous)
{
m_previousNode = previous;
- if(NULL!=previous)
+ if(nullptr!=previous)
{
m_result->setPrevious(previous->getResult());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -111,7 +111,7 @@ QString StringNode::toString(bool withLabel) const
qint64 StringNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -121,7 +121,7 @@ ExecutionNode* StringNode::getCopy() const
{
StringNode* node = new StringNode();
node->setString(m_data);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/operationcondition.cpp b/operationcondition.cpp
index 6664c83..220e810 100644
--- a/operationcondition.cpp
+++ b/operationcondition.cpp
@@ -21,7 +21,7 @@
#include "operationcondition.h"
OperationCondition::OperationCondition()
- : m_operator(Modulo),m_boolean(NULL),m_value(0)
+ : m_operator(Modulo),m_boolean(nullptr),m_value(0)
{
}
diff --git a/range.cpp b/range.cpp
index 39a46ce..081e253 100644
--- a/range.cpp
+++ b/range.cpp
@@ -41,7 +41,7 @@ qint64 Range::hasValid(Die* m,bool recursive, bool unhighlight) const
qint64 result = 0;
if(recursive)
{
- foreach(qint64 value, m->getListValue())
+ for(qint64 value: m->getListValue())
{
if((value>=m_start)&&(value<=m_end))
{
diff --git a/result/diceresult.cpp b/result/diceresult.cpp
index ddedd1c..dd624e9 100644
--- a/result/diceresult.cpp
+++ b/result/diceresult.cpp
@@ -143,7 +143,7 @@ void DiceResult::setOperator(const Die::ArithmeticOperator& dieOperator)
QString DiceResult::toString(bool wl)
{
QStringList scalarSum;
- foreach(Die* die,m_diceValues)
+ for(Die* die:m_diceValues)
{
scalarSum << QString::number(die->getValue());
}
diff --git a/result/result.cpp b/result/result.cpp
index 6e1ea7a..f79e004 100644
--- a/result/result.cpp
+++ b/result/result.cpp
@@ -23,7 +23,7 @@
#include <QUuid>
Result::Result()
- : m_resultTypes(NONE),m_id(QString("\"%1\"").arg(QUuid::createUuid().toString())),m_previous(NULL)
+ : m_resultTypes(NONE),m_id(QString("\"%1\"").arg(QUuid::createUuid().toString())),m_previous(nullptr)
{
}
Result::~Result()
@@ -55,7 +55,7 @@ void Result::generateDotTree(QString& s)
s.append(toString(true));
s.append(";\n");
- if(NULL!=m_previous)
+ if(nullptr!=m_previous)
{
s.append(toString(false));
s.append(" -> ");
@@ -67,7 +67,7 @@ void Result::generateDotTree(QString& s)
{
s.append(toString(false));
s.append(" -> ");
- s.append("NULL");
+ s.append("nullptr");
s.append(" [label=\"previousResult\"];\n");
}