diff options
| author | 2015-05-16 00:05:08 +0200 | |
|---|---|---|
| committer | 2015-05-16 00:05:08 +0200 | |
| commit | bb89b91d9919ad9fed8b9d30ea0df79ceea4d3f7 (patch) | |
| tree | 090223d5ab28601d52c63bb9489835f191cf797a /parsingtoolbox.cpp | |
| parent | b79df1fffd6677a584d6ad8ed44004aae0dad7b4 (diff) | |
| parent | f8a2e958e699ca41730cb785e7284c07eaaa5a82 (diff) | |
| download | OneRoll-bb89b91d9919ad9fed8b9d30ea0df79ceea4d3f7.tar.gz OneRoll-bb89b91d9919ad9fed8b9d30ea0df79ceea4d3f7.zip | |
Merge branch 'master' of github.com:obiwankennedy/DiceParser
Diffstat (limited to 'parsingtoolbox.cpp')
| -rw-r--r-- | parsingtoolbox.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index 3e09bac..0052f07 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -141,7 +141,7 @@ bool ParsingToolBox::readNumber(QString& str, int& myNumber) QString number; int i=0; - while(i<str.length() && str[i].isNumber()) + while(i<str.length() && ((str[i].isNumber()) || ( (i==0) && (str[i]=='-')))) { number+=str[i]; ++i; @@ -234,3 +234,44 @@ DiceRollerNode* ParsingToolBox::getDiceRollerNode(ExecutionNode* previous) previous = previous->getPreviousNode(); } } +bool ParsingToolBox::readDiceRange(QString& str,int& start, int& end) +{ + bool expectSquareBrasket=false; + + qDebug()<<"readDiceRange"<<str; + if((str.startsWith("["))) + { + str=str.remove(0,1); + expectSquareBrasket = true; + } +qDebug()<<"readDiceRange"<<str; + if(readNumber(str,start)) + { + qDebug()<<"readDiceRange"<<str; + if(str.startsWith("-")) + { + str=str.remove(0,1); + if(readNumber(str,end)) + { + if(expectSquareBrasket) + { + if(str.startsWith("]")) + { + str=str.remove(0,1); + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + qDebug()<<"readDiceRange"<<str; + } + } + +} |