13#include "mcrl2/lts/lts_algorithm.h"
14#include "mcrl2/lts/lts_io.h"
16using namespace mcrl2::
core;
18using namespace mcrl2::log;
28 std::string::size_type pos = s.find_last_of(
'.');
30 if (pos != std::string::npos)
32 std::string ext = s.substr(pos+1);
38 mCRL2log(log_level_t::verbose) <<
"Detected .aut extension.\n";
40 return lts_type::lts_aut;
42 else if (ext ==
"lts")
46 mCRL2log(log_level_t::verbose) <<
"Detected .lts extension.\n";
48 return lts_type::lts_lts;
50 else if (ext ==
"fsm")
54 mCRL2log(log_level_t::verbose) <<
"Detected .fsm extension.\n";
56 return lts_type::lts_fsm;
58 else if (ext ==
"dot")
62 mCRL2log(log_level_t::verbose) <<
"Detected .dot extension.\n";
64 return lts_type::lts_dot;
68 return lts_type::lts_none;
78 "Aldebaran format (CADP)",
79 "Finite State Machine format",
80 "GraphViz format (no longer supported as input format)"
95 return lts_type::lts_lts;
99 return lts_type::lts_aut;
103 return lts_type::lts_fsm;
107 return lts_type::lts_dot;
109 return lts_type::lts_none;
114 return (type_strings.at(
static_cast<std::size_t>(type)));
119 return (extension_strings.at(
static_cast<std::size_t>(type)));
124 return (mime_type_strings.at(
static_cast<std::size_t>(type)));
129 static std::set<lts_type> s;
130 for (std::size_t i =
static_cast<std::size_t>(lts_type::lts_type_min); i<1+
static_cast<std::size_t>(lts_type::lts_type_max); ++i)
132 if (lts_type::lts_none != (lts_type) i)
134 s.insert((lts_type) i);
141 static const std::set<lts_type>& s = initialise_supported_lts_formats();
146template<std::size_t Size,
typename T>
149 return N[
static_cast<std::size_t>(a)] < N[
static_cast<std::size_t>(b)];
154 std::vector<lts_type> types(supported.begin(), supported.end());
155 std::sort(types.begin(),
157 [](
const lts_type& t1,
const lts_type& t2){
return lts_named_cmp(type_strings, t1, t2); });
160 for (std::vector<lts_type>::iterator i=types.begin(); i!=types.end(); ++i)
162 r +=
" '" + type_strings.at(
static_cast<std::size_t>(*i)) +
"' for the " + type_desc_strings.at(
static_cast<std::size_t>(*i));
164 if (*i == default_format)
171 const std::size_t remaining =
static_cast<std::size_t>(std::distance(i, types.end()));
176 else if (remaining > 2)
187 return supported_lts_formats_text(lts_type::lts_none,supported);
192 std::vector<lts_type> types(supported.begin(), supported.end());
193 std::sort(types.begin(),
195 [](
const lts_type& t1,
const lts_type& t2){
return lts_named_cmp(extension_strings, t1, t2); });
200 for (
auto & type : types)
202 if (extension_strings[
static_cast<std::size_t>(type)] == prev)
214 r +=
"*." + extension_strings[
static_cast<std::size_t>(type)];
215 prev = extension_strings[
static_cast<std::size_t>(type)];
223 return lts_extensions_as_string(
",",supported);
function object to compare two constln_t pointers based on their contents
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
lts_type guess_format(std::string const &s, const bool be_verbose)
Determines the LTS format from a filename by its extension.
static const std::array< std::string, 5 > extension_strings
std::string supported_lts_formats_text(const std::set< lts_type > &supported)
Gives a textual list describing supported LTS formats.
std::string string_for_type(const lts_type type)
Gives a string representation of an LTS format.
std::string mime_type_for_type(const lts_type type)
Gives the MIME type associated with an LTS format.
lts_type parse_format(std::string const &s)
Determines the LTS format from a format specification string.
static const std::array< std::string, 5 > type_strings
std::string extension_for_type(const lts_type type)
Gives the filename extension associated with an LTS format.
const std::set< lts_type > & supported_lts_formats()
Gives the set of all supported LTS formats.
std::string lts_extensions_as_string(const std::set< lts_type > &supported)
Gives a list of extensions for supported LTS formats.
std::string lts_extensions_as_string(const std::string &sep, const std::set< lts_type > &supported)
Gives a list of extensions for supported LTS formats.
bool lts_named_cmp(const std::array< std::string, Size > &N, T a, T b)
std::string supported_lts_formats_text(lts_type default_format, const std::set< lts_type > &supported)
Gives a textual list describing supported LTS formats.
static const std::array< std::string, 5 > type_desc_strings
static const std::array< std::string, 5 > mime_type_strings
static const std::set< lts_type > & initialise_supported_lts_formats()