1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_locale.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_locale.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,22 +1,22 @@
1.4 /*
1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.6 + * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Silicon Graphics Computer Systems, Inc.
1.10 *
1.11 * Copyright (c) 1999
1.12 - * Silicon Graphics Computer Systems, Inc.
1.13 - *
1.14 - * Copyright (c) 1999
1.15 * Boris Fomitchev
1.16 *
1.17 * This material is provided "as is", with absolutely no warranty expressed
1.18 * or implied. Any use is at your own risk.
1.19 *
1.20 - * Permission to use or copy this software for any purpose is hereby granted
1.21 + * Permission to use or copy this software for any purpose is hereby granted
1.22 * without fee, provided the above notices are retained on all copies.
1.23 * Permission to modify the code and to distribute modified code is granted,
1.24 * provided the above notices are retained, and a notice that the code was
1.25 * modified is included with the above copyright notice.
1.26 *
1.27 - */
1.28 + */
1.29 // WARNING: This is an internal header file, included by other C++
1.30 // standard library headers. You should not attempt to use this header
1.31 // file directly.
1.32 @@ -25,88 +25,92 @@
1.33 #ifndef _STLP_INTERNAL_LOCALE_H
1.34 #define _STLP_INTERNAL_LOCALE_H
1.35
1.36 -#ifndef _STLP_CSTDLIB
1.37 -# include <cstdlib>
1.38 +#ifndef _STLP_INTERNAL_CSTDLIB
1.39 +# include <stl/_cstdlib.h>
1.40 #endif
1.41
1.42 -#ifndef _STLP_CWCHAR_H
1.43 -# include <stl/_cwchar.h>
1.44 +#ifndef _STLP_INTERNAL_CWCHAR
1.45 +# include <stl/_cwchar.h>
1.46 #endif
1.47
1.48 #ifndef _STLP_INTERNAL_THREADS_H
1.49 -# include <stl/_threads.h>
1.50 +# include <stl/_threads.h>
1.51 #endif
1.52
1.53 #ifndef _STLP_STRING_FWD_H
1.54 -# include <stl/_string_fwd.h>
1.55 +# include <stl/_string_fwd.h>
1.56 #endif
1.57
1.58 _STLP_BEGIN_NAMESPACE
1.59
1.60 -class _STLP_CLASS_DECLSPEC _Locale_impl; // Forward declaration of opaque type.
1.61 -class _STLP_CLASS_DECLSPEC _Locale; // Forward declaration of opaque type.
1.62 -class _STLP_CLASS_DECLSPEC locale;
1.63 -class _STLP_CLASS_DECLSPEC ios_base;
1.64 -
1.65 +class _Locale_impl; // Forward declaration of opaque type.
1.66 +class ios_base;
1.67 +class locale;
1.68
1.69 template <class _CharT, class _Traits, class _Alloc>
1.70 -bool
1.71 -__locale_do_operator_call (const locale* __that,
1.72 - const basic_string<_CharT, _Traits, _Alloc >& __x,
1.73 - const basic_string<_CharT, _Traits, _Alloc >& __y);
1.74 +bool __locale_do_operator_call (const locale& __loc,
1.75 + const basic_string<_CharT, _Traits, _Alloc>& __x,
1.76 + const basic_string<_CharT, _Traits, _Alloc>& __y);
1.77
1.78 -# define _BaseFacet locale::facet
1.79 +_STLP_DECLSPEC _Locale_impl * _STLP_CALL _get_Locale_impl( _Locale_impl *locimpl );
1.80 +_STLP_DECLSPEC _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl *locimpl );
1.81 +
1.82 +template <class _Facet>
1.83 +bool _HasFacet(const locale& __loc, const _Facet* /*__facet */ ) _STLP_NOTHROW;
1.84 +
1.85 +template <class _Facet>
1.86 +_Facet* _UseFacet(const locale& __loc, const _Facet* /* __facet */);
1.87 +
1.88 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.89 +# define locale _STLP_NO_MEM_T_NAME(loc)
1.90 +#endif
1.91
1.92 class _STLP_CLASS_DECLSPEC locale {
1.93 public:
1.94 // types:
1.95 -
1.96 - class
1.97 -#if defined (__SYMBIAN32__) || defined(__GCCE__)
1.98 - _STLP_CLASS_DECLSPEC
1.99 -#else
1.100 - _STLP_DECLSPEC
1.101 -#endif
1.102 - facet : private _Refcount_Base {
1.103 + class _STLP_CLASS_DECLSPEC facet : protected _Refcount_Base {
1.104 protected:
1.105 - explicit facet(size_t __no_del = 0) : _Refcount_Base(1), _M_delete(__no_del == 0) {}
1.106 -
1.107 + /* Here we filter __init_count user value to 0 or 1 because __init_count is a
1.108 + * size_t instance and _Refcount_Base use __stl_atomic_t instances that might
1.109 + * have lower sizeof and generate roll issues. 1 is enough to keep the facet
1.110 + * alive when required.
1.111 + */
1.112 + explicit facet(size_t __init_count = 0) : _Refcount_Base( __init_count == 0 ? 0 : 1 )
1.113 + { if (__init_count ) {/* do nothing. to avoid warnings */} }
1.114 _STLP_DECLSPEC virtual ~facet();
1.115 friend class locale;
1.116 friend class _Locale_impl;
1.117 - friend class _Locale;
1.118 -
1.119 + friend facet * _STLP_CALL _get_facet( facet * );
1.120 + friend void _STLP_CALL _release_facet( facet *& );
1.121 +
1.122 private: // Invalidate assignment and copying.
1.123 - facet(const facet& __f) : _Refcount_Base(1), _M_delete(__f._M_delete == 0) {};
1.124 - void operator=(const facet&);
1.125 -
1.126 - private: // Data members.
1.127 - const bool _M_delete;
1.128 + facet(const facet& ) /* : _Refcount_Base(1) {} */;
1.129 + void operator=(const facet&);
1.130 };
1.131 -
1.132 -#if defined(__MVS__) || defined(__OS400__)
1.133 +
1.134 +#if defined (__MVS__) || defined (__OS400__)
1.135 struct
1.136 #else
1.137 class
1.138 #endif
1.139 - _STLP_DECLSPEC id {
1.140 + _STLP_CLASS_DECLSPEC id {
1.141 friend class locale;
1.142 friend class _Locale_impl;
1.143 public:
1.144 size_t _M_index;
1.145 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.146 - static _STLP_STATIC_MEMBER_DECLSPEC size_t& get_locale_id_S_max();
1.147 +#if defined(__SYMBIAN32__WSD__)
1.148 + static inline size_t& get_locale_id_S_max();
1.149 # else
1.150 static size_t _S_max;
1.151 # endif
1.152 };
1.153
1.154 typedef int category;
1.155 -# if defined (_STLP_STATIC_CONST_INIT_BUG)
1.156 +#if defined (_STLP_STATIC_CONST_INIT_BUG)
1.157 enum _Category {
1.158 -# else
1.159 +#else
1.160 static const category
1.161 -# endif
1.162 +#endif
1.163 none = 0x000,
1.164 collate = 0x010,
1.165 ctype = 0x020,
1.166 @@ -115,140 +119,222 @@
1.167 time = 0x200,
1.168 messages = 0x400,
1.169 all = collate | ctype | monetary | numeric | time | messages
1.170 -# if defined (_STLP_STATIC_CONST_INIT_BUG)
1.171 +#if defined (_STLP_STATIC_CONST_INIT_BUG)
1.172 }
1.173 -# endif
1.174 +#endif
1.175 ;
1.176
1.177 // construct/copy/destroy:
1.178 - _STLP_DECLSPEC locale();
1.179 + _STLP_DECLSPEC locale() _STLP_NOTHROW;
1.180 _STLP_DECLSPEC locale(const locale&) _STLP_NOTHROW;
1.181 - explicit locale(const char *);
1.182 + _STLP_DECLSPEC explicit locale(const char *);
1.183 locale(const locale&, const char*, category);
1.184
1.185 +#if defined(__SYMBIAN32__WSD__) || defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
1.186 +#define id GetFacetLocaleId()
1.187 +#endif
1.188 +
1.189 +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.190 + template <class _Facet>
1.191 + locale(const locale& __loc, _Facet* __f) {
1.192 + if ( __f != 0 ) {
1.193 + this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) );
1.194 + this->_M_insert(__f, _Facet::id);
1.195 + } else {
1.196 + this->_M_impl = _get_Locale_impl( __loc._M_impl );
1.197 + }
1.198 + }
1.199 +#if defined(__SYMBIAN32__WSD__) || defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
1.200 +#undef id
1.201 +#endif
1.202 +#endif // _STLP_MEMBER_TEMPLATES
1.203 +
1.204 +protected:
1.205 // those are for internal use
1.206 locale(_Locale_impl*);
1.207 - locale(_Locale_impl*, bool);
1.208
1.209 public:
1.210
1.211 -# if defined ( _STLP_MEMBER_TEMPLATES ) /* && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) */
1.212 - template <class _Facet>
1.213 - locale(const locale& __loc, _Facet* __f) : _M_impl(0)
1.214 - {
1.215 - // _M_impl = this->_S_copy_impl(__loc._M_impl, __f != 0);
1.216 - new(this) locale(__loc._M_impl, __f != 0);
1.217 - if (__f != 0)
1.218 - this->_M_insert((facet*)__f, _Facet::GetFacetLocaleId());
1.219 - }
1.220 -# endif
1.221 -
1.222 locale(const locale&, const locale&, category);
1.223 - _STLP_DECLSPEC ~locale() _STLP_NOTHROW;
1.224 _STLP_DECLSPEC const locale& operator=(const locale&) _STLP_NOTHROW;
1.225
1.226 -# if !(defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS))
1.227 - template <class _Facet> locale combine(const locale& __loc) const{
1.228 - locale __result(__loc._M_impl, true);
1.229 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.230 - if (facet* __f = __loc._M_get_facet(_Facet::GetFacetLocaleId())) {
1.231 - __result._M_insert((facet*)__f, _Facet::GetFacetLocaleId());
1.232 -#else
1.233 - if (facet* __f = __loc._M_get_facet(_Facet::id)) {
1.234 - __result._M_insert((facet*)__f, _Facet::id);
1.235 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.236 + virtual
1.237 #endif
1.238 - __f->_M_incr();
1.239 - }
1.240 - else
1.241 - _M_throw_runtime_error();
1.242 - return __result;
1.243 + _STLP_DECLSPEC ~locale() _STLP_NOTHROW;
1.244 +
1.245 +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && \
1.246 + !defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.247 + template <class _Facet>
1.248 + locale combine(const locale& __loc) const {
1.249 + _Facet *__facet = 0;
1.250 + if (!_HasFacet(__loc, __facet))
1.251 + _M_throw_runtime_error();
1.252 +
1.253 + return locale(*this, _UseFacet(__loc, __facet));
1.254 }
1.255 -# endif
1.256 +#endif // _STLP_MEMBER_TEMPLATES && !_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.257 +
1.258 // locale operations:
1.259 - _STLP_DECLSPEC string name() const;
1.260 + _STLP_DECLSPEC string name() const;
1.261
1.262 _STLP_DECLSPEC bool operator==(const locale&) const;
1.263 _STLP_DECLSPEC bool operator!=(const locale&) const;
1.264
1.265 -# if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
1.266 - bool operator()(const string& __x, const string& __y) const;
1.267 +#if !defined (_STLP_MEMBER_TEMPLATES) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
1.268 + _STLP_DECLSPEC bool operator()(const string& __x, const string& __y) const;
1.269 # ifndef _STLP_NO_WCHAR_T
1.270 - bool operator()(const wstring& __x, const wstring& __y) const;
1.271 + _STLP_DECLSPEC bool operator()(const wstring& __x, const wstring& __y) const;
1.272 # endif
1.273 -# else
1.274 +#elif !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.275 template <class _CharT, class _Traits, class _Alloc>
1.276 bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
1.277 - const basic_string<_CharT, _Traits, _Alloc>& __y) const {
1.278 - return __locale_do_operator_call(this, __x, __y);
1.279 - }
1.280 -# endif
1.281 + const basic_string<_CharT, _Traits, _Alloc>& __y) const
1.282 + { return __locale_do_operator_call(*this, __x, __y); }
1.283 +#endif
1.284
1.285 // global locale objects:
1.286 _STLP_DECLSPEC static locale _STLP_CALL global(const locale&);
1.287 _STLP_DECLSPEC static const locale& _STLP_CALL classic();
1.288
1.289 -public: // Helper functions for locale globals.
1.290 +//protected: // Helper functions for locale globals.
1.291 _STLP_DECLSPEC facet* _M_get_facet(const id&) const;
1.292 // same, but throws
1.293 _STLP_DECLSPEC facet* _M_use_facet(const id&) const;
1.294 - _STLP_DECLSPEC static void _STLP_CALL _M_throw_runtime_error(const char* = 0);
1.295 - static void _STLP_CALL _S_initialize();
1.296 - static void _STLP_CALL _S_uninitialize();
1.297 + _STLP_DECLSPEC static void _STLP_FUNCTION_THROWS _M_throw_runtime_error(const char* = 0);
1.298
1.299 -private: // More helper functions.
1.300 - // static _Locale_impl* _STLP_CALL _S_copy_impl(_Locale_impl*, bool);
1.301 +protected: // More helper functions.
1.302 _STLP_DECLSPEC void _M_insert(facet* __f, id& __id);
1.303
1.304 // friends:
1.305 friend class _Locale_impl;
1.306 - friend class _Locale;
1.307 friend class ios_base;
1.308
1.309 -private: // Data members
1.310 +protected: // Data members
1.311 _Locale_impl* _M_impl;
1.312 + _Locale_impl* _M_get_impl() const { return _M_impl; }
1.313 };
1.314
1.315 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.316 +# undef locale
1.317 +# define _Locale _STLP_NO_MEM_T_NAME(loc)
1.318 +
1.319 +class locale : public _Locale {
1.320 +public:
1.321 +
1.322 + // construct/copy/destroy:
1.323 + _STLP_DECLSPEC locale() _STLP_NOTHROW {}
1.324 + locale(const locale& __loc) _STLP_NOTHROW : _Locale(__loc) {}
1.325 + explicit locale(const char *__str) : _Locale(__str) {}
1.326 + locale(const locale& __loc, const char* __str, category __cat)
1.327 + : _Locale(__loc, __str, __cat) {}
1.328 +
1.329 + template <class _Facet>
1.330 + locale(const locale& __loc, _Facet* __f) {
1.331 + if ( __f != 0 ) {
1.332 + this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) );
1.333 + this->_M_insert(__f, _Facet::id);
1.334 + } else {
1.335 + this->_M_impl = _get_Locale_impl( __loc._M_impl );
1.336 + }
1.337 + }
1.338 +
1.339 +private:
1.340 + // those are for internal use
1.341 + locale(_Locale_impl* __impl) : _Locale(__impl) {}
1.342 + locale(const _Locale& __loc) : _Locale(__loc) {}
1.343 +
1.344 +public:
1.345 +
1.346 + locale(const locale& __loc1, const locale& __loc2, category __cat)
1.347 + : _Locale(__loc1, __loc2, __cat) {}
1.348 +
1.349 + const locale& operator=(const locale& __loc) _STLP_NOTHROW {
1.350 + _Locale::operator=(__loc);
1.351 + return *this;
1.352 + }
1.353 +
1.354 + template <class _Facet>
1.355 + locale combine(const locale& __loc) const {
1.356 + _Facet *__facet = 0;
1.357 + if (!_HasFacet(__loc, __facet))
1.358 + _M_throw_runtime_error();
1.359 +
1.360 + return locale(*this, _UseFacet(__loc, __facet));
1.361 + }
1.362 +
1.363 + // locale operations:
1.364 + bool operator==(const locale& __loc) const { return _Locale::operator==(__loc); }
1.365 + bool operator!=(const locale& __loc) const { return _Locale::operator!=(__loc); }
1.366 +
1.367 + template <class _CharT, class _Traits, class _Alloc>
1.368 + bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
1.369 + const basic_string<_CharT, _Traits, _Alloc>& __y) const
1.370 + { return __locale_do_operator_call(*this, __x, __y); }
1.371 +
1.372 + // global locale objects:
1.373 + static locale _STLP_CALL global(const locale& __loc) {
1.374 + return _Locale::global(__loc);
1.375 + }
1.376 + static const locale& _STLP_CALL classic() {
1.377 + return __STATIC_CAST(const locale&, _Locale::classic());
1.378 + }
1.379 +
1.380 + // friends:
1.381 + friend class _Locale_impl;
1.382 + friend class ios_base;
1.383 +};
1.384 +
1.385 +#endif /* _STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND */
1.386 +
1.387 //----------------------------------------------------------------------
1.388 // locale globals
1.389
1.390 -# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.391 +#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.392 template <class _Facet>
1.393 -inline const _Facet&
1.394 +inline const _Facet&
1.395 _Use_facet<_Facet>::operator *() const
1.396 -# else
1.397 +#else
1.398 template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
1.399 -# endif
1.400 +#endif
1.401 {
1.402 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.403 - return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::GetFacetLocaleId()));
1.404 -#else
1.405 - return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id));
1.406 -#endif
1.407 + _Facet *__facet = 0;
1.408 + return *_UseFacet(__loc, __facet);
1.409 }
1.410
1.411 -
1.412 -# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.413 -template <class _Facet>
1.414 +
1.415 +#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.416 +template <class _Facet>
1.417 struct has_facet {
1.418 const locale& __loc;
1.419 has_facet(const locale& __p_loc) : __loc(__p_loc) {}
1.420 operator bool() const _STLP_NOTHROW
1.421 -# else
1.422 -template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW
1.423 -# endif
1.424 +#else
1.425 +template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW
1.426 +#endif
1.427 {
1.428 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.429 - return (__loc._M_get_facet(_Facet::GetFacetLocaleId()) != 0);
1.430 -#else
1.431 - return (__loc._M_get_facet(_Facet::id) != 0);
1.432 -#endif
1.433 + _Facet *__facet = 0;
1.434 + return _HasFacet(__loc, __facet);
1.435 }
1.436
1.437 -# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.438 - // close class definition
1.439 -};
1.440 -# endif
1.441 +#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.442 +}; // close class definition
1.443 +#endif
1.444 +#if defined(__SYMBIAN32__WSD__) || defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
1.445 +#define id GetFacetLocaleId()
1.446 +#endif
1.447
1.448 +template <class _Facet>
1.449 +bool _HasFacet(const locale& __loc, const _Facet* ) _STLP_NOTHROW
1.450 +{ return (__loc._M_get_facet(_Facet::id) != 0); }
1.451 +
1.452 +template <class _Facet>
1.453 +_Facet* _UseFacet(const locale& __loc, const _Facet* )
1.454 +{ return __STATIC_CAST(_Facet*, __loc._M_use_facet(_Facet::id)); }
1.455 +
1.456 +#if defined(__SYMBIAN32__WSD__) || defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
1.457 +#undef id
1.458 +#endif
1.459 _STLP_END_NAMESPACE
1.460
1.461 #endif /* _STLP_INTERNAL_LOCALE_H */