ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/XmlTools2/trunk/util.h
Revision: 926
Committed: Wed Feb 5 18:31:05 2014 UTC (11 years, 8 months ago) by s10k
Content type: text/x-chdr
File size: 2287 byte(s)
Log Message:
XmlTools2
Added --aei-patch-files-list for AEI2

File Contents

# Content
1 #ifndef UTIL_H
2 #define UTIL_H
3
4 #include <QFile>
5 #include <QDir>
6 #include <QString>
7 #include <QStringList>
8 #include <QRegExp>
9 #include <iostream> // cout, cin etc.
10
11 namespace GlobalVars{
12 extern QString AppName;
13 extern QString AppExecutable;
14 extern QString AppVersion;
15 }
16
17 /**
18 Utilities functions (global)
19 **/
20 namespace Util{
21 QString normalizePath(QString path);
22 QString cutName(QString path);
23 QString insertQuotes(QString path);
24 QString normalizeAndQuote(QString path);
25 QString fullTrim(QString str);
26 QString normalizeDecimalSeparator(QString value);
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);
31 QList<double> qListDoubleFromSpacedString(const QString &mySpacedString);
32 int indexOfBackward(const QString &myString, const QString &toSearch, int from = -1);
33 bool checkEmptySpaces(QStringList toCheck);
34 bool checkIfIntegers(QStringList toCheck);
35 bool checkIfDoubles(QStringList toCheck);
36 bool isStringInteger(QString myString);
37 bool isStringDouble(QString myString);
38 bool backupFile(QString file);
39 bool copyFile(QString src, QString dest);
40 // The commented code bellow is a big mistake because toLatin1() creates a temp object that gets
41 // destroyed after the semicolon: https://qt-project.org/forums/viewthread/12885 (Volker answer)
42 //// Convert a QString to a c string
43 //// Caution don't use as for example: std::cout << toCstr(a) << " " << toCstr(b);
44 //// as the result will be always a.
45 //inline const char* toCstr(const QString &myString){
46 // return myString.toLatin1().constData();
47 //}
48 // Converts a std::string to QString
49 inline QString toQString(std::string myString){
50 return QString::fromStdString(myString);
51 }
52
53 inline QStringList QStringToArgsArray(const QString &args){
54 QStringList result;
55 result=Util::substring(args," ");
56
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
59 }
60
61 return result;
62 }
63
64 }
65
66 #endif // UTIL_H