00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _POD_CHAR_TRAITS_H
00038 #define _POD_CHAR_TRAITS_H 1
00039
00040 #include <string>
00041
00042 namespace __gnu_cxx
00043 {
00044
00045 template<typename V, typename I, typename S = mbstate_t>
00046 struct character
00047 {
00048 typedef V value_type;
00049 typedef I int_type;
00050 typedef S state_type;
00051 value_type value;
00052 };
00053
00054 template<typename V, typename I>
00055 inline bool
00056 operator==(const character<V, I>& lhs, const character<V, I>& rhs)
00057 { return lhs.value == rhs.value; }
00058
00059 template<typename V, typename I>
00060 inline bool
00061 operator<(const character<V, I>& lhs, const character<V, I>& rhs)
00062 { return lhs.value < rhs.value; }
00063 }
00064
00065 namespace std
00066 {
00067
00068 template<typename V, typename I, typename S>
00069 struct char_traits<__gnu_cxx::character<V, I, S> >
00070 {
00071 typedef __gnu_cxx::character<V, I, S> char_type;
00072
00073
00074
00075
00076
00077
00078
00079 typedef typename char_type::int_type int_type;
00080 typedef typename char_type::state_type state_type;
00081 typedef fpos<state_type> pos_type;
00082 typedef streamoff off_type;
00083
00084 static void
00085 assign(char_type& __c1, const char_type& __c2)
00086 { __c1 = __c2; }
00087
00088 static bool
00089 eq(const char_type& __c1, const char_type& __c2)
00090 { return __c1 == __c2; }
00091
00092 static bool
00093 lt(const char_type& __c1, const char_type& __c2)
00094 { return __c1 < __c2; }
00095
00096 static int
00097 compare(const char_type* __s1, const char_type* __s2, size_t __n)
00098 {
00099 for (size_t __i = 0; __i < __n; ++__i)
00100 if (!eq(__s1[__i], __s2[__i]))
00101 return lt(__s1[__i], __s2[__i]) ? -1 : 1;
00102 return 0;
00103 }
00104
00105 static size_t
00106 length(const char_type* __s)
00107 {
00108 const char_type* __p = __s;
00109 while (__p->value)
00110 ++__p;
00111 return (__p - __s);
00112 }
00113
00114 static const char_type*
00115 find(const char_type* __s, size_t __n, const char_type& __a)
00116 {
00117 for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
00118 if (*__p == __a)
00119 return __p;
00120 return 0;
00121 }
00122
00123 static char_type*
00124 move(char_type* __s1, const char_type* __s2, size_t __n)
00125 { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
00126
00127 static char_type*
00128 copy(char_type* __s1, const char_type* __s2, size_t __n)
00129 { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
00130
00131 static char_type*
00132 assign(char_type* __s, size_t __n, char_type __a)
00133 {
00134 for (char_type* __p = __s; __p < __s + __n; ++__p)
00135 assign(*__p, __a);
00136 return __s;
00137 }
00138
00139 static char_type
00140 to_char_type(const int_type& __c)
00141 {
00142 char_type __r = { __c };
00143 return __r;
00144 }
00145
00146 static int_type
00147 to_int_type(const char_type& __c)
00148 { return int_type(__c.value); }
00149
00150 static bool
00151 eq_int_type(const int_type& __c1, const int_type& __c2)
00152 { return __c1 == __c2; }
00153
00154 static int_type
00155 eof() { return static_cast<int_type>(-1); }
00156
00157 static int_type
00158 not_eof(const int_type& __c)
00159 { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
00160 };
00161 }
00162
00163 #endif