source: XmlTools2/trunk/util.h@ 909

Last change on this file since 909 was 906, checked in by s10k, 11 years ago
File size: 1.9 KB
RevLine 
[906]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 AppVersion;
13}
14
15/**
16 Utilities functions (global)
17 **/
18namespace Util{
19QString normalizePath(QString path);
20QString cutName(QString path);
21QString insertQuotes(QString path);
22QString normalizeAndQuote(QString path);
23QString fullTrim(QString str);
24QString normalizeDecimalSeparator(QString value);
25QStringList substring(const QString &myString, const QString &separator, Qt::CaseSensitivity cs = Qt::CaseSensitive);
26QStringList qStringListFromSpacedString(const QString &mySpacedString);
27QStringList getAllFilesByWildcard(const QString &wildcard);
28QList<int> qListIntFromSpacedString(const QString &mySpacedString);
29QList<double> qListDoubleFromSpacedString(const QString &mySpacedString);
30int indexOfBackward(const QString &myString, const QString &toSearch, int from = -1);
31bool checkEmptySpaces(QStringList toCheck);
32bool checkIfIntegers(QStringList toCheck);
33bool checkIfDoubles(QStringList toCheck);
34bool isStringInteger(QString myString);
35bool isStringDouble(QString myString);
36bool backupFile(QString file);
37bool 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
47inline QString toQString(std::string myString){
48 return QString::fromStdString(myString);
49}
50
51}
52
53#endif // UTIL_H
Note: See TracBrowser for help on using the repository browser.