17 #ifndef VCSN_TOOLS_IO_HH
18 # define VCSN_TOOLS_IO_HH
20 # include <vaucanson/automata/concept/handlers.hh>
21 # include <vaucanson/automata/concept/automata_base.hh>
22 # include <vaucanson/automata/concept/transducer_base.hh>
37 template <
typename Auto,
typename TransitionConverter,
typename Format>
38 struct automaton_saver_
40 typedef Auto automaton_t;
41 typedef TransitionConverter transition_converter_t;
42 typedef Format format_t;
44 automaton_saver_(
const Auto&,
45 const TransitionConverter&,
48 automaton_t& automaton();
49 const automaton_t& automaton()
const;
52 const automaton_t& a_;
53 transition_converter_t conv_;
56 template<
typename A,
typename E,
typename F>
58 operator<<(std::ostream&, const automaton_saver_<A, E, F>&);
62 template <
typename Auto,
typename TransitionConverter,
typename Format>
64 operator<<(std::ostream&,
65 const automaton_saver_<Auto, TransitionConverter, Format>&);
69 std::string check_empty_word(
const std::string&)
const;
71 template<
typename S,
typename T>
72 std::string operator()(
const AutomataBase<S>&,
const T&)
const;
74 template<
typename S,
typename T>
75 std::string operator()(
const TransducerBase<S>&,
const T&)
const;
81 template <
typename Auto,
typename TransitionConverter,
typename Format>
82 tools::automaton_saver_<Auto, TransitionConverter, Format>
83 automaton_saver(
const Auto&,
84 const TransitionConverter& e = TransitionConverter(),
85 const Format& f = Format());
95 template <
typename RE,
typename TransitionConverter,
typename Format>
99 typedef TransitionConverter transition_converter_t;
100 typedef Format format_t;
102 regexp_saver_(
const RE&,
103 const TransitionConverter&,
106 rat_exp_t& rat_exp();
107 const rat_exp_t& rat_exp()
const;
111 transition_converter_t conv_;
114 template<
typename A,
typename E,
typename F>
116 operator<<(std::ostream&, const regexp_saver_<A, E, F>&);
120 template <
typename RE,
typename TransitionConverter,
typename Format>
122 operator<<(std::ostream&,
123 const regexp_saver_<RE, TransitionConverter, Format>&);
127 template <
typename RE,
typename TransitionConverter,
typename Format>
128 tools::regexp_saver_<RE, TransitionConverter, Format>
129 regexp_saver(
const RE&,
130 const TransitionConverter& e = TransitionConverter(),
131 const Format& f = Format());
140 template <
typename Auto,
typename TransitionConverter,
typename Format>
141 struct automaton_loader_
143 typedef Auto automaton_t;
144 typedef typename Auto::hstate_t hstate_t;
145 typedef typename Auto::htransition_t htransition_t;
146 typedef TransitionConverter transition_converter_t;
147 typedef Format format_t;
149 automaton_loader_(automaton_t& a,
150 const transition_converter_t& conv,
151 const format_t& format,
154 automaton_t& automaton();
155 const automaton_t& automaton()
const;
157 hstate_t add_state(
unsigned);
158 void set_initial(
unsigned,
const std::string&);
159 void set_final(
unsigned,
const std::string&);
160 void add_transition(
unsigned,
unsigned,
const std::string&);
161 void add_spontaneous(
unsigned,
unsigned);
165 transition_converter_t conv_;
168 std::map<unsigned, hstate_t> smap_;
171 template<
typename A,
typename E,
typename F>
173 operator>>(std::istream&, automaton_loader_<A, E, F>);
176 template <
typename Auto,
typename TransitionConverter,
typename Format>
178 operator>>(std::istream&, automaton_loader_<Auto, TransitionConverter, Format>);
184 template <
typename Auto,
typename TransitionConverter,
typename Format>
185 tools::automaton_loader_<Auto, TransitionConverter, Format>
186 automaton_loader(Auto& a,
187 const TransitionConverter& e = TransitionConverter(),
188 const Format& f = Format(),
189 bool merge_states =
false);
193 template <
typename RE,
typename TransitionConverter,
typename Format>
194 struct regexp_loader_
196 typedef RE rat_exp_t;
197 typedef TransitionConverter transition_converter_t;
198 typedef Format format_t;
200 regexp_loader_(rat_exp_t& r,
201 const transition_converter_t& conv,
202 const format_t& format);
204 rat_exp_t& rat_exp();
205 const rat_exp_t& rat_exp()
const;
209 transition_converter_t conv_;
212 template <
typename R,
typename T,
typename F>
214 operator>>(std::istream&, regexp_loader_<R, T, F>);
217 template <
typename RE,
typename TransitionConverter,
typename Format>
219 operator>>(std::istream&, regexp_loader_<RE, TransitionConverter, Format>);
222 template <
typename RE,
typename TransitionConverter,
typename Format>
223 tools::regexp_loader_<RE, TransitionConverter, Format>
225 const TransitionConverter& e = TransitionConverter(),
226 const Format& f = Format());
230 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
231 # include <vaucanson/tools/io.hxx>
232 #endif // VCSN_USE_INTERFACE_ONLY
235 #endif // ! VCSN_TOOLS_IO_HH