Vaucanson  1.4.1
window.hh
Go to the documentation of this file.
1 // window.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 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_MISC_WINDOW_HH
18 # define VCSN_MISC_WINDOW_HH
19 
31 # include <iostream>
32 # include <string>
33 
34 namespace vcsn {
35  namespace misc {
36 
59  template <class InputIterator, class Letter>
60  struct Window
61  {
62  typedef InputIterator iterator_t;
63  typedef Letter letter_t;
64  typedef typename std::basic_string<letter_t> string_t;
65  typedef unsigned int length_t;
66 
80  Window (const iterator_t& stream,
81  const iterator_t& eof,
82  letter_t eol,
83  length_t length);
84 
86  bool eof () const;
88  bool eol () const;
89 
95  void shift (unsigned int n);
97  void shift ();
98 
100 
101  void moveto (length_t offset);
102  void moveto (iterator_t position);
104 
106  length_t size () const;
107 
109  letter_t operator[] (length_t i) const;
110 
112  std::ostream& print (std::ostream& ostr) const;
113 
115 
116 
117  iterator_t begin () const;
119  iterator_t stream () const;
121  iterator_t end () const;
123  size_t offset () const;
125  letter_t eol_value () const;
127  length_t length () const;
129  string_t window () const;
131  protected:
132  void compute_size ();
133 
134  iterator_t begin_;
135  iterator_t stream_;
136  iterator_t end_;
137  letter_t eol_;
138  length_t length_;
139  length_t size_;
140  };
141 
142  template <class InputIterator, class Letter>
143  std::ostream&
144  operator<< (std::ostream& ostr, const Window<InputIterator, Letter>& w);
145 
148  } // misc
149 } // vcsn
150 
151 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
152 # include <vaucanson/misc/window.hxx>
153 # endif // VCSN_USE_INTERFACE_ONLY
154 
155 #endif // ! VCSN_MISC_WINDOW_HH