Browse Source

Parse toplevel element from json

tempestpy_adaptions
Matthias Volk 8 years ago
parent
commit
b571d176c0
  1. 12
      src/storm-dft/parser/DFTJsonParser.cpp

12
src/storm-dft/parser/DFTJsonParser.cpp

@ -66,6 +66,8 @@ namespace storm {
parsedJson << file; parsedJson << file;
file.close(); file.close();
std::string toplevelName = "";
// Start by building mapping from ids to names // Start by building mapping from ids to names
std::map<std::string, std::string> nameMapping; std::map<std::string, std::string> nameMapping;
for (auto& element: parsedJson) { for (auto& element: parsedJson) {
@ -74,11 +76,13 @@ namespace storm {
std::string id = data.at("id"); std::string id = data.at("id");
std::string name = data.at("name"); std::string name = data.at("name");
nameMapping[id] = 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) { for (auto& element : parsedJson) {
bool success = true; bool success = true;
@ -130,7 +134,7 @@ namespace storm {
STORM_LOG_THROW(success, storm::exceptions::FileIoException, "Error while adding element '" << element << "'."); 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."); STORM_LOG_THROW(false, storm::exceptions::FileIoException, "Top level id unknown.");
} }
} }

Loading…
Cancel
Save