From b571d176c0e6bc6308df39eaf6151ce517d4f8f1 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Tue, 7 Feb 2017 13:59:13 +0100 Subject: [PATCH] Parse toplevel element from json --- src/storm-dft/parser/DFTJsonParser.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/storm-dft/parser/DFTJsonParser.cpp b/src/storm-dft/parser/DFTJsonParser.cpp index 9a5c5d047..2d0ddfe39 100644 --- a/src/storm-dft/parser/DFTJsonParser.cpp +++ b/src/storm-dft/parser/DFTJsonParser.cpp @@ -66,6 +66,8 @@ namespace storm { parsedJson << file; file.close(); + std::string toplevelName = ""; + // Start by building mapping from ids to names std::map nameMapping; for (auto& element: parsedJson) { @@ -74,11 +76,13 @@ namespace storm { std::string id = data.at("id"); std::string name = data.at("name"); nameMapping[id] = name; + if (data.count("toplevel") > 0) { + STORM_LOG_ASSERT(toplevelName.empty(), "Toplevel element already defined."); + toplevelName = name; + } } } - - // TODO: avoid hack - std::string toplevelId = nameMapping["1"]; + std::cout << toplevelName << std::endl; for (auto& element : parsedJson) { bool success = true; @@ -130,7 +134,7 @@ namespace storm { STORM_LOG_THROW(success, storm::exceptions::FileIoException, "Error while adding element '" << element << "'."); } - if(!builder.setTopLevel(toplevelId)) { + if(!builder.setTopLevel(toplevelName)) { STORM_LOG_THROW(false, storm::exceptions::FileIoException, "Top level id unknown."); } }