diff options
| author | Marcus Tillmanns <[email protected]> | 2022-11-24 08:52:47 +0100 |
|---|---|---|
| committer | Marcus Tillmanns <[email protected]> | 2022-12-14 10:39:29 +0000 |
| commit | eca7044361415db47b62326ae3235d97d4cb7420 (patch) | |
| tree | a38c727f70a7cc8cce9490bd3bb8f94387552cf6 /src/libs/qmljs/qmljsmodelmanagerinterface.cpp | |
| parent | 13c7283c0e3f8cb1c199bbc3ddb16bc5f99f5910 (diff) | |
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 <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/libs/qmljs/qmljsmodelmanagerinterface.cpp')
| -rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
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<QByteArray> contents = qmldirFile.fileContents(); + const expected_str<QByteArray> contents = qmldirFile.fileContents(); if (!contents) return false; QString qmldirData = QString::fromUtf8(*contents); @@ -985,7 +985,7 @@ void ModelManagerInterface::parseLoop(QSet<Utils::FilePath> &scannedPaths, contents = entry.first; documentRevision = entry.second; } else { - const std::optional<QByteArray> fileContents = fileName.fileContents(); + const expected_str<QByteArray> fileContents = fileName.fileContents(); if (fileContents) { QTextStream ins(*fileContents); contents = ins.readAll(); |
