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