ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/XmlTools2/trunk/util.h
(Generate patch)

Comparing XmlTools2/trunk/util.h (file contents):
Revision 935 by s10k, Thu Feb 6 13:05:39 2014 UTC vs.
Revision 942 by s10k, Thu Feb 6 22:15:55 2014 UTC

# Line 5 | Line 5
5   #include <QDir>
6   #include <QString>
7   #include <QStringList>
8 #include <QRegExp>
8   #include <iostream> // cout, cin etc.
9  
10   namespace GlobalVars{
# Line 24 | Line 23 | QString insertQuotes(QString path);
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);
# Line 50 | Line 50 | inline QString toQString(std::string myS
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)