Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmltoolingutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5
6#include <QtCore/qfileinfo.h>
7#include <QtCore/qdir.h>
8
9using namespace Qt::StringLiterals;
10
20void QQmlToolingUtils::warnForInvalidDirs(const QStringList &dirs, const QString &origin)
21{
22 for (const QString &path : dirs) {
24 if (!info.exists()) {
25 qWarning().noquote().nospace()
26 << u"Argument \"%1\" %2 does not exist."_s.arg(path, origin);
27 continue;
28 }
29 if (!info.isDir()) {
30 qWarning().noquote().nospace()
31 << "Argument \"" << path << "\" " << origin << " is not a directory.";
32 continue;
33 }
34 }
35}
36
39{
40 const QStringList envPaths = qEnvironmentVariable(environmentVariableName.toUtf8())
42 warnForInvalidDirs(envPaths,
43 u"from environment variable \"%1\""_s.arg(environmentVariableName));
44 return envPaths;
45}
46
49{
50 if (!parser.isSet(option))
51 return {};
52
53 const QStringList dirs = parser.values(option);
54 const QString optionName = option.names().constFirst();
55 warnForInvalidDirs(dirs, u"passed to -%1"_s.arg(optionName));
56 return dirs;
57}
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
The QCommandLineParser class provides a means for handling the command line options.
QStringList values(const QString &name) const
Returns a list of option values found for the given option name optionName, or an empty list if not f...
bool isSet(const QString &name) const
Checks whether the option name was passed to the application.
static constexpr QChar listSeparator() noexcept
Definition qdir.h:200
static QStringList getAndWarnForInvalidDirsFromEnv(const QString &environmentVariableName)
static QStringList getAndWarnForInvalidDirsFromOption(const QCommandLineParser &parser, const QCommandLineOption &option)
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
Definition qstring.cpp:8218
@ SkipEmptyParts
Definition qnamespace.h:128
#define qWarning
Definition qlogging.h:166
GLsizei const GLchar *const * path
GLuint GLenum option
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
QHostInfo info
[0]