From f70e7b6f1c5a20c374d4b1de033e0b07fd9b6665 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 13 Dec 2024 11:38:22 +0100 Subject: [PATCH] split library and model --- src/solver/systemParser/converter.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/solver/systemParser/converter.cpp b/src/solver/systemParser/converter.cpp index 77e17369a0..e044c10689 100644 --- a/src/solver/systemParser/converter.cpp +++ b/src/solver/systemParser/converter.cpp @@ -29,10 +29,25 @@ using namespace Antares::Study; namespace Antares::Solver::SystemConverter { +static std::pair splitLibraryModelString(const std::string& s) +{ + size_t pos = s.find('.'); + if (pos == std::string::npos) + { + throw std::runtime_error("Error while splitting library model: " + s + + "Correct format is lirabry.model"); + } + + std::string library = s.substr(0, pos); + std::string model = s.substr(pos + 1); + return {library, model}; +} + static SystemModel::Component createComponent(const SystemParser::Component& c) { + const auto [libraryId, modelId] = splitLibraryModelString(c.model); SystemModel::ModelBuilder model_builder; - auto model = model_builder.withId(c.model).build(); + auto model = model_builder.withId(modelId).build(); SystemModel::ComponentBuilder component_builder; /* std::map parameters; */