epoc32/include/stdapis/stlportv5/stl/_locale.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_locale.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,259 @@
     1.4 +/*
     1.5 + * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     1.6 + *
     1.7 + * Copyright (c) 1999
     1.8 + * Silicon Graphics Computer Systems, Inc.
     1.9 + *
    1.10 + * Copyright (c) 1999 
    1.11 + * Boris Fomitchev
    1.12 + *
    1.13 + * This material is provided "as is", with absolutely no warranty expressed
    1.14 + * or implied. Any use is at your own risk.
    1.15 + *
    1.16 + * Permission to use or copy this software for any purpose is hereby granted 
    1.17 + * without fee, provided the above notices are retained on all copies.
    1.18 + * Permission to modify the code and to distribute modified code is granted,
    1.19 + * provided the above notices are retained, and a notice that the code was
    1.20 + * modified is included with the above copyright notice.
    1.21 + *
    1.22 + */ 
    1.23 +// WARNING: This is an internal header file, included by other C++
    1.24 +// standard library headers.  You should not attempt to use this header
    1.25 +// file directly.
    1.26 +
    1.27 +
    1.28 +#ifndef _STLP_INTERNAL_LOCALE_H
    1.29 +#define _STLP_INTERNAL_LOCALE_H
    1.30 +
    1.31 +#ifndef _STLP_CSTDLIB
    1.32 +# include <cstdlib>
    1.33 +#endif
    1.34 +
    1.35 +#ifndef _STLP_CWCHAR_H
    1.36 +# include <stl/_cwchar.h>
    1.37 +#endif
    1.38 +
    1.39 +#ifndef _STLP_INTERNAL_THREADS_H
    1.40 +# include <stl/_threads.h>
    1.41 +#endif
    1.42 +
    1.43 +#ifndef _STLP_STRING_FWD_H
    1.44 +# include <stl/_string_fwd.h>
    1.45 +#endif
    1.46 +
    1.47 +_STLP_BEGIN_NAMESPACE
    1.48 +
    1.49 +class _STLP_CLASS_DECLSPEC _Locale_impl;             // Forward declaration of opaque type.
    1.50 +class _STLP_CLASS_DECLSPEC _Locale;             // Forward declaration of opaque type.
    1.51 +class _STLP_CLASS_DECLSPEC locale;
    1.52 +class _STLP_CLASS_DECLSPEC ios_base;
    1.53 +
    1.54 +
    1.55 +template <class _CharT, class _Traits, class _Alloc>
    1.56 +bool 
    1.57 +__locale_do_operator_call (const locale* __that, 
    1.58 +                           const basic_string<_CharT, _Traits, _Alloc >& __x,
    1.59 +                           const basic_string<_CharT, _Traits, _Alloc >& __y);
    1.60 +
    1.61 +#  define _BaseFacet locale::facet
    1.62 +
    1.63 +class _STLP_CLASS_DECLSPEC locale {
    1.64 +public:
    1.65 +  // types:
    1.66 +
    1.67 +  class 
    1.68 +#if defined (__SYMBIAN32__) || defined(__GCCE__)
    1.69 +  _STLP_CLASS_DECLSPEC  
    1.70 +#else
    1.71 +    _STLP_DECLSPEC 
    1.72 +#endif
    1.73 +  facet : private _Refcount_Base {
    1.74 +  protected:
    1.75 +    explicit facet(size_t __no_del = 0) : _Refcount_Base(1), _M_delete(__no_del == 0) {}
    1.76 +
    1.77 +    _STLP_DECLSPEC virtual ~facet();
    1.78 +    friend class locale;
    1.79 +    friend class _Locale_impl;
    1.80 +    friend class _Locale;
    1.81 +    
    1.82 +  private:                        // Invalidate assignment and copying.
    1.83 +    facet(const facet& __f) : _Refcount_Base(1), _M_delete(__f._M_delete == 0)  {};       
    1.84 +    void operator=(const facet&); 
    1.85 +    
    1.86 +  private:                        // Data members.
    1.87 +    const bool _M_delete;
    1.88 +  };
    1.89 +  
    1.90 +#if defined(__MVS__) || defined(__OS400__)
    1.91 +  struct
    1.92 +#else
    1.93 +  class
    1.94 +#endif
    1.95 +  _STLP_DECLSPEC id {
    1.96 +    friend class locale;
    1.97 +    friend class _Locale_impl;
    1.98 +  public:
    1.99 +    size_t _M_index;
   1.100 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   1.101 +   static _STLP_STATIC_MEMBER_DECLSPEC size_t& get_locale_id_S_max();
   1.102 +# else
   1.103 +    static size_t _S_max;
   1.104 +# endif
   1.105 +  };
   1.106 +
   1.107 +  typedef int category;
   1.108 +# if defined (_STLP_STATIC_CONST_INIT_BUG)
   1.109 +  enum _Category {
   1.110 +# else
   1.111 +  static const category
   1.112 +# endif
   1.113 +    none      = 0x000,
   1.114 +    collate   = 0x010,
   1.115 +    ctype     = 0x020,
   1.116 +    monetary  = 0x040,
   1.117 +    numeric   = 0x100,
   1.118 +    time      = 0x200,
   1.119 +    messages  = 0x400,
   1.120 +    all       = collate | ctype | monetary | numeric | time | messages
   1.121 +# if defined (_STLP_STATIC_CONST_INIT_BUG)
   1.122 +  }
   1.123 +# endif
   1.124 +  ;
   1.125 +
   1.126 +  // construct/copy/destroy:
   1.127 +  _STLP_DECLSPEC locale();
   1.128 +  _STLP_DECLSPEC locale(const locale&) _STLP_NOTHROW;
   1.129 +  explicit locale(const char *);
   1.130 +  locale(const locale&, const char*, category);
   1.131 +
   1.132 +  // those are for internal use
   1.133 +  locale(_Locale_impl*);
   1.134 +  locale(_Locale_impl*, bool);
   1.135 +
   1.136 +public:
   1.137 +
   1.138 +# if defined ( _STLP_MEMBER_TEMPLATES ) /* && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) */
   1.139 +  template <class _Facet> 
   1.140 +  locale(const locale& __loc, _Facet* __f) : _M_impl(0)
   1.141 +    {
   1.142 +      //      _M_impl = this->_S_copy_impl(__loc._M_impl, __f != 0);
   1.143 +      new(this) locale(__loc._M_impl, __f != 0);
   1.144 +      if (__f != 0)
   1.145 +        this->_M_insert((facet*)__f, _Facet::GetFacetLocaleId());
   1.146 +    }
   1.147 +# endif
   1.148 +
   1.149 +  locale(const locale&, const locale&, category);
   1.150 +  _STLP_DECLSPEC ~locale() _STLP_NOTHROW;
   1.151 +  _STLP_DECLSPEC const locale& operator=(const locale&) _STLP_NOTHROW;
   1.152 +
   1.153 +# if !(defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS))
   1.154 +  template <class _Facet> locale combine(const locale& __loc) const{
   1.155 +    locale __result(__loc._M_impl, true);
   1.156 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   1.157 +    if (facet* __f = __loc._M_get_facet(_Facet::GetFacetLocaleId())) {
   1.158 +      __result._M_insert((facet*)__f, _Facet::GetFacetLocaleId());
   1.159 +#else
   1.160 +    if (facet* __f = __loc._M_get_facet(_Facet::id)) {
   1.161 +      __result._M_insert((facet*)__f, _Facet::id);
   1.162 +#endif
   1.163 +      __f->_M_incr();
   1.164 +    }
   1.165 +    else
   1.166 +      _M_throw_runtime_error();    
   1.167 +    return __result;
   1.168 +  }
   1.169 +# endif
   1.170 +  // locale operations:
   1.171 +  _STLP_DECLSPEC string name() const;
   1.172 +
   1.173 +  _STLP_DECLSPEC bool operator==(const locale&) const;
   1.174 +  _STLP_DECLSPEC bool operator!=(const locale&) const;
   1.175 +
   1.176 +# if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
   1.177 +  bool operator()(const string& __x, const string& __y) const;
   1.178 +#  ifndef _STLP_NO_WCHAR_T
   1.179 +  bool operator()(const wstring& __x, const wstring& __y) const;
   1.180 +#  endif
   1.181 +# else
   1.182 +  template <class _CharT, class _Traits, class _Alloc>
   1.183 +  bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
   1.184 +                  const basic_string<_CharT, _Traits, _Alloc>& __y) const  {
   1.185 +    return __locale_do_operator_call(this, __x, __y);
   1.186 +  }              
   1.187 +# endif
   1.188 +
   1.189 +  // global locale objects:
   1.190 +  _STLP_DECLSPEC static locale _STLP_CALL global(const locale&);
   1.191 +  _STLP_DECLSPEC static const locale& _STLP_CALL classic();
   1.192 +
   1.193 +public:                         // Helper functions for locale globals.
   1.194 +  _STLP_DECLSPEC facet* _M_get_facet(const id&) const;
   1.195 +  // same, but throws
   1.196 +  _STLP_DECLSPEC facet* _M_use_facet(const id&) const;
   1.197 +  _STLP_DECLSPEC static void _STLP_CALL _M_throw_runtime_error(const char* = 0);
   1.198 +  static void _STLP_CALL _S_initialize();
   1.199 +  static void _STLP_CALL _S_uninitialize();
   1.200 +
   1.201 +private:                        // More helper functions.
   1.202 +  //  static _Locale_impl* _STLP_CALL _S_copy_impl(_Locale_impl*, bool);
   1.203 +  _STLP_DECLSPEC void _M_insert(facet* __f, id& __id);
   1.204 +
   1.205 +  // friends:
   1.206 +  friend class _Locale_impl;
   1.207 +  friend class _Locale;
   1.208 +  friend class ios_base;
   1.209 +
   1.210 +private:                        // Data members
   1.211 +  _Locale_impl* _M_impl;
   1.212 +};
   1.213 +
   1.214 +//----------------------------------------------------------------------
   1.215 +// locale globals
   1.216 +
   1.217 +# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
   1.218 +template <class _Facet>
   1.219 +inline const _Facet& 
   1.220 +_Use_facet<_Facet>::operator *() const
   1.221 +# else
   1.222 +template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
   1.223 +# endif
   1.224 +{
   1.225 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   1.226 +  return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::GetFacetLocaleId()));
   1.227 +#else
   1.228 +  return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id));
   1.229 +#endif
   1.230 +}
   1.231 +
   1.232 + 
   1.233 +# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
   1.234 +template <class _Facet> 
   1.235 +struct has_facet {
   1.236 +  const locale& __loc;
   1.237 +  has_facet(const locale& __p_loc) : __loc(__p_loc) {}
   1.238 +  operator bool() const _STLP_NOTHROW
   1.239 +# else
   1.240 +template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW 
   1.241 +# endif
   1.242 +{
   1.243 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   1.244 +  return (__loc._M_get_facet(_Facet::GetFacetLocaleId()) != 0);
   1.245 +#else
   1.246 +  return (__loc._M_get_facet(_Facet::id) != 0);
   1.247 +#endif
   1.248 +}
   1.249 +
   1.250 +# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
   1.251 +  // close class definition
   1.252 +};
   1.253 +# endif
   1.254 +
   1.255 +_STLP_END_NAMESPACE
   1.256 +
   1.257 +#endif /* _STLP_INTERNAL_LOCALE_H */
   1.258 +
   1.259 +// Local Variables:
   1.260 +// mode:C++
   1.261 +// End:
   1.262 +