Storm
1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ModelExportFormat.cpp
Go to the documentation of this file.
1
#include "
storm/io/ModelExportFormat.h
"
2
3
#include <filesystem>
4
5
#include "
storm/exceptions/InvalidArgumentException.h
"
6
#include "
storm/io/CompressionMode.h
"
7
#include "
storm/utility/macros.h
"
8
9
namespace
storm
{
10
namespace
io
{
11
12
ModelExportFormat
getModelExportFormatFromString
(std::string
const
& input) {
13
if
(input ==
"dot"
) {
14
return
ModelExportFormat::Dot
;
15
}
else
if
(input ==
"drdd"
) {
16
return
ModelExportFormat::Drdd
;
17
}
else
if
(input ==
"drn"
) {
18
return
ModelExportFormat::Drn
;
19
}
else
if
(input ==
"json"
) {
20
return
ModelExportFormat::Json
;
21
}
else
if
(input ==
"umb"
) {
22
return
ModelExportFormat::Umb
;
23
}
24
STORM_LOG_THROW
(
false
, storm::exceptions::InvalidArgumentException,
"The model export format '"
<< input <<
"' does not match any known format."
);
25
}
26
27
std::string
toString
(
ModelExportFormat
const
& input) {
28
switch
(input) {
29
case
ModelExportFormat::Dot
:
30
return
"dot"
;
31
case
ModelExportFormat::Drdd
:
32
return
"drdd"
;
33
case
ModelExportFormat::Drn
:
34
return
"drn"
;
35
case
ModelExportFormat::Json
:
36
return
"json"
;
37
case
ModelExportFormat::Umb
:
38
return
"umb"
;
39
}
40
STORM_LOG_THROW
(
false
, storm::exceptions::InvalidArgumentException,
"Unhandled model export format."
);
41
}
42
43
ModelExportFormat
getModelExportFormatFromFileExtension
(std::string
const
& filename) {
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&) {
51
STORM_LOG_THROW
(
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
CompressionMode.h
InvalidArgumentException.h
ModelExportFormat.h
macros.h
STORM_LOG_THROW
#define STORM_LOG_THROW(cond, exception, message)
Definition
macros.h:30
storm::io
Definition
ArchiveReader.cpp:14
storm::io::ModelExportFormat
ModelExportFormat
Definition
ModelExportFormat.h:8
storm::io::ModelExportFormat::Drdd
@ Drdd
Definition
ModelExportFormat.h:8
storm::io::ModelExportFormat::Umb
@ Umb
Definition
ModelExportFormat.h:8
storm::io::ModelExportFormat::Drn
@ Drn
Definition
ModelExportFormat.h:8
storm::io::ModelExportFormat::Dot
@ Dot
Definition
ModelExportFormat.h:8
storm::io::ModelExportFormat::Json
@ Json
Definition
ModelExportFormat.h:8
storm::io::toString
std::string toString(CompressionMode const &input)
Definition
CompressionMode.cpp:23
storm::io::CompressionMode::None
@ None
Definition
CompressionMode.h:8
storm::io::getCompressionModeFromFileExtension
CompressionMode getCompressionModeFromFileExtension(std::filesystem::path const &filename)
Definition
CompressionMode.cpp:39
storm::io::getModelExportFormatFromString
ModelExportFormat getModelExportFormatFromString(std::string const &input)
Definition
ModelExportFormat.cpp:12
storm::io::getModelExportFormatFromFileExtension
ModelExportFormat getModelExportFormatFromFileExtension(std::string const &filename)
Definition
ModelExportFormat.cpp:43
storm
Definition
AutomaticSettings.cpp:13
src
storm
io
ModelExportFormat.cpp
Generated by
1.15.0