From 8e9cad0753457ce3d245a626fb4ad693e5701703 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 9 Nov 2014 12:06:54 +0100 Subject: Add error management. Protect sort node after scalar result node. --- main.cpp | 6 +++--- node/executionnode.cpp | 4 ++++ node/executionnode.h | 3 +++ node/sortresult.cpp | 13 ++++++------- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/main.cpp b/main.cpp index eff3d60..b5c270b 100644 --- a/main.cpp +++ b/main.cpp @@ -44,8 +44,8 @@ int main(int argc, char *argv[]) << "1D100a[>=95]a[>=96]a[>=97]a[>=98]a[>=99]e[>=100]" << "3D100" << "4k3" - << "10D10e[>=6]s" - //<< "100190D6666666s" + << "10D10e[>=6]sc[>=6]" + << "100190D6666666s" << "10D10e10s" << "10D10s" << "15D10e10c[8-10]" @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) for(int i=1;i ExecutionNode::getErrorList() +{ + return m_errors; +} diff --git a/node/executionnode.h b/node/executionnode.h index 59308ff..b83a6f1 100644 --- a/node/executionnode.h +++ b/node/executionnode.h @@ -6,6 +6,7 @@ class ExecutionNode { public: + enum ERROR_CODE {NO_ERROR,DIE_RESULT_EXPECTED,BAD_SYNTAXE}; ExecutionNode(); virtual ~ExecutionNode(); virtual void run(ExecutionNode* previous = NULL)=0; @@ -14,9 +15,11 @@ public: ExecutionNode* getNextNode(); virtual QString toString()const=0; virtual qint64 getPriority() const=0; + virtual QList getErrorList(); protected: Result* m_result; ExecutionNode* m_nextNode; + QList m_errors; }; #endif // EXECUTIONNODE_H diff --git a/node/sortresult.cpp b/node/sortresult.cpp index 8a0e58d..c80ebec 100644 --- a/node/sortresult.cpp +++ b/node/sortresult.cpp @@ -17,7 +17,7 @@ void SortResultNode::run(ExecutionNode* node) { return; } - DiceResult* previousDiceResult = static_cast(node->getResult()); + DiceResult* previousDiceResult = dynamic_cast(node->getResult()); m_diceResult->setPrevious(previousDiceResult); if(NULL!=previousDiceResult) { @@ -61,12 +61,7 @@ void SortResultNode::run(ExecutionNode* node) } } - //qDebug() << tmp1->getValue() << j << found; - //if(found) - diceList2.insert(j,tmp1); - /*else - diceList2.append(tmp1);*/ - + diceList2.insert(j,tmp1); } if(!m_ascending) @@ -86,6 +81,10 @@ void SortResultNode::run(ExecutionNode* node) m_nextNode->run(this); } } + else + { + m_errors.append(DIE_RESULT_EXPECTED); + } } void SortResultNode::setSortAscending(bool asc) -- cgit v1.2.3-70-g09d2