source: XmlTools2/trunk/util.h@ 925

Last change on this file since 925 was 920, checked in by s10k, 11 years ago

more fixes and updated examples

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