2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
5 * Silicon Graphics Computer Systems, Inc.
10 * This material is provided "as is", with absolutely no warranty expressed
11 * or implied. Any use is at your own risk.
13 * Permission to use or copy this software for any purpose is hereby granted
14 * without fee, provided the above notices are retained on all copies.
15 * Permission to modify the code and to distribute modified code is granted,
16 * provided the above notices are retained, and a notice that the code was
17 * modified is included with the above copyright notice.
20 // WARNING: This is an internal header file, included by other C++
21 // standard library headers. You should not attempt to use this header
25 #ifndef _STLP_INTERNAL_LOCALE_H
26 #define _STLP_INTERNAL_LOCALE_H
32 #ifndef _STLP_CWCHAR_H
33 # include <stl/_cwchar.h>
36 #ifndef _STLP_INTERNAL_THREADS_H
37 # include <stl/_threads.h>
40 #ifndef _STLP_STRING_FWD_H
41 # include <stl/_string_fwd.h>
46 class _STLP_CLASS_DECLSPEC _Locale_impl; // Forward declaration of opaque type.
47 class _STLP_CLASS_DECLSPEC _Locale; // Forward declaration of opaque type.
48 class _STLP_CLASS_DECLSPEC locale;
49 class _STLP_CLASS_DECLSPEC ios_base;
52 template <class _CharT, class _Traits, class _Alloc>
54 __locale_do_operator_call (const locale* __that,
55 const basic_string<_CharT, _Traits, _Alloc >& __x,
56 const basic_string<_CharT, _Traits, _Alloc >& __y);
58 # define _BaseFacet locale::facet
60 class _STLP_CLASS_DECLSPEC locale {
65 #if defined (__SYMBIAN32__) || defined(__GCCE__)
70 facet : private _Refcount_Base {
72 explicit facet(size_t __no_del = 0) : _Refcount_Base(1), _M_delete(__no_del == 0) {}
74 _STLP_DECLSPEC virtual ~facet();
76 friend class _Locale_impl;
79 private: // Invalidate assignment and copying.
80 facet(const facet& __f) : _Refcount_Base(1), _M_delete(__f._M_delete == 0) {};
81 void operator=(const facet&);
83 private: // Data members.
87 #if defined(__MVS__) || defined(__OS400__)
94 friend class _Locale_impl;
97 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
98 static _STLP_STATIC_MEMBER_DECLSPEC size_t& get_locale_id_S_max();
100 static size_t _S_max;
104 typedef int category;
105 # if defined (_STLP_STATIC_CONST_INIT_BUG)
108 static const category
117 all = collate | ctype | monetary | numeric | time | messages
118 # if defined (_STLP_STATIC_CONST_INIT_BUG)
123 // construct/copy/destroy:
124 _STLP_DECLSPEC locale();
125 _STLP_DECLSPEC locale(const locale&) _STLP_NOTHROW;
126 explicit locale(const char *);
127 locale(const locale&, const char*, category);
129 // those are for internal use
130 locale(_Locale_impl*);
131 locale(_Locale_impl*, bool);
135 # if defined ( _STLP_MEMBER_TEMPLATES ) /* && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) */
136 template <class _Facet>
137 locale(const locale& __loc, _Facet* __f) : _M_impl(0)
139 // _M_impl = this->_S_copy_impl(__loc._M_impl, __f != 0);
140 new(this) locale(__loc._M_impl, __f != 0);
142 this->_M_insert((facet*)__f, _Facet::GetFacetLocaleId());
146 locale(const locale&, const locale&, category);
147 _STLP_DECLSPEC ~locale() _STLP_NOTHROW;
148 _STLP_DECLSPEC const locale& operator=(const locale&) _STLP_NOTHROW;
150 # if !(defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS))
151 template <class _Facet> locale combine(const locale& __loc) const{
152 locale __result(__loc._M_impl, true);
153 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
154 if (facet* __f = __loc._M_get_facet(_Facet::GetFacetLocaleId())) {
155 __result._M_insert((facet*)__f, _Facet::GetFacetLocaleId());
157 if (facet* __f = __loc._M_get_facet(_Facet::id)) {
158 __result._M_insert((facet*)__f, _Facet::id);
163 _M_throw_runtime_error();
167 // locale operations:
168 _STLP_DECLSPEC string name() const;
170 _STLP_DECLSPEC bool operator==(const locale&) const;
171 _STLP_DECLSPEC bool operator!=(const locale&) const;
173 # if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
174 bool operator()(const string& __x, const string& __y) const;
175 # ifndef _STLP_NO_WCHAR_T
176 bool operator()(const wstring& __x, const wstring& __y) const;
179 template <class _CharT, class _Traits, class _Alloc>
180 bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
181 const basic_string<_CharT, _Traits, _Alloc>& __y) const {
182 return __locale_do_operator_call(this, __x, __y);
186 // global locale objects:
187 _STLP_DECLSPEC static locale _STLP_CALL global(const locale&);
188 _STLP_DECLSPEC static const locale& _STLP_CALL classic();
190 public: // Helper functions for locale globals.
191 _STLP_DECLSPEC facet* _M_get_facet(const id&) const;
193 _STLP_DECLSPEC facet* _M_use_facet(const id&) const;
194 _STLP_DECLSPEC static void _STLP_CALL _M_throw_runtime_error(const char* = 0);
195 static void _STLP_CALL _S_initialize();
196 static void _STLP_CALL _S_uninitialize();
198 private: // More helper functions.
199 // static _Locale_impl* _STLP_CALL _S_copy_impl(_Locale_impl*, bool);
200 _STLP_DECLSPEC void _M_insert(facet* __f, id& __id);
203 friend class _Locale_impl;
204 friend class _Locale;
205 friend class ios_base;
207 private: // Data members
208 _Locale_impl* _M_impl;
211 //----------------------------------------------------------------------
214 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
215 template <class _Facet>
217 _Use_facet<_Facet>::operator *() const
219 template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
222 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
223 return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::GetFacetLocaleId()));
225 return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id));
230 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
231 template <class _Facet>
234 has_facet(const locale& __p_loc) : __loc(__p_loc) {}
235 operator bool() const _STLP_NOTHROW
237 template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW
240 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
241 return (__loc._M_get_facet(_Facet::GetFacetLocaleId()) != 0);
243 return (__loc._M_get_facet(_Facet::id) != 0);
247 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
248 // close class definition
254 #endif /* _STLP_INTERNAL_LOCALE_H */