forked from qt-creator/qt-creator
Utils: Add std::expected implementation
Adds a std::expected implementation that is compatible with >= C++11. FilePath::fileContents and FilePath::writeFileContents as well as FilePath::copyFile are changed to return std::expected. A couple of macros have been added to aid in using the expected types. An auto test was added showing how to use the library. Change-Id: Ibe3aecfc1029a0cf13b45bf5184ff03a04a2393b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "presetsparser.h"
|
||||
#include "utils/algorithm.h"
|
||||
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
@@ -391,7 +392,7 @@ const PresetsData &PresetsParser::presetsData() const
|
||||
|
||||
bool PresetsParser::parse(const Utils::FilePath &jsonFile, QString &errorMessage, int &errorLine)
|
||||
{
|
||||
const std::optional<QByteArray> jsonContents = jsonFile.fileContents();
|
||||
const Utils::expected_str<QByteArray> jsonContents = jsonFile.fileContents();
|
||||
if (!jsonContents) {
|
||||
errorMessage = Tr::tr("Failed to read %1 file").arg(jsonFile.fileName());
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user