From eca7044361415db47b62326ae3235d97d4cb7420 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 24 Nov 2022 08:52:47 +0100 Subject: 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 Reviewed-by: Qt CI Bot --- src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libs/qmljs/qmljsmodelmanagerinterface.cpp') diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index 71bd55119be..9ba1d43fcf7 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -875,7 +875,7 @@ static bool findNewQmlLibraryInPath(const Utils::FilePath &path, } // found a new library! - const std::optional contents = qmldirFile.fileContents(); + const expected_str contents = qmldirFile.fileContents(); if (!contents) return false; QString qmldirData = QString::fromUtf8(*contents); @@ -985,7 +985,7 @@ void ModelManagerInterface::parseLoop(QSet &scannedPaths, contents = entry.first; documentRevision = entry.second; } else { - const std::optional fileContents = fileName.fileContents(); + const expected_str fileContents = fileName.fileContents(); if (fileContents) { QTextStream ins(*fileContents); contents = ins.readAll(); -- cgit v1.2.3