17 #ifndef VCSN_TOOLS_DUMPER_HXX
18 # define VCSN_TOOLS_DUMPER_HXX
20 # include <vaucanson/tools/usual_io.hh>
22 # include <vaucanson/tools/dot_dump.hh>
24 # include <vaucanson/tools/simple_dump.hh>
35 string_to_int (
const std::string& s)
39 const char *ccp = s.c_str ();
41 long res = std::strtol (ccp, &cp, 10);
42 if (*cp || INT_MAX < res || errno)
44 std::cerr <<
"integer out of bounds: " << s;
46 std::cerr <<
" (" << std::strerror (errno) <<
")";
47 std::cerr << std::endl;
53 dumper::dumper (
int argc,
char **argv,
int pos)
54 : fmt_ (fmt_xml), argc_ (argc), argv_ (argv)
57 fmt_ = dump_format (argv_[pos]);
59 if (fmt_ == fmt_error)
61 std::cerr <<
"Invalid input: " << pos <<
" " << argv_[pos] << std::endl;
67 dumper::usage (
int estatus)
69 std::cerr <<
"Usage: " << argv_[0] <<
" ... <fmt>" << std::endl
70 <<
"where fmt is one of:" << std::endl
71 <<
" dot graphviz format" << std::endl
72 <<
" fsm FSM toolbox format" << std::endl
73 <<
" simple internal Vaucanson format" << std::endl
74 <<
" xml Vaucanson XML I/O format" << std::endl;
78 enum dumper::dump_format
79 dumper::dump_format (std::string fmt)
83 else if (fmt ==
"simple")
85 else if (fmt ==
"xml")
87 else if (fmt ==
"fsm")
95 dumper::get_fmt()
const
99 case fmt_dot:
return "dot";
100 case fmt_xml:
return "xml";
101 case fmt_simple:
return "simple";
102 case fmt_fsm:
return "fsm";
103 case fmt_error: abort ();
109 dumper::operator() (std::ostream& o,
110 const automaton_t& automaton,
111 const std::string& name)
116 vcsn::tools::dot_dump (o, automaton, name);
119 vcsn::tools::xml_dump (o, automaton, name);
122 vcsn::tools::simple_dump (o, automaton,
123 vcsn::tools::usual_converter_poly<rat_exp_t>());
126 vcsn::tools::fsm_dump (o, automaton);
137 #endif // !VCSN_TOOLS_DUMPER_HXX