17 #ifndef VCSN_TOOLS_SIMPLE_FORMAT_HXX
18 # define VCSN_TOOLS_SIMPLE_FORMAT_HXX
20 # include <vaucanson/tools/simple_format.hh>
27 template<
typename Saver,
typename Conv>
28 void simple::operator()(std::ostream& o,
const Saver& s,
const Conv& conv)
const
30 typedef typename Saver::automaton_t auto_t;
31 const auto_t& a = s.automaton();
34 o <<
"# States list" << std::endl;
35 for (
typename auto_t::state_iterator i = a.states().begin();
36 i != a.states().end();
39 o <<
's' << *i <<
' ';
41 o <<
"i[" << conv(a, a.get_initial(*i)) <<
"] ";
43 o <<
"f[" << conv(a, a.get_final(*i)) <<
"]";
48 o <<
"# Transitions list" << std::endl;
49 for (
typename auto_t::transition_iterator i = a.transitions().begin();
50 i != a.transitions().end();
53 o <<
's' << a.src_of(*i) <<
' '
54 <<
's' << a.dst_of(*i) <<
' ';
55 if (a.is_spontaneous(*i))
58 o <<
"l[" << conv(a, a.series_of(*i)) <<
"]" << std::endl;
60 o <<
'.' << std::endl;
63 void get_delimited_exp(std::istream& in, std::string& s)
65 std::string::size_type i = 1;
70 std::getline(in, s,
']');
71 for (i = 0; i < s.size() && s[s.size() - i - 1] ==
'\\' ; ++i)
80 std::getline(in, tmp,
']');
82 for (i = 0; i < tmp.size() && tmp[tmp.size() - i - 1] ==
'\\' ; ++i)
87 template<
typename Loader>
88 void simple::operator()(std::istream& in, Loader& l)
const
105 get_delimited_exp(in, str);
106 l.set_initial(to, str);
109 get_delimited_exp(in, str);
110 l.set_final(to, str);
113 get_delimited_exp(in, str);
114 l.add_transition(from, to, str);
117 l.add_spontaneous(from, to);
123 std::getline(in, str);
133 #endif // ! VCSN_TOOLS_SIMPLE_FORMAT_HXX