[PR] この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。
/home/ntakagi/work/STLport-5.1.5/stlport/stl/_ctype.hGo to the documentation of this file.00001 /* 00002 * Copyright (c) 1999 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Copyright (c) 1999 00006 * Boris Fomitchev 00007 * 00008 * This material is provided "as is", with absolutely no warranty expressed 00009 * or implied. Any use is at your own risk. 00010 * 00011 * Permission to use or copy this software for any purpose is hereby granted 00012 * without fee, provided the above notices are retained on all copies. 00013 * Permission to modify the code and to distribute modified code is granted, 00014 * provided the above notices are retained, and a notice that the code was 00015 * modified is included with the above copyright notice. 00016 * 00017 */ 00018 // WARNING: This is an internal header file, included by other C++ 00019 // standard library headers. You should not attempt to use this header 00020 // file directly. 00021 00022 #ifndef _STLP_INTERNAL_CTYPE_H 00023 #define _STLP_INTERNAL_CTYPE_H 00024 00025 #ifndef _STLP_C_LOCALE_H 00026 # include <stl/c_locale.h> 00027 #endif 00028 00029 #ifndef _STLP_INTERNAL_LOCALE_H 00030 # include <stl/_locale.h> 00031 #endif 00032 00033 #ifndef _STLP_INTERNAL_ALGOBASE_H 00034 # include <stl/_algobase.h> 00035 #endif 00036 00037 _STLP_BEGIN_NAMESPACE 00038 00039 class _STLP_CLASS_DECLSPEC ctype_base { 00040 public: 00041 enum mask { 00042 space = _Locale_SPACE, 00043 print = _Locale_PRINT, 00044 cntrl = _Locale_CNTRL, 00045 upper = _Locale_UPPER, 00046 lower = _Locale_LOWER, 00047 alpha = _Locale_ALPHA, 00048 digit = _Locale_DIGIT, 00049 punct = _Locale_PUNCT, 00050 xdigit = _Locale_XDIGIT, 00051 alnum = alpha | digit, 00052 graph = alnum | punct 00053 }; 00054 }; 00055 00056 // ctype<> template 00057 00058 template <class charT> class ctype {}; 00059 template <class charT> class ctype_byname {}; 00060 00061 //ctype specializations 00062 00063 _STLP_TEMPLATE_NULL 00064 class _STLP_CLASS_DECLSPEC ctype<char> : public locale::facet, public ctype_base { 00065 #ifndef _STLP_NO_WCHAR_T 00066 # ifdef _STLP_MSVC 00067 typedef ctype<wchar_t> _Wctype; 00068 friend _Wctype; 00069 # else 00070 friend class ctype<wchar_t>; 00071 # endif 00072 #endif 00073 friend class _Locale_impl; 00074 public: 00075 00076 typedef char char_type; 00077 00078 explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0); 00079 bool is(mask __m, char __c) const 00080 { return ((*(_M_ctype_table+(unsigned char)__c)) & __m) != 0; } 00081 00082 const char* is(const char* __low, const char* __high, mask* __vec) const { 00083 for (const char* __p = __low;__p != __high; ++__p, ++__vec) { 00084 *__vec = _M_ctype_table[(unsigned char)*__p]; 00085 } 00086 return __high; 00087 } 00088 00089 const char* scan_is(mask __m, const char* __low, const char* __high) const; 00090 const char* scan_not(mask __m, const char* __low, const char* __high) const; 00091 00092 char (toupper)(char __c) const { return do_toupper(__c); } 00093 const char* (toupper)(char* __low, const char* __high) const { 00094 return do_toupper(__low, __high); 00095 } 00096 00097 char (tolower)(char __c) const { return do_tolower(__c); } 00098 const char* (tolower)(char* __low, const char* __high) const { 00099 return do_tolower(__low, __high); 00100 } 00101 00102 char widen(char __c) const { return do_widen(__c); } 00103 const char* widen(const char* __low, const char* __high, char* __to) const { 00104 return do_widen(__low, __high, __to); 00105 } 00106 00107 char narrow(char __c, char __dfault) const { 00108 return do_narrow(__c, __dfault); 00109 } 00110 const char* narrow(const char* __low, const char* __high, 00111 char __dfault, char* __to) const { 00112 return do_narrow(__low, __high, __dfault, __to); 00113 } 00114 00115 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id; 00116 # if defined(_STLP_STATIC_CONST_INIT_BUG) 00117 enum __TableSize { table_size = 256 }; 00118 # else 00119 static const size_t table_size = 256; 00120 # endif 00121 00122 protected: 00123 const mask* table() const _STLP_NOTHROW { return _M_ctype_table; } 00124 static const mask* _STLP_CALL classic_table() _STLP_NOTHROW; 00125 00126 ~ctype(); 00127 00128 virtual char do_toupper(char __c) const; 00129 virtual char do_tolower(char __c) const; 00130 virtual const char* do_toupper(char* __low, const char* __high) const; 00131 virtual const char* do_tolower(char* __low, const char* __high) const; 00132 virtual char do_widen(char __c) const; 00133 virtual const char* do_widen(const char* __low, const char* __high, 00134 char* __to) const; 00135 virtual char do_narrow(char __c, char /* dfault */ ) const; 00136 virtual const char* do_narrow(const char* __low, const char* __high, 00137 char /* dfault */, char* __to) const; 00138 private: 00139 struct _Is_mask { 00140 mask __m; 00141 _Is_mask(mask __x): __m(__x) {} 00142 bool operator()(char __c) {return (__m & (unsigned char) __c) != 0;} 00143 }; 00144 00145 protected: 00146 const mask* _M_ctype_table; 00147 private: 00148 bool _M_delete; 00149 }; 00150 00151 _STLP_TEMPLATE_NULL 00152 class _STLP_CLASS_DECLSPEC ctype_byname<char>: public ctype<char> { 00153 public: 00154 explicit ctype_byname(const char*, size_t = 0, _Locale_name_hint* __hint = 0); 00155 ~ctype_byname(); 00156 00157 virtual char do_toupper(char __c) const; 00158 virtual char do_tolower(char __c) const; 00159 00160 virtual const char* do_toupper(char*, const char*) const; 00161 virtual const char* do_tolower(char*, const char*) const; 00162 00163 private: 00164 mask _M_byname_table[table_size]; 00165 _Locale_ctype* _M_ctype; 00166 00167 //explicitely defined as private to avoid warnings: 00168 typedef ctype_byname<char> _Self; 00169 ctype_byname(_Self const&); 00170 _Self& operator = (_Self const&); 00171 friend _Locale_name_hint* _Locale_extract_hint(ctype_byname<char>*); 00172 }; 00173 00174 # ifndef _STLP_NO_WCHAR_T 00175 _STLP_TEMPLATE_NULL 00176 class _STLP_CLASS_DECLSPEC ctype<wchar_t> : public locale::facet, public ctype_base 00177 { 00178 friend class _Locale_impl; 00179 public: 00180 typedef wchar_t char_type; 00181 00182 explicit ctype(size_t __refs = 0) : locale::facet(__refs) {} 00183 00184 bool is(mask __m, wchar_t __c) const 00185 { return do_is(__m, __c); } 00186 00187 const wchar_t* is(const wchar_t* __low, const wchar_t* __high, 00188 mask* __vec) const 00189 { return do_is(__low, __high, __vec); } 00190 00191 const wchar_t* scan_is(mask __m, 00192 const wchar_t* __low, const wchar_t* __high) const 00193 { return do_scan_is(__m, __low, __high); } 00194 00195 const wchar_t* scan_not (mask __m, 00196 const wchar_t* __low, const wchar_t* __high) const 00197 { return do_scan_not(__m, __low, __high); } 00198 00199 wchar_t (toupper)(wchar_t __c) const { return do_toupper(__c); } 00200 const wchar_t* (toupper)(wchar_t* __low, const wchar_t* __high) const 00201 { return do_toupper(__low, __high); } 00202 00203 wchar_t (tolower)(wchar_t __c) const { return do_tolower(__c); } 00204 const wchar_t* (tolower)(wchar_t* __low, const wchar_t* __high) const 00205 { return do_tolower(__low, __high); } 00206 00207 wchar_t widen(char __c) const { return do_widen(__c); } 00208 const char* widen(const char* __low, const char* __high, 00209 wchar_t* __to) const 00210 { return do_widen(__low, __high, __to); } 00211 00212 char narrow(wchar_t __c, char __dfault) const 00213 { return do_narrow(__c, __dfault); } 00214 const wchar_t* narrow(const wchar_t* __low, const wchar_t* __high, 00215 char __dfault, char* __to) const 00216 { return do_narrow(__low, __high, __dfault, __to); } 00217 00218 static _STLP_STATIC_MEMBER_DECLSPEC locale::id id; 00219 00220 protected: 00221 ~ctype(); 00222 00223 virtual bool do_is(mask __m, wchar_t __c) const; 00224 virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const; 00225 virtual const wchar_t* do_scan_is(mask, 00226 const wchar_t*, const wchar_t*) const; 00227 virtual const wchar_t* do_scan_not(mask, 00228 const wchar_t*, const wchar_t*) const; 00229 virtual wchar_t do_toupper(wchar_t __c) const; 00230 virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const; 00231 virtual wchar_t do_tolower(wchar_t c) const; 00232 virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const; 00233 virtual wchar_t do_widen(char c) const; 00234 virtual const char* do_widen(const char*, const char*, wchar_t*) const; 00235 virtual char do_narrow(wchar_t __c, char __dfault) const; 00236 virtual const wchar_t* do_narrow(const wchar_t*, const wchar_t*, 00237 char, char*) const; 00238 }; 00239 00240 _STLP_TEMPLATE_NULL 00241 class _STLP_CLASS_DECLSPEC ctype_byname<wchar_t>: public ctype<wchar_t> { 00242 public: 00243 explicit ctype_byname(const char* __name, size_t __refs = 0, _Locale_name_hint* __hint = 0); 00244 00245 protected: 00246 ~ctype_byname(); 00247 00248 virtual bool do_is(mask __m, wchar_t __c) const; 00249 virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const; 00250 virtual const wchar_t* do_scan_is(mask, 00251 const wchar_t*, const wchar_t*) const; 00252 virtual const wchar_t* do_scan_not(mask, 00253 const wchar_t*, const wchar_t*) const; 00254 virtual wchar_t do_toupper(wchar_t __c) const; 00255 virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const; 00256 virtual wchar_t do_tolower(wchar_t c) const; 00257 virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const; 00258 00259 private: 00260 _Locale_ctype* _M_ctype; 00261 00262 //explicitely defined as private to avoid warnings: 00263 typedef ctype_byname<wchar_t> _Self; 00264 ctype_byname(_Self const&); 00265 _Self& operator = (_Self const&); 00266 }; 00267 00268 # endif /* WCHAR_T */ 00269 00270 _STLP_END_NAMESPACE 00271 00272 #endif /* _STLP_INTERNAL_CTYPE_H */ 00273 00274 // Local Variables: 00275 // mode:C++ 00276 // End: 00277
Generated on Mon Mar 10 15:32:20 2008 by ![]() |