From 62b7114ce29af10395273acec8dffeb41f255145 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Fri, 19 Jun 2020 08:54:57 +0200 Subject: change the way diceparser is giving its result. --- include/diceparser.h | 126 +++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 70 deletions(-) (limited to 'include') diff --git a/include/diceparser.h b/include/diceparser.h index 7cc4018..eb4dee4 100644 --- a/include/diceparser.h +++ b/include/diceparser.h @@ -22,6 +22,7 @@ #ifndef DICEPARSER_H #define DICEPARSER_H +#include #include #include #include @@ -63,6 +64,7 @@ public: */ virtual ~DiceParser(); + // Command process methods /** * @brief parseLine, method to call for starting the dice roll. It will parse the command and run the execution * tree. @@ -70,93 +72,65 @@ public: * @return bool every thing is fine or not */ bool parseLine(QString str, bool allowAlias= true); - QString convertAlias(const QString& cmd) const; - /** - * @brief getStartNodeCount - * @return - */ - int getStartNodeCount() const; - /** - * @brief Start running the execution tree - * - */ void start(); - /** - * @brief displayDotTree - Write the execution tree into file using dot format. - * @param filepath absolute or relative path to the tree file. - */ + void cleanAll(); + + // debug void writeDownDotTree(QString filepath); + + // control methods + bool hasIntegerResultNotInFirst() const; + bool hasDiceResult() const; + bool hasStringResult() const; + bool hasSeparator() const; + + // alias management + const QList& constAliases() const; + QList* aliases() const; + void cleanAliases(); + void insertAlias(DiceAlias*, int); /** - * @brief getLastIntegerResults - * @return - */ - QList getLastIntegerResults(); - /** - * @brief getSumOfDiceResult - * @return - */ - QList getSumOfDiceResult(); - /** - * @brief getLastDiceResult - * @return - */ - void getLastDiceResult(QList& diceValues, bool& homogeneous); - /** - * @brief hasIntegerResultNotInFirst - * @return - */ - bool hasIntegerResultNotInFirst(); - /** - * @brief hasDiceResult - * @return - */ - bool hasDiceResult(); - /** - * @brief getDiceCommand - * @return - */ - QString getDiceCommand() const; - /** - * @brief hasStringResult + * @brief getErrorList * @return */ - bool hasStringResult(); + QMap errorMap() const; /** - * @brief getStringResult - * @return + * @brief setPathToHelp set the path to the documentation, this path must be adatped to the lang of application etc… + * @param l the path. */ - QStringList getStringResult(); + void setPathToHelp(QString l); /** - * @brief humanReadableError + * @brief allFirstResultAsString * @return */ - QString humanReadableError(); + QStringList allFirstResultAsString(bool& hasAlias); /** - * @brief getAliases + * @brief getAllDiceResult + * @param hasAlias * @return */ - const QList& getAliases() const; - QList* aliases() const; - void cleanAliases(); + QStringList getAllDiceResult(bool& hasAlias); /** - * @brief insertAlias + * @brief hasSeparator allows to know if the current command has separator. + * @return true when the command has separator, false otherwise. */ - void insertAlias(DiceAlias*, int); + bool hasSeparator() const; +// beginning of strange code ||||||| parent of af8b69b... change the way diceparser is giving its result. /** * @brief getErrorList * @return */ - QMap errorMap() const; + QMap getErrorMap(); /** * @brief setPathToHelp set the path to the documentation, this path must be adatped to the lang of application etc… * @param l the path. */ void setPathToHelp(QString l); /** - * @brief allFirstResultAsString + * @brief getAllStringResult * @return */ - QStringList allFirstResultAsString(bool& hasAlias); + QStringList getAllStringResult(bool& hasAlias); /** * @brief getAllDiceResult * @param hasAlias @@ -168,19 +142,31 @@ public: * @return true when the command has separator, false otherwise. */ bool hasSeparator() const; +// END of strange code + QString convertAlias(const QString& cmd) const; - /** - * @brief setVariableDictionary - * @param variables - */ - void setVariableDictionary(const QHash& variables); - QString getComment() const; - void setComment(const QString& comment); + // Accessors + int startNodeCount() const; + QList scalarResultsFromEachInstruction() const; + QStringList stringResultFromEachInstruction(bool& hasAlias) const; + void diceResultFromEachInstruction(QList& resultList) const; - void getDiceResultFromAllInstruction(QList& resultList); - QString humanReadableWarning(); + QString diceCommand() const; + QMap errorMap() const; + QString comment() const; + QString humanReadableWarning() const; + QString humanReadableError() const; + QJsonObject exportResult() const; - void cleanAll(); + // QStringList stringResult() const; + // QStringList allDiceResult(bool& hasAlias) const; + // void lastDiceResult(QList& diceValues, bool& homogeneous) const; + // QList sumOfDiceResult() const; + + // setters + void setPathToHelp(QString l); + void setVariableDictionary(const QHash& variables); + void setComment(const QString& comment); private: /** -- cgit v1.2.3-70-g09d2