forked from qt-creator/qt-creator
Utils/Axivion: Remove last traces of expected_str
Change-Id: I7ade4764199c6a15d8bc05c4d9ea1225635db35a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -11,9 +11,6 @@ namespace Utils {
|
|||||||
|
|
||||||
using namespace tl;
|
using namespace tl;
|
||||||
|
|
||||||
template<class T>
|
|
||||||
using expected_str = tl::expected<T, QString>;
|
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|
||||||
//! If 'expected' has an error the error will be printed and the 'action' will be executed.
|
//! If 'expected' has an error the error will be printed and the 'action' will be executed.
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include "idataprovider.h"
|
#include "idataprovider.h"
|
||||||
|
|
||||||
#include <utils/expected.h>
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <utils/result.h>
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
{
|
{
|
||||||
const FilePath statusMemory = FilePath::fromString(
|
const FilePath statusMemory = FilePath::fromString(
|
||||||
QStringLiteral("/proc/%1/status").arg(m_pid));
|
QStringLiteral("/proc/%1/status").arg(m_pid));
|
||||||
const expected_str<QByteArray> statusMemoryContent = statusMemory.fileContents();
|
const Result<QByteArray> statusMemoryContent = statusMemory.fileContents();
|
||||||
|
|
||||||
if (!statusMemoryContent)
|
if (!statusMemoryContent)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FilePath meminfoFile("/proc/meminfo");
|
const FilePath meminfoFile("/proc/meminfo");
|
||||||
const expected_str<QByteArray> meminfoContent = meminfoFile.fileContents();
|
const Result<QByteArray> meminfoContent = meminfoFile.fileContents();
|
||||||
if (!meminfoContent)
|
if (!meminfoContent)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -120,8 +120,8 @@ public:
|
|||||||
const FilePath status = FilePath::fromString(QStringLiteral("/proc/%1/stat").arg(m_pid));
|
const FilePath status = FilePath::fromString(QStringLiteral("/proc/%1/stat").arg(m_pid));
|
||||||
const FilePath uptimeFile = FilePath::fromString(QStringLiteral("/proc/uptime"));
|
const FilePath uptimeFile = FilePath::fromString(QStringLiteral("/proc/uptime"));
|
||||||
const double clkTck = static_cast<double>(sysconf(_SC_CLK_TCK));
|
const double clkTck = static_cast<double>(sysconf(_SC_CLK_TCK));
|
||||||
const expected_str<QByteArray> statusFileContent = status.fileContents();
|
const Result<QByteArray> statusFileContent = status.fileContents();
|
||||||
const expected_str<QByteArray> uptimeFileContent = uptimeFile.fileContents();
|
const Result<QByteArray> uptimeFileContent = uptimeFile.fileContents();
|
||||||
|
|
||||||
if (!statusFileContent.has_value() || !uptimeFileContent.has_value() || clkTck == 0)
|
if (!statusFileContent.has_value() || !uptimeFileContent.has_value() || clkTck == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -558,7 +558,7 @@ void IssuesWidget::initDashboardList(const QString &preferredProject)
|
|||||||
void IssuesWidget::reinitProjectList(const QString ¤tProject)
|
void IssuesWidget::reinitProjectList(const QString ¤tProject)
|
||||||
{
|
{
|
||||||
const auto onDashboardInfoFetched
|
const auto onDashboardInfoFetched
|
||||||
= [this, currentProject] (const expected_str<DashboardInfo> &info) {
|
= [this, currentProject] (const Result<DashboardInfo> &info) {
|
||||||
if (!info) {
|
if (!info) {
|
||||||
m_issuesView->hideProgressIndicator();
|
m_issuesView->hideProgressIndicator();
|
||||||
return;
|
return;
|
||||||
|
@@ -586,7 +586,7 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
|
|||||||
|
|
||||||
QString errorString;
|
QString errorString;
|
||||||
if (contentType == s_jsonContentType) {
|
if (contentType == s_jsonContentType) {
|
||||||
const Utils::expected_str<Dto::ErrorDto> error
|
const Result<Dto::ErrorDto> error
|
||||||
= Dto::ErrorDto::deserializeExpected(reply->readAll());
|
= Dto::ErrorDto::deserializeExpected(reply->readAll());
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -622,18 +622,18 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
|
|||||||
return DoneResult::Error;
|
return DoneResult::Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto onDeserializeSetup = [storage](Async<expected_str<DtoType>> &task) {
|
const auto onDeserializeSetup = [storage](Async<Result<DtoType>> &task) {
|
||||||
if (!*storage)
|
if (!*storage)
|
||||||
return SetupResult::StopWithSuccess;
|
return SetupResult::StopWithSuccess;
|
||||||
|
|
||||||
const auto deserialize = [](QPromise<expected_str<DtoType>> &promise, const QByteArray &input) {
|
const auto deserialize = [](QPromise<Result<DtoType>> &promise, const QByteArray &input) {
|
||||||
promise.addResult(DtoType::deserializeExpected(input));
|
promise.addResult(DtoType::deserializeExpected(input));
|
||||||
};
|
};
|
||||||
task.setConcurrentCallData(deserialize, **storage);
|
task.setConcurrentCallData(deserialize, **storage);
|
||||||
return SetupResult::Continue;
|
return SetupResult::Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto onDeserializeDone = [dtoStorage](const Async<expected_str<DtoType>> &task,
|
const auto onDeserializeDone = [dtoStorage](const Async<Result<DtoType>> &task,
|
||||||
DoneWith doneWith) {
|
DoneWith doneWith) {
|
||||||
if (doneWith == DoneWith::Success && task.isResultAvailable()) {
|
if (doneWith == DoneWith::Success && task.isResultAvailable()) {
|
||||||
const auto result = task.result();
|
const auto result = task.result();
|
||||||
@@ -652,7 +652,7 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
|
|||||||
return {
|
return {
|
||||||
storage,
|
storage,
|
||||||
NetworkQueryTask(onNetworkQuerySetup, onNetworkQueryDone),
|
NetworkQueryTask(onNetworkQuerySetup, onNetworkQueryDone),
|
||||||
AsyncTask<expected_str<DtoType>>(onDeserializeSetup, onDeserializeDone)
|
AsyncTask<Result<DtoType>>(onDeserializeSetup, onDeserializeDone)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include "dashboard/dto.h"
|
#include "dashboard/dto.h"
|
||||||
|
|
||||||
#include <utils/expected.h>
|
|
||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
|
#include <utils/result.h>
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
@@ -85,20 +85,20 @@ QUrl resolveDashboardInfoUrl(const QUrl &url);
|
|||||||
|
|
||||||
Tasking::Group downloadDataRecipe(const Tasking::Storage<DownloadData> &storage);
|
Tasking::Group downloadDataRecipe(const Tasking::Storage<DownloadData> &storage);
|
||||||
|
|
||||||
using DashboardInfoHandler = std::function<void(const Utils::expected_str<DashboardInfo> &)>;
|
using DashboardInfoHandler = std::function<void(const Utils::Result<DashboardInfo> &)>;
|
||||||
Tasking::Group dashboardInfoRecipe(const DashboardInfoHandler &handler = {});
|
Tasking::Group dashboardInfoRecipe(const DashboardInfoHandler &handler = {});
|
||||||
|
|
||||||
Tasking::Group projectInfoRecipe(const QString &projectName);
|
Tasking::Group projectInfoRecipe(const QString &projectName);
|
||||||
|
|
||||||
// TODO: Wrap into expected_str<>?
|
// TODO: Wrap into Result<>?
|
||||||
using TableInfoHandler = std::function<void(const Dto::TableInfoDto &)>;
|
using TableInfoHandler = std::function<void(const Dto::TableInfoDto &)>;
|
||||||
Tasking::Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler);
|
Tasking::Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler);
|
||||||
|
|
||||||
// TODO: Wrap into expected_str<>?
|
// TODO: Wrap into Result<>?
|
||||||
using IssueTableHandler = std::function<void(const Dto::IssueTableDto &)>;
|
using IssueTableHandler = std::function<void(const Dto::IssueTableDto &)>;
|
||||||
Tasking::Group issueTableRecipe(const IssueListSearch &search, const IssueTableHandler &handler);
|
Tasking::Group issueTableRecipe(const IssueListSearch &search, const IssueTableHandler &handler);
|
||||||
|
|
||||||
// TODO: Wrap into expected_str<>?
|
// TODO: Wrap into Result<>?
|
||||||
using LineMarkerHandler = std::function<void(const Dto::FileViewDto &)>;
|
using LineMarkerHandler = std::function<void(const Dto::FileViewDto &)>;
|
||||||
Tasking::Group lineMarkerRecipe(const Utils::FilePath &filePath, const LineMarkerHandler &handler);
|
Tasking::Group lineMarkerRecipe(const Utils::FilePath &filePath, const LineMarkerHandler &handler);
|
||||||
|
|
||||||
|
@@ -134,7 +134,7 @@ static QList<AxivionServer> readAxivionJson(const FilePath &filePath)
|
|||||||
{
|
{
|
||||||
if (!filePath.exists())
|
if (!filePath.exists())
|
||||||
return {};
|
return {};
|
||||||
expected_str<QByteArray> contents = filePath.fileContents();
|
Result<QByteArray> contents = filePath.fileContents();
|
||||||
if (!contents)
|
if (!contents)
|
||||||
return {};
|
return {};
|
||||||
const QJsonDocument doc = QJsonDocument::fromJson(*contents);
|
const QJsonDocument doc = QJsonDocument::fromJson(*contents);
|
||||||
|
Reference in New Issue
Block a user