aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/parsingtoolbox.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2016-11-01 12:10:54 +0100
committerRenaud G <renaud@rolisteam.org>2016-11-01 12:10:54 +0100
commitd5876d9b88c2f695592338335308a32e584d86a4 (patch)
treebb0c3f757512fb913812902143b73b7380451502 /parsingtoolbox.cpp
parentd29b6d34b713d9241eb96cb99802ca8bc24cc3bd (diff)
downloadOneRoll-d5876d9b88c2f695592338335308a32e584d86a4.tar.gz
OneRoll-d5876d9b88c2f695592338335308a32e584d86a4.zip
-add management of string node to display text in some condition.
Diffstat (limited to 'parsingtoolbox.cpp')
-rw-r--r--parsingtoolbox.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp
index 212c006..cc1a800 100644
--- a/parsingtoolbox.cpp
+++ b/parsingtoolbox.cpp
@@ -282,6 +282,7 @@ bool ParsingToolBox::readNumber(QString& str, qint64& myNumber)
if(str.isEmpty())
return false;
+
QString number;
int i=0;
while(i<str.length() && ((str[i].isNumber()) || ( (i==0) && (str[i]=='-'))))
@@ -306,6 +307,57 @@ bool ParsingToolBox::readNumber(QString& str, qint64& myNumber)
return false;
}
+bool ParsingToolBox::readString(QString &str, QString& strResult)
+{
+ if(str.isEmpty())
+ return false;
+
+
+ if(str.startsWith('"'))
+ {
+ str=str.remove(0,1);
+ }
+
+ int i=0;
+ int j=0;
+ bool previousEscape=false;
+ QString result;
+ /*&&
+ (((!previousEscape) && !(str[i]=='"')) || (previousEscape) && !(str[i]=='"'))
+ || (str[i]=='\\'))*/
+ while(i<str.length() && (!(!previousEscape && (str[i]=='"')) || (previousEscape && str[i]!='"')))
+ {
+ if(str[i]=='\\')
+ {
+ previousEscape = true;
+ }
+ else
+ {
+ if(previousEscape && str[i]!='\"')
+ {
+ result += '\\';
+ ++j;
+ }
+ result+=str[i];
+ previousEscape = false;
+ }
+ ++i;
+ }
+ qDebug() << "previous" << previousEscape << str[i];
+
+ if(!result.isEmpty())
+ {
+ str=str.remove(0,i);
+ strResult = result;
+ if(str.startsWith('"'))
+ {
+ str=str.remove(0,1);
+ return true;
+ }
+ }
+ return false;
+}
+
bool ParsingToolBox::readVariable(QString &str, qint64 &myNumber)
{
if(str.isEmpty())