diff options
| author | 2020-03-28 01:08:11 +0000 | |
|---|---|---|
| committer | 2020-03-28 01:08:11 +0000 | |
| commit | 944072519b4e7bc31e93024ece61b1079f7427a5 (patch) | |
| tree | 522475f7c4d5dade1c0b3482ab35d3f625b99ebe /include/diceparser.h | |
| parent | 932d863c2a2c9b08d8ce1f4e1041e5795daedc6d (diff) | |
| parent | 088b2fa45dc2c763187109ec7d77f9eb096e498e (diff) | |
| download | OneRoll-944072519b4e7bc31e93024ece61b1079f7427a5.tar.gz OneRoll-944072519b4e7bc31e93024ece61b1079f7427a5.zip | |
Merge branch 'repeat2' into 'master'
All new features
See merge request kde/rolisteam-diceparser!4
Diffstat (limited to 'include/diceparser.h')
| -rw-r--r-- | include/diceparser.h | 167 |
1 files changed, 3 insertions, 164 deletions
diff --git a/include/diceparser.h b/include/diceparser.h index 31f9760..e60f30d 100644 --- a/include/diceparser.h +++ b/include/diceparser.h @@ -24,6 +24,7 @@ #include <QMap> #include <QString> +#include <memory> #include <vector> #include "diceparserhelper.h" @@ -53,52 +54,6 @@ class DiceParser { public: /** - * @brief The DiceOperator enum gathering all dice operators - */ - enum DiceOperator - { - D, - L - }; - /** - * @brief The DiceSymbol enum - */ - enum NodeAction - { - JumpBackward - }; - /** - * @brief The OptionOperator enum gathering all options availables for result. - */ - enum OptionOperator - { - KeepAndExplode, - Keep, - Reroll, - RerollUntil, - Explode, - Sort, - Count, - RerollAndAdd, - Merge, - ifOperator, - Painter, - Filter, - Split, - Group, - Occurences, - Unique, - Bind, - AllSameExplode - }; - /** - * @brief The CommandOperator enum - */ - enum CommandOperator - { - }; - - /** * @brief DiceParser default constructor */ DiceParser(); @@ -178,18 +133,12 @@ public: * @brief getAliases * @return */ - QList<DiceAlias*>* getAliases(); + const QList<DiceAlias*>& getAliases() const; /** * @brief insertAlias */ void insertAlias(DiceAlias*, int); /** - * @brief DiceParser::convertAlias - * @param str - * @return - */ - QString convertAlias(QString str); - /** * @brief getErrorList * @return */ @@ -227,106 +176,10 @@ public: void getDiceResultFromAllInstruction(QList<ExportedDiceResult>& resultList); QString humanReadableWarning(); - bool readValuesList(QString& str, ExecutionNode*& node); void cleanAll(); private: /** - * @brief readIfInstruction reads the current command to build if node with proper parameters. - * @param str is the command string, if IF istruction is found, the str will be changed, in other case the string is - * unmodified - * @param trueNode is the branch's beginning to be executed if the IfNode is true. - * @param falseNode is the branch's beginning to be executed if the IfNode is false. - * @return true, ifNode has been found, false otherwise - */ - bool readIfInstruction(QString& str, ExecutionNode*& trueNode, ExecutionNode*& falseNode); - bool readInstructionList(QString& str); - bool readOptionFromNull(QString& str, ExecutionNode*& node); - bool readOperatorFromNull(QString& str, ExecutionNode*& node); - bool readParameterNode(QString& str, ExecutionNode*& node); - /** - * @brief readExpression - * @param str - * @param node - * @return - */ - bool readExpression(QString& str, ExecutionNode*& node); - /** - * @brief readDice - * @param str - * @return - */ - bool readDice(QString& str, ExecutionNode*& node); - /** - * @brief readDiceOperator - * @return - */ - bool readDiceOperator(QString&, DiceOperator&); - /** - * @brief readDiceExpression - * @param node - * @return - */ - bool readDiceExpression(QString&, ExecutionNode*& node); - /** - * @brief readOperator - * @return - */ - bool readOperator(QString&, ExecutionNode* previous); - /** - * @brief DiceParser::readCommand - * @param str - * @param node - * @return - */ - bool readCommand(QString& str, ExecutionNode*& node); - - /** - * @brief readOption - */ - bool readOption(QString&, ExecutionNode* node); // OptionOperator& option, - - /** - * @brief addRollDiceNode - * @param faces - * @return - */ - DiceRollerNode* addRollDiceNode(qint64 faces, ExecutionNode*); - /** - * @brief addExplodeDiceNode - * @param faces - * @param previous - * @return - */ - ExplodeDiceNode* addExplodeDiceNode(qint64 faces, ExecutionNode* previous); - /** - * @brief readOperand - * @param node - * @return - */ - bool readOperand(QString&, ExecutionNode*& node); - - /** - * @brief readInstructionOperator - * @param c - * @return - */ - bool readInstructionOperator(QChar c); - /** - * @brief readNode - * @param str - * @param node - * @return - */ - bool readNode(QString& str, ExecutionNode*& node); - - /** - * @brief getLeafNode - * @return - */ - ExecutionNode* getLeafNode(ExecutionNode* node); - - /** * @brief hasResultOfType * @param notthelast * @return @@ -335,22 +188,8 @@ private: bool readBlocInstruction(QString& str, ExecutionNode*& resultnode); private: - QMap<QString, DiceOperator>* m_mapDiceOp; - QMap<QString, OptionOperator>* m_OptionOp; - QMap<QString, NodeAction>* m_nodeActionMap; - QList<DiceAlias*>* m_aliasList; - QStringList* m_commandList; - - QMap<Dice::ERROR_CODE, QString> m_errorMap; - QMap<Dice::ERROR_CODE, QString> m_warningMap; - - ExecutionNode* m_start= nullptr; - std::vector<ExecutionNode*> m_startNodes; + std::unique_ptr<ParsingToolBox> m_parsingToolbox; QString m_command; - ParsingToolBox* m_parsingToolbox; - QString m_helpPath; - bool m_currentTreeHasSeparator; - QString m_comment; }; #endif // DICEPARSER_H |