1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/tools/stlport/stl/_locale.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,317 @@
1.4 +/*
1.5 + * Copyright (c) 1999
1.6 + * Silicon Graphics Computer Systems, Inc.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Boris Fomitchev
1.10 + *
1.11 + * This material is provided "as is", with absolutely no warranty expressed
1.12 + * or implied. Any use is at your own risk.
1.13 + *
1.14 + * Permission to use or copy this software for any purpose is hereby granted
1.15 + * without fee, provided the above notices are retained on all copies.
1.16 + * Permission to modify the code and to distribute modified code is granted,
1.17 + * provided the above notices are retained, and a notice that the code was
1.18 + * modified is included with the above copyright notice.
1.19 + *
1.20 + */
1.21 +// WARNING: This is an internal header file, included by other C++
1.22 +// standard library headers. You should not attempt to use this header
1.23 +// file directly.
1.24 +
1.25 +
1.26 +#ifndef _STLP_INTERNAL_LOCALE_H
1.27 +#define _STLP_INTERNAL_LOCALE_H
1.28 +
1.29 +#ifndef _STLP_INTERNAL_CSTDLIB
1.30 +# include <stl/_cstdlib.h>
1.31 +#endif
1.32 +
1.33 +#ifndef _STLP_INTERNAL_CWCHAR
1.34 +# include <stl/_cwchar.h>
1.35 +#endif
1.36 +
1.37 +#ifndef _STLP_INTERNAL_THREADS_H
1.38 +# include <stl/_threads.h>
1.39 +#endif
1.40 +
1.41 +#ifndef _STLP_STRING_FWD_H
1.42 +# include <stl/_string_fwd.h>
1.43 +#endif
1.44 +
1.45 +_STLP_BEGIN_NAMESPACE
1.46 +
1.47 +class _Locale_impl; // Forward declaration of opaque type.
1.48 +class ios_base;
1.49 +
1.50 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.51 +class locale;
1.52 +# define locale _STLP_NO_MEM_T_NAME(loc)
1.53 +#endif
1.54 +
1.55 +class locale;
1.56 +
1.57 +template <class _CharT, class _Traits, class _Alloc>
1.58 +bool __locale_do_operator_call (const locale* __that,
1.59 + const basic_string<_CharT, _Traits, _Alloc>& __x,
1.60 + const basic_string<_CharT, _Traits, _Alloc>& __y);
1.61 +
1.62 +_STLP_DECLSPEC _Locale_impl * _STLP_CALL _get_Locale_impl( _Locale_impl *locimpl );
1.63 +_STLP_DECLSPEC _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl *locimpl );
1.64 +
1.65 +class _STLP_CLASS_DECLSPEC locale {
1.66 +public:
1.67 + // types:
1.68 + class _STLP_CLASS_DECLSPEC facet : protected _Refcount_Base {
1.69 + protected:
1.70 + /* Here we filter __init_count user value to 0 or 1 because __init_count is a
1.71 + * size_t instance and _Refcount_Base use __stl_atomic_t instances that might
1.72 + * have lower sizeof and generate roll issues. 1 is enough to keep the facet
1.73 + * alive when required.
1.74 + */
1.75 + explicit facet(size_t __init_count = 0) : _Refcount_Base( __init_count == 0 ? 0 : 1 ) {}
1.76 + virtual ~facet();
1.77 + friend class locale;
1.78 + friend class _Locale_impl;
1.79 + friend facet * _STLP_CALL _get_facet( facet * );
1.80 + friend void _STLP_CALL _release_facet( facet *& );
1.81 +
1.82 + private: // Invalidate assignment and copying.
1.83 + facet(const facet& ) /* : _Refcount_Base(1) {} */;
1.84 + void operator=(const facet&);
1.85 + };
1.86 +
1.87 +#if defined (__MVS__) || defined (__OS400__)
1.88 + struct
1.89 +#else
1.90 + class
1.91 +#endif
1.92 + _STLP_CLASS_DECLSPEC id {
1.93 + friend class locale;
1.94 + friend class _Locale_impl;
1.95 + public:
1.96 + size_t _M_index;
1.97 + static size_t _S_max;
1.98 + };
1.99 +
1.100 + typedef int category;
1.101 +#if defined (_STLP_STATIC_CONST_INIT_BUG)
1.102 + enum _Category {
1.103 +#else
1.104 + static const category
1.105 +#endif
1.106 + none = 0x000,
1.107 + collate = 0x010,
1.108 + ctype = 0x020,
1.109 + monetary = 0x040,
1.110 + numeric = 0x100,
1.111 + time = 0x200,
1.112 + messages = 0x400,
1.113 + all = collate | ctype | monetary | numeric | time | messages
1.114 +#if defined (_STLP_STATIC_CONST_INIT_BUG)
1.115 + }
1.116 +#endif
1.117 + ;
1.118 +
1.119 + // construct/copy/destroy:
1.120 + locale();
1.121 + locale(const locale&) _STLP_NOTHROW;
1.122 + explicit locale(const char *);
1.123 + locale(const locale&, const char*, category);
1.124 +
1.125 +#if defined (_STLP_MEMBER_TEMPLATES) && !defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.126 + template <class _Facet>
1.127 + locale(const locale& __loc, _Facet* __f) {
1.128 + if ( __f != 0 ) {
1.129 + this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) );
1.130 + this->_M_insert(__f, _Facet::id);
1.131 + } else {
1.132 + this->_M_impl = _get_Locale_impl( __loc._M_impl );
1.133 + }
1.134 + }
1.135 +#endif // _STLP_MEMBER_TEMPLATES
1.136 +
1.137 +protected:
1.138 + // those are for internal use
1.139 + locale(_Locale_impl*);
1.140 +
1.141 +public:
1.142 +
1.143 + locale(const locale&, const locale&, category);
1.144 + const locale& operator=(const locale&) _STLP_NOTHROW;
1.145 +
1.146 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.147 + virtual
1.148 +#endif
1.149 + ~locale() _STLP_NOTHROW;
1.150 +
1.151 +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && \
1.152 + !defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.153 + template <class _Facet>
1.154 + locale combine(const locale& __loc) {
1.155 + facet* __f = __loc._M_get_facet( _Facet::id );
1.156 + if ( __f == 0 )
1.157 + _M_throw_runtime_error();
1.158 +
1.159 + locale __result(__loc._M_impl);
1.160 +
1.161 + __result._M_insert(__f, _Facet::id);
1.162 +
1.163 + return __result;
1.164 + }
1.165 +#endif // _STLP_MEMBER_TEMPLATES && !_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.166 +
1.167 + // locale operations:
1.168 + string name() const;
1.169 +
1.170 + bool operator==(const locale&) const;
1.171 + bool operator!=(const locale&) const;
1.172 +
1.173 +#if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
1.174 + bool operator()(const string& __x, const string& __y) const;
1.175 +# ifndef _STLP_NO_WCHAR_T
1.176 + bool operator()(const wstring& __x, const wstring& __y) const;
1.177 +# endif
1.178 +#else
1.179 + template <class _CharT, class _Traits, class _Alloc>
1.180 + bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
1.181 + const basic_string<_CharT, _Traits, _Alloc>& __y) const {
1.182 + return __locale_do_operator_call(this, __x, __y);
1.183 + }
1.184 +#endif
1.185 +
1.186 + // global locale objects:
1.187 + static locale _STLP_CALL global(const locale&);
1.188 + static const locale& _STLP_CALL classic();
1.189 +
1.190 +//protected: // Helper functions for locale globals.
1.191 + facet* _M_get_facet(const id&) const;
1.192 + // same, but throws
1.193 + facet* _M_use_facet(const id&) const;
1.194 + static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_runtime_error(const char* = 0);
1.195 +
1.196 +protected: // More helper functions.
1.197 + void _M_insert(facet* __f, id& __id);
1.198 +
1.199 + // friends:
1.200 + friend class _Locale_impl;
1.201 + friend class ios_base;
1.202 +
1.203 +protected: // Data members
1.204 + _Locale_impl* _M_impl;
1.205 + _Locale_impl* _M_get_impl() const { return _M_impl; }
1.206 +};
1.207 +
1.208 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.209 +# undef locale
1.210 +# define _Locale _STLP_NO_MEM_T_NAME(loc)
1.211 +
1.212 +class locale : public _Locale {
1.213 +public:
1.214 +
1.215 + // construct/copy/destroy:
1.216 + locale() {}
1.217 + locale(const locale& __loc) _STLP_NOTHROW : _Locale(__loc) {}
1.218 + explicit locale(const char *__str) : _Locale(__str) {}
1.219 + locale(const locale& __loc, const char* __str, category __cat)
1.220 + : _Locale(__loc, __str, __cat) {}
1.221 +
1.222 + template <class _Facet>
1.223 + locale(const locale& __loc, _Facet* __f) {
1.224 + if ( __f != 0 ) {
1.225 + this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) );
1.226 + this->_M_insert(__f, _Facet::id);
1.227 + } else {
1.228 + this->_M_impl = _get_Locale_impl( __loc._M_impl );
1.229 + }
1.230 + }
1.231 +
1.232 +private:
1.233 + // those are for internal use
1.234 + locale(_Locale_impl* __impl) : _Locale(__impl) {}
1.235 + locale(const _Locale& __loc) : _Locale(__loc) {}
1.236 +
1.237 +public:
1.238 +
1.239 + locale(const locale& __loc1, const locale& __loc2, category __cat)
1.240 + : _Locale(__loc1, __loc2, __cat) {}
1.241 +
1.242 + const locale& operator=(const locale& __loc) _STLP_NOTHROW {
1.243 + _Locale::operator=(__loc);
1.244 + return *this;
1.245 + }
1.246 +
1.247 + template <class _Facet>
1.248 + locale combine(const locale& __loc) {
1.249 + facet* __f = __loc._M_get_facet( _Facet::id );
1.250 + if ( __f == 0 )
1.251 + _M_throw_runtime_error();
1.252 +
1.253 + locale __result(__loc._M_impl);
1.254 +
1.255 + __result._M_insert(__f, _Facet::id);
1.256 +
1.257 + return __result;
1.258 + }
1.259 +
1.260 + // locale operations:
1.261 + bool operator==(const locale& __loc) const { return _Locale::operator==(__loc); }
1.262 + bool operator!=(const locale& __loc) const { return _Locale::operator!=(__loc); }
1.263 +
1.264 + // global locale objects:
1.265 + static locale _STLP_CALL global(const locale& __loc) {
1.266 + return _Locale::global(__loc);
1.267 + }
1.268 + static const locale& _STLP_CALL classic() {
1.269 + return __STATIC_CAST(const locale&, _Locale::classic());
1.270 + }
1.271 +
1.272 + // friends:
1.273 + friend class _Locale_impl;
1.274 + friend class ios_base;
1.275 +};
1.276 +
1.277 +#endif /* _STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND */
1.278 +
1.279 +
1.280 +//----------------------------------------------------------------------
1.281 +// locale globals
1.282 +
1.283 +# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.284 +template <class _Facet>
1.285 +inline const _Facet&
1.286 +_Use_facet<_Facet>::operator *() const
1.287 +# else
1.288 +template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
1.289 +# endif
1.290 +{
1.291 + return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id));
1.292 +}
1.293 +
1.294 +
1.295 +# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.296 +template <class _Facet>
1.297 +struct has_facet {
1.298 + const locale& __loc;
1.299 + has_facet(const locale& __p_loc) : __loc(__p_loc) {}
1.300 + operator bool() const _STLP_NOTHROW
1.301 +# else
1.302 +template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW
1.303 +# endif
1.304 +{
1.305 + return (__loc._M_get_facet(_Facet::id) != 0);
1.306 +}
1.307 +
1.308 +# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
1.309 + // close class definition
1.310 +};
1.311 +# endif
1.312 +
1.313 +_STLP_END_NAMESPACE
1.314 +
1.315 +#endif /* _STLP_INTERNAL_LOCALE_H */
1.316 +
1.317 +// Local Variables:
1.318 +// mode:C++
1.319 +// End:
1.320 +