- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

# int_letter.hxx

    00001 // int_letter.hxx: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2004, 2005, 2007 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_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX
    00018 # define VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX
    00019
    00020 # include <sstream>
    00021
    00022 # include <vaucanson/algebra/implementation/letter/int_letter.hh>
    00023
    00024 namespace vcsn {
    00025
    00026   namespace algebra {
    00027
    00028     template <typename S>
    00029     bool op_parse(const algebra::FreeMonoidBase<S>& set,
    00030                   std::list<int>& v,
    00031                   const std::string& s,
    00032                   typename std::string::const_iterator& i,
    00033                   const std::list<char>& escaped)
    00034     {
    00035       typename std::string::const_iterator j = i;
    00036       typename std::string::const_iterator k;
    00037       typename std::string::const_iterator back;
    00038
    00039       while ((i != s.end()) &&
    00040              (std::find(escaped.begin(), escaped.end(), *i) == escaped.end())) {
    00041         std::string out;
    00042         back = i;
    00043
    00044         while ((i != s.end()) && (((*i >= '0') && (*i <= '9'))) || (*i == '\\'))
    00045           if (*i == '\\') {
    00046             k = i;
    00047             ++k;
    00048             if (k != s.end())
    00049               i = k;
    00050             out += *i;
    00051             ++i;
    00052           }
    00053           else {
    00054             out += *i;
    00055             ++i;
    00056           }
    00057
    00058         int value;
    00059         std::istringstream is(out);
    00060         is >> value;
    00061         if (!set.alphabet().contains(value)) {
    00062           i = back;
    00063           break ;
    00064         }
    00065         v.push_back(value);
    00066       }
    00067       return (i != j);
    00068     }
    00069
    00070   } // algebra
    00071
    00072 } // vcsn
    00073
    00074 namespace std {
    00075
    00076   ostream& operator<<(ostream& o, list<int> s)
    00077   {
    00078     list<int>::const_iterator i;
    00079     list<int>::const_iterator j;
    00080
    00081     for (i = s.begin(); i != s.end(); ) {
    00082       o << *i;
    00083       i++;
    00084       if (i != s.end())
    00085         o << ",";
    00086     }
    00087
    00088     return o;
    00089   }
    00090
    00091 } // std
    00092
    00093 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_INT_LETTER_HXX