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