diff options
| -rw-r--r-- | parsingtoolbox.cpp | 23 | ||||
| -rw-r--r-- | parsingtoolbox.h | 8 |
2 files changed, 31 insertions, 0 deletions
diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index 02cdd13..0567ba4 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -345,7 +345,30 @@ bool ParsingToolBox::readNumber(QString& str, qint64& myNumber) return false; } +bool ParsingToolBox::readDynamicVariable(QString& str, qint64& index) +{ + if(str.isEmpty()) + return false; + if(str.startsWith('$')) + { + QString number; + int i=0; + while(i<str.length() && (str[i].isNumber())) + { + number+=str[i]; + ++i; + } + bool ok; + index = number.toLongLong(&ok); + if(ok) + { + str=str.remove(0,number.size()); + return true; + } + } + return false; +} bool ParsingToolBox::readString(QString &str, QString& strResult) { if(str.isEmpty()) diff --git a/parsingtoolbox.h b/parsingtoolbox.h index 5a87573..8328dc8 100644 --- a/parsingtoolbox.h +++ b/parsingtoolbox.h @@ -125,6 +125,14 @@ public: static bool readCloseParentheses(QString& str); /** + * @brief readNumber read number in the given str and remove from the string the read character. + * @param str the command line + * @param myNumber reference to the found number + * @return true, succeed to read number, false otherwise. + */ + static bool readDynamicVariable(QString& str, qint64& index); + + /** * @brief readList * @param str * @param list |