Vaucanson 1.4
|
00001 // usual_io.hxx: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // 00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005 The Vaucanson Group. 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 // 00012 // The complete GNU General Public Licence Notice can be found as the 00013 // `COPYING' file in the root directory. 00014 // 00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 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