diff options
| author | 2022-04-16 01:58:40 +0200 | |
|---|---|---|
| committer | 2022-04-16 02:59:30 +0200 | |
| commit | 6ba9324cf4864ebd2e2cdec8098b0889ceaea0a8 (patch) | |
| tree | e29af0f803de724e28eab85da2dfe6c535a8292b /include | |
| parent | 0c040da59e6aa2df3bd0c22e38b2afe0512d3749 (diff) | |
| download | OneRoll-6ba9324cf4864ebd2e2cdec8098b0889ceaea0a8.tar.gz OneRoll-6ba9324cf4864ebd2e2cdec8098b0889ceaea0a8.zip | |
Make sure Windows compilation works
Diffstat (limited to 'include')
| -rw-r--r-- | include/diceparser/dicealias.h (renamed from include/dicealias.h) | 4 | ||||
| -rw-r--r-- | include/diceparser/diceparser.h (renamed from include/diceparser.h) | 9 | ||||
| -rw-r--r-- | include/diceparser/diceparser_global.h | 11 | ||||
| -rw-r--r-- | include/diceparser/diceparserhelper.h (renamed from include/diceparserhelper.h) | 35 | ||||
| -rw-r--r-- | include/diceparser/highlightdice.h (renamed from include/highlightdice.h) | 4 | ||||
| -rw-r--r-- | include/diceparser/parsingtoolbox.h (renamed from include/parsingtoolbox.h) | 50 | ||||
| -rw-r--r-- | include/diceparser_qobject/diceparser_qobject_global.h | 11 | ||||
| -rw-r--r-- | include/diceparser_qobject/diceroller.h | 74 | ||||
| -rw-r--r-- | include/diceparser_qobject/qmltypesregister.h | 27 |
9 files changed, 198 insertions, 27 deletions
diff --git a/include/dicealias.h b/include/diceparser/dicealias.h index c390d21..05d5a0b 100644 --- a/include/dicealias.h +++ b/include/diceparser/dicealias.h @@ -23,11 +23,13 @@ #define DICEALIAS_H #include <QString> + +#include <diceparser/diceparser_global.h> /** * @brief The DiceAlias class is dedicated to store aliases, alias is mainly two QString. The Alias and its replacement. * The replacement can be a simple QString or a RegExp. */ -class DiceAlias +class DICEPARSER_EXPORT DiceAlias { public: enum RESOLUTION_TYPE diff --git a/include/diceparser.h b/include/diceparser/diceparser.h index 3c42bcc..bf2d570 100644 --- a/include/diceparser.h +++ b/include/diceparser/diceparser.h @@ -29,9 +29,10 @@ #include <memory> #include <vector> -#include "diceparserhelper.h" -#include "highlightdice.h" -//#include "node/executionnode.h" +#include <diceparser/diceparser_global.h> + +#include <diceparser/diceparserhelper.h> +#include <diceparser/highlightdice.h> class ExplodeDiceNode; class ParsingToolBox; @@ -52,7 +53,7 @@ class ExecutionNode; /** * @brief The DiceParser class facade class, it receives a command and return a DiceResult class (not yet implemented). */ -class DiceParser +class DICEPARSER_EXPORT DiceParser { public: /** diff --git a/include/diceparser/diceparser_global.h b/include/diceparser/diceparser_global.h new file mode 100644 index 0000000..47829cc --- /dev/null +++ b/include/diceparser/diceparser_global.h @@ -0,0 +1,11 @@ +#ifndef DICEPARSER_GLOBAL_H +#define DICEPARSER_GLOBAL_H + +#include <QtCore/qglobal.h> + +#if defined(DICEPARSER_LIBRARY) +#define DICEPARSER_EXPORT Q_DECL_EXPORT +#else +#define DICEPARSER_EXPORT Q_DECL_IMPORT +#endif +#endif // DICEPARSER_GLOBAL_H diff --git a/include/diceparserhelper.h b/include/diceparser/diceparserhelper.h index 1ae5c3f..6190df2 100644 --- a/include/diceparserhelper.h +++ b/include/diceparser/diceparserhelper.h @@ -4,6 +4,8 @@ class ValidatorList; class ExecutionNode; +#include <diceparser/diceparser_global.h> + namespace Dice { enum class CONDITION_STATE : int @@ -54,7 +56,38 @@ enum ConditionType OnScalar }; -struct CaseInfo +enum class CompareOperator +{ + Equal, + GreaterThan, + LesserThan, + GreaterOrEqual, + LesserOrEqual, + Different +}; +enum class ArithmeticOperator +{ + PLUS, + MINUS, + DIVIDE, + MULTIPLICATION, + INTEGER_DIVIDE, + POW +}; +enum class LogicOperation +{ + OR, + EXCLUSIVE_OR, + AND, + NONE +}; + +enum class ConditionOperator +{ + Modulo +}; + +struct DICEPARSER_EXPORT CaseInfo { ValidatorList* validatorList; ExecutionNode* node; diff --git a/include/highlightdice.h b/include/diceparser/highlightdice.h index 66bd445..a3928a1 100644 --- a/include/highlightdice.h +++ b/include/diceparser/highlightdice.h @@ -24,7 +24,9 @@ #include <QMap> #include <QString> -class HighLightDice +#include <diceparser/diceparser_global.h> + +class DICEPARSER_EXPORT HighLightDice { public: HighLightDice(QList<qint64> result, bool isHighlighted, QString color, bool displayed, quint64 faces, diff --git a/include/parsingtoolbox.h b/include/diceparser/parsingtoolbox.h index 08e876a..69f433a 100644 --- a/include/parsingtoolbox.h +++ b/include/diceparser/parsingtoolbox.h @@ -22,28 +22,38 @@ #ifndef PARSINGTOOLBOX_H #define PARSINGTOOLBOX_H +#include <QJsonArray> +#include <QJsonDocument> +#include <QJsonObject> #include <QMap> +#include <QVariant> #include <functional> #include <vector> -#include "booleancondition.h" +#include "diceparserhelper.h" #include "highlightdice.h" -#include "node/dicerollernode.h" -#include "node/executionnode.h" -#include "node/ifnode.h" -#include "node/paintnode.h" -#include "node/scalaroperatornode.h" -#include "operationcondition.h" -#include "range.h" -#include "validatorlist.h" +//#include "dicerollernode.h" +//#include "executionnode.h" +//#include "node/ifnode.h" +//#include "node/paintnode.h" +//#include "node/scalaroperatornode.h" +//#include "operationcondition.h" +//#include "range.h" +//#include "validatorlist.h" +#include <diceparser/diceparser_global.h> +class Range; class RepeaterNode; class DiceAlias; class ExplodeDiceNode; class SwitchCaseNode; class ReplaceValueNode; - -class SubtituteInfo +class PainterNode; +class ValidatorList; +class Validator; +class DiceRollerNode; +class ExecutionNode; +class DICEPARSER_EXPORT SubtituteInfo { public: SubtituteInfo(); @@ -77,7 +87,7 @@ private: * @brief The ParsingToolBox is gathering many useful methods for dice parsing. * Its goal is to make the diceparser a bit lighter. */ -class ParsingToolBox +class DICEPARSER_EXPORT ParsingToolBox { public: enum LIST_OPERATOR @@ -139,7 +149,7 @@ public: // parsing tools static bool readAscending(QString& str); static bool readStopAtFirst(QString& str); - bool readLogicOperator(QString& str, BooleanCondition::LogicOperator& op); + bool readLogicOperator(QString& str, Dice::CompareOperator& op); Validator* readValidator(QString& str, bool hasSquare= false); ValidatorList* readValidatorList(QString& str); static bool readNumber(QString& str, qint64& myNumber); @@ -153,9 +163,9 @@ public: bool readDiceRange(QString& str, qint64& start, qint64& end); static LIST_OPERATOR readListOperator(QString& str); void readProbability(QStringList& str, QList<Range>& ranges); - bool readLogicOperation(QString& str, ValidatorList::LogicOperation& op); - bool readDiceLogicOperator(QString& str, OperationCondition::ConditionOperator& op); - bool readArithmeticOperator(QString& str, Die::ArithmeticOperator& op); + bool readLogicOperation(QString& str, Dice::LogicOperation& op); + bool readDiceLogicOperator(QString& str, Dice::ConditionOperator& op); + bool readArithmeticOperator(QString& str, Dice::ArithmeticOperator& op); std::vector<ExecutionNode*> readInstructionList(QString& str, bool startNode); static Dice::ConditionType readConditionType(QString& str); bool readComment(QString& str, QString&, QString&); @@ -250,10 +260,10 @@ public: static QString replacePlaceHolderFromJson(const QString& source, const QJsonObject& obj); private: - QMap<QString, BooleanCondition::LogicOperator> m_logicOp; - QMap<QString, ValidatorList::LogicOperation> m_logicOperation; - QMap<QString, OperationCondition::ConditionOperator> m_conditionOperation; - std::vector<std::pair<QString, Die::ArithmeticOperator>> m_arithmeticOperation; + QMap<QString, Dice::CompareOperator> m_logicOp; + QMap<QString, Dice::LogicOperation> m_logicOperation; + QMap<QString, Dice::ConditionOperator> m_conditionOperation; + std::vector<std::pair<QString, Dice::ArithmeticOperator>> m_arithmeticOperation; QMap<QString, DiceOperator> m_mapDiceOp; QMap<QString, OptionOperator> m_OptionOp; QMap<QString, NodeAction> m_nodeActionMap; diff --git a/include/diceparser_qobject/diceparser_qobject_global.h b/include/diceparser_qobject/diceparser_qobject_global.h new file mode 100644 index 0000000..ea49727 --- /dev/null +++ b/include/diceparser_qobject/diceparser_qobject_global.h @@ -0,0 +1,11 @@ +#ifndef DICEPARSER_QOBJECT_GLOBAL_H +#define DICEPARSER_QOBJECT_GLOBAL_H + +#include <QtCore/qglobal.h> + +#if defined(DICEPARSER_QOBJECT_LIBRARY) +#define DICEPARSER_QOBJECT_EXPORT Q_DECL_EXPORT +#else +#define DICEPARSER_QOBJECT_EXPORT Q_DECL_IMPORT +#endif +#endif // DICEPARSER_QOBJECT_GLOBAL_H diff --git a/include/diceparser_qobject/diceroller.h b/include/diceparser_qobject/diceroller.h new file mode 100644 index 0000000..72c4e10 --- /dev/null +++ b/include/diceparser_qobject/diceroller.h @@ -0,0 +1,74 @@ +/*************************************************************************** + * Copyright (C) 2017 by Renaud Guezennec * + * https://rolisteam.org/contact * + * * + * Rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef DICEROLLER_H +#define DICEROLLER_H + +#include <QObject> +#include <diceparser/diceparser.h> + +#include <diceparser_qobject/diceparser_qobject_global.h> + +class DICEPARSER_QOBJECT_EXPORT DiceRoller : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal result READ result NOTIFY resultChanged) + Q_PROPERTY(QString dicelist READ diceList NOTIFY diceListChanged) + Q_PROPERTY(QString resultStr READ resultStr NOTIFY resultStrChanged) + Q_PROPERTY(QString command READ command WRITE setCommand NOTIFY commandChanged) + Q_PROPERTY(QString error READ error WRITE setError NOTIFY errorOccurs) + +public: + DiceRoller(QObject* parent= nullptr); + + QString diceList() const; + QString resultStr() const; + QString command() const; + qreal result() const; + QString error() const; + QList<DiceAlias*>* aliases() const; + + DiceParser* parser(); + +signals: + void resultChanged(); + void diceListChanged(); + void resultStrChanged(); + void commandChanged(); + void errorOccurs(); + +public slots: + void start(); + void readErrorAndWarning(); + void setCommand(const QString& cmd); + void setError(const QString& error); + + /*protected: + QString diceToText(QList<ExportedDiceResult>& diceList);*/ + +private: + DiceParser m_diceparser; + qreal m_result; + QString m_diceList; + QString m_resultStr; + QString m_command; + QString m_error; +}; + +#endif // DICEROLLER_H diff --git a/include/diceparser_qobject/qmltypesregister.h b/include/diceparser_qobject/qmltypesregister.h new file mode 100644 index 0000000..e0b1a09 --- /dev/null +++ b/include/diceparser_qobject/qmltypesregister.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (C) 2017 by Renaud Guezennec * + * https://rolisteam.org/contact * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef REGISTER_QML_TYPE_H +#define REGISTER_QML_TYPE_H + +#include <diceparser_qobject/diceparser_qobject_global.h> + +DICEPARSER_QOBJECT_EXPORT void registerQmlTypes(); + +#endif // REGISTER_QML_TYPE_H |