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
00038
00039
00040
#ifndef _CPP_BITS_CHAR_TRAITS_H
00041
#define _CPP_BITS_CHAR_TRAITS_H 1
00042
00043
#pragma GCC system_header
00044
00045
#include <cstring>
00046
#include <bits/fpos.h>
00047
00048
namespace std
00049 {
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
template<
class _CharT>
00062 struct char_traits
00063 {
00064
typedef _CharT char_type;
00065
00066
typedef unsigned long int_type;
00067
typedef streampos pos_type;
00068
typedef streamoff off_type;
00069
typedef mbstate_t state_type;
00070
00071
static void
00072 assign(char_type& __c1,
const char_type& __c2);
00073
00074
static bool
00075 eq(
const char_type& __c1,
const char_type& __c2);
00076
00077
static bool
00078 lt(
const char_type& __c1,
const char_type& __c2);
00079
00080
static int
00081 compare(
const char_type* __s1,
const char_type* __s2, size_t __n);
00082
00083
static size_t
00084 length(
const char_type* __s);
00085
00086
static const char_type*
00087
find(
const char_type* __s, size_t __n,
const char_type& __a);
00088
00089
static char_type*
00090 move(char_type* __s1,
const char_type* __s2, size_t __n);
00091
00092
static char_type*
00093
copy(char_type* __s1,
const char_type* __s2, size_t __n);
00094
00095
static char_type*
00096 assign(char_type* __s, size_t __n, char_type __a);
00097
00098
static char_type
00099 to_char_type(
const int_type& __c);
00100
00101
static int_type
00102 to_int_type(
const char_type& __c);
00103
00104
static bool
00105 eq_int_type(
const int_type& __c1,
const int_type& __c2);
00106
00107
static int_type
00108 eof();
00109
00110
static int_type
00111 not_eof(
const int_type& __c);
00112 };
00113
00114
00115
00116
template<>
00117 struct char_traits<char>
00118 {
00119
typedef char char_type;
00120
typedef int int_type;
00121
typedef streampos pos_type;
00122
typedef streamoff off_type;
00123
typedef mbstate_t state_type;
00124
00125
static void
00126 assign(char_type& __c1,
const char_type& __c2)
00127 { __c1 = __c2; }
00128
00129
static bool
00130 eq(
const char_type& __c1,
const char_type& __c2)
00131 {
return __c1 == __c2; }
00132
00133
static bool
00134 lt(
const char_type& __c1,
const char_type& __c2)
00135 {
return __c1 < __c2; }
00136
00137
static int
00138 compare(
const char_type* __s1,
const char_type* __s2, size_t __n)
00139 {
return memcmp(__s1, __s2, __n); }
00140
00141
static size_t
00142 length(
const char_type* __s)
00143 {
return strlen(__s); }
00144
00145
static const char_type*
00146
find(
const char_type* __s, size_t __n,
const char_type& __a)
00147 {
return static_cast<const char_type*>(memchr(__s, __a, __n)); }
00148
00149
static char_type*
00150 move(char_type* __s1,
const char_type* __s2, size_t __n)
00151 {
return static_cast<char_type*>(memmove(__s1, __s2, __n)); }
00152
00153
static char_type*
00154
copy(char_type* __s1,
const char_type* __s2, size_t __n)
00155 {
return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
00156
00157
static char_type*
00158 assign(char_type* __s, size_t __n, char_type __a)
00159 {
return static_cast<char_type*>(memset(__s, __a, __n)); }
00160
00161
static char_type
00162 to_char_type(
const int_type& __c)
00163 {
return static_cast<char_type>(__c); }
00164
00165
00166
00167
static int_type
00168 to_int_type(
const char_type& __c)
00169 {
return static_cast<int_type>(static_cast<unsigned char>(__c)); }
00170
00171
static bool
00172 eq_int_type(
const int_type& __c1,
const int_type& __c2)
00173 {
return __c1 == __c2; }
00174
00175
static int_type
00176 eof() {
return static_cast<int_type>(EOF); }
00177
00178
static int_type
00179 not_eof(
const int_type& __c)
00180 {
return (__c == eof()) ? 0 : __c; }
00181 };
00182
00183
00184
#ifdef _GLIBCPP_USE_WCHAR_T
00185
00186
template<>
00187
struct char_traits<wchar_t>
00188 {
00189
typedef wchar_t char_type;
00190
typedef wint_t int_type;
00191
typedef streamoff off_type;
00192
typedef wstreampos pos_type;
00193
typedef mbstate_t state_type;
00194
00195
static void
00196 assign(char_type& __c1,
const char_type& __c2)
00197 { __c1 = __c2; }
00198
00199
static bool
00200 eq(
const char_type& __c1,
const char_type& __c2)
00201 {
return __c1 == __c2; }
00202
00203
static bool
00204 lt(
const char_type& __c1,
const char_type& __c2)
00205 {
return __c1 < __c2; }
00206
00207
static int
00208 compare(
const char_type* __s1,
const char_type* __s2, size_t __n)
00209 {
return wmemcmp(__s1, __s2, __n); }
00210
00211
static size_t
00212 length(
const char_type* __s)
00213 {
return wcslen(__s); }
00214
00215
static const char_type*
00216
find(
const char_type* __s, size_t __n,
const char_type& __a)
00217 {
return wmemchr(__s, __a, __n); }
00218
00219
static char_type*
00220 move(char_type* __s1,
const char_type* __s2, int_type __n)
00221 {
return wmemmove(__s1, __s2, __n); }
00222
00223
static char_type*
00224
copy(char_type* __s1,
const char_type* __s2, size_t __n)
00225 {
return wmemcpy(__s1, __s2, __n); }
00226
00227
static char_type*
00228 assign(char_type* __s, size_t __n, char_type __a)
00229 {
return wmemset(__s, __a, __n); }
00230
00231
static char_type
00232 to_char_type(
const int_type& __c) {
return char_type(__c); }
00233
00234
static int_type
00235 to_int_type(
const char_type& __c) {
return int_type(__c); }
00236
00237
static bool
00238 eq_int_type(
const int_type& __c1,
const int_type& __c2)
00239 {
return __c1 == __c2; }
00240
00241
static int_type
00242 eof() {
return static_cast<int_type>(WEOF); }
00243
00244
static int_type
00245 not_eof(
const int_type& __c)
00246 {
return eq_int_type(__c, eof()) ? 0 : __c; }
00247 };
00248
#endif //_GLIBCPP_USE_WCHAR_T
00249
00250
template<
typename _CharT,
typename _Traits>
00251
struct _Char_traits_match
00252 {
00253 _CharT _M_c;
00254 _Char_traits_match(_CharT
const& __c) : _M_c(__c) { }
00255
00256
bool
00257 operator()(_CharT
const& __a) {
return _Traits::eq(_M_c, __a); }
00258 };
00259 }
00260
00261
#endif