tools.hh

00001 // tools.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2004, 2005, 2006 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_FREE_MONOID_TOOLS_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_FREE_MONOID_TOOLS_HH
00019 
00020 # include <vaucanson/algebra/concept/freemonoid_base.hh>
00021 # include <string>
00022 # include <list>
00023 
00024 namespace vcsn {
00025 
00026   namespace algebra {
00027 
00028     template <typename L>
00029     struct list_or_string
00030     {
00031       typedef std::list<L> ret;
00032     };
00033 
00034     template <>
00035     struct list_or_string<char>
00036     {
00037       typedef std::string ret;
00038     };
00039 
00040     template <>
00041     struct list_or_string<wchar_t>
00042     {
00043       typedef std::basic_string<wchar_t> ret;
00044     };
00045 
00046     template <typename A, typename B>
00047     struct list_or_string<std::pair<A,B> >
00048     {
00049       typedef std::basic_string<std::pair<A,B> > ret;
00050     };
00051 
00052   } // algebra
00053 
00054   template<typename A>
00055   const std::list<typename A::letter_t>&
00056   identity_value(SELECTOR(algebra::FreeMonoidBase<A>),
00057                  SELECTOR(std::list<typename A::letter_t>));
00058 
00059   template<typename A>
00060   std::list<typename A::letter_t>
00061   op_convert(SELECTOR(algebra::FreeMonoidBase<A>),
00062              SELECTOR(std::list<typename A::letter_t>),
00063              const typename A::letter_t& c);
00064 
00065   template <typename A>
00066   void
00067   op_in_mul(const algebra::FreeMonoidBase<A>& s,
00068             std::list<typename A::letter_t>& dst,
00069             const std::list<typename A::letter_t>& src);
00070 
00071   template <typename A>
00072   std::list<typename A::letter_t>
00073   op_mul(const algebra::FreeMonoidBase<A>& s,
00074          const std::list<typename A::letter_t>& a,
00075          const std::list<typename A::letter_t>& b);
00076 
00077 } // vcsn
00078 
00080 #define USE_LETTERS(X...) \
00081   typedef X Letter; \
00082   typedef vcsn::algebra::AlphabetSet< Letter > Alphabets; \
00083   typedef vcsn::Element<Alphabets, std::set< Letter > > Alphabet; \
00084   typedef vcsn::algebra::AlphabetDecorator< Letter , std::set< Letter > > DAlphabetImpl; \
00085   typedef vcsn::Element<Alphabets, DAlphabetImpl> DAlphabet; \
00086   typedef vcsn::algebra::FreeMonoid<Alphabet> Words; \
00087   typedef vcsn::algebra::list_or_string< Letter >::ret WordValue; \
00088   typedef vcsn::Element<Words, WordValue> Word;
00089 
00090 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00091 # include <vaucanson/algebra/implementation/free_monoid/tools.hxx>
00092 #endif // VCSN_USE_INTERFACE_ONLY
00093 
00094 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_FREE_MONOID_TOOLS_HH

Generated on Sun Jul 29 19:35:30 2007 for Vaucanson by  doxygen 1.5.2