00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _STLP_INTERNAL_LOCALE_H
00024 #define _STLP_INTERNAL_LOCALE_H
00025
00026 #ifndef _STLP_CSTDLIB
00027 # include <cstdlib>
00028 #endif
00029
00030 #ifndef _STLP_CWCHAR
00031 # include <cwchar>
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 _STLP_BEGIN_NAMESPACE
00043
00044 class _STLP_CLASS_DECLSPEC _Locale_impl;
00045 class _STLP_CLASS_DECLSPEC _Locale;
00046 class _STLP_CLASS_DECLSPEC locale;
00047 class _STLP_CLASS_DECLSPEC ios_base;
00048
00049
00050 template <class _CharT>
00051 bool
00052 __locale_do_operator_call (const locale* __that,
00053 const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >& __x,
00054 const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >& __y);
00055
00056 # define _BaseFacet locale::facet
00057
00058 class _STLP_CLASS_DECLSPEC locale {
00059 public:
00060
00061
00062 class _STLP_DECLSPEC facet : private _Refcount_Base {
00063 protected:
00064 explicit facet(size_t __no_del = 0) : _Refcount_Base(1), _M_delete(__no_del == 0) {}
00065 virtual ~facet();
00066 friend class locale;
00067 friend class _Locale_impl;
00068 friend class _Locale;
00069
00070 private:
00071 facet(const facet& __f) : _Refcount_Base(1), _M_delete(__f._M_delete == 0) {};
00072 void operator=(const facet&);
00073
00074 private:
00075 const bool _M_delete;
00076 };
00077
00078 #if defined(__MVS__) || defined(__OS400__)
00079 struct
00080 #else
00081 class
00082 #endif
00083 _STLP_DECLSPEC id {
00084 friend class locale;
00085 friend class _Locale_impl;
00086 public:
00087 size_t _M_index;
00088 static size_t _S_max;
00089 };
00090
00091 typedef int category;
00092 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00093 enum _Category {
00094 # else
00095 static const category
00096 # endif
00097 none = 0x000,
00098 collate = 0x010,
00099 ctype = 0x020,
00100 monetary = 0x040,
00101 numeric = 0x100,
00102 time = 0x200,
00103 messages = 0x400,
00104 all = collate | ctype | monetary | numeric | time | messages
00105 # if defined (_STLP_STATIC_CONST_INIT_BUG)
00106 }
00107 # endif
00108 ;
00109
00110
00111 locale();
00112 locale(const locale&) _STLP_NOTHROW;
00113 explicit locale(const char *);
00114 locale(const locale&, const char*, category);
00115
00116
00117 locale(_Locale_impl*);
00118 locale(_Locale_impl*, bool);
00119
00120 public:
00121
00122 # if defined ( _STLP_MEMBER_TEMPLATES )
00123 template <class _Facet>
00124 locale(const locale& __loc, _Facet* __f) : _M_impl(0)
00125 {
00126
00127 new(this) locale(__loc._M_impl, __f != 0);
00128 if (__f != 0)
00129 this->_M_insert(__f, _Facet::id);
00130 }
00131 # endif
00132
00133 locale(const locale&, const locale&, category);
00134 ~locale() _STLP_NOTHROW;
00135 const locale& operator=(const locale&) _STLP_NOTHROW;
00136
00137 # if !(defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS))
00138 template <class _Facet> locale combine(const locale& __loc) {
00139 locale __result(__loc._M_impl, true);
00140 if (facet* __f = __loc._M_get_facet(_Facet::id)) {
00141 __result._M_insert(__f, _Facet::id);
00142 __f->_M_incr();
00143 }
00144 else
00145 _M_throw_runtime_error();
00146 return __result;
00147 }
00148 # endif
00149
00150 string name() const;
00151
00152 bool operator==(const locale&) const;
00153 bool operator!=(const locale&) const;
00154
00155 # if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
00156 bool operator()(const string& __x, const string& __y) const;
00157 # ifndef _STLP_NO_WCHAR_T
00158 bool operator()(const wstring& __x, const wstring& __y) const;
00159 # endif
00160 # else
00161 template <class _CharT, class _Traits, class _Alloc>
00162 bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
00163 const basic_string<_CharT, _Traits, _Alloc>& __y) const {
00164 return __locale_do_operator_call(this, __x, __y);
00165 }
00166 # endif
00167
00168
00169 static locale _STLP_CALL global(const locale&);
00170 static const locale& _STLP_CALL classic();
00171
00172 public:
00173 facet* _M_get_facet(const id&) const;
00174
00175 facet* _M_use_facet(const id&) const;
00176 static void _STLP_CALL _M_throw_runtime_error(const char* = 0);
00177 static void _STLP_CALL _S_initialize();
00178 static void _STLP_CALL _S_uninitialize();
00179
00180 private:
00181
00182 void _M_insert(facet* __f, id& __id);
00183
00184
00185 friend class _Locale_impl;
00186 friend class _Locale;
00187 friend class ios_base;
00188
00189 private:
00190 _Locale_impl* _M_impl;
00191 };
00192
00193
00194
00195
00196 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
00197 template <class _Facet>
00198 inline const _Facet&
00199 _Use_facet<_Facet>::operator *() const
00200 # else
00201 template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
00202 # endif
00203 {
00204 return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id));
00205 }
00206
00207
00208 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
00209 template <class _Facet>
00210 struct has_facet {
00211 const locale& __loc;
00212 has_facet(const locale& __p_loc) : __loc(__p_loc) {}
00213 operator bool() const _STLP_NOTHROW
00214 # else
00215 template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW
00216 # endif
00217 {
00218 return (__loc._M_get_facet(_Facet::id) != 0);
00219 }
00220
00221 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
00222
00223 };
00224 # endif
00225
00226 _STLP_END_NAMESPACE
00227
00228 #endif
00229
00230
00231
00232
00233