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         
00061         
00062         
00063         sstr >> std::noskipws >> ret;
00064 
00065         
00066         if (!sstr.eof())
00067           return std::make_pair(false, 0);
00068 
00069         return std::make_pair(true, ret);
00070       }
00071 
00072       static
00073       std::string
00074       letter_to_literal(const int& c)
00075       {
00076         std::stringstream sstr;
00077         sstr << c;
00078         return sstr.str();
00079       }
00080 
00081       
00082       static std::string kind() { return "simple"; }
00083       static int dim() { return 1; }
00084 
00085     };
00086 
00087   } 
00088 
00089 } 
00090 
00091 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX