00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_LETTER_COUPLE_LETTER_HH
00019 # define VCSN_ALGEBRA_IMPLEMENTATION_LETTER_COUPLE_LETTER_HH
00020
00021 # include <climits>
00022 # include <string>
00023 # include <iostream>
00024
00025 # include <vaucanson/algebra/concept/letter.hh>
00026 # include <vaucanson/algebra/concept/freemonoid_base.hh>
00027
00028
00029
00030 namespace vcsn
00031 {
00032
00033 namespace algebra
00034 {
00035
00036 template <typename U, typename V>
00037 struct letter_traits< std::pair<U, V> >
00038 {
00039
00040 typedef misc::true_t is_char_letter;
00041
00042 enum
00043 {
00044
00045
00046
00047
00048
00049
00050
00051
00052 cardinal = INT_MAX
00053 };
00054
00055 LETTER_DEFAULT(open_par, "[")
00056 LETTER_DEFAULT(close_par, "]")
00057 LETTER_DEFAULT(plus, "+")
00058 LETTER_DEFAULT(times, ".")
00059 LETTER_DEFAULT(star, "*")
00060 LETTER_DEFAULT(epsilon, "eps")
00061 LETTER_DEFAULT(zero, "zero")
00062 LETTER_DEFAULT(open_weight, "{")
00063 LETTER_DEFAULT(close_weight, "}")
00064 LETTER_DEFAULT(space, " ")
00065
00066 static
00067 std::pair<U, V>
00068 literal_to_letter(const std::string& str)
00069 {
00070 std::stringstream sstr(str);
00071 std::pair<U, V> ret;
00072 sstr >> ret;
00073 return ret;
00074 }
00075
00076 static
00077 std::string
00078 letter_to_literal(const std::pair<U, V>& c)
00079 {
00080 std::stringstream sstr;
00081 sstr << c;
00082 return sstr.str();
00083 }
00084
00085 // A pair is a "tuple" with dimension 2.
00086 static std::string kind() { return "tuple"; }
00087 static int dim() { return 2; }
00088
00089 };
00090
00091 } // ! algebra
00092
00093 } // ! vcsn
00094
00095 namespace vcsn {
00096
00097 namespace algebra {
00098
00099 // Specialization for pairs.
00100 template <typename S, typename U, typename V, typename CharContainer>
00101 bool op_parse (const algebra::FreeMonoidBase<S>& set,
00102 std::basic_string< std::pair<U, V> >& v,
00103 const std::string& s,
00104 typename std::string::const_iterator& i,
00105 const CharContainer& escaped);
00106 }
00107 } // ! vcsn
00108
00109 namespace std {
00110
00115 template <typename U, typename V>
00116 std::ostream& operator<< (std::ostream& o, std::pair<U, V> p);
00117
00119 template <typename U, typename V, class Traits, class Allocator>
00120 std::ostream&
00121 operator<< (std::ostream& o,
00122 std::basic_string<std::pair<U, V>, Traits, Allocator> s);
00123
00125 template <typename U, typename V>
00126 std::istream& operator>> (std::istream& i, std::pair<U, V>& p);
00127
00128 } // ! std
00129
00130 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00131 # include <vaucanson/algebra/implementation/letter/couple_letter.hxx>
00132 # endif // ! VCSN_USE_INTERFACE_ONLY
00133
00134 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_COUPLE_LETTER_HH