Vaucanson  1.4.1
str_words.hh
1 // str_words.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 The Vaucanson
6 // Group.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
12 //
13 // The complete GNU General Public Licence Notice can be found as the
14 // `COPYING' file in the root directory.
15 //
16 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
17 //
18 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_MONOID_STR_WORDS_HH
19 # define VCSN_ALGEBRA_IMPLEMENTATION_MONOID_STR_WORDS_HH
20 
21 // We will use std::basic_string as a `word' implementation.
22 # include <string>
23 
24 # include <vaucanson/algebra/implementation/monoid/free_monoid.hh>
25 # include <vaucanson/algebra/implementation/alphabets/alphabet_set.hh>
26 
27 namespace vcsn {
28 
29  namespace algebra {
30 
31  /*-----------------------------------------------.
32  | Implementation of words with std::basic_string |
33  `-----------------------------------------------*/
34 
35  template <typename A>
36  std::pair<bool, int>
37  op_parse(const FreeMonoid<A>& s,
38  std::basic_string<typename A::letter_t>& v,
39  const std::string& in);
40 
41  template <typename A>
42  void
43  op_in_mul(const algebra::FreeMonoid<A>& s,
44  std::basic_string<typename A::letter_t>& dst,
45  const std::basic_string<typename A::letter_t>& src);
46 
47  template<typename A>
48  std::basic_string<typename A::letter_t>
49  op_mul(const algebra::FreeMonoid<A>& s,
50  const std::basic_string<typename A::letter_t>& a,
51  const std::basic_string<typename A::letter_t>& b);
52 
53  template<typename A, typename St, typename U, typename V>
54  St&
55  op_rout(const FreeMonoid<A>& s,
56  St& st,
57  const std::basic_string<typename A::letter_t, U, V>& v);
58 
59  template<typename A>
60  const std::basic_string<typename A::letter_t>&
61  identity_value(SELECTOR(algebra::FreeMonoid<A>),
62  SELECTOR(std::basic_string<typename A::letter_t>));
63 
64  // one can create words from a single character
65  template<typename A>
66  std::basic_string<typename A::letter_t>
67  op_convert(SELECTOR(algebra::FreeMonoid<A>),
68  SELECTOR(std::basic_string<typename A::letter_t>),
69  const typename A::letter_t& c);
70 
71  template<typename A, typename B, typename C, typename D>
72  bool
73  op_is_atom(const algebra::FreeMonoid<A>&,
74  const std::basic_string<B, C, D>& v);
75 
76  /*---------------------------------------------------------------------.
77  | word_traits<FreeMonoid<A>, std::basic_string<typename A::letter_t> > |
78  `---------------------------------------------------------------------*/
79 
84  template <typename A>
86  std::basic_string<typename A::letter_t> >
87  {
89  typedef A alphabet_t;
90 
92  typedef Element<FreeMonoid<A>,
93  std::basic_string<typename alphabet_t::letter_t> > word_t;
94 
96  typedef typename word_t::value_t word_value_t;
97 
99  typedef typename alphabet_traits<typename alphabet_t::set_t,
100  typename alphabet_t::value_t>::
102 
104  typedef typename alphabet_traits<typename alphabet_t::set_t,
105  typename alphabet_t::value_t>::
107 
110 
113 
115  typedef Element<first_monoid_t,
116  std::basic_string<typename first_projection_alphabet_t::
117  letter_t> > first_projection_t;
118 
121 
123  typedef Element<second_monoid_t,
124  std::basic_string<typename second_projection_alphabet_t::
125  letter_t> > second_projection_t;
126 
129 
131  static first_projection_t first_projection(const first_monoid_t&,
132  const word_t&);
133  static first_projection_value_t first_projection(const word_value_t&);
134 
136  static second_projection_t second_projection(const second_monoid_t&,
137  const word_t&);
138  static second_projection_value_t second_projection(const word_value_t&);
139  };
140 
141  } // ! algebra
142 
143 } // ! vcsn
144 
145 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
146 # include <vaucanson/algebra/implementation/monoid/str_words.hxx>
147 # endif // ! VCSN_USE_INTERFACE_ONLY
148 
149 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_MONOID_STR_WORDS_HH