Vaucanson 1.4
|
00001 // str_words.hh: 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, 2006, 2007, 2008, 2010 The Vaucanson 00006 // Group. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation; either version 2 00011 // of the License, or (at your option) any later version. 00012 // 00013 // The complete GNU General Public Licence Notice can be found as the 00014 // `COPYING' file in the root directory. 00015 // 00016 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 00017 // 00018 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_MONOID_STR_WORDS_HH 00019 # define VCSN_ALGEBRA_IMPLEMENTATION_MONOID_STR_WORDS_HH 00020 00021 // We will use std::basic_string as a `word' implementation. 00022 # include <string> 00023 00024 # include <vaucanson/algebra/implementation/monoid/free_monoid.hh> 00025 # include <vaucanson/algebra/implementation/alphabets/alphabet_set.hh> 00026 00027 namespace vcsn { 00028 00029 namespace algebra { 00030 00031 /*-----------------------------------------------. 00032 | Implementation of words with std::basic_string | 00033 `-----------------------------------------------*/ 00034 00035 template <typename A> 00036 std::pair<bool, int> 00037 op_parse(const FreeMonoid<A>& s, 00038 std::basic_string<typename A::letter_t>& v, 00039 const std::string& in); 00040 00041 template <typename A> 00042 void 00043 op_in_mul(const algebra::FreeMonoid<A>& s, 00044 std::basic_string<typename A::letter_t>& dst, 00045 const std::basic_string<typename A::letter_t>& src); 00046 00047 template<typename A> 00048 std::basic_string<typename A::letter_t> 00049 op_mul(const algebra::FreeMonoid<A>& s, 00050 const std::basic_string<typename A::letter_t>& a, 00051 const std::basic_string<typename A::letter_t>& b); 00052 00053 template<typename A, typename St, typename U, typename V> 00054 St& 00055 op_rout(const FreeMonoid<A>& s, 00056 St& st, 00057 const std::basic_string<typename A::letter_t, U, V>& v); 00058 00059 template<typename A> 00060 const std::basic_string<typename A::letter_t>& 00061 identity_value(SELECTOR(algebra::FreeMonoid<A>), 00062 SELECTOR(std::basic_string<typename A::letter_t>)); 00063 00064 // one can create words from a single character 00065 template<typename A> 00066 std::basic_string<typename A::letter_t> 00067 op_convert(SELECTOR(algebra::FreeMonoid<A>), 00068 SELECTOR(std::basic_string<typename A::letter_t>), 00069 const typename A::letter_t& c); 00070 00071 template<typename A, typename B, typename C, typename D> 00072 bool 00073 op_is_atom(const algebra::FreeMonoid<A>&, 00074 const std::basic_string<B, C, D>& v); 00075 00076 /*---------------------------------------------------------------------. 00077 | word_traits<FreeMonoid<A>, std::basic_string<typename A::letter_t> > | 00078 `---------------------------------------------------------------------*/ 00079 00084 template <typename A> 00085 struct word_traits<FreeMonoid<A>, 00086 std::basic_string<typename A::letter_t> > 00087 { 00089 typedef A alphabet_t; 00090 00092 typedef Element<FreeMonoid<A>, 00093 std::basic_string<typename alphabet_t::letter_t> > word_t; 00094 00096 typedef typename word_t::value_t word_value_t; 00097 00099 typedef typename alphabet_traits<typename alphabet_t::set_t, 00100 typename alphabet_t::value_t>:: 00101 first_projection_t first_projection_alphabet_t; 00102 00104 typedef typename alphabet_traits<typename alphabet_t::set_t, 00105 typename alphabet_t::value_t>:: 00106 second_projection_t second_projection_alphabet_t; 00107 00109 typedef FreeMonoid<first_projection_alphabet_t> first_monoid_t; 00110 00112 typedef FreeMonoid<second_projection_alphabet_t> second_monoid_t; 00113 00115 typedef Element<first_monoid_t, 00116 std::basic_string<typename first_projection_alphabet_t:: 00117 letter_t> > first_projection_t; 00118 00120 typedef typename first_projection_t::value_t first_projection_value_t; 00121 00123 typedef Element<second_monoid_t, 00124 std::basic_string<typename second_projection_alphabet_t:: 00125 letter_t> > second_projection_t; 00126 00128 typedef typename second_projection_t::value_t second_projection_value_t; 00129 00131 static first_projection_t first_projection(const first_monoid_t&, 00132 const word_t&); 00133 static first_projection_value_t first_projection(const word_value_t&); 00134 00136 static second_projection_t second_projection(const second_monoid_t&, 00137 const word_t&); 00138 static second_projection_value_t second_projection(const word_value_t&); 00139 }; 00140 00141 } // ! algebra 00142 00143 } // ! vcsn 00144 00145 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00146 # include <vaucanson/algebra/implementation/monoid/str_words.hxx> 00147 # endif // ! VCSN_USE_INTERFACE_ONLY 00148 00149 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_MONOID_STR_WORDS_HH