Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_ctype.h
Go 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 public: 00074 00075 typedef char char_type; 00076 00077 explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0); 00078 bool is(mask __m, char __c) const 00079 { return ((*(_M_ctype_table+(unsigned char)__c)) & __m) != 0; } 00080 00081 const char* is(const char* __low, const char* __high, mask* __vec) const { 00082 for (const char* __p = __low;__p != __high; ++__p, ++__vec) { 00083 *__vec = _M_ctype_table[(unsigned char)*__p]; 00084 } 00085 return __high; 00086 } 00087 00088 const char* scan_is(mask __m, const char* __low, const char* __high) const; 00089 const char* scan_not(mask __m, const char* __low, const char* __high) const; 00090 00091 char (toupper)(char __c) const { return do_toupper(__c); } 00092 const char* (toupper)(char* __low, const char* __high) const { 00093 return do_toupper(__low, __high); 00094 } 00095 00096 char (tolower)(char __c) const { return do_tolower(__c); } 00097 const char* (tolower)(char* __low, const char* __high) const { 00098 return do_tolower(__low, __high); 00099 } 00100 00101 char widen(char __c) const { return do_widen(__c); } 00102 const char* widen(const char* __low, const char* __high, char* __to) const { 00103 return do_widen(__low, __high, __to); 00104 } 00105 00106 char narrow(char __c, char __dfault) const { 00107 return do_narrow(__c, __dfault); 00108 } 00109 const char* narrow(const char* __low, const char* __high, 00110 char __dfault, char* __to) const { 00111 return do_narrow(__low, __high, __dfault, __to); 00112 } 00113 00114 static _STLP_STATIC_DECLSPEC locale::id id; 00115 _STLP_STATIC_CONSTANT(size_t, table_size = 256); 00116 00117 protected: 00118 const mask* table() const _STLP_NOTHROW { return _M_ctype_table; } 00119 static const mask* _STLP_CALL classic_table() _STLP_NOTHROW; 00120 00121 ~ctype(); 00122 00123 virtual char do_toupper(char __c) const; 00124 virtual char do_tolower(char __c) const; 00125 virtual const char* do_toupper(char* __low, const char* __high) const; 00126 virtual const char* do_tolower(char* __low, const char* __high) const; 00127 virtual char do_widen(char __c) const; 00128 virtual const char* do_widen(const char* __low, const char* __high, 00129 char* __to) const; 00130 virtual char do_narrow(char __c, char /* dfault */ ) const; 00131 virtual const char* do_narrow(const char* __low, const char* __high, 00132 char /* dfault */, char* __to) const; 00133 private: 00134 struct _Is_mask { 00135 mask __m; 00136 _Is_mask(mask __x): __m(__x) {} 00137 bool operator()(char __c) {return (__m & (unsigned char) __c) != 0;} 00138 }; 00139 00140 protected: 00141 const mask* _M_ctype_table; 00142 private: 00143 bool _M_delete; 00144 }; 00145 00146 _STLP_TEMPLATE_NULL 00147 class _STLP_CLASS_DECLSPEC ctype_byname<char>: public ctype<char> { 00148 friend class _Locale_impl; 00149 public: 00150 explicit ctype_byname(const char*, size_t = 0); 00151 ~ctype_byname(); 00152 00153 virtual char do_toupper(char __c) const; 00154 virtual char do_tolower(char __c) const; 00155 00156 virtual const char* do_toupper(char*, const char*) const; 00157 virtual const char* do_tolower(char*, const char*) const; 00158 00159 private: 00160 ctype_byname(_Locale_ctype* __ctype) 00161 : _M_ctype(__ctype) 00162 { _M_init(); } 00163 00164 void _M_init(); 00165 00166 //explicitely defined as private to avoid warnings: 00167 typedef ctype_byname<char> _Self; 00168 ctype_byname(_Self const&); 00169 _Self& operator = (_Self const&); 00170 00171 mask _M_byname_table[table_size]; 00172 _Locale_ctype* _M_ctype; 00173 }; 00174 00175 # ifndef _STLP_NO_WCHAR_T 00176 _STLP_TEMPLATE_NULL 00177 class _STLP_CLASS_DECLSPEC ctype<wchar_t> : public locale::facet, public ctype_base { 00178 public: 00179 typedef wchar_t char_type; 00180 00181 explicit ctype(size_t __refs = 0) : locale::facet(__refs) {} 00182 00183 bool is(mask __m, wchar_t __c) const 00184 { return do_is(__m, __c); } 00185 00186 const wchar_t* is(const wchar_t* __low, const wchar_t* __high, 00187 mask* __vec) const 00188 { return do_is(__low, __high, __vec); } 00189 00190 const wchar_t* scan_is(mask __m, 00191 const wchar_t* __low, const wchar_t* __high) const 00192 { return do_scan_is(__m, __low, __high); } 00193 00194 const wchar_t* scan_not (mask __m, 00195 const wchar_t* __low, const wchar_t* __high) const 00196 { return do_scan_not(__m, __low, __high); } 00197 00198 wchar_t (toupper)(wchar_t __c) const { return do_toupper(__c); } 00199 const wchar_t* (toupper)(wchar_t* __low, const wchar_t* __high) const 00200 { return do_toupper(__low, __high); } 00201 00202 wchar_t (tolower)(wchar_t __c) const { return do_tolower(__c); } 00203 const wchar_t* (tolower)(wchar_t* __low, const wchar_t* __high) const 00204 { return do_tolower(__low, __high); } 00205 00206 wchar_t widen(char __c) const { return do_widen(__c); } 00207 const char* widen(const char* __low, const char* __high, 00208 wchar_t* __to) const 00209 { return do_widen(__low, __high, __to); } 00210 00211 char narrow(wchar_t __c, char __dfault) const 00212 { return do_narrow(__c, __dfault); } 00213 const wchar_t* narrow(const wchar_t* __low, const wchar_t* __high, 00214 char __dfault, char* __to) const 00215 { return do_narrow(__low, __high, __dfault, __to); } 00216 00217 static _STLP_STATIC_DECLSPEC locale::id id; 00218 00219 protected: 00220 ~ctype(); 00221 00222 virtual bool do_is(mask __m, wchar_t __c) const; 00223 virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const; 00224 virtual const wchar_t* do_scan_is(mask, 00225 const wchar_t*, const wchar_t*) const; 00226 virtual const wchar_t* do_scan_not(mask, 00227 const wchar_t*, const wchar_t*) const; 00228 virtual wchar_t do_toupper(wchar_t __c) const; 00229 virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const; 00230 virtual wchar_t do_tolower(wchar_t c) const; 00231 virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const; 00232 virtual wchar_t do_widen(char c) const; 00233 virtual const char* do_widen(const char*, const char*, wchar_t*) const; 00234 virtual char do_narrow(wchar_t __c, char __dfault) const; 00235 virtual const wchar_t* do_narrow(const wchar_t*, const wchar_t*, 00236 char, char*) const; 00237 }; 00238 00239 _STLP_TEMPLATE_NULL 00240 class _STLP_CLASS_DECLSPEC ctype_byname<wchar_t>: public ctype<wchar_t> { 00241 friend class _Locale_impl; 00242 public: 00243 explicit ctype_byname(const char* __name, size_t __refs = 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 ctype_byname(_Locale_ctype* __ctype) 00261 : _M_ctype(__ctype) {} 00262 00263 //explicitely defined as private to avoid warnings: 00264 typedef ctype_byname<wchar_t> _Self; 00265 ctype_byname(_Self const&); 00266 _Self& operator = (_Self const&); 00267 00268 _Locale_ctype* _M_ctype; 00269 }; 00270 00271 # endif /* WCHAR_T */ 00272 00273 _STLP_END_NAMESPACE 00274 00275 #endif /* _STLP_INTERNAL_CTYPE_H */ 00276 00277 // Local Variables: 00278 // mode:C++ 00279 // End: 00280 Generated on Sat May 26 2012 04:27:32 for ReactOS by
1.7.6.1
|