window.hh

Go to the documentation of this file.
00001 // window.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2001, 2002, 2003, 2004 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_MISC_WINDOW_HH
00018 # define VCSN_MISC_WINDOW_HH
00019 
00031 # include <iostream>
00032 # include <string>
00033 
00034 namespace utility {
00035 
00058   template <class InputIterator, class Letter>
00059   struct Window
00060   {
00061     typedef InputIterator                               iterator_t;
00062     typedef Letter                                      letter_t;
00063     typedef typename std::basic_string<letter_t>        string_t;
00064     typedef unsigned int                                length_t;
00065 
00079     Window(const iterator_t& stream,
00080            const iterator_t& eof,
00081            letter_t eol,
00082            length_t length);
00083 
00085     bool                eof() const;
00087     bool                eol() const;
00088 
00094     void                shift(unsigned int n);
00096     void                shift();
00097 
00099 
00100     void                moveto(length_t offset);
00101     void                moveto(iterator_t position);
00103 
00105     length_t            size() const;
00106 
00108     letter_t            operator [] (length_t i) const;
00109 
00111     std::ostream&       print(std::ostream& ostr) const;
00112 
00114 
00115 
00116     iterator_t          begin() const;
00118     iterator_t          stream() const;
00120     iterator_t          end() const;
00122     size_t              offset() const;
00124     letter_t            eol_value() const;
00126     length_t            length() const;
00128     string_t            window() const;
00130   protected:
00131     void                compute_size();
00132 
00133     iterator_t          begin_;
00134     iterator_t          stream_;
00135     iterator_t          end_;
00136     letter_t            eol_;
00137     length_t            length_;
00138     length_t            size_;
00139   };
00140 
00141   template <class InputIterator, class Letter>
00142   std::ostream&
00143   operator << (std::ostream& ostr, const Window<InputIterator, Letter>& w);
00144 
00147 } // utility
00148 
00149 # ifndef VCSN_USE_INTERFACE_ONLY
00150 #  include <vaucanson/misc/window.hxx>
00151 # endif // VCSN_USE_INTERFACE_ONLY
00152 
00153 #endif // ! VCSN_MISC_WINDOW_HH

Generated on Fri Jul 28 12:18:56 2006 for Vaucanson by  doxygen 1.4.6