diff options
| author | 2020-06-19 08:54:57 +0200 | |
|---|---|---|
| committer | 2020-08-21 22:50:44 +0200 | |
| commit | 62b7114ce29af10395273acec8dffeb41f255145 (patch) | |
| tree | b15ccf438ea03c0d7673e8efb174b3a1042e92aa /include | |
| parent | 80ab093722485fe7ac577415ae401f347907623c (diff) | |
| download | OneRoll-62b7114ce29af10395273acec8dffeb41f255145.tar.gz OneRoll-62b7114ce29af10395273acec8dffeb41f255145.zip | |
change the way diceparser is giving its result.
Diffstat (limited to 'include')
| -rw-r--r-- | include/diceparser.h | 126 |
1 files changed, 56 insertions, 70 deletions
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 <QJsonObject> #include <QMap> #include <QString> #include <QVariant> @@ -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<DiceAlias*>& constAliases() const; + QList<DiceAlias*>* aliases() const; + void cleanAliases(); + void insertAlias(DiceAlias*, int); /** - * @brief getLastIntegerResults - * @return - */ - QList<qreal> getLastIntegerResults(); - /** - * @brief getSumOfDiceResult - * @return - */ - QList<qreal> getSumOfDiceResult(); - /** - * @brief getLastDiceResult - * @return - */ - void getLastDiceResult(QList<ExportedDiceResult>& 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<Dice::ERROR_CODE, QString> 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<DiceAlias*>& getAliases() const; - QList<DiceAlias*>* 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<Dice::ERROR_CODE, QString> errorMap() const; + QMap<Dice::ERROR_CODE, QString> 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<QString, QString>& variables); - QString getComment() const; - void setComment(const QString& comment); + // Accessors + int startNodeCount() const; + QList<qreal> scalarResultsFromEachInstruction() const; + QStringList stringResultFromEachInstruction(bool& hasAlias) const; + void diceResultFromEachInstruction(QList<ExportedDiceResult>& resultList) const; - void getDiceResultFromAllInstruction(QList<ExportedDiceResult>& resultList); - QString humanReadableWarning(); + QString diceCommand() const; + QMap<Dice::ERROR_CODE, QString> 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<ExportedDiceResult>& diceValues, bool& homogeneous) const; + // QList<qreal> sumOfDiceResult() const; + + // setters + void setPathToHelp(QString l); + void setVariableDictionary(const QHash<QString, QString>& variables); + void setComment(const QString& comment); private: /** |