00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX
00019
00020 # include <string>
00021 # include <sstream>
00022 # include <utility>
00023 # include <climits>
00024
00025 # include <vaucanson/algebra/implementation/letter/int_letter.hh>
00026
00027 namespace vcsn
00028 {
00029 namespace algebra
00030 {
00031 template <>
00032 struct letter_traits<int>
00033 {
00034
00035 typedef misc::false_t is_char_letter;
00036
00037 enum
00038 {
00039
00040
00041 cardinal = UINT_MAX
00042 };
00043
00044
00045 typedef undefined_type first_projection_t;
00046 typedef undefined_type second_projection_t;
00047
00048 static
00049 std::pair<bool, int>
00050 literal_to_letter(const std::string& str)
00051 {
00052 std::stringstream sstr(str);
00053
00054
00055
00056 if (str[0] == '+')
00057 return std::make_pair(false, 0);
00058
00059 int ret = 0;
00060 sstr >> ret;
00061
00062
00063 if (!sstr.eof())
00064 return std::make_pair(false, 0);
00065
00066 return std::make_pair(true, ret);
00067 }
00068
00069 static
00070 std::string
00071 letter_to_literal(const int& c)
00072 {
00073 std::stringstream sstr;
00074 sstr << c;
00075 return sstr.str();
00076 }
00077
00078
00079 static std::string kind() { return "simple"; }
00080 static int dim() { return 1; }
00081
00082 };
00083
00084 }
00085
00086 }
00087
00088 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX