Utils/Axivion: Remove last traces of expected_str

Change-Id: I7ade4764199c6a15d8bc05c4d9ea1225635db35a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2025-04-11 16:55:06 +02:00
parent f95be0315c
commit 9c41079085
6 changed files with 17 additions and 20 deletions

View File

@@ -11,9 +11,6 @@ namespace Utils {
using namespace tl;
template<class T>
using expected_str = tl::expected<T, QString>;
} // namespace Utils
//! If 'expected' has an error the error will be printed and the 'action' will be executed.

View File

@@ -3,9 +3,9 @@
#include "idataprovider.h"
#include <utils/expected.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/result.h>
#include <QByteArray>
#include <QRegularExpression>
@@ -84,7 +84,7 @@ public:
{
const FilePath statusMemory = FilePath::fromString(
QStringLiteral("/proc/%1/status").arg(m_pid));
const expected_str<QByteArray> statusMemoryContent = statusMemory.fileContents();
const Result<QByteArray> statusMemoryContent = statusMemory.fileContents();
if (!statusMemoryContent)
return 0;
@@ -99,7 +99,7 @@ public:
}
const FilePath meminfoFile("/proc/meminfo");
const expected_str<QByteArray> meminfoContent = meminfoFile.fileContents();
const Result<QByteArray> meminfoContent = meminfoFile.fileContents();
if (!meminfoContent)
return 0;
@@ -120,8 +120,8 @@ public:
const FilePath status = FilePath::fromString(QStringLiteral("/proc/%1/stat").arg(m_pid));
const FilePath uptimeFile = FilePath::fromString(QStringLiteral("/proc/uptime"));
const double clkTck = static_cast<double>(sysconf(_SC_CLK_TCK));
const expected_str<QByteArray> statusFileContent = status.fileContents();
const expected_str<QByteArray> uptimeFileContent = uptimeFile.fileContents();
const Result<QByteArray> statusFileContent = status.fileContents();
const Result<QByteArray> uptimeFileContent = uptimeFile.fileContents();
if (!statusFileContent.has_value() || !uptimeFileContent.has_value() || clkTck == 0)
return 0;

View File

@@ -558,7 +558,7 @@ void IssuesWidget::initDashboardList(const QString &preferredProject)
void IssuesWidget::reinitProjectList(const QString &currentProject)
{
const auto onDashboardInfoFetched
= [this, currentProject] (const expected_str<DashboardInfo> &info) {
= [this, currentProject] (const Result<DashboardInfo> &info) {
if (!info) {
m_issuesView->hideProgressIndicator();
return;

View File

@@ -586,7 +586,7 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
QString errorString;
if (contentType == s_jsonContentType) {
const Utils::expected_str<Dto::ErrorDto> error
const Result<Dto::ErrorDto> error
= Dto::ErrorDto::deserializeExpected(reply->readAll());
if (error) {
@@ -622,18 +622,18 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
return DoneResult::Error;
};
const auto onDeserializeSetup = [storage](Async<expected_str<DtoType>> &task) {
const auto onDeserializeSetup = [storage](Async<Result<DtoType>> &task) {
if (!*storage)
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));
};
task.setConcurrentCallData(deserialize, **storage);
return SetupResult::Continue;
};
const auto onDeserializeDone = [dtoStorage](const Async<expected_str<DtoType>> &task,
const auto onDeserializeDone = [dtoStorage](const Async<Result<DtoType>> &task,
DoneWith doneWith) {
if (doneWith == DoneWith::Success && task.isResultAvailable()) {
const auto result = task.result();
@@ -652,7 +652,7 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
return {
storage,
NetworkQueryTask(onNetworkQuerySetup, onNetworkQueryDone),
AsyncTask<expected_str<DtoType>>(onDeserializeSetup, onDeserializeDone)
AsyncTask<Result<DtoType>>(onDeserializeSetup, onDeserializeDone)
};
}

View File

@@ -5,8 +5,8 @@
#include "dashboard/dto.h"
#include <utils/expected.h>
#include <utils/id.h>
#include <utils/result.h>
#include <QHash>
#include <QMap>
@@ -85,20 +85,20 @@ QUrl resolveDashboardInfoUrl(const QUrl &url);
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 projectInfoRecipe(const QString &projectName);
// TODO: Wrap into expected_str<>?
// TODO: Wrap into Result<>?
using TableInfoHandler = std::function<void(const Dto::TableInfoDto &)>;
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 &)>;
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 &)>;
Tasking::Group lineMarkerRecipe(const Utils::FilePath &filePath, const LineMarkerHandler &handler);

View File

@@ -134,7 +134,7 @@ static QList<AxivionServer> readAxivionJson(const FilePath &filePath)
{
if (!filePath.exists())
return {};
expected_str<QByteArray> contents = filePath.fileContents();
Result<QByteArray> contents = filePath.fileContents();
if (!contents)
return {};
const QJsonDocument doc = QJsonDocument::fromJson(*contents);