WSF
Util.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11#ifndef UTIL_HPP
12#define UTIL_HPP
13
14#include <algorithm>
15#include <iosfwd>
16#include <set>
17#include <string>
18
19#include <QMap>
20#include <QRegExp>
21#include <QString>
22#include <QStringList>
23
24#include "UtPath.hpp"
25#include "UtTextDocument.hpp"
26#include "ViExport.hpp"
27
28class QDir;
29
30namespace wizard
31{
32
33#ifdef _WIN32
34struct UtilWindowsFileCharCompare
35{
36 bool operator()(char a, char b) const { return tolower(a) < tolower(b); }
37 bool operator()(QChar a, QChar b) const { return tolower(a.toLatin1()) < tolower(b.toLatin1()); }
38};
39#endif
41{
42 bool operator()(const std::string& lhs, const std::string& rhs) const
43 {
44#ifdef _WIN32
45 return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), UtilWindowsFileCharCompare());
46#else
47 return lhs < rhs;
48#endif
49 }
50};
51
53{
54 bool operator()(const QString& lhs, const QString& rhs) const
55 {
56#ifdef _WIN32
57 return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), UtilWindowsFileCharCompare());
58#else
59 return lhs < rhs;
60#endif
61 }
62};
63
64// Compare 2 null-terminated strings
66{
67 bool operator()(const char* aLhs, const char* aRhs) const
68 {
69 while ((*aLhs | *aRhs) != 0)
70 {
71 if (*aLhs < *aRhs)
72 return true;
73 if (*aRhs < *aLhs)
74 return false;
75 ++aLhs;
76 ++aRhs;
77 }
78 return false;
79 }
80};
81
83{
84public:
85 static bool IsExecutable(const UtPath& aExePath);
86 static QStringList SplitCommandLine(const QString& aCommandLine, const QMap<QString, QString>& aVariables);
87
88 static bool IsNonTextFile(const QString& aPath);
89
90 static int FilesInDirectory(QDir& aDir, int aStopAt = 10000);
91
92 static std::string MakeTempFileName();
93
94 static bool CreateNewFile(const UtPath& aName);
95
96 static QString QuotePathWithSpaces(const QString& aPath);
97 static QString StripHtml(const QString& htmlStr);
98
99 static QRegExp SimpleRegex(const QString& aText);
100
101 static void EscapeForCSV(std::string& aText);
102
103 static QString BuildFileLineColURL(const QString& aFilePath, int aLine, int aColumn = 0, const QString& aLabel = QString());
104
105 static QString BuildHRef(const QString& aUrl, const QString& aLabel);
106
107 // RegExp to be used in creating QRegExpValidators. This one disallows
108 // white space characters and comment tokens.
109 static const QRegExp wsfValidInputRegexp;
110};
111} // namespace wizard
112
113#endif
#define VI_EXPORT
Definition ViExport.hpp:38
Definition Util.hpp:83
static const QRegExp wsfValidInputRegexp
Definition Util.hpp:109
static QString BuildFileLineColURL(const QString &aFilePath, int aLine, int aColumn=0, const QString &aLabel=QString())
Definition Util.cpp:498
static QRegExp SimpleRegex(const QString &aText)
Definition Util.cpp:485
static bool CreateNewFile(const UtPath &aName)
Definition Util.cpp:321
static void EscapeForCSV(std::string &aText)
static QString StripHtml(const QString &htmlStr)
Definition Util.cpp:474
static bool IsNonTextFile(const QString &aPath)
Definition Util.cpp:268
static bool IsExecutable(const UtPath &aExePath)
Definition Util.cpp:41
static QStringList SplitCommandLine(const QString &aCommandLine, const QMap< QString, QString > &aVariables)
Definition Util.cpp:228
static QString BuildHRef(const QString &aUrl, const QString &aLabel)
Definition Util.cpp:517
static QString QuotePathWithSpaces(const QString &aPath)
Definition Util.cpp:465
static std::string MakeTempFileName()
Definition Util.cpp:313
static int FilesInDirectory(QDir &aDir, int aStopAt=10000)
Definition Util.cpp:296
Definition Runner.hpp:22
Definition Util.hpp:66
bool operator()(const char *aLhs, const char *aRhs) const
Definition Util.hpp:67
Definition Util.hpp:53
bool operator()(const QString &lhs, const QString &rhs) const
Definition Util.hpp:54
Definition Util.hpp:41
bool operator()(const std::string &lhs, const std::string &rhs) const
Definition Util.hpp:42
Copyrights Multiple, All Rights Reserved