From 67fd3b480f543f2f18bd632ea85d829ba2102a20 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 2 Apr 2015 23:44:42 +0200 Subject: Add list for warnings Remove data where reading list. --- diceparser.h | 1 + 1 file changed, 1 insertion(+) (limited to 'diceparser.h') diff --git a/diceparser.h b/diceparser.h index 683be88..bec3975 100644 --- a/diceparser.h +++ b/diceparser.h @@ -257,6 +257,7 @@ private: QStringList* m_commandList; QMap m_errorMap; + QMap m_warningMap; ExecutionNode* m_start; -- cgit v1.2.3-70-g09d2 From 26e813ad2e4fa13f4b2873df99cb8e3be380c875 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 27 Aug 2015 01:29:13 +0200 Subject: add method to get all string results --- diceparser.cpp | 23 +++++++++++++++++++++++ diceparser.h | 5 +++++ 2 files changed, 28 insertions(+) (limited to 'diceparser.h') diff --git a/diceparser.cpp b/diceparser.cpp index 3831400..8c910a2 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -393,6 +393,29 @@ QString DiceParser::getStringResult() } return str; } +QStringList DiceParser::getAllStringResult(bool& hasAlias) +{ + ExecutionNode* next = getLeafNode(); + Result* result=next->getResult(); + QStringList stringListResult; + + while(NULL!=result) + { + if(result->hasResultOfType(Result::STRING)) + { + StringResult* stringResult = dynamic_cast(result); + if(NULL!=stringResult) + { + stringListResult << stringResult->getText(); + hasAlias = stringResult->hasHighLight(); + } + } + result = result->getPrevious(); + } + + return stringListResult; +} + void DiceParser::getLastDiceResult(ExportedDiceResult& diceValues) { ExecutionNode* next = getLeafNode(); diff --git a/diceparser.h b/diceparser.h index 3eb55f1..6cc6d47 100644 --- a/diceparser.h +++ b/diceparser.h @@ -191,6 +191,11 @@ public: * @param l the path. */ void setPathToHelp(QString l); + /** + * @brief getAllStringResult + * @return + */ + QStringList getAllStringResult(bool& hasAlias); private: /** -- cgit v1.2.3-70-g09d2 From 7ce5a4af6fb836432eb6ce7637ea09d6a5b4e0bd Mon Sep 17 00:00:00 2001 From: Renaud G Date: Tue, 1 Sep 2015 16:34:56 +0200 Subject: add getAllDiceResult function and hasSeparator --- diceparser.cpp | 45 +++++++++++++++++++++++++++++++++++++++------ diceparser.h | 9 +++++++++ 2 files changed, 48 insertions(+), 6 deletions(-) (limited to 'diceparser.h') diff --git a/diceparser.cpp b/diceparser.cpp index dcb5030..802b5f2 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -44,6 +44,7 @@ DiceParser::DiceParser() : m_start(NULL),m_current(NULL) { + m_currentTreeHasSeparator =false; m_parsingToolbox = new ParsingToolBox(); m_mapDiceOp = new QMap(); @@ -145,6 +146,7 @@ void DiceParser::insertAlias(DiceAlias* dice, int i) bool DiceParser::parseLine(QString str) { + m_currentTreeHasSeparator = false; m_errorMap.clear(); if(NULL!=m_start) { @@ -412,7 +414,36 @@ QStringList DiceParser::getAllStringResult(bool& hasAlias) return stringListResult; } +QStringList DiceParser::getAllDiceResult(bool& hasAlias) +{ + ExecutionNode* next = getLeafNode(); + Result* result=next->getResult(); + QList dieListResult; + QStringList stringListResult; + while(NULL!=result) + { + if(result->hasResultOfType(Result::DICE_LIST)) + { + DiceResult* stringResult = dynamic_cast(result); + if(NULL!=stringResult) + { + dieListResult << stringResult->getResultList(); + hasAlias = true; + } + } + result = result->getPrevious(); + } + foreach(Die* die, dieListResult) + { + foreach (qint64 value, die->getListValue()) + { + stringListResult << QString::number(value); + } + } + + return stringListResult; +} void DiceParser::getLastDiceResult(ExportedDiceResult& diceValues) { ExecutionNode* next = getLeafNode(); @@ -701,21 +732,19 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous) } else if(readInstructionOperator(str[0])) { - str=str.remove(0,1); - delete node; + str=str.remove(0,1); + delete node; ExecutionNode* nodeExec = NULL; if(readExpression(str,nodeExec)) { - - // nodeExec = getLatestNode(nodeExec); - if(NULL==nodeExec) { return false; } previous->setNextNode(nodeExec); - + m_currentTreeHasSeparator = true; return true; + } } else @@ -728,6 +757,10 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous) } return false; } +bool DiceParser::hasSeparator()const +{ + return m_currentTreeHasSeparator; +} DiceRollerNode* DiceParser::addRollDiceNode(qint64 faces,ExecutionNode* previous) { DiceRollerNode* mydiceRoller= new DiceRollerNode(faces); diff --git a/diceparser.h b/diceparser.h index 6cc6d47..3fc2cb7 100644 --- a/diceparser.h +++ b/diceparser.h @@ -196,6 +196,14 @@ public: * @return */ QStringList getAllStringResult(bool& hasAlias); + /** + * @brief getAllDiceResult + * @param hasAlias + * @return + */ + QStringList getAllDiceResult(bool& hasAlias); + + bool hasSeparator()const; private: /** @@ -301,6 +309,7 @@ private: QString m_command; ParsingToolBox* m_parsingToolbox; QString m_helpPath; + bool m_currentTreeHasSeparator; }; #endif // DICEPARSER_H -- cgit v1.2.3-70-g09d2