Storm
1.11.1.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
}
22
STORM_LOG_THROW
(
false
, storm::exceptions::InvalidArgumentException,
"The model export format '"
<< input <<
"' does not match any known format."
);
23
}
24
25
std::string
toString
(
ModelExportFormat
const
& input) {
26
switch
(input) {
27
case
ModelExportFormat::Dot
:
28
return
"dot"
;
29
case
ModelExportFormat::Drdd
:
30
return
"drdd"
;
31
case
ModelExportFormat::Drn
:
32
return
"drn"
;
33
case
ModelExportFormat::Json
:
34
return
"json"
;
35
}
36
STORM_LOG_THROW
(
false
, storm::exceptions::InvalidArgumentException,
"Unhandled model export format."
);
37
}
38
39
ModelExportFormat
getModelExportFormatFromFileExtension
(std::string
const
& filename) {
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&) {
47
STORM_LOG_THROW
(
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
CompressionMode.h
InvalidArgumentException.h
ModelExportFormat.h
macros.h
STORM_LOG_THROW
#define STORM_LOG_THROW(cond, exception, message)
Definition
macros.h:30
storm::io::ModelExportFormat
ModelExportFormat
Definition
ModelExportFormat.h:8
storm::io::ModelExportFormat::Drdd
@ Drdd
storm::io::ModelExportFormat::Drn
@ Drn
storm::io::ModelExportFormat::Dot
@ Dot
storm::io::ModelExportFormat::Json
@ Json
storm::io::toString
std::string toString(CompressionMode const &input)
Definition
CompressionMode.cpp:23
storm::io::CompressionMode::None
@ None
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:39
storm
Definition
AutomaticSettings.cpp:13
src
storm
io
ModelExportFormat.cpp
Generated by
1.9.8