Skip to content

Commit

Permalink
header separation
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jun 20, 2024
1 parent 7dbb39c commit 2aaeaa2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
29 changes: 18 additions & 11 deletions src/libs/antares/study/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,33 @@ bool StudyHeader::internalLoadFromINIFile(const IniFile& ini, bool warnings)
}
}

if (warnings)
{
logs.error() << "Study header: Invalid format";
}
return false;
}

bool StudyHeader::validateVersion()
{
if (version >= StudyVersion(7, 0))
{
if (version > Data::StudyVersion::latest())
{
if (warnings)
{
logs.error() << "Header: This version is not supported (version found:"
<< version.toString()
<< ", expected: <=" << Data::StudyVersion::latest().toString() << ')';
}
logs.error() << "Header: This version is not supported (version found:"
<< version.toString()
<< ", expected: <=" << Data::StudyVersion::latest().toString() << ')';

return false;
}
return true;
}

if (warnings)
else
{
logs.error() << "Study header: Invalid format";
logs.error() << "Version before 7.0 not supported, please upgrade";
return false;
}
return false;

return true;
}

bool StudyHeader::loadFromFile(const AnyString& filename, bool warnings)
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/include/antares/study/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class StudyHeader final
*/
static bool readVersionFromFile(const std::filesystem::path& filename, std::string& version);

public:
//! \name Constructor & Destructor
//@{
/*!
Expand Down Expand Up @@ -109,7 +108,8 @@ class StudyHeader final
*/
static StudyVersion tryToFindTheVersion(const std::string& folder);

public:
bool validateVersion();

//! Caption of the study
Yuni::String caption;

Expand Down
6 changes: 6 additions & 0 deletions src/libs/antares/study/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ bool Study::internalLoadHeader(const String& path)
return false;
}

if (!header.validateVersion())
{
logs.error() << path << ": error with the version, aborting";
return false;
}

// Informations about the study
logs.info();
logs.notice() << "Preparing " << header.caption << "...";
Expand Down

0 comments on commit 2aaeaa2

Please sign in to comment.