char_traits.hh

Go to the documentation of this file.
00001 // char_traits.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 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_CHAR_TRAITS_HH
00018 # define VCSN_MISC_CHAR_TRAITS_HH
00019 
00048 # include <string>
00049 
00050 namespace utility
00051 {
00052  
00062   template <class CharT>
00063   struct generic_int_type
00064   {
00065     typedef CharT char_type;
00066 
00067     generic_int_type();
00068     generic_int_type(const char_type&);
00069 
00070     operator CharT () const;
00071 
00072     bool operator == (const generic_int_type<CharT>&) const;
00073     bool eof() const;
00074   protected:
00075     char_type val_;
00076     bool eof_;
00077   };
00078 
00086   template <typename CharT>
00087   struct char_traits
00088   {
00089     typedef CharT                       char_type;
00090     typedef generic_int_type<char_type> int_type;
00091     typedef std::streamoff              off_type;
00092     typedef std::streampos              pos_type;
00093     typedef mbstate_t                   state_type;
00094 
00095     static void                 assign(char_type&, const char_type&);
00096     static bool                 eq(const char_type&, const char_type&);
00097     static bool                 lt(const char_type&, const char_type&);
00098     static int                  compare(const char_type*,
00099                                         const char_type*,
00100                                         size_t);
00101     static size_t               length(const char_type*);
00102     static const char_type*     find(const char_type*,
00103                                      size_t,
00104                                      const char_type&);
00105     static char_type*           move(char_type*, const char_type*, size_t);
00106     static char_type*           copy(char_type*, const char_type*, size_t);
00107     static char_type*           assign(char_type*, size_t, char_type);
00108     static int_type             not_eof(const int_type&);
00109     static char_type            to_char_type(const int_type&);
00110     static int_type             to_int_type(const char_type&);
00111     static bool                 eq_int_type(const int_type&, const int_type&);
00112     static int_type             eof();
00113   };
00114 
00116 } // end of namespace utility
00117 
00118 # ifndef VCSN_USE_INTERFACE_ONLY
00119 #  include <vaucanson/misc/char_traits.hxx>
00120 # endif // VCSN_USE_INTERFACE_ONLY
00121 
00122 #endif // ! VCSN_MISC_CHAR_TRAITS_HH

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