18 #ifndef VCSN_TOOLS_IO_HXX
19 # define VCSN_TOOLS_IO_HXX
21 # include <vaucanson/tools/io.hh>
34 template<
typename Auto,
typename TransitionConverter,
typename Format>
35 Auto& automaton_saver_<Auto, TransitionConverter, Format>::automaton()
40 template<
typename Auto,
typename TransitionConverter,
typename Format>
41 const Auto& automaton_saver_<Auto, TransitionConverter, Format>::
47 template<
typename Auto,
typename TransitionConverter,
typename Format>
48 automaton_saver_<Auto, TransitionConverter, Format>::
49 automaton_saver_(
const Auto& a,
50 const TransitionConverter& c,
52 : a_(a), conv_(c), format_(f)
55 template<
typename Auto,
typename TransitionConverter,
typename Format>
57 operator<<(std::ostream& o,
58 const automaton_saver_<Auto, TransitionConverter, Format>& s)
60 BENCH_TASK_SCOPED(
"automaton output");
61 s.format_(o, s, s.conv_);
65 template<
typename S,
typename T>
66 std::string string_out::operator()(
const AutomataBase<S>&,
const T& t)
const
68 std::ostringstream os;
73 template<
typename S,
typename T>
74 std::string string_out::operator()(
const TransducerBase<S>&,
const T& t)
const
76 std::ostringstream os;
83 template<
typename Auto,
typename TransitionConverter,
typename Format>
84 tools::automaton_saver_<Auto, TransitionConverter, Format>
85 automaton_saver(
const Auto& a,
86 const TransitionConverter& e,
89 return tools::automaton_saver_<Auto, TransitionConverter, Format>(a, e, f);
98 template<
typename RE,
typename TransitionConverter,
typename Format>
99 RE& regexp_saver_<RE, TransitionConverter, Format>::rat_exp()
104 template<
typename RE,
typename TransitionConverter,
typename Format>
105 const RE& regexp_saver_<RE, TransitionConverter, Format>::
111 template<
typename RE,
typename TransitionConverter,
typename Format>
112 regexp_saver_<RE, TransitionConverter, Format>::
113 regexp_saver_(
const RE& r,
114 const TransitionConverter& c,
116 : r_(r), conv_(c), format_(f)
119 template<
typename RE,
typename TransitionConverter,
typename Format>
121 operator<<(std::ostream& o,
122 const regexp_saver_<RE, TransitionConverter, Format>& s)
124 BENCH_TASK_SCOPED(
"regexp output");
125 s.format_(o, s, s.conv_);
131 template<
typename RE,
typename TransitionConverter,
typename Format>
132 tools::regexp_saver_<RE, TransitionConverter, Format>
133 regexp_saver(
const RE& r,
134 const TransitionConverter& e,
137 return tools::regexp_saver_<RE, TransitionConverter, Format>(r, e, f);
147 template<
typename Auto,
typename TransitionConverter,
typename Format>
148 Auto& automaton_loader_<Auto, TransitionConverter, Format>::automaton()
153 template<
typename Auto,
typename TransitionConverter,
typename Format>
155 automaton_loader_<Auto, TransitionConverter, Format>::automaton()
const
160 template<
typename Auto,
typename TransitionConverter,
typename Format>
161 automaton_loader_<Auto, TransitionConverter, Format>::
162 automaton_loader_(Auto& a,
163 const TransitionConverter& conv,
164 const Format& format,
171 merge_states_(merge_states)
174 template<
typename Auto,
typename TransitionConverter,
typename Format>
175 typename Auto::hstate_t
176 automaton_loader_<Auto, TransitionConverter, Format>::
177 add_state(
unsigned s)
179 if (smap_.find(s) == smap_.end())
181 if (a_.has_state(s) && merge_states_)
182 smap_[s] = hstate_t(s);
184 smap_[s] = a_.add_state();
189 template<
typename Auto,
typename TransitionConverter,
typename Format>
190 void automaton_loader_<Auto, TransitionConverter, Format>::
191 set_initial(
unsigned s,
const std::string& lbl)
193 a_.set_initial(add_state(s), conv_(a_, lbl));
196 template<
typename Auto,
typename TransitionConverter,
typename Format>
197 void automaton_loader_<Auto, TransitionConverter, Format>::
198 set_final(
unsigned s,
const std::string& lbl)
200 a_.set_final(add_state(s), conv_(a_, lbl));
203 template<
typename Auto,
typename TransitionConverter,
typename Format>
204 void automaton_loader_<Auto, TransitionConverter, Format>::
205 add_spontaneous(
unsigned from,
unsigned to)
207 a_.add_spontaneous(add_state(from), add_state(to));
210 template<
typename Auto,
typename TransitionConverter,
typename Format>
211 void automaton_loader_<Auto, TransitionConverter, Format>::
212 add_transition(
unsigned from,
unsigned to,
const std::string& lbl)
214 a_.add_series_transition(add_state(from), add_state(to), conv_(a_, lbl));
217 template<
typename Auto,
typename TransitionConverter,
typename Format>
220 automaton_loader_<Auto, TransitionConverter, Format> l)
222 BENCH_TASK_SCOPED(
"automaton input");
229 template<
typename Auto,
typename TransitionConverter,
typename Format>
230 tools::automaton_loader_<Auto, TransitionConverter, Format>
231 automaton_loader(Auto& a,
232 const TransitionConverter& e,
236 return tools::automaton_loader_<Auto, TransitionConverter, Format>
237 (a, e, f, merge_states);
247 template<
typename RE,
typename TransitionConverter,
typename Format>
248 RE& regexp_loader_<RE, TransitionConverter, Format>::rat_exp()
253 template<
typename RE,
typename TransitionConverter,
typename Format>
255 regexp_loader_<RE, TransitionConverter, Format>::rat_exp()
const
260 template<
typename RE,
typename TransitionConverter,
typename Format>
261 regexp_loader_<RE, TransitionConverter, Format>::
262 regexp_loader_(RE& r,
263 const TransitionConverter& conv,
264 const Format& format)
270 template<
typename RE,
typename TransitionConverter,
typename Format>
273 regexp_loader_<RE, TransitionConverter, Format> l)
275 BENCH_TASK_SCOPED(
"regexp input");
282 template<
typename RE,
typename TransitionConverter,
typename Format>
283 tools::regexp_loader_<RE, TransitionConverter, Format>
285 const TransitionConverter& e,
288 return tools::regexp_loader_<RE, TransitionConverter, Format>
295 #endif // ! VCSN_TOOLS_IO_HXX