epoc32/include/stdapis/stlport/stl/_locale.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  *
     4  * Copyright (c) 1999
     5  * Silicon Graphics Computer Systems, Inc.
     6  *
     7  * Copyright (c) 1999 
     8  * Boris Fomitchev
     9  *
    10  * This material is provided "as is", with absolutely no warranty expressed
    11  * or implied. Any use is at your own risk.
    12  *
    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.
    18  *
    19  */ 
    20 // WARNING: This is an internal header file, included by other C++
    21 // standard library headers.  You should not attempt to use this header
    22 // file directly.
    23 
    24 
    25 #ifndef _STLP_INTERNAL_LOCALE_H
    26 #define _STLP_INTERNAL_LOCALE_H
    27 
    28 #ifndef _STLP_CSTDLIB
    29 # include <cstdlib>
    30 #endif
    31 
    32 #ifndef _STLP_CWCHAR_H
    33 # include <stl/_cwchar.h>
    34 #endif
    35 
    36 #ifndef _STLP_INTERNAL_THREADS_H
    37 # include <stl/_threads.h>
    38 #endif
    39 
    40 #ifndef _STLP_STRING_FWD_H
    41 # include <stl/_string_fwd.h>
    42 #endif
    43 
    44 _STLP_BEGIN_NAMESPACE
    45 
    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;
    50 
    51 
    52 template <class _CharT, class _Traits, class _Alloc>
    53 bool 
    54 __locale_do_operator_call (const locale* __that, 
    55                            const basic_string<_CharT, _Traits, _Alloc >& __x,
    56                            const basic_string<_CharT, _Traits, _Alloc >& __y);
    57 
    58 #  define _BaseFacet locale::facet
    59 
    60 class _STLP_CLASS_DECLSPEC locale {
    61 public:
    62   // types:
    63 
    64   class 
    65 #if defined (__SYMBIAN32__) || defined(__GCCE__)
    66   _STLP_CLASS_DECLSPEC  
    67 #else
    68     _STLP_DECLSPEC 
    69 #endif
    70   facet : private _Refcount_Base {
    71   protected:
    72     explicit facet(size_t __no_del = 0) : _Refcount_Base(1), _M_delete(__no_del == 0) {}
    73 
    74     _STLP_DECLSPEC virtual ~facet();
    75     friend class locale;
    76     friend class _Locale_impl;
    77     friend class _Locale;
    78     
    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&); 
    82     
    83   private:                        // Data members.
    84     const bool _M_delete;
    85   };
    86   
    87 #if defined(__MVS__) || defined(__OS400__)
    88   struct
    89 #else
    90   class
    91 #endif
    92   _STLP_DECLSPEC id {
    93     friend class locale;
    94     friend class _Locale_impl;
    95   public:
    96     size_t _M_index;
    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();
    99 # else
   100     static size_t _S_max;
   101 # endif
   102   };
   103 
   104   typedef int category;
   105 # if defined (_STLP_STATIC_CONST_INIT_BUG)
   106   enum _Category {
   107 # else
   108   static const category
   109 # endif
   110     none      = 0x000,
   111     collate   = 0x010,
   112     ctype     = 0x020,
   113     monetary  = 0x040,
   114     numeric   = 0x100,
   115     time      = 0x200,
   116     messages  = 0x400,
   117     all       = collate | ctype | monetary | numeric | time | messages
   118 # if defined (_STLP_STATIC_CONST_INIT_BUG)
   119   }
   120 # endif
   121   ;
   122 
   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);
   128 
   129   // those are for internal use
   130   locale(_Locale_impl*);
   131   locale(_Locale_impl*, bool);
   132 
   133 public:
   134 
   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)
   138     {
   139       //      _M_impl = this->_S_copy_impl(__loc._M_impl, __f != 0);
   140       new(this) locale(__loc._M_impl, __f != 0);
   141       if (__f != 0)
   142         this->_M_insert((facet*)__f, _Facet::GetFacetLocaleId());
   143     }
   144 # endif
   145 
   146   locale(const locale&, const locale&, category);
   147   _STLP_DECLSPEC ~locale() _STLP_NOTHROW;
   148   _STLP_DECLSPEC const locale& operator=(const locale&) _STLP_NOTHROW;
   149 
   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());
   156 #else
   157     if (facet* __f = __loc._M_get_facet(_Facet::id)) {
   158       __result._M_insert((facet*)__f, _Facet::id);
   159 #endif
   160       __f->_M_incr();
   161     }
   162     else
   163       _M_throw_runtime_error();    
   164     return __result;
   165   }
   166 # endif
   167   // locale operations:
   168   _STLP_DECLSPEC string name() const;
   169 
   170   _STLP_DECLSPEC bool operator==(const locale&) const;
   171   _STLP_DECLSPEC bool operator!=(const locale&) const;
   172 
   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;
   177 #  endif
   178 # else
   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);
   183   }              
   184 # endif
   185 
   186   // global locale objects:
   187   _STLP_DECLSPEC static locale _STLP_CALL global(const locale&);
   188   _STLP_DECLSPEC static const locale& _STLP_CALL classic();
   189 
   190 public:                         // Helper functions for locale globals.
   191   _STLP_DECLSPEC facet* _M_get_facet(const id&) const;
   192   // same, but throws
   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();
   197 
   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);
   201 
   202   // friends:
   203   friend class _Locale_impl;
   204   friend class _Locale;
   205   friend class ios_base;
   206 
   207 private:                        // Data members
   208   _Locale_impl* _M_impl;
   209 };
   210 
   211 //----------------------------------------------------------------------
   212 // locale globals
   213 
   214 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
   215 template <class _Facet>
   216 inline const _Facet& 
   217 _Use_facet<_Facet>::operator *() const
   218 # else
   219 template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
   220 # endif
   221 {
   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()));
   224 #else
   225   return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id));
   226 #endif
   227 }
   228 
   229  
   230 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
   231 template <class _Facet> 
   232 struct has_facet {
   233   const locale& __loc;
   234   has_facet(const locale& __p_loc) : __loc(__p_loc) {}
   235   operator bool() const _STLP_NOTHROW
   236 # else
   237 template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW 
   238 # endif
   239 {
   240 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   241   return (__loc._M_get_facet(_Facet::GetFacetLocaleId()) != 0);
   242 #else
   243   return (__loc._M_get_facet(_Facet::id) != 0);
   244 #endif
   245 }
   246 
   247 # ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
   248   // close class definition
   249 };
   250 # endif
   251 
   252 _STLP_END_NAMESPACE
   253 
   254 #endif /* _STLP_INTERNAL_LOCALE_H */
   255 
   256 // Local Variables:
   257 // mode:C++
   258 // End:
   259