letter.hxx

00001 // letter.hxx: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2008 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_CONCEPT_LETTER_HXX
00018 # define VCSN_ALGEBRA_CONCEPT_LETTER_HXX
00019 
00020 # include <string>
00021 # include <vector>
00022 
00023 # include <vaucanson/misc/contract.hh>
00024 # include <vaucanson/algebra/concept/letter.hh>
00025 
00026 namespace vcsn {
00027 
00028   namespace algebra {
00029 
00030     // Dummy implementation.
00031     template <typename L>
00032     std::string
00033     letter_traits<L>::kind()
00034     {
00035       return 0;
00036     }
00037 
00038     // Dummy implementation.
00039     template <typename L>
00040     int
00041     letter_traits<L>::dim()
00042     {
00043       return 0;
00044     }
00045 
00046     // Dummy implementation.
00047     template <typename L>
00048     L
00049     letter_traits<L>::literal_to_letter(const std::string&)
00050     {
00051       return 0;
00052     }
00053 
00054     // Dummy implementation.
00055     template <typename L>
00056     std::string
00057     letter_traits<L>::letter_to_literal(const L&)
00058     {
00059       return 0;
00060     }
00061 
00062     // Concept defaults.
00063 # define STATIC_DEFAULT(name) \
00064     template <typename L> \
00065     const std::string \
00066     letter_traits<L>::default_##name () \
00067     { \
00068       static_error(need_default_##name); \
00069       return 0; \
00070     } \
00071     template <> \
00072     inline const std::string \
00073     letter_traits<misc::true_t>::default_##name () \
00074     { \
00075       return ""; \
00076     }
00077 
00078     STATIC_DEFAULT(open_par)
00079     STATIC_DEFAULT(close_par)
00080     STATIC_DEFAULT(plus)
00081     STATIC_DEFAULT(times)
00082     STATIC_DEFAULT(star)
00083     STATIC_DEFAULT(epsilon)
00084     STATIC_DEFAULT(zero)
00085     STATIC_DEFAULT(open_weight)
00086     STATIC_DEFAULT(close_weight)
00087     STATIC_DEFAULT(space)
00088 
00089 # undef STATIC_DEFAULT
00090 
00091     // Default CTOR.
00092     template <typename L>
00093     token_representation<L>::token_representation() :
00094         open_par(letter_traits<L>::default_open_par()),
00095         close_par(letter_traits<L>::default_close_par()),
00096         plus(letter_traits<L>::default_plus()),
00097         times(letter_traits<L>::default_times()),
00098         star(letter_traits<L>::default_star()),
00099         one(letter_traits<L>::default_epsilon()),
00100         zero(letter_traits<L>::default_zero()),
00101         open_weight(letter_traits<L>::default_open_weight()),
00102         close_weight(letter_traits<L>::default_close_weight())
00103     {
00104       spaces.push_back(letter_traits<L>::default_space());
00105     }
00106 
00107     // Convertion CTOR.
00108     template <typename L>
00109     template <typename U>
00110     token_representation<L>::
00111     token_representation(const token_representation<U>& arg) :
00112         open_par(arg.open_par),
00113         close_par(arg.close_par),
00114         plus(arg.plus),
00115         times(arg.times),
00116         star(arg.star),
00117         one(arg.one),
00118         zero(arg.zero),
00119         open_weight(arg.open_weight),
00120         close_weight(arg.close_weight),
00121         spaces(arg.spaces)
00122     {
00123     }
00124 
00125   } // ! algebra
00126 
00127 } // ! vcsn
00128 
00129 #endif // ! VCSN_ALGEBRA_CONCEPT_LETTER_HXX

Generated on Thu Oct 9 20:22:39 2008 for Vaucanson by  doxygen 1.5.1