00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #if !defined(IOTRAITS_H)
00021 #define IOTRAITS_H
00022 
00023 #include <cstring>
00024 #include <cctype>
00025 #include <streambuf.h>
00026 
00027 #if defined(__GNUC__) && __GNUC_MINOR__ <= 7
00028 #  define PORT_TEMPLATE_SPECIALIZATION
00029 #else
00030 #  define PORT_TEMPLATE_SPECIALIZATION template <>
00031 #endif
00032 
00033 
00034 
00035 template <class charT> struct ctype {};
00036 
00037 PORT_TEMPLATE_SPECIALIZATION
00038 struct ctype<char>
00039 {
00040   typedef char         char_type;
00041   typedef int          int_type;
00042 
00043   
00044   char_type newline() const           { return '\n'; }
00045 };
00046 
00047 
00048 
00049 template <class charT> struct ios_traits {};
00050 
00051 
00052 
00053 PORT_TEMPLATE_SPECIALIZATION
00054 struct ios_traits<char>
00055 {
00056   typedef char      char_type;
00057   typedef int       int_type;
00058   typedef streampos pos_type;
00059   typedef streamoff off_type;
00060   typedef int       state_type;
00061 
00062   static inline char_type eos()                { return char_type(); }
00063   static inline int_type  eof()                { return -1; }
00064   static inline int_type  not_eof(int_type c)  { return c == eof()? eof() + 1: c; }
00065   static inline char_type newline()            { return '\n'; }
00066 
00067   static inline bool eq(char_type c1, char_type c2) { return c1 == c2; }
00068   static inline bool eq_int_type(int_type i1, int_type i2)    { return i1 == i2; }
00069   static inline void assign(char& to, char from) { to = from; }
00070 
00071   static inline char_type to_char_type(int_type c) { return char_type(c); }
00072   static inline int_type  to_int_type(char_type c) { return int_type(c); }
00073 
00074   static inline char_type *copy(char_type *dst, char_type const *src, pos_type n)
00075     {
00076       memcpy(dst, src, n);
00077       return dst;
00078     }
00079   static inline size_t    length(char_type const *s) { return strlen(s); }
00080 };
00081 
00082 
00083 
00084 #endif