| 5 |
|
#include <QDir> |
| 6 |
|
#include <QString> |
| 7 |
|
#include <QStringList> |
| 8 |
– |
#include <QRegExp> |
| 8 |
|
#include <iostream> // cout, cin etc. |
| 9 |
|
|
| 10 |
|
namespace GlobalVars{ |
| 23 |
|
QString normalizeAndQuote(QString path); |
| 24 |
|
QString fullTrim(QString str); |
| 25 |
|
QString normalizeDecimalSeparator(QString value); |
| 26 |
< |
QStringList substring(const QString &myString, const QString &separator, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
| 26 |
> |
// Use qstring split |
| 27 |
> |
// QStringList substring(const QString &myString, const QString &separator, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
| 28 |
|
QStringList qStringListFromSpacedString(const QString &mySpacedString); |
| 29 |
|
QStringList getAllFilesByWildcard(const QString &wildcard); |
| 30 |
|
QList<int> qListIntFromSpacedString(const QString &mySpacedString); |
| 50 |
|
return QString::fromStdString(myString); |
| 51 |
|
} |
| 52 |
|
|
| 53 |
+ |
// Needs optimization |
| 54 |
|
inline QStringList QStringToArgsArray(const QString &args){ |
| 55 |
|
QStringList result; |
| 56 |
< |
result=Util::substring(args," "); |
| 56 |
> |
int startIdx=0, endIdx=0; |
| 57 |
> |
|
| 58 |
> |
if(!args.isEmpty()){ // if non empty arguments |
| 59 |
> |
|
| 60 |
> |
while(endIdx<args.length()){ |
| 61 |
> |
|
| 62 |
> |
startIdx=endIdx; |
| 63 |
> |
|
| 64 |
> |
if(args.at(startIdx)==' '){ // Ignore spaces until a different char is found |
| 65 |
> |
endIdx++; |
| 66 |
> |
continue; |
| 67 |
> |
} |
| 68 |
> |
else if(args.at(startIdx)!='"'){ // if first character is different from quote it ends with space |
| 69 |
> |
endIdx=args.indexOf(' ',startIdx+1); |
| 70 |
> |
} |
| 71 |
> |
else{ // If is a quote try to get the all the string until next quote |
| 72 |
> |
endIdx=args.indexOf('"',startIdx+1); |
| 73 |
> |
} |
| 74 |
> |
|
| 75 |
> |
if(endIdx==-1) break; |
| 76 |
> |
|
| 77 |
> |
endIdx++; |
| 78 |
> |
|
| 79 |
> |
result << args.mid(startIdx,endIdx-startIdx).replace("\"","").trimmed(); // remove quotes |
| 80 |
> |
} |
| 81 |
|
|
| 57 |
– |
for(int i=0; i<result.size(); i++){ |
| 58 |
– |
result[i].remove('"'); // remove quotes, they are not necessary as we had already splited the spaces |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
return result; |