aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2016-04-15 10:54:38 +0200
committerRenaud G <renaud@rolisteam.org>2016-04-15 10:54:38 +0200
commite55d89b50abd103dcc860faba2c7719064b5aa46 (patch)
treec47cf70d0d3b35c5941f80b3728dc596f572bf5a
parent7329c3414954112da46ad1af1d900ded0363ba9c (diff)
parent711d11ae25c7aa86ae675fd849c7240c9e2cf298 (diff)
downloadOneRoll-e55d89b50abd103dcc860faba2c7719064b5aa46.tar.gz
OneRoll-e55d89b50abd103dcc860faba2c7719064b5aa46.zip
Merge branch 'master' of github.com:Rolisteam/DiceParser
-rw-r--r--booleancondition.cpp2
-rw-r--r--booleancondition.h2
-rw-r--r--compositevalidator.cpp2
-rw-r--r--compositevalidator.h2
-rw-r--r--dicealias.cpp2
-rw-r--r--dicealias.h2
-rw-r--r--diceparser.cpp6
-rw-r--r--diceparser.h7
-rw-r--r--die.cpp2
-rw-r--r--die.h2
-rw-r--r--node/helpnode.cpp2
-rw-r--r--node/ifnode.cpp2
-rw-r--r--node/mergenode.cpp2
-rw-r--r--node/mergenode.h2
-rw-r--r--node/numbernode.cpp2
-rw-r--r--node/numbernode.h2
-rw-r--r--node/parenthesesnode.cpp2
-rw-r--r--node/parenthesesnode.h2
-rw-r--r--node/scalaroperatornode.cpp2
-rw-r--r--node/scalaroperatornode.h2
-rw-r--r--node/sortresult.cpp2
-rw-r--r--node/sortresult.h2
-rw-r--r--node/startingnode.cpp2
-rw-r--r--node/startingnode.h2
-rw-r--r--operationcondition.cpp2
-rw-r--r--operationcondition.h2
-rw-r--r--parsingtoolbox.cpp52
-rw-r--r--parsingtoolbox.h22
-rw-r--r--range.cpp2
-rw-r--r--range.h2
-rw-r--r--result/diceresult.cpp2
-rw-r--r--result/diceresult.h2
-rw-r--r--result/result.cpp2
-rw-r--r--result/result.h2
-rw-r--r--result/scalarresult.cpp2
-rw-r--r--result/scalarresult.h2
-rw-r--r--validator.cpp2
-rw-r--r--validator.h2
38 files changed, 113 insertions, 42 deletions
diff --git a/booleancondition.cpp b/booleancondition.cpp
index 40a3804..83076e0 100644
--- a/booleancondition.cpp
+++ b/booleancondition.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/booleancondition.h b/booleancondition.h
index 2177106..55a6b12 100644
--- a/booleancondition.h
+++ b/booleancondition.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/compositevalidator.cpp b/compositevalidator.cpp
index 167c73b..2de9dba 100644
--- a/compositevalidator.cpp
+++ b/compositevalidator.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/compositevalidator.h b/compositevalidator.h
index 789f33f..a5afcbf 100644
--- a/compositevalidator.h
+++ b/compositevalidator.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/dicealias.cpp b/dicealias.cpp
index 08adb7a..a2683e3 100644
--- a/dicealias.cpp
+++ b/dicealias.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/dicealias.h b/dicealias.h
index 51ee5d3..a85c9a0 100644
--- a/dicealias.h
+++ b/dicealias.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/diceparser.cpp b/diceparser.cpp
index 90d52e3..f88cfc3 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
@@ -1086,3 +1086,7 @@ void DiceParser::setPathToHelp(QString l)
{
m_helpPath = l;
}
+void DiceParser::setVariableDictionary(QHash<QString,QString>* variables)
+{
+ ParsingToolBox::setVariableHash(variables);
+}
diff --git a/diceparser.h b/diceparser.h
index 0df633b..b532b3e 100644
--- a/diceparser.h
+++ b/diceparser.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
@@ -204,6 +204,11 @@ public:
bool hasSeparator()const;
bool readIfInstruction(QString &str, ExecutionNode* &trueNode, ExecutionNode* &falseNode);
+ /**
+ * @brief setVariableDictionary
+ * @param variables
+ */
+ void setVariableDictionary(QHash<QString,QString>* variables);
private:
/**
diff --git a/die.cpp b/die.cpp
index e5dfb68..7a79e88 100644
--- a/die.cpp
+++ b/die.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/die.h b/die.h
index b6d5d72..8ebda1a 100644
--- a/die.h
+++ b/die.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/helpnode.cpp b/node/helpnode.cpp
index 76ddf50..30fa904 100644
--- a/node/helpnode.cpp
+++ b/node/helpnode.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2015 by Renaud Guezennec *
- * http://renaudguezennec.homelinux.org/accueil,3.html *
+ * http://www.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 *
diff --git a/node/ifnode.cpp b/node/ifnode.cpp
index a8982a8..e25ad78 100644
--- a/node/ifnode.cpp
+++ b/node/ifnode.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2016 by Renaud Guezennec *
- * http://renaudguezennec.homelinux.org/accueil,3.html *
+ * http://www.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 *
diff --git a/node/mergenode.cpp b/node/mergenode.cpp
index 7f3bec0..16a6649 100644
--- a/node/mergenode.cpp
+++ b/node/mergenode.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/mergenode.h b/node/mergenode.h
index 347975f..e32faab 100644
--- a/node/mergenode.h
+++ b/node/mergenode.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/numbernode.cpp b/node/numbernode.cpp
index e2da54f..01a170e 100644
--- a/node/numbernode.cpp
+++ b/node/numbernode.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/numbernode.h b/node/numbernode.h
index 50d29ad..c96a47a 100644
--- a/node/numbernode.h
+++ b/node/numbernode.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/parenthesesnode.cpp b/node/parenthesesnode.cpp
index f54a976..7eefaba 100644
--- a/node/parenthesesnode.cpp
+++ b/node/parenthesesnode.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/parenthesesnode.h b/node/parenthesesnode.h
index fbb1caf..fc0799d 100644
--- a/node/parenthesesnode.h
+++ b/node/parenthesesnode.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index d4c691c..0dcb9b9 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/scalaroperatornode.h b/node/scalaroperatornode.h
index fccc5e5..7fa9b6b 100644
--- a/node/scalaroperatornode.h
+++ b/node/scalaroperatornode.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/sortresult.cpp b/node/sortresult.cpp
index d149507..0bf531c 100644
--- a/node/sortresult.cpp
+++ b/node/sortresult.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/sortresult.h b/node/sortresult.h
index c4f96dc..f0c9269 100644
--- a/node/sortresult.h
+++ b/node/sortresult.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/node/startingnode.cpp b/node/startingnode.cpp
index 5f1966e..3a300b4 100644
--- a/node/startingnode.cpp
+++ b/node/startingnode.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2015 by Renaud Guezennec *
- * http://renaudguezennec.homelinux.org/accueil,3.html *
+ * http://www.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 *
diff --git a/node/startingnode.h b/node/startingnode.h
index 923e84b..834a9dc 100644
--- a/node/startingnode.h
+++ b/node/startingnode.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2015 by Renaud Guezennec *
- * http://renaudguezennec.homelinux.org/accueil,3.html *
+ * http://www.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 *
diff --git a/operationcondition.cpp b/operationcondition.cpp
index bcc1b75..943cac9 100644
--- a/operationcondition.cpp
+++ b/operationcondition.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2015 by Renaud Guezennec *
- * http://renaudguezennec.homelinux.org/accueil,3.html *
+ * http://www.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 *
diff --git a/operationcondition.h b/operationcondition.h
index 0c049a0..a1a1b55 100644
--- a/operationcondition.h
+++ b/operationcondition.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2015 by Renaud Guezennec *
- * http://renaudguezennec.homelinux.org/accueil,3.html *
+ * http://www.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 *
diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp
index 00dfe81..7950e4d 100644
--- a/parsingtoolbox.cpp
+++ b/parsingtoolbox.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
@@ -24,6 +24,7 @@
#include "parsingtoolbox.h"
#include "node/sortresult.h"
+QHash<QString,QString>* ParsingToolBox::m_variableHash = NULL;
ParsingToolBox::ParsingToolBox()
{
@@ -279,7 +280,9 @@ bool ParsingToolBox::readNumber(QString& str, qint64& myNumber)
}
if(number.isEmpty())
- return false;
+ {
+ return readVariable(str,myNumber);
+ }
bool ok;
myNumber = number.toLongLong(&ok);
@@ -288,8 +291,43 @@ bool ParsingToolBox::readNumber(QString& str, qint64& myNumber)
str=str.remove(0,number.size());
return true;
}
+
return false;
}
+
+bool ParsingToolBox::readVariable(QString &str, qint64 &myNumber)
+{
+ if(str.isEmpty())
+ return false;
+ if(str.startsWith("${"))
+ {
+ str=str.remove(0,2);
+ }
+ QString key;
+ int post = str.indexOf('}');
+ key = str.left(post);
+
+ if(NULL!=m_variableHash)
+ {
+ if(m_variableHash->contains(key))
+ {
+ QString value = m_variableHash->value(key);
+ bool ok;
+ int valueInt = value.toInt(&ok);
+ if(ok)
+ {
+ myNumber = valueInt;
+ str=str.remove(0,post+1);
+ return true;
+ }
+
+ }
+ }
+
+
+ return false;
+
+}
bool ParsingToolBox::readOpenParentheses(QString& str)
{
if(str.startsWith("("))
@@ -436,6 +474,16 @@ void ParsingToolBox::readPainterParameter(PainterNode* painter,QString& str)
}
}
+QHash<QString, QString> *ParsingToolBox::getVariableHash()
+{
+ return m_variableHash;
+}
+
+void ParsingToolBox::setVariableHash(QHash<QString, QString> *variableHash)
+{
+ m_variableHash = variableHash;
+}
+
void ParsingToolBox::readProbability(QStringList& str,QList<Range>& ranges)
{
quint64 totalDistance=0;
diff --git a/parsingtoolbox.h b/parsingtoolbox.h
index 4aeb16e..3046570 100644
--- a/parsingtoolbox.h
+++ b/parsingtoolbox.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
@@ -95,7 +95,13 @@ public:
*/
static bool readNumber(QString& str, qint64& myNumber);
-
+ /**
+ * @brief readVariable
+ * @param str
+ * @param myNumber
+ * @return
+ */
+ static bool readVariable(QString& str,qint64& myNumber);
/**
* @brief readOpenParentheses
* @param str
@@ -154,11 +160,19 @@ public:
bool readArithmeticOperator(QString& str, ScalarOperatorNode::ArithmeticOperator& op);
static void readPainterParameter(PainterNode *painter, QString &str);
+
+ static QHash<QString, QString> *getVariableHash();
+ static void setVariableHash(QHash<QString, QString> *variableHash);
+
private:
- QMap<QString,BooleanCondition::LogicOperator>* m_logicOp;
- QMap<QString,CompositeValidator::LogicOperation>* m_logicOperation;
+
+ QMap<QString,BooleanCondition::LogicOperator>* m_logicOp;
+ QMap<QString,CompositeValidator::LogicOperation>* m_logicOperation;
QMap<QString,OperationCondition::ConditionOperator>* m_conditionOperation;
QHash<QString,ScalarOperatorNode::ArithmeticOperator>* m_arithmeticOperation;
+
+
+ static QHash<QString,QString>* m_variableHash;
};
#endif // PARSINGTOOLBOX_H
diff --git a/range.cpp b/range.cpp
index 337cdc1..a5acc7e 100644
--- a/range.cpp
+++ b/range.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/range.h b/range.h
index 75fc69a..40b4277 100644
--- a/range.h
+++ b/range.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/result/diceresult.cpp b/result/diceresult.cpp
index 37db727..462c989 100644
--- a/result/diceresult.cpp
+++ b/result/diceresult.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/result/diceresult.h b/result/diceresult.h
index fe24277..3be47ed 100644
--- a/result/diceresult.h
+++ b/result/diceresult.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/result/result.cpp b/result/result.cpp
index 10056aa..3fa0aec 100644
--- a/result/result.cpp
+++ b/result/result.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/result/result.h b/result/result.h
index efadbb2..2037814 100644
--- a/result/result.h
+++ b/result/result.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/result/scalarresult.cpp b/result/scalarresult.cpp
index 9168938..67624ba 100644
--- a/result/scalarresult.cpp
+++ b/result/scalarresult.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/result/scalarresult.h b/result/scalarresult.h
index f441c9b..6c02dd6 100644
--- a/result/scalarresult.h
+++ b/result/scalarresult.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/validator.cpp b/validator.cpp
index d532fdb..f8cac8f 100644
--- a/validator.cpp
+++ b/validator.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
diff --git a/validator.h b/validator.h
index 4728065..6a404da 100644
--- a/validator.h
+++ b/validator.h
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *