From 8122ac01552c631b14ea096117c775ff6509ea24 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 3 Apr 2016 14:29:21 +0200 Subject: change contact link. --- booleancondition.cpp | 2 +- booleancondition.h | 2 +- compositevalidator.cpp | 2 +- compositevalidator.h | 2 +- dicealias.cpp | 2 +- dicealias.h | 2 +- diceparser.cpp | 2 +- diceparser.h | 2 +- die.cpp | 2 +- die.h | 2 +- node/helpnode.cpp | 2 +- node/ifnode.cpp | 2 +- node/mergenode.cpp | 2 +- node/mergenode.h | 2 +- node/numbernode.cpp | 2 +- node/numbernode.h | 2 +- node/parenthesesnode.cpp | 2 +- node/parenthesesnode.h | 2 +- node/scalaroperatornode.cpp | 2 +- node/scalaroperatornode.h | 2 +- node/sortresult.cpp | 2 +- node/sortresult.h | 2 +- node/startingnode.cpp | 2 +- node/startingnode.h | 2 +- operationcondition.cpp | 2 +- operationcondition.h | 2 +- parsingtoolbox.cpp | 6 +++--- parsingtoolbox.h | 2 +- range.cpp | 2 +- range.h | 2 +- result/diceresult.cpp | 2 +- result/diceresult.h | 2 +- result/result.cpp | 2 +- result/result.h | 2 +- result/scalarresult.cpp | 2 +- result/scalarresult.h | 2 +- validator.cpp | 2 +- validator.h | 2 +- 38 files changed, 40 insertions(+), 40 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..3369f7d 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 * * * diff --git a/diceparser.h b/diceparser.h index 0df633b..871a0d3 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 * * * diff --git a/die.cpp b/die.cpp index 64f08d6..504c1a9 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 1c9dc90..7a52c65 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 * * * @@ -100,8 +100,8 @@ bool ParsingToolBox::readArithmeticOperator(QString &str, ScalarOperatorNode::Ar { bool found = false; //QHash::Iterator - auto i = m_arithmeticOperation->begin(); - for(; i !=m_arithmeticOperation->end() && !found; ++i) + + for(auto i = m_arithmeticOperation->begin() ; i !=m_arithmeticOperation->end() && !found; ++i) { if(str.startsWith(i.key())) { diff --git a/parsingtoolbox.h b/parsingtoolbox.h index 4aeb16e..09ab592 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 * * * 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 * * * -- cgit v1.2.3-70-g09d2 From 9311cabe959739e74b62e46563bace3ebc63e15d Mon Sep 17 00:00:00 2001 From: Renaud Guezennec Date: Wed, 13 Apr 2016 16:23:48 +0200 Subject: Add management for variable in DiceParser. --- diceparser.cpp | 4 ++++ diceparser.h | 5 +++++ parsingtoolbox.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- parsingtoolbox.h | 20 +++++++++++++++++--- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/diceparser.cpp b/diceparser.cpp index 90d52e3..af87199 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -1086,3 +1086,7 @@ void DiceParser::setPathToHelp(QString l) { m_helpPath = l; } +void DiceParser::setVariableDictionary(QHash* variables) +{ + ParsingToolBox::setVariableHash(variables); +} diff --git a/diceparser.h b/diceparser.h index 0df633b..0757f99 100644 --- a/diceparser.h +++ b/diceparser.h @@ -204,6 +204,11 @@ public: bool hasSeparator()const; bool readIfInstruction(QString &str, ExecutionNode* &trueNode, ExecutionNode* &falseNode); + /** + * @brief setVariableDictionary + * @param variables + */ + void setVariableDictionary(QHash* variables); private: /** diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index 00dfe81..5014b31 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -24,6 +24,7 @@ #include "parsingtoolbox.h" #include "node/sortresult.h" +QHash* 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 *ParsingToolBox::getVariableHash() +{ + return m_variableHash; +} + +void ParsingToolBox::setVariableHash(QHash *variableHash) +{ + m_variableHash = variableHash; +} + void ParsingToolBox::readProbability(QStringList& str,QList& ranges) { quint64 totalDistance=0; diff --git a/parsingtoolbox.h b/parsingtoolbox.h index 4aeb16e..efe7acd 100644 --- a/parsingtoolbox.h +++ b/parsingtoolbox.h @@ -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 *getVariableHash(); + static void setVariableHash(QHash *variableHash); + private: - QMap* m_logicOp; - QMap* m_logicOperation; + + QMap* m_logicOp; + QMap* m_logicOperation; QMap* m_conditionOperation; QHash* m_arithmeticOperation; + + + static QHash* m_variableHash; }; #endif // PARSINGTOOLBOX_H -- cgit v1.2.3-70-g09d2