mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
Refactor RifFormationNamesReader to return std::expected
Replace the QString* errorMessage out-parameter with std::expected<RigFormationNames, QString> in RifFormationNamesReader, and propagate the pattern to RimFormationNames::readFormationNamesFile() which now returns std::expected<void, QString>. Fatal errors (file cannot be opened, FMU line-parse failure) return std::unexpected. Malformed .lyr lines are still skipped so the rest of the file loads, with warnings logged via RiaLogging instead of collected in the out-parameter. RimFormationNamesCollection::readAllFormationNames() now logs errors it previously discarded.
This commit is contained in:
1 parent
db36c761dd
commit
d87a0d3048
9 files changed
+66
-75
No files matched your search
@@ -20,10 +20,11 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <memory>
|
||||
#include "RigFormationNames.h"
|
||||
|
||||
class RigFormationNames;
|
||||
class QString;
|
||||
#include <expected>
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@@ -36,11 +37,11 @@ class Color3f;
|
||||
class RifFormationNamesReader
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] static std::unique_ptr<RigFormationNames> readFormationNamesFile( const QString& fileName, QString* errorMessage );
|
||||
[[nodiscard]] static std::expected<RigFormationNames, QString> readFormationNamesFile( const QString& fileName );
|
||||
|
||||
private:
|
||||
static std::unique_ptr<RigFormationNames> readLyrFormationNameFile( const QString& fileName, QString* errorMessage );
|
||||
static std::unique_ptr<RigFormationNames> readFmuFormationNameFile( const QString& fileName, QString* errorMessage );
|
||||
static std::expected<RigFormationNames, QString> readLyrFormationNameFile( const QString& fileName );
|
||||
static std::expected<RigFormationNames, QString> readFmuFormationNameFile( const QString& fileName );
|
||||
|
||||
static bool convertStringToColor( const QString& word, cvf::Color3f* color );
|
||||
};
|
||||
Reference in new issue
Block a user