Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ModelExportFormat.cpp
Go to the documentation of this file.
2
3#include <filesystem>
4
8
9namespace storm {
10namespace io {
11
13 if (input == "dot") {
15 } else if (input == "drdd") {
17 } else if (input == "drn") {
19 } else if (input == "json") {
21 } else if (input == "umb") {
23 }
24 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The model export format '" << input << "' does not match any known format.");
25}
26
27std::string toString(ModelExportFormat const& input) {
28 switch (input) {
30 return "dot";
32 return "drdd";
34 return "drn";
36 return "json";
38 return "umb";
39 }
40 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Unhandled model export format.");
41}
42
44 std::filesystem::path path(filename);
45 // correctly get the relevant extension (e.g. '.drn' in model.drn and model.drn.gz)
46 auto compression = getCompressionModeFromFileExtension(path);
47 std::string extension = compression == CompressionMode::None ? path.extension() : path.stem().extension();
48 try {
49 return getModelExportFormatFromString(extension.substr(1));
50 } catch (storm::exceptions::InvalidArgumentException&) {
52 false, storm::exceptions::InvalidArgumentException,
53 "The file '" << filename
54 << "' does not have an extension to determine the model export format from. Add a file extension or specify the format explicitly.");
55 }
56}
57
58} // namespace io
59} // namespace storm
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::string toString(CompressionMode const &input)
CompressionMode getCompressionModeFromFileExtension(std::filesystem::path const &filename)
ModelExportFormat getModelExportFormatFromString(std::string const &input)
ModelExportFormat getModelExportFormatFromFileExtension(std::string const &filename)