00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_TOOLS_USUAL_IO_HXX
00018 # define VCSN_TOOLS_USUAL_IO_HXX
00019 
00020 # include <vaucanson/tools/usual_io.hh>
00021 # include <vaucanson/algebra/implementation/series/krat_exp_parser.hh>
00022 # include <vaucanson/algorithms/finite_support_conversion.hh>
00023 # include <sstream>
00024 
00025 namespace vcsn
00026 {
00027   namespace tools
00028   {
00029     template<typename ExpType>
00030     template<typename Auto>
00031     std::string
00032     usual_converter_poly<ExpType>::
00033     operator()(const Auto& a,
00034                const typename Auto::series_set_elt_t& p) const
00035     {
00036       ExpType e = ExpType(a.structure().series());
00037       finite_support_convert(e, p);
00038       std::ostringstream os;
00039       os << e;
00040       return os.str();
00041     }
00042 
00043     template<typename ExpType>
00044     template<typename Auto>
00045     typename Auto::series_set_elt_t
00046     usual_converter_poly<ExpType>::operator()(const Auto& a,
00047                                               const std::string& str) const
00048     {
00049       ExpType e = ExpType(a.structure().series());
00050       algebra::parse(str, e);
00051       typename Auto::series_set_elt_t s =
00052         typename Auto::series_set_elt_t(a.structure().series());
00053       finite_support_convert(s, e);
00054       return s;
00055     }
00056 
00057     template<typename Auto>
00058     std::string
00059     usual_converter_exp::operator()(const Auto& a,
00060                                     const typename Auto::series_set_elt_t& e) const
00061     {
00062       std::ostringstream os;
00063       os << e;
00064       return os.str();
00065     }
00066 
00067     template<typename Auto>
00068     typename Auto::series_set_elt_t
00069     usual_converter_exp::operator()(const Auto& a, const std::string& s) const
00070     {
00071       typedef typename Auto::series_set_elt_t exp_t;
00072       exp_t ret = exp_t(a.structure().series());
00073       algebra::parse(s, ret);
00074       return ret;
00075     }
00076 
00077   }
00078 
00079 }
00080 
00081 #endif // ! VCSN_TOOLS_USUAL_IO_HXX