williamr@2: /* williamr@2: * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. williamr@2: * williamr@2: * Copyright (c) 1999 williamr@2: * Silicon Graphics Computer Systems, Inc. williamr@2: * williamr@2: * Copyright (c) 1999 williamr@2: * Boris Fomitchev williamr@2: * williamr@2: * This material is provided "as is", with absolutely no warranty expressed williamr@2: * or implied. Any use is at your own risk. williamr@2: * williamr@2: * Permission to use or copy this software for any purpose is hereby granted williamr@2: * without fee, provided the above notices are retained on all copies. williamr@2: * Permission to modify the code and to distribute modified code is granted, williamr@2: * provided the above notices are retained, and a notice that the code was williamr@2: * modified is included with the above copyright notice. williamr@2: * williamr@2: */ williamr@2: // WARNING: This is an internal header file, included by other C++ williamr@2: // standard library headers. You should not attempt to use this header williamr@2: // file directly. williamr@2: williamr@2: williamr@2: #ifndef _STLP_INTERNAL_LOCALE_H williamr@2: #define _STLP_INTERNAL_LOCALE_H williamr@2: williamr@2: #ifndef _STLP_CSTDLIB williamr@2: # include williamr@2: #endif williamr@2: williamr@2: #ifndef _STLP_CWCHAR_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: #ifndef _STLP_INTERNAL_THREADS_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: #ifndef _STLP_STRING_FWD_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: _STLP_BEGIN_NAMESPACE williamr@2: williamr@2: class _STLP_CLASS_DECLSPEC _Locale_impl; // Forward declaration of opaque type. williamr@2: class _STLP_CLASS_DECLSPEC _Locale; // Forward declaration of opaque type. williamr@2: class _STLP_CLASS_DECLSPEC locale; williamr@2: class _STLP_CLASS_DECLSPEC ios_base; williamr@2: williamr@2: williamr@2: template williamr@2: bool williamr@2: __locale_do_operator_call (const locale* __that, williamr@2: const basic_string<_CharT, _Traits, _Alloc >& __x, williamr@2: const basic_string<_CharT, _Traits, _Alloc >& __y); williamr@2: williamr@2: # define _BaseFacet locale::facet williamr@2: williamr@2: class _STLP_CLASS_DECLSPEC locale { williamr@2: public: williamr@2: // types: williamr@2: williamr@2: class williamr@2: #if defined (__SYMBIAN32__) || defined(__GCCE__) williamr@2: _STLP_CLASS_DECLSPEC williamr@2: #else williamr@2: _STLP_DECLSPEC williamr@2: #endif williamr@2: facet : private _Refcount_Base { williamr@2: protected: williamr@2: explicit facet(size_t __no_del = 0) : _Refcount_Base(1), _M_delete(__no_del == 0) {} williamr@2: williamr@2: _STLP_DECLSPEC virtual ~facet(); williamr@2: friend class locale; williamr@2: friend class _Locale_impl; williamr@2: friend class _Locale; williamr@2: williamr@2: private: // Invalidate assignment and copying. williamr@2: facet(const facet& __f) : _Refcount_Base(1), _M_delete(__f._M_delete == 0) {}; williamr@2: void operator=(const facet&); williamr@2: williamr@2: private: // Data members. williamr@2: const bool _M_delete; williamr@2: }; williamr@2: williamr@2: #if defined(__MVS__) || defined(__OS400__) williamr@2: struct williamr@2: #else williamr@2: class williamr@2: #endif williamr@2: _STLP_DECLSPEC id { williamr@2: friend class locale; williamr@2: friend class _Locale_impl; williamr@2: public: williamr@2: size_t _M_index; williamr@2: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) williamr@2: static _STLP_STATIC_MEMBER_DECLSPEC size_t& get_locale_id_S_max(); williamr@2: # else williamr@2: static size_t _S_max; williamr@2: # endif williamr@2: }; williamr@2: williamr@2: typedef int category; williamr@2: # if defined (_STLP_STATIC_CONST_INIT_BUG) williamr@2: enum _Category { williamr@2: # else williamr@2: static const category williamr@2: # endif williamr@2: none = 0x000, williamr@2: collate = 0x010, williamr@2: ctype = 0x020, williamr@2: monetary = 0x040, williamr@2: numeric = 0x100, williamr@2: time = 0x200, williamr@2: messages = 0x400, williamr@2: all = collate | ctype | monetary | numeric | time | messages williamr@2: # if defined (_STLP_STATIC_CONST_INIT_BUG) williamr@2: } williamr@2: # endif williamr@2: ; williamr@2: williamr@2: // construct/copy/destroy: williamr@2: _STLP_DECLSPEC locale(); williamr@2: _STLP_DECLSPEC locale(const locale&) _STLP_NOTHROW; williamr@2: explicit locale(const char *); williamr@2: locale(const locale&, const char*, category); williamr@2: williamr@2: // those are for internal use williamr@2: locale(_Locale_impl*); williamr@2: locale(_Locale_impl*, bool); williamr@2: williamr@2: public: williamr@2: williamr@2: # if defined ( _STLP_MEMBER_TEMPLATES ) /* && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) */ williamr@2: template williamr@2: locale(const locale& __loc, _Facet* __f) : _M_impl(0) williamr@2: { williamr@2: // _M_impl = this->_S_copy_impl(__loc._M_impl, __f != 0); williamr@2: new(this) locale(__loc._M_impl, __f != 0); williamr@2: if (__f != 0) williamr@2: this->_M_insert((facet*)__f, _Facet::GetFacetLocaleId()); williamr@2: } williamr@2: # endif williamr@2: williamr@2: locale(const locale&, const locale&, category); williamr@2: _STLP_DECLSPEC ~locale() _STLP_NOTHROW; williamr@2: _STLP_DECLSPEC const locale& operator=(const locale&) _STLP_NOTHROW; williamr@2: williamr@2: # if !(defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS)) williamr@2: template locale combine(const locale& __loc) const{ williamr@2: locale __result(__loc._M_impl, true); williamr@2: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) williamr@2: if (facet* __f = __loc._M_get_facet(_Facet::GetFacetLocaleId())) { williamr@2: __result._M_insert((facet*)__f, _Facet::GetFacetLocaleId()); williamr@2: #else williamr@2: if (facet* __f = __loc._M_get_facet(_Facet::id)) { williamr@2: __result._M_insert((facet*)__f, _Facet::id); williamr@2: #endif williamr@2: __f->_M_incr(); williamr@2: } williamr@2: else williamr@2: _M_throw_runtime_error(); williamr@2: return __result; williamr@2: } williamr@2: # endif williamr@2: // locale operations: williamr@2: _STLP_DECLSPEC string name() const; williamr@2: williamr@2: _STLP_DECLSPEC bool operator==(const locale&) const; williamr@2: _STLP_DECLSPEC bool operator!=(const locale&) const; williamr@2: williamr@2: # if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301) williamr@2: bool operator()(const string& __x, const string& __y) const; williamr@2: # ifndef _STLP_NO_WCHAR_T williamr@2: bool operator()(const wstring& __x, const wstring& __y) const; williamr@2: # endif williamr@2: # else williamr@2: template williamr@2: bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x, williamr@2: const basic_string<_CharT, _Traits, _Alloc>& __y) const { williamr@2: return __locale_do_operator_call(this, __x, __y); williamr@2: } williamr@2: # endif williamr@2: williamr@2: // global locale objects: williamr@2: _STLP_DECLSPEC static locale _STLP_CALL global(const locale&); williamr@2: _STLP_DECLSPEC static const locale& _STLP_CALL classic(); williamr@2: williamr@2: public: // Helper functions for locale globals. williamr@2: _STLP_DECLSPEC facet* _M_get_facet(const id&) const; williamr@2: // same, but throws williamr@2: _STLP_DECLSPEC facet* _M_use_facet(const id&) const; williamr@2: _STLP_DECLSPEC static void _STLP_CALL _M_throw_runtime_error(const char* = 0); williamr@2: static void _STLP_CALL _S_initialize(); williamr@2: static void _STLP_CALL _S_uninitialize(); williamr@2: williamr@2: private: // More helper functions. williamr@2: // static _Locale_impl* _STLP_CALL _S_copy_impl(_Locale_impl*, bool); williamr@2: _STLP_DECLSPEC void _M_insert(facet* __f, id& __id); williamr@2: williamr@2: // friends: williamr@2: friend class _Locale_impl; williamr@2: friend class _Locale; williamr@2: friend class ios_base; williamr@2: williamr@2: private: // Data members williamr@2: _Locale_impl* _M_impl; williamr@2: }; williamr@2: williamr@2: //---------------------------------------------------------------------- williamr@2: // locale globals williamr@2: williamr@2: # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS williamr@2: template williamr@2: inline const _Facet& williamr@2: _Use_facet<_Facet>::operator *() const williamr@2: # else williamr@2: template inline const _Facet& use_facet(const locale& __loc) williamr@2: # endif williamr@2: { williamr@2: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) williamr@2: return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::GetFacetLocaleId())); williamr@2: #else williamr@2: return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id)); williamr@2: #endif williamr@2: } williamr@2: williamr@2: williamr@2: # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS williamr@2: template williamr@2: struct has_facet { williamr@2: const locale& __loc; williamr@2: has_facet(const locale& __p_loc) : __loc(__p_loc) {} williamr@2: operator bool() const _STLP_NOTHROW williamr@2: # else williamr@2: template inline bool has_facet(const locale& __loc) _STLP_NOTHROW williamr@2: # endif williamr@2: { williamr@2: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) williamr@2: return (__loc._M_get_facet(_Facet::GetFacetLocaleId()) != 0); williamr@2: #else williamr@2: return (__loc._M_get_facet(_Facet::id) != 0); williamr@2: #endif williamr@2: } williamr@2: williamr@2: # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS williamr@2: // close class definition williamr@2: }; williamr@2: # endif williamr@2: williamr@2: _STLP_END_NAMESPACE williamr@2: williamr@2: #endif /* _STLP_INTERNAL_LOCALE_H */ williamr@2: williamr@2: // Local Variables: williamr@2: // mode:C++ williamr@2: // End: williamr@2: