Storm 1.11.1.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 }
22 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The model export format '" << input << "' does not match any known format.");
23}
24
25std::string toString(ModelExportFormat const& input) {
26 switch (input) {
28 return "dot";
30 return "drdd";
32 return "drn";
34 return "json";
35 }
36 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Unhandled model export format.");
37}
38
40 std::filesystem::path path(filename);
41 // correctly get the relevant extension (e.g. '.drn' in model.drn and model.drn.gz)
42 auto compression = getCompressionModeFromFileExtension(path);
43 std::string extension = compression == CompressionMode::None ? path.extension() : path.stem().extension();
44 try {
45 return getModelExportFormatFromString(extension.substr(1));
46 } catch (storm::exceptions::InvalidArgumentException&) {
48 false, storm::exceptions::InvalidArgumentException,
49 "The file '" << filename
50 << "' does not have an extension to determine the model export format from. Add a file extension or specify the format explicitly.");
51 }
52}
53
54} // namespace io
55} // 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)