Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_locale.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 00023 #ifndef _STLP_INTERNAL_LOCALE_H 00024 #define _STLP_INTERNAL_LOCALE_H 00025 00026 #ifndef _STLP_INTERNAL_CSTDLIB 00027 # include <stl/_cstdlib.h> 00028 #endif 00029 00030 #ifndef _STLP_INTERNAL_CWCHAR 00031 # include <stl/_cwchar.h> 00032 #endif 00033 00034 #ifndef _STLP_INTERNAL_THREADS_H 00035 # include <stl/_threads.h> 00036 #endif 00037 00038 #ifndef _STLP_STRING_FWD_H 00039 # include <stl/_string_fwd.h> 00040 #endif 00041 00042 #include <stl/_facets_fwd.h> 00043 00044 _STLP_BEGIN_NAMESPACE 00045 00046 class _Locale_impl; // Forward declaration of opaque type. 00047 class locale; 00048 00049 template <class _CharT, class _Traits, class _Alloc> 00050 bool __locale_do_operator_call(const locale& __loc, 00051 const basic_string<_CharT, _Traits, _Alloc>& __x, 00052 const basic_string<_CharT, _Traits, _Alloc>& __y); 00053 00054 _STLP_DECLSPEC _Locale_impl * _STLP_CALL _get_Locale_impl( _Locale_impl *locimpl ); 00055 _STLP_DECLSPEC _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl *locimpl ); 00056 00057 _STLP_MOVE_TO_PRIV_NAMESPACE 00058 00059 template <class _Facet> 00060 bool _HasFacet(const locale& __loc, const _Facet* __facet) _STLP_NOTHROW; 00061 00062 template <class _Facet> 00063 _Facet* _UseFacet(const locale& __loc, const _Facet* __facet); 00064 00065 template <class _Facet> 00066 void _InsertFacet(locale& __loc, _Facet* __facet); 00067 00068 _STLP_MOVE_TO_STD_NAMESPACE 00069 00070 #if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ 00071 defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) 00072 # define locale _STLP_NO_MEM_T_NAME(loc) 00073 #endif 00074 00075 class _STLP_CLASS_DECLSPEC locale { 00076 public: 00077 // types: 00078 class _STLP_CLASS_DECLSPEC facet : protected _Refcount_Base { 00079 protected: 00080 /* Here we filter __init_count user value to 0 or 1 because __init_count is a 00081 * size_t instance and _Refcount_Base use __stl_atomic_t instances that might 00082 * have lower sizeof and generate roll issues. 1 is enough to keep the facet 00083 * alive when required. */ 00084 explicit facet(size_t __init_count = 0) : _Refcount_Base( __init_count == 0 ? 0 : 1 ) {} 00085 virtual ~facet(); 00086 friend class locale; 00087 friend class _Locale_impl; 00088 friend facet * _STLP_CALL _get_facet( facet * ); 00089 friend void _STLP_CALL _release_facet( facet *& ); 00090 00091 private: // Invalidate assignment and copying. 00092 facet(const facet& ) /* : _Refcount_Base(1) {} */; 00093 void operator=(const facet&); 00094 }; 00095 00096 #if defined (__MVS__) || defined (__OS400__) 00097 struct 00098 #else 00099 class 00100 #endif 00101 _STLP_CLASS_DECLSPEC id { 00102 public: 00103 size_t _M_index; 00104 static size_t _S_max; 00105 }; 00106 00107 typedef int category; 00108 _STLP_STATIC_CONSTANT(category, none = 0x000); 00109 _STLP_STATIC_CONSTANT(category, collate = 0x010); 00110 _STLP_STATIC_CONSTANT(category, ctype = 0x020); 00111 _STLP_STATIC_CONSTANT(category, monetary = 0x040); 00112 _STLP_STATIC_CONSTANT(category, numeric = 0x100); 00113 _STLP_STATIC_CONSTANT(category, time = 0x200); 00114 _STLP_STATIC_CONSTANT(category, messages = 0x400); 00115 _STLP_STATIC_CONSTANT(category, all = collate | ctype | monetary | numeric | time | messages); 00116 00117 // construct/copy/destroy: 00118 locale() _STLP_NOTHROW; 00119 locale(const locale&) _STLP_NOTHROW; 00120 explicit locale(const char *); 00121 locale(const locale&, const char*, category); 00122 00123 #if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00124 template <class _Facet> 00125 locale(const locale& __loc, _Facet* __f) { 00126 if ( __f != 0 ) { 00127 this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) ); 00128 _STLP_PRIV _InsertFacet(*this, __f); 00129 } else { 00130 this->_M_impl = _get_Locale_impl( __loc._M_impl ); 00131 } 00132 } 00133 #endif 00134 00135 protected: 00136 // those are for internal use 00137 locale(_Locale_impl*); 00138 00139 public: 00140 locale(const locale&, const locale&, category); 00141 const locale& operator=(const locale&) _STLP_NOTHROW; 00142 00143 #if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00144 protected: 00145 #endif 00146 ~locale() _STLP_NOTHROW; 00147 00148 public: 00149 #if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && \ 00150 !defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00151 template <class _Facet> 00152 locale combine(const locale& __loc) const { 00153 _Facet *__facet = 0; 00154 if (!_STLP_PRIV _HasFacet(__loc, __facet)) 00155 _M_throw_on_combine_error(__loc.name()); 00156 00157 return locale(*this, _STLP_PRIV _UseFacet(__loc, __facet)); 00158 } 00159 #endif 00160 00161 // locale operations: 00162 string name() const; 00163 00164 bool operator==(const locale&) const; 00165 bool operator!=(const locale&) const; 00166 00167 #if !defined (_STLP_MEMBER_TEMPLATES) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301) 00168 bool operator()(const string& __x, const string& __y) const; 00169 # ifndef _STLP_NO_WCHAR_T 00170 bool operator()(const wstring& __x, const wstring& __y) const; 00171 # endif 00172 #elif !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00173 template <class _CharT, class _Traits, class _Alloc> 00174 bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x, 00175 const basic_string<_CharT, _Traits, _Alloc>& __y) const 00176 { return __locale_do_operator_call(*this, __x, __y); } 00177 #endif 00178 00179 // global locale objects: 00180 #if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00181 static locale _STLP_CALL global(const locale&); 00182 #else 00183 static _Locale_impl* _STLP_CALL global(const locale&); 00184 #endif 00185 static const locale& _STLP_CALL classic(); 00186 00187 //protected: // Helper functions for locale globals. 00188 facet* _M_get_facet(const id&) const; 00189 // same, but throws 00190 facet* _M_use_facet(const id&) const; 00191 static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_combine_error(const string& name); 00192 static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_null_name(); 00193 static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_creation_failure(int __err_code, 00194 const char* name, const char* facet); 00195 00196 //protected: // More helper functions. 00197 void _M_insert(facet* __f, id& __id); 00198 00199 // friends: 00200 friend class _Locale_impl; 00201 00202 protected: // Data members 00203 _Locale_impl* _M_impl; 00204 _Locale_impl* _M_get_impl() const { return _M_impl; } 00205 }; 00206 00207 #if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ 00208 defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) 00209 # undef locale 00210 # define _Locale _STLP_NO_MEM_T_NAME(loc) 00211 00212 class locale : public _Locale { 00213 public: 00214 00215 // construct/copy/destroy: 00216 locale() _STLP_NOTHROW { 00217 #if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) 00218 _STLP_CHECK_RUNTIME_COMPATIBILITY(); 00219 #endif 00220 } 00221 locale(const locale& __loc) _STLP_NOTHROW : _Locale(__loc) {} 00222 explicit locale(const char *__str) : _Locale(__str) {} 00223 locale(const locale& __loc, const char* __str, category __cat) 00224 : _Locale(__loc, __str, __cat) {} 00225 00226 template <class _Facet> 00227 locale(const locale& __loc, _Facet* __f) 00228 : _Locale(__f != 0 ? _copy_Nameless_Locale_impl(__loc._M_impl) : __loc._M_impl) { 00229 if ( __f != 0 ) { 00230 _STLP_PRIV _InsertFacet(*this, __f); 00231 } 00232 } 00233 00234 private: 00235 // those are for internal use 00236 locale(_Locale_impl* __impl) : _Locale(__impl) {} 00237 locale(const _Locale& __loc) : _Locale(__loc) {} 00238 00239 public: 00240 00241 locale(const locale& __loc1, const locale& __loc2, category __cat) 00242 : _Locale(__loc1, __loc2, __cat) {} 00243 00244 const locale& operator=(const locale& __loc) _STLP_NOTHROW { 00245 _Locale::operator=(__loc); 00246 return *this; 00247 } 00248 00249 template <class _Facet> 00250 locale combine(const locale& __loc) const { 00251 _Facet *__facet = 0; 00252 if (!_STLP_PRIV _HasFacet(__loc, __facet)) 00253 _M_throw_on_combine_error(__loc.name()); 00254 00255 return locale(*this, _STLP_PRIV _UseFacet(__loc, __facet)); 00256 } 00257 00258 // locale operations: 00259 bool operator==(const locale& __loc) const { return _Locale::operator==(__loc); } 00260 bool operator!=(const locale& __loc) const { return _Locale::operator!=(__loc); } 00261 00262 template <class _CharT, class _Traits, class _Alloc> 00263 bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x, 00264 const basic_string<_CharT, _Traits, _Alloc>& __y) const 00265 { return __locale_do_operator_call(*this, __x, __y); } 00266 00267 // global locale objects: 00268 static locale _STLP_CALL global(const locale& __loc) { 00269 return _Locale::global(__loc); 00270 } 00271 static const locale& _STLP_CALL classic() { 00272 return __STATIC_CAST(const locale&, _Locale::classic()); 00273 } 00274 00275 // friends: 00276 friend class _Locale_impl; 00277 }; 00278 00279 # undef _Locale 00280 #endif 00281 00282 //---------------------------------------------------------------------- 00283 // locale globals 00284 00285 template <class _Facet> 00286 inline const _Facet& 00287 #ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 00288 _Use_facet<_Facet>::operator *() const 00289 #else 00290 use_facet(const locale& __loc) 00291 #endif 00292 { 00293 _Facet *__facet = 0; 00294 return *(_STLP_PRIV _UseFacet(__loc, __facet)); 00295 } 00296 00297 template <class _Facet> 00298 #ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 00299 struct has_facet { 00300 const locale& __loc; 00301 has_facet(const locale& __p_loc) : __loc(__p_loc) {} 00302 operator bool() const _STLP_NOTHROW 00303 #else 00304 inline bool has_facet(const locale& __loc) _STLP_NOTHROW 00305 #endif 00306 { 00307 _Facet *__facet = 0; 00308 return _STLP_PRIV _HasFacet(__loc, __facet); 00309 } 00310 00311 #ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS 00312 }; // close class definition 00313 #endif 00314 00315 _STLP_MOVE_TO_PRIV_NAMESPACE 00316 00317 /* _GetFacetId is a helper function that allow delaying access to 00318 * facet id static instance in the library source code to avoid 00319 * the other static instances that many compilers are generating 00320 * in all dynamic library or executable when instanciating facet 00321 * template class. 00322 */ 00323 template <class _Facet> 00324 inline locale::id& _GetFacetId(const _Facet*) 00325 { return _Facet::id; } 00326 00327 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<char, istreambuf_iterator<char, char_traits<char> > >*); 00328 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<char, ostreambuf_iterator<char, char_traits<char> > >*); 00329 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<char, istreambuf_iterator<char, char_traits<char> > >*); 00330 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<char, ostreambuf_iterator<char, char_traits<char> > >*); 00331 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<char, istreambuf_iterator<char, char_traits<char> > >*); 00332 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<char, ostreambuf_iterator<char, char_traits<char> > >*); 00333 00334 #ifndef _STLP_NO_WCHAR_T 00335 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*); 00336 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*); 00337 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*); 00338 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*); 00339 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*); 00340 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*); 00341 #endif 00342 00343 template <class _Facet> 00344 inline bool _HasFacet(const locale& __loc, const _Facet* __facet) _STLP_NOTHROW 00345 { return (__loc._M_get_facet(_GetFacetId(__facet)) != 0); } 00346 00347 template <class _Facet> 00348 inline _Facet* _UseFacet(const locale& __loc, const _Facet* __facet) 00349 { return __STATIC_CAST(_Facet*, __loc._M_use_facet(_GetFacetId(__facet))); } 00350 00351 template <class _Facet> 00352 inline void _InsertFacet(locale& __loc, _Facet* __facet) 00353 { __loc._M_insert(__facet, _GetFacetId(__facet)); } 00354 00355 _STLP_MOVE_TO_STD_NAMESPACE 00356 00357 _STLP_END_NAMESPACE 00358 00359 #endif /* _STLP_INTERNAL_LOCALE_H */ 00360 00361 // Local Variables: 00362 // mode:C++ 00363 // End: 00364 Generated on Sat May 26 2012 04:27:51 for ReactOS by
1.7.6.1
|