From 95d4b12f2900f13e5836cb460261c96889bdd4e5 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 25 Nov 2017 02:51:23 +0100 Subject: remove useless commit --- README.md | 24 ++++------------------ booleancondition.cpp | 2 +- cli/main.cpp | 2 +- compositevalidator.cpp | 2 +- diceparser.cpp | 14 ++++++++----- die.h | 4 ++-- irc/botircdiceparser.cpp | 3 ++- node/countexecutenode.cpp | 18 ++++++++--------- node/dicerollernode.cpp | 2 ++ node/executionnode.cpp | 2 +- node/explosedicenode.cpp | 16 +++++++-------- node/filternode.cpp | 14 ++++++------- node/ifnode.cpp | 9 ++------- node/jumpbackwardnode.cpp | 2 +- node/keepdiceexecnode.cpp | 10 ++++----- node/listaliasnode.cpp | 4 ++-- node/listsetrollnode.cpp | 4 ++-- node/paintnode.cpp | 2 +- node/rerolldicenode.cpp | 4 ++-- node/scalaroperatornode.cpp | 49 ++++++++++++++++++++++++++------------------- node/scalaroperatornode.h | 5 ----- node/separatornode.cpp | 0 node/separatornode.h | 44 ---------------------------------------- node/sortresult.cpp | 8 ++++---- node/startingnode.cpp | 5 +++-- parsingtoolbox.cpp | 9 ++++----- range.cpp | 2 +- result/diceresult.cpp | 2 +- 28 files changed, 103 insertions(+), 159 deletions(-) delete mode 100644 node/separatornode.cpp delete mode 100644 node/separatornode.h diff --git a/README.md b/README.md index 36c7a41..0e32f80 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,9 @@ -[![Build Status](https://raw.githubusercontent.com/Rolisteam/rolisteam/master/resources/logo/1000-rolisteam.png)](http://www.rolisteam.org) +[![Build Status](http://www.rolisteam.org/sites/default/files/pixture_reloaded_logo.png)](http://www.rolisteam.org) # DiceParser -Dice Parser merges several tool to roll any kind of dice to play at role playing games. -It can be use as command line application on GNU/Linux -It also provides IRC bot, discord bot, twitter bot and webservice. - -[More informations](http://www.rolisteam.org/) +Rolisteam Dice Parser ## Grammar The grammar is something like this: @@ -39,20 +35,6 @@ parenthese =: (expression) count =: c Validator ``` -## Build - -``` -git clone git@github.com:Rolisteam/DiceParser.git -cd DiceParser -mkdir build -cd build -cmake ../ -make -make install -``` -# Downloads - --DiceParser is part of rolisteam : http://www.rolisteam.org/download but it can be use as standalone tool. ## Example: @@ -81,6 +63,8 @@ roll 1 die with 25 faces ### 8+8+8 compute: 24 + + ### 100/28*3 compute: 100/28 = 3 3*3 = 9 diff --git a/booleancondition.cpp b/booleancondition.cpp index 907746c..7be9836 100644 --- a/booleancondition.cpp +++ b/booleancondition.cpp @@ -39,7 +39,7 @@ qint64 BooleanCondition::hasValid(Die* b,bool recursive,bool unhighlight) const } qint64 sum= 0; - for(qint64 value : listValues) + foreach(qint64 value, listValues) { switch(m_operator) { diff --git a/cli/main.cpp b/cli/main.cpp index 6ed6036..be02507 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -151,7 +151,7 @@ QString diceToText(QList& diceList,bool highlight,bool homog for(auto dice : diceList) { QStringList resultGlobal; - for(int face : dice.keys()) + foreach(int face, dice.keys()) { QStringList result; ListDiceResult diceResult = dice.value(face); diff --git a/compositevalidator.cpp b/compositevalidator.cpp index 9023460..4689678 100644 --- a/compositevalidator.cpp +++ b/compositevalidator.cpp @@ -40,7 +40,7 @@ qint64 CompositeValidator::hasValid(Die* b,bool recursive,bool unhighlight) cons int i = 0; qint64 sum = 0; bool highLight = false; - for(const Validator* validator: *m_validatorList) + foreach(const Validator* validator, *m_validatorList) { qint64 val = validator->hasValid(b,recursive,unhighlight); if(i==0) diff --git a/diceparser.cpp b/diceparser.cpp index 902f6ba..c2191ce 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -254,7 +254,7 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node) { NumberNode* numberNode=new NumberNode(); numberNode->setNumber(1); - ExecutionNode* previous = diceNode->getPreviousNode(); + ExecutionNode* previous = diceNode->getPreviousNode(); numberNode->setPreviousNode(previous); numberNode->setNextNode(diceNode); node = numberNode; @@ -567,7 +567,7 @@ QString DiceParser::getDiceCommand() const bool DiceParser::hasIntegerResultNotInFirst() { - bool result=false; + bool result; for(auto node : m_startNodes) { result |= hasResultOfType(Result::SCALAR,node); @@ -577,7 +577,7 @@ bool DiceParser::hasIntegerResultNotInFirst() bool DiceParser::hasDiceResult() { - bool result=false; + bool result; for(auto node : m_startNodes) { result |= hasResultOfType(Result::DICE_LIST,node); @@ -586,7 +586,7 @@ bool DiceParser::hasDiceResult() } bool DiceParser::hasStringResult() { - bool result=false; + bool result; for(auto node : m_startNodes) { result |= hasResultOfType(Result::STRING,node); @@ -871,7 +871,6 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous) } previous->setNextNode(nullptr); m_startNodes.append(nodeExec); - auto test = dynamic_cast(nodeExec); m_currentTreeHasSeparator = true; return true; } @@ -928,6 +927,11 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, { case Keep: { + qDebug() << "keep " << previous->toString(true) << str; + if(str == "4+7") + { + qDebug() << "nauteanuit"; + } qint64 myNumber=0; bool ascending = m_parsingToolbox->readAscending(str); diff --git a/die.h b/die.h index c048ee6..7f5cf44 100644 --- a/die.h +++ b/die.h @@ -34,7 +34,7 @@ public: /** * @brief The ArithmeticOperator enum */ - enum ArithmeticOperator {PLUS,MINUS,DIVIDE,MULTIPLICATION,POWER}; + enum ArithmeticOperator {PLUS,MINUS,DIVIDE,MULTIPLICATION}; /** * @brief Die */ @@ -154,6 +154,6 @@ private: std::mt19937 m_rng; }; -Q_DECLARE_TYPEINFO(Die,Q_MOVABLE_TYPE); + #endif // DIE_H diff --git a/irc/botircdiceparser.cpp b/irc/botircdiceparser.cpp index ce9bf3a..44a3224 100644 --- a/irc/botircdiceparser.cpp +++ b/irc/botircdiceparser.cpp @@ -164,7 +164,8 @@ QString BotIrcDiceParser::diceToText(QList& diceList,bool hi { QStringList result; ListDiceResult diceResult = dice.value(face); - for (const auto& tmp : diceResult) + //patternColor = patternColorarg(); + foreach (HighLightDice tmp, diceResult) { QStringList diceListStr; QStringList diceListChildren; diff --git a/node/countexecutenode.cpp b/node/countexecutenode.cpp index ca2c599..84946df 100644 --- a/node/countexecutenode.cpp +++ b/node/countexecutenode.cpp @@ -4,7 +4,7 @@ CountExecuteNode::CountExecuteNode() - : m_scalarResult(new ScalarResult()),m_validator(nullptr) + : m_scalarResult(new ScalarResult()),m_validator(nullptr) { m_result = m_scalarResult; } @@ -14,7 +14,7 @@ void CountExecuteNode::setValidator(Validator* validator) } CountExecuteNode::~CountExecuteNode() { - if(nullptr!=m_validator) + if(nullptr!=m_validator) { delete m_validator; } @@ -23,19 +23,19 @@ CountExecuteNode::~CountExecuteNode() void CountExecuteNode::run(ExecutionNode *previous) { m_previousNode = previous; - if(nullptr==previous) + if(nullptr==previous) { return; } DiceResult* previousResult = dynamic_cast(previous->getResult()); - if(NULL!=previousResult) + if(nullptr!=previousResult) { m_result->setPrevious(previousResult); QList diceList=previousResult->getResultList(); qint64 sum = 0; foreach(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(nullptr!=m_nextNode) + if(nullptr!=m_nextNode) { m_nextNode->run(this); } @@ -63,7 +63,7 @@ QString CountExecuteNode::toString(bool withlabel) const qint64 CountExecuteNode::getPriority() const { qint64 priority=0; - if(nullptr!=m_previousNode) + if(nullptr!=m_nextNode) { priority = m_nextNode->getPriority(); } @@ -75,11 +75,11 @@ qint64 CountExecuteNode::getPriority() const 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 f2b002d..ed6d102 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -70,6 +70,8 @@ qint64 DiceRollerNode::getPriority() const // { // priority = m_nextNode->getPriority(); // } + + return priority; } ExecutionNode* DiceRollerNode::getCopy() const diff --git a/node/executionnode.cpp b/node/executionnode.cpp index 94d0d46..84aa17c 100644 --- a/node/executionnode.cpp +++ b/node/executionnode.cpp @@ -41,7 +41,7 @@ QMap ExecutionNode::getExecutionErrorMap { if(nullptr!=m_nextNode) { - for (const auto& key : m_nextNode->getExecutionErrorMap().keys()) + foreach (ExecutionNode::DICE_ERROR_CODE key, m_nextNode->getExecutionErrorMap().keys()) { m_errors.insert(key,m_nextNode->getExecutionErrorMap().value(key)); } diff --git a/node/explosedicenode.cpp b/node/explosedicenode.cpp index 81e80ee..96caaeb 100644 --- a/node/explosedicenode.cpp +++ b/node/explosedicenode.cpp @@ -1,18 +1,18 @@ #include "explosedicenode.h" ExploseDiceNode::ExploseDiceNode() - : m_diceResult(new DiceResult()),m_validator(nullptr) + : 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(previous->getResult()); m_result->setPrevious(previous_result); - if(NULL!=previous_result) + if(nullptr!=previous_result) { foreach(Die* die,previous_result->getResultList()) { @@ -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(nullptr!=m_validator) + if(nullptr!=m_validator) { delete m_validator; } @@ -66,7 +66,7 @@ QString ExploseDiceNode::toString(bool withlabel) const qint64 ExploseDiceNode::getPriority() const { qint64 priority=0; - if(nullptr!=m_previousNode) + if(nullptr!=m_nextNode) { priority = m_nextNode->getPriority(); } @@ -78,11 +78,11 @@ qint64 ExploseDiceNode::getPriority() const 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/filternode.cpp b/node/filternode.cpp index 5153c79..462774b 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(previous->getResult()); m_result->setPrevious(previousDiceResult); - if(NULL!=previousDiceResult) + if(nullptr!=previousDiceResult) { QList diceList=previousDiceResult->getResultList(); QList 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,7 +69,7 @@ QString FilterNode::toString(bool wl) const qint64 FilterNode::getPriority() const { qint64 priority=0; - if(nullptr!=m_previousNode) + if(nullptr!=m_nextNode) { priority = m_nextNode->getPriority(); } @@ -80,11 +80,11 @@ qint64 FilterNode::getPriority() const 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/ifnode.cpp b/node/ifnode.cpp index b15e203..b40ed82 100644 --- a/node/ifnode.cpp +++ b/node/ifnode.cpp @@ -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 @@ -245,12 +245,7 @@ QString IfNode::toString(bool wl) const qint64 IfNode::getPriority() const { - qint64 priority=0; - if(nullptr != getPreviousNode()) - { - priority=getPreviousNode()->getPriority(); - } - return priority; + return 4; } ExecutionNode* IfNode::getLeafNode(ExecutionNode* node) diff --git a/node/jumpbackwardnode.cpp b/node/jumpbackwardnode.cpp index e860f99..1309b3b 100644 --- a/node/jumpbackwardnode.cpp +++ b/node/jumpbackwardnode.cpp @@ -130,7 +130,7 @@ void JumpBackwardNode::run(ExecutionNode* previous) DiceResult* diceResult = dynamic_cast(result); if(nullptr!=diceResult) { - for(Die* die : diceResult->getResultList()) + foreach(Die* die,diceResult->getResultList()) { Die* tmpdie = new Die(); *tmpdie=*die; diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp index 6167632..a93cc11 100644 --- a/node/keepdiceexecnode.cpp +++ b/node/keepdiceexecnode.cpp @@ -36,13 +36,13 @@ KeepDiceExecNode::~KeepDiceExecNode() void KeepDiceExecNode::run(ExecutionNode* previous) { m_previousNode = previous; - if(NULL==previous) + if(nullptr==previous) { return; } DiceResult* previousDiceResult = static_cast(previous->getResult()); m_result->setPrevious(previousDiceResult); - if(NULL!=previousDiceResult) + if(nullptr!=previousDiceResult) { QList diceList=previousDiceResult->getResultList(); @@ -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,7 +94,7 @@ QString KeepDiceExecNode::toString(bool wl) const qint64 KeepDiceExecNode::getPriority() const { qint64 priority=0; - if(nullptr!=m_previousNode) + if(nullptr!=m_nextNode) { priority = m_nextNode->getPriority(); } @@ -107,7 +107,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 4c9f9f2..642f601 100644 --- a/node/listaliasnode.cpp +++ b/node/listaliasnode.cpp @@ -53,7 +53,7 @@ void ListAliasNode::run(ExecutionNode* previous ) QString ListAliasNode::buildList() const { QString result(QObject::tr("List of Alias:\n")); - for(DiceAlias* key : *m_aliasList) + foreach(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; - for(DiceAlias* key : *m_aliasList) + foreach(DiceAlias* key, *m_aliasList) { resultList << "{" <getCommand() << key->getValue()<< "}"; } diff --git a/node/listsetrollnode.cpp b/node/listsetrollnode.cpp index 8f86332..21d5403 100644 --- a/node/listsetrollnode.cpp +++ b/node/listsetrollnode.cpp @@ -106,7 +106,7 @@ void ListSetRollNode::computeFacesNumber(Die* die) Q_ASSERT(m_values.size() == m_rangeList.size()); qint64 max; int i=0; - for(Range range: m_rangeList) + foreach(Range range, m_rangeList) { if(((i==0)||(max diceList=previousDiceResult->getResultList(); int pastDice=0; - for(ColorItem item: m_colors) + foreach(ColorItem item, m_colors) { int current=item.colorNumber(); QList::iterator it; diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp index 8e8be2c..1f8cd7e 100644 --- a/node/rerolldicenode.cpp +++ b/node/rerolldicenode.cpp @@ -23,7 +23,7 @@ void RerollDiceNode::run(ExecutionNode* previous) m_result->setPrevious(previous_result); if(nullptr!=previous_result) { - for(Die* die : previous_result->getResultList()) + foreach(Die* die,previous_result->getResultList()) { Die* tmpdie = new Die(); *tmpdie=*die; @@ -34,7 +34,7 @@ void RerollDiceNode::run(ExecutionNode* previous) QList list = m_diceResult->getResultList(); - for(Die* die: list) + foreach(Die* die, list) { if(m_validator->hasValid(die,false)) { diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp index f4884c8..a9a19e3 100644 --- a/node/scalaroperatornode.cpp +++ b/node/scalaroperatornode.cpp @@ -38,37 +38,44 @@ ScalarOperatorNode::ScalarOperatorNode() } ScalarOperatorNode::~ScalarOperatorNode() { - if(nullptr!=m_internalNode) - { - delete m_internalNode; - m_internalNode = nullptr; - } + 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); } - if(NULL!=previous) + if(nullptr!=previous) { DiceResult* previousResult = static_cast(previous->getResult()); - if(NULL!=previousResult) + if(nullptr!=previousResult) { ExecutionNode* internal = m_internalNode; - if(NULL != internal) + if(nullptr != internal) { - while(nullptr != internal->getNextNode() ) - { + while(nullptr != internal->getNextNode() ) + { internal = internal->getNextNode(); } - switch(m_arithmeticOperator) - { + Result* internalResult = internal->getResult(); + m_result->setPrevious(internalResult); + if(nullptr!=m_internalNode->getResult()) + { + m_internalNode->getResult()->setPrevious(previousResult); + } + + switch(m_arithmeticOperator) + { case Die::PLUS: m_scalarResult->setValue(add(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal())); break; @@ -87,7 +94,7 @@ void ScalarOperatorNode::run(ExecutionNode* previous) } } - if(NULL!=m_nextNode) + if(nullptr!=m_nextNode) { m_nextNode->run(this); } @@ -186,7 +193,7 @@ void ScalarOperatorNode::generateDotTree(QString& s) s.append(toString(true)); s.append(";\n"); - if(NULL!=m_nextNode) + if(nullptr!=m_nextNode) { s.append(toString(false)); s.append(" -> "); @@ -198,12 +205,12 @@ void ScalarOperatorNode::generateDotTree(QString& s) { s.append(toString(false)); s.append(" -> "); - s.append("nullptr"); - 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(" -> "); @@ -215,14 +222,14 @@ void ScalarOperatorNode::generateDotTree(QString& s) } QMap 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()) { @@ -236,7 +243,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 7753a6f..0855a4c 100644 --- a/node/scalaroperatornode.h +++ b/node/scalaroperatornode.h @@ -115,11 +115,6 @@ private: * @return */ static qint64 multiple(qint64,qint64); - /** - * @brief power - * @return - */ - static qint64 power(qint64,qint64); private: ExecutionNode* m_internalNode; diff --git a/node/separatornode.cpp b/node/separatornode.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/node/separatornode.h b/node/separatornode.h deleted file mode 100644 index 0820429..0000000 --- a/node/separatornode.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2017 by Renaud Guezennec * -* http://www.rolisteam.org/contact * -* * -* This file is part of DiceParser * -* * -* DiceParser is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ -#ifndef SEPARATORNODE_H -#define SEPARATORNODE_H - -#include "node/executionnode.h" -#include "result/diceresult.h" - -/** - * @brief The MergeNode class is an ExecutionNode. It is dedicated to merge result of several commands. - */ -class SeparatorNode : public ExecutionNode -{ -public: - SeparatorNode(); - void run(ExecutionNode* previous); - virtual QString toString(bool withLabel)const; - virtual qint64 getPriority() const; - virtual ExecutionNode *getCopy() const; -private: - DiceResult* m_diceResult; - ExecutionNode* m_; -}; - -#endif // SEPARATORNODE_H diff --git a/node/sortresult.cpp b/node/sortresult.cpp index 062e1d2..5406eb6 100644 --- a/node/sortresult.cpp +++ b/node/sortresult.cpp @@ -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,7 +123,7 @@ QString SortResultNode::toString(bool wl) const qint64 SortResultNode::getPriority() const { qint64 priority=0; - if(nullptr != m_previousNode) + if(nullptr!=m_nextNode) { priority = m_nextNode->getPriority(); } @@ -135,7 +135,7 @@ 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()); } diff --git a/node/startingnode.cpp b/node/startingnode.cpp index 43a0dd7..670dc7d 100644 --- a/node/startingnode.cpp +++ b/node/startingnode.cpp @@ -26,6 +26,7 @@ StartingNode::StartingNode() } void StartingNode::run(ExecutionNode*) { + m_previousNode = nullptr; if(nullptr!=m_nextNode) { m_nextNode->run(this); @@ -47,7 +48,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(); } @@ -56,7 +57,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/parsingtoolbox.cpp b/parsingtoolbox.cpp index a5a9920..02cdd13 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -58,7 +58,6 @@ ParsingToolBox::ParsingToolBox() m_arithmeticOperation->insert(QStringLiteral("x"),Die::MULTIPLICATION); m_arithmeticOperation->insert(QStringLiteral("/"),Die::DIVIDE); m_arithmeticOperation->insert(QStringLiteral("÷"),Die::DIVIDE); - m_arithmeticOperation->insert(QStringLiteral("^"),Die::POWER); } @@ -99,7 +98,7 @@ ExecutionNode* ParsingToolBox::addSort(ExecutionNode* e,bool b) bool ParsingToolBox::readDiceLogicOperator(QString& str,OperationCondition::ConditionOperator& op) { QString longKey; - for(const QString& tmp: m_conditionOperation->keys()) + foreach(QString tmp, m_conditionOperation->keys()) { if(str.startsWith(tmp)) { @@ -139,7 +138,7 @@ bool ParsingToolBox::readArithmeticOperator(QString &str, Die::ArithmeticOperato bool ParsingToolBox::readLogicOperator(QString& str,BooleanCondition::LogicOperator& op) { QString longKey; - for(const QString& tmp: m_logicOp->keys()) + foreach(QString tmp, m_logicOp->keys()) { if(str.startsWith(tmp)) { @@ -296,7 +295,7 @@ Validator* ParsingToolBox::readCompositeValidator(QString& str) bool ParsingToolBox::readLogicOperation(QString& str,CompositeValidator::LogicOperation& op) { QString longKey; - for(const QString& tmp: m_logicOperation->keys()) + foreach(QString tmp, m_logicOperation->keys()) { if(str.startsWith(tmp)) { @@ -570,7 +569,7 @@ void ParsingToolBox::readPainterParameter(PainterNode* painter,QString& str) QString data = str.left(pos); str=str.remove(0,pos+1); QStringList duos = data.split(','); - for(const QString& duoStr : duos) + foreach(QString duoStr,duos) { QStringList keyValu = duoStr.split(':'); if(keyValu.size()==2) diff --git a/range.cpp b/range.cpp index 081e253..39a46ce 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) { - for(qint64 value: m->getListValue()) + foreach(qint64 value, m->getListValue()) { if((value>=m_start)&&(value<=m_end)) { diff --git a/result/diceresult.cpp b/result/diceresult.cpp index dd624e9..ddedd1c 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; - for(Die* die:m_diceValues) + foreach(Die* die,m_diceValues) { scalarSum << QString::number(die->getValue()); } -- cgit v1.2.3-70-g09d2