Vaucanson  1.4.1
usual_io.hxx
1 // usual_io.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_TOOLS_USUAL_IO_HXX
18 # define VCSN_TOOLS_USUAL_IO_HXX
19 
20 # include <vaucanson/tools/usual_io.hh>
23 # include <sstream>
24 
25 namespace vcsn
26 {
27  namespace tools
28  {
29  template<typename ExpType>
30  template<typename Auto>
31  std::string
32  usual_converter_poly<ExpType>::
33  operator()(const Auto& a,
34  const typename Auto::series_set_elt_t& p) const
35  {
36  ExpType e = ExpType(a.structure().series());
38  std::ostringstream os;
39  os << e;
40  return os.str();
41  }
42 
43  template<typename ExpType>
44  template<typename Auto>
45  typename Auto::series_set_elt_t
46  usual_converter_poly<ExpType>::operator()(const Auto& a,
47  const std::string& str) const
48  {
49  ExpType e = ExpType(a.structure().series());
50  algebra::parse(str, e);
51  typename Auto::series_set_elt_t s =
52  typename Auto::series_set_elt_t(a.structure().series());
54  return s;
55  }
56 
57  template<typename Auto>
58  std::string
59  usual_converter_exp::operator()(const Auto& a,
60  const typename Auto::series_set_elt_t& e) const
61  {
62  std::ostringstream os;
63  os << e;
64  return os.str();
65  }
66 
67  template<typename Auto>
68  typename Auto::series_set_elt_t
69  usual_converter_exp::operator()(const Auto& a, const std::string& s) const
70  {
71  typedef typename Auto::series_set_elt_t exp_t;
72  exp_t ret = exp_t(a.structure().series());
73  algebra::parse(s, ret);
74  return ret;
75  }
76 
77  }
78 
79 }
80 
81 #endif // ! VCSN_TOOLS_USUAL_IO_HXX