forked from qt-creator/qt-creator
Utils: Remove Utils::optional
Since we are now requiring macOS 10.14 we can remove our local implementation of optional and use std::optional for macOS too. Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -9,13 +9,13 @@
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/id.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
Command introspect(const Utils::FilePath &sourceDirectory) const;
|
||||
|
||||
static inline Utils::optional<Utils::FilePath> find()
|
||||
static inline std::optional<Utils::FilePath> find()
|
||||
{
|
||||
return ToolWrapper::findTool({"meson.py", "meson"});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class NinjaWrapper final : public ToolWrapper
|
||||
public:
|
||||
using ToolWrapper::ToolWrapper;
|
||||
|
||||
static inline Utils::optional<Utils::FilePath> find()
|
||||
static inline std::optional<Utils::FilePath> find()
|
||||
{
|
||||
return ToolWrapper::findTool({"ninja", "ninja-build"});
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ Version ToolWrapper::read_version(const Utils::FilePath &toolPath)
|
||||
return {};
|
||||
}
|
||||
|
||||
Utils::optional<Utils::FilePath> ToolWrapper::findTool(const QStringList &exeNames)
|
||||
std::optional<Utils::FilePath> ToolWrapper::findTool(const QStringList &exeNames)
|
||||
{
|
||||
using namespace Utils;
|
||||
Environment systemEnvironment = Environment::systemEnvironment();
|
||||
@@ -58,7 +58,7 @@ Utils::optional<Utils::FilePath> ToolWrapper::findTool(const QStringList &exeNam
|
||||
if (exe_path.exists())
|
||||
return exe_path;
|
||||
}
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <QVariant>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -64,7 +66,7 @@ public:
|
||||
|
||||
static Version read_version(const Utils::FilePath &toolPath);
|
||||
|
||||
static Utils::optional<Utils::FilePath> findTool(const QStringList &exeNames);
|
||||
static std::optional<Utils::FilePath> findTool(const QStringList &exeNames);
|
||||
|
||||
template<typename T>
|
||||
friend QVariantMap toVariantMap(const T &);
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
@@ -13,6 +12,8 @@
|
||||
#include <QSpinBox>
|
||||
#include <QVariant>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -58,7 +59,7 @@ struct BuildOption
|
||||
const QString name;
|
||||
const QString section;
|
||||
const QString description;
|
||||
const Utils::optional<QString> subproject;
|
||||
const std::optional<QString> subproject;
|
||||
virtual ~BuildOption() {}
|
||||
virtual QVariant value() const = 0;
|
||||
virtual QString valueStr() const = 0;
|
||||
@@ -79,8 +80,8 @@ struct BuildOption
|
||||
: name{name.contains(":") ? name.split(":").last() : name}
|
||||
, section{section}
|
||||
, description{description}
|
||||
, subproject{name.contains(":") ? Utils::optional<QString>(name.split(":").first())
|
||||
: Utils::nullopt}
|
||||
, subproject{name.contains(":") ? std::optional<QString>(name.split(":").first())
|
||||
: std::nullopt}
|
||||
{}
|
||||
}; // namespace Internal
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include "target.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
@@ -26,7 +27,7 @@ struct Result
|
||||
TargetsList targets;
|
||||
BuildOptionsList buildOptions;
|
||||
std::vector<Utils::FilePath> buildSystemFiles;
|
||||
Utils::optional<MesonInfo> mesonInfo;
|
||||
std::optional<MesonInfo> mesonInfo;
|
||||
};
|
||||
|
||||
inline Result parse(const QString &buildDir)
|
||||
@@ -43,7 +44,7 @@ inline Result parse(const QByteArray &data)
|
||||
return {TargetParser{json}.targetList(),
|
||||
BuildOptionsParser{json}.takeBuildOptions(),
|
||||
BuildSystemFilesParser{json}.files(),
|
||||
Utils::nullopt};
|
||||
std::nullopt};
|
||||
}
|
||||
|
||||
inline Result parse(QIODevice *introFile)
|
||||
@@ -57,7 +58,7 @@ inline Result parse(QIODevice *introFile)
|
||||
}
|
||||
return {};
|
||||
}
|
||||
inline Utils::optional<MesonInfo> mesonInfo(const QString &buildDir)
|
||||
inline std::optional<MesonInfo> mesonInfo(const QString &buildDir)
|
||||
{
|
||||
return InfoParser{buildDir}.info();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Internal {
|
||||
class BuildSystemFilesParser
|
||||
{
|
||||
std::vector<Utils::FilePath> m_files;
|
||||
static void appendFiles(const Utils::optional<QJsonArray> &arr, std::vector<Utils::FilePath> &dest)
|
||||
static void appendFiles(const std::optional<QJsonArray> &arr, std::vector<Utils::FilePath> &dest)
|
||||
{
|
||||
if (arr)
|
||||
std::transform(std::cbegin(*arr),
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -45,7 +45,7 @@ inline QJsonObject load<QJsonObject>(const QJsonValueRef &ref)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Utils::optional<T> load(const QString &jsonFile)
|
||||
inline std::optional<T> load(const QString &jsonFile)
|
||||
{
|
||||
QFile js(jsonFile);
|
||||
js.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
@@ -53,40 +53,40 @@ inline Utils::optional<T> load(const QString &jsonFile)
|
||||
auto data = js.readAll();
|
||||
return load<T>(QJsonDocument::fromJson(data));
|
||||
}
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Utils::optional<T> get(const QJsonObject &obj, const QString &name);
|
||||
inline std::optional<T> get(const QJsonObject &obj, const QString &name);
|
||||
|
||||
template<>
|
||||
inline Utils::optional<QJsonArray> get<QJsonArray>(const QJsonObject &obj, const QString &name)
|
||||
inline std::optional<QJsonArray> get<QJsonArray>(const QJsonObject &obj, const QString &name)
|
||||
{
|
||||
if (obj.contains(name)) {
|
||||
auto child = obj[name];
|
||||
if (child.isArray())
|
||||
return child.toArray();
|
||||
}
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Utils::optional<QJsonObject> get<QJsonObject>(const QJsonObject &obj, const QString &name)
|
||||
inline std::optional<QJsonObject> get<QJsonObject>(const QJsonObject &obj, const QString &name)
|
||||
{
|
||||
if (obj.contains(name)) {
|
||||
auto child = obj[name];
|
||||
if (child.isObject())
|
||||
return child.toObject();
|
||||
}
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<typename T, typename... Strings>
|
||||
inline Utils::optional<T> get(const QJsonObject &obj, const QString &firstPath, const Strings &...path)
|
||||
inline std::optional<T> get(const QJsonObject &obj, const QString &firstPath, const Strings &...path)
|
||||
{
|
||||
if (obj.contains(firstPath))
|
||||
return get<T>(obj[firstPath].toObject(), path...);
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QVariant>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -56,7 +57,7 @@ struct Target
|
||||
const QString definedIn;
|
||||
const QStringList fileName;
|
||||
const QStringList extraFiles;
|
||||
const Utils::optional<QString> subproject;
|
||||
const std::optional<QString> subproject;
|
||||
const SourceGroupList sources;
|
||||
|
||||
static inline QString fullName(const Utils::FilePath &srcDir, const Target &target)
|
||||
@@ -104,8 +105,8 @@ struct Target
|
||||
, definedIn{QDir::cleanPath(definedIn)}
|
||||
, fileName{cleanPath(std::move(fileName))}
|
||||
, extraFiles{cleanPath(std::move(extraFiles))}
|
||||
, subproject{subproject.isNull() ? Utils::nullopt
|
||||
: Utils::optional<QString>{std::move(subproject)}}
|
||||
, subproject{subproject.isNull() ? std::nullopt
|
||||
: std::optional<QString>{std::move(subproject)}}
|
||||
, sources{std::move(sources)}
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
inline const QString &name() const { return m_currentValue->name; }
|
||||
inline const QString §ion() const { return m_currentValue->section; }
|
||||
inline const QString &description() const { return m_currentValue->description; }
|
||||
inline const Utils::optional<QString> &subproject() const
|
||||
inline const std::optional<QString> &subproject() const
|
||||
{
|
||||
return m_currentValue->subproject;
|
||||
};
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/runextensions.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -29,21 +30,21 @@ struct CompilerArgs
|
||||
ProjectExplorer::Macros macros;
|
||||
};
|
||||
|
||||
inline Utils::optional<QString> extractValueIfMatches(const QString &arg,
|
||||
inline std::optional<QString> extractValueIfMatches(const QString &arg,
|
||||
const QStringList &candidates)
|
||||
{
|
||||
for (const auto &flag : candidates) {
|
||||
if (arg.startsWith(flag))
|
||||
return arg.mid(flag.length());
|
||||
}
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
inline Utils::optional<QString> extractInclude(const QString &arg)
|
||||
inline std::optional<QString> extractInclude(const QString &arg)
|
||||
{
|
||||
return extractValueIfMatches(arg, {"-I", "/I", "-isystem", "-imsvc", "/imsvc"});
|
||||
}
|
||||
inline Utils::optional<ProjectExplorer::Macro> extractMacro(const QString &arg)
|
||||
inline std::optional<ProjectExplorer::Macro> extractMacro(const QString &arg)
|
||||
{
|
||||
auto define = extractValueIfMatches(arg, {"-D", "/D"});
|
||||
if (define)
|
||||
@@ -51,7 +52,7 @@ inline Utils::optional<ProjectExplorer::Macro> extractMacro(const QString &arg)
|
||||
auto undef = extractValueIfMatches(arg, {"-U", "/U"});
|
||||
if (undef)
|
||||
return ProjectExplorer::Macro(undef->toLatin1(), ProjectExplorer::MacroType::Undefine);
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
CompilerArgs splitArgs(const QStringList &args)
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Internal {
|
||||
|
||||
NinjaParser::NinjaParser() {}
|
||||
|
||||
Utils::optional<int> NinjaParser::extractProgress(const QString &line)
|
||||
std::optional<int> NinjaParser::extractProgress(const QString &line)
|
||||
{
|
||||
auto progress = m_progressRegex.match(line);
|
||||
if (progress.hasMatch()) {
|
||||
@@ -18,7 +18,7 @@ Utils::optional<int> NinjaParser::extractProgress(const QString &line)
|
||||
auto pos = progress.captured(1).toInt();
|
||||
return pos * 100 / total;
|
||||
}
|
||||
return Utils::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void NinjaParser::setSourceDirectory(const Utils::FilePath &sourceDir)
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
#include <projectexplorer/ioutputparser.h>
|
||||
#include <projectexplorer/task.h>
|
||||
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -17,7 +17,7 @@ class NinjaParser final : public ProjectExplorer::OutputTaskParser
|
||||
{
|
||||
Q_OBJECT
|
||||
QRegularExpression m_progressRegex{R"(^\[(\d+)/(\d+)\])"};
|
||||
Utils::optional<int> extractProgress(const QString &line);
|
||||
std::optional<int> extractProgress(const QString &line);
|
||||
|
||||
public:
|
||||
NinjaParser();
|
||||
|
||||
@@ -34,7 +34,7 @@ class MesonFileNode : public ProjectExplorer::ProjectNode
|
||||
public:
|
||||
MesonFileNode(const Utils::FilePath &file);
|
||||
bool showInSimpleTree() const final { return false; }
|
||||
Utils::optional<Utils::FilePath> visibleAfterAddFileAction() const override
|
||||
std::optional<Utils::FilePath> visibleAfterAddFileAction() const override
|
||||
{
|
||||
return filePath().pathAppended("meson.build");
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ ToolItemSettings::~ToolItemSettings()
|
||||
void ToolItemSettings::load(ToolTreeItem *item)
|
||||
{
|
||||
if (item) {
|
||||
m_currentId = Utils::nullopt;
|
||||
m_currentId = std::nullopt;
|
||||
ui->mesonNameLineEdit->setDisabled(item->isAutoDetected());
|
||||
ui->mesonNameLineEdit->setText(item->name());
|
||||
ui->mesonPathChooser->setDisabled(item->isAutoDetected());
|
||||
ui->mesonPathChooser->setFilePath(item->executable());
|
||||
m_currentId = item->id();
|
||||
} else {
|
||||
m_currentId = Utils::nullopt;
|
||||
m_currentId = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
#include <utils/id.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -29,7 +30,7 @@ public:
|
||||
|
||||
private:
|
||||
Ui::ToolItemSettings *ui;
|
||||
Utils::optional<Utils::Id> m_currentId{Utils::nullopt};
|
||||
std::optional<Utils::Id> m_currentId{std::nullopt};
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/id.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/treemodel.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user