epoc32/include/tools/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.
williamr@4
     1
/*
williamr@4
     2
 * Copyright (c) 1999
williamr@4
     3
 * Silicon Graphics Computer Systems, Inc.
williamr@4
     4
 *
williamr@4
     5
 * Copyright (c) 1999
williamr@4
     6
 * Boris Fomitchev
williamr@4
     7
 *
williamr@4
     8
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
     9
 * or implied. Any use is at your own risk.
williamr@4
    10
 *
williamr@4
    11
 * Permission to use or copy this software for any purpose is hereby granted
williamr@4
    12
 * without fee, provided the above notices are retained on all copies.
williamr@4
    13
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    14
 * provided the above notices are retained, and a notice that the code was
williamr@4
    15
 * modified is included with the above copyright notice.
williamr@4
    16
 *
williamr@4
    17
 */
williamr@4
    18
// WARNING: This is an internal header file, included by other C++
williamr@4
    19
// standard library headers.  You should not attempt to use this header
williamr@4
    20
// file directly.
williamr@4
    21
williamr@4
    22
williamr@4
    23
#ifndef _STLP_INTERNAL_LOCALE_H
williamr@4
    24
#define _STLP_INTERNAL_LOCALE_H
williamr@4
    25
williamr@4
    26
#ifndef _STLP_INTERNAL_CSTDLIB
williamr@4
    27
#  include <stl/_cstdlib.h>
williamr@4
    28
#endif
williamr@4
    29
williamr@4
    30
#ifndef _STLP_INTERNAL_CWCHAR
williamr@4
    31
#  include <stl/_cwchar.h>
williamr@4
    32
#endif
williamr@4
    33
williamr@4
    34
#ifndef _STLP_INTERNAL_THREADS_H
williamr@4
    35
#  include <stl/_threads.h>
williamr@4
    36
#endif
williamr@4
    37
williamr@4
    38
#ifndef _STLP_STRING_FWD_H
williamr@4
    39
#  include <stl/_string_fwd.h>
williamr@4
    40
#endif
williamr@4
    41
williamr@4
    42
_STLP_BEGIN_NAMESPACE
williamr@4
    43
williamr@4
    44
class _Locale_impl;        // Forward declaration of opaque type.
williamr@4
    45
class ios_base;
williamr@4
    46
williamr@4
    47
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
williamr@4
    48
class locale;
williamr@4
    49
#  define locale _STLP_NO_MEM_T_NAME(loc)
williamr@4
    50
#endif
williamr@4
    51
williamr@4
    52
class locale;
williamr@4
    53
williamr@4
    54
template <class _CharT, class _Traits, class _Alloc>
williamr@4
    55
bool __locale_do_operator_call (const locale* __that,
williamr@4
    56
                                const basic_string<_CharT, _Traits, _Alloc>& __x,
williamr@4
    57
                                const basic_string<_CharT, _Traits, _Alloc>& __y);
williamr@4
    58
williamr@4
    59
_STLP_DECLSPEC _Locale_impl * _STLP_CALL _get_Locale_impl( _Locale_impl *locimpl );
williamr@4
    60
_STLP_DECLSPEC _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl *locimpl );
williamr@4
    61
williamr@4
    62
class _STLP_CLASS_DECLSPEC locale {
williamr@4
    63
public:
williamr@4
    64
  // types:
williamr@4
    65
  class _STLP_CLASS_DECLSPEC facet : protected _Refcount_Base {
williamr@4
    66
  protected:
williamr@4
    67
    /* Here we filter __init_count user value to 0 or 1 because __init_count is a
williamr@4
    68
     * size_t instance and _Refcount_Base use __stl_atomic_t instances that might
williamr@4
    69
     * have lower sizeof and generate roll issues. 1 is enough to keep the facet
williamr@4
    70
     * alive when required.
williamr@4
    71
     */
williamr@4
    72
    explicit facet(size_t __init_count = 0) : _Refcount_Base( __init_count == 0 ? 0 : 1 ) {}
williamr@4
    73
    virtual ~facet();
williamr@4
    74
    friend class locale;
williamr@4
    75
    friend class _Locale_impl;
williamr@4
    76
    friend facet * _STLP_CALL _get_facet( facet * );
williamr@4
    77
    friend void _STLP_CALL _release_facet( facet *& );
williamr@4
    78
williamr@4
    79
  private:                        // Invalidate assignment and copying.
williamr@4
    80
    facet(const facet& ) /* : _Refcount_Base(1) {} */;
williamr@4
    81
    void operator=(const facet&);
williamr@4
    82
  };
williamr@4
    83
williamr@4
    84
#if defined (__MVS__) || defined (__OS400__)
williamr@4
    85
  struct
williamr@4
    86
#else
williamr@4
    87
  class
williamr@4
    88
#endif
williamr@4
    89
  _STLP_CLASS_DECLSPEC id {
williamr@4
    90
    friend class locale;
williamr@4
    91
    friend class _Locale_impl;
williamr@4
    92
  public:
williamr@4
    93
    size_t _M_index;
williamr@4
    94
    static size_t _S_max;
williamr@4
    95
  };
williamr@4
    96
williamr@4
    97
  typedef int category;
williamr@4
    98
#if defined (_STLP_STATIC_CONST_INIT_BUG)
williamr@4
    99
  enum _Category {
williamr@4
   100
#else
williamr@4
   101
  static const category
williamr@4
   102
#endif
williamr@4
   103
    none      = 0x000,
williamr@4
   104
    collate   = 0x010,
williamr@4
   105
    ctype     = 0x020,
williamr@4
   106
    monetary  = 0x040,
williamr@4
   107
    numeric   = 0x100,
williamr@4
   108
    time      = 0x200,
williamr@4
   109
    messages  = 0x400,
williamr@4
   110
    all       = collate | ctype | monetary | numeric | time | messages
williamr@4
   111
#if defined (_STLP_STATIC_CONST_INIT_BUG)
williamr@4
   112
  }
williamr@4
   113
#endif
williamr@4
   114
  ;
williamr@4
   115
williamr@4
   116
  // construct/copy/destroy:
williamr@4
   117
  locale();
williamr@4
   118
  locale(const locale&) _STLP_NOTHROW;
williamr@4
   119
  explicit locale(const char *);
williamr@4
   120
  locale(const locale&, const char*, category);
williamr@4
   121
williamr@4
   122
#if defined (_STLP_MEMBER_TEMPLATES) && !defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
williamr@4
   123
  template <class _Facet>
williamr@4
   124
  locale(const locale& __loc, _Facet* __f) {
williamr@4
   125
    if ( __f != 0 ) {
williamr@4
   126
      this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) );
williamr@4
   127
      this->_M_insert(__f, _Facet::id);
williamr@4
   128
    } else {
williamr@4
   129
      this->_M_impl = _get_Locale_impl( __loc._M_impl );
williamr@4
   130
    }
williamr@4
   131
  }
williamr@4
   132
#endif // _STLP_MEMBER_TEMPLATES
williamr@4
   133
williamr@4
   134
protected:
williamr@4
   135
  // those are for internal use
williamr@4
   136
  locale(_Locale_impl*);
williamr@4
   137
williamr@4
   138
public:
williamr@4
   139
williamr@4
   140
  locale(const locale&, const locale&, category);
williamr@4
   141
  const locale& operator=(const locale&) _STLP_NOTHROW;
williamr@4
   142
williamr@4
   143
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
williamr@4
   144
  virtual
williamr@4
   145
#endif
williamr@4
   146
   ~locale() _STLP_NOTHROW;
williamr@4
   147
williamr@4
   148
#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && \
williamr@4
   149
   !defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
williamr@4
   150
  template <class _Facet>
williamr@4
   151
  locale combine(const locale& __loc) {
williamr@4
   152
    facet* __f = __loc._M_get_facet( _Facet::id );
williamr@4
   153
    if ( __f == 0 )
williamr@4
   154
      _M_throw_runtime_error();
williamr@4
   155
williamr@4
   156
    locale __result(__loc._M_impl);
williamr@4
   157
williamr@4
   158
    __result._M_insert(__f, _Facet::id);
williamr@4
   159
williamr@4
   160
    return __result;
williamr@4
   161
  }
williamr@4
   162
#endif // _STLP_MEMBER_TEMPLATES && !_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
williamr@4
   163
williamr@4
   164
  // locale operations:
williamr@4
   165
  string name() const;
williamr@4
   166
williamr@4
   167
  bool operator==(const locale&) const;
williamr@4
   168
  bool operator!=(const locale&) const;
williamr@4
   169
williamr@4
   170
#if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
williamr@4
   171
  bool operator()(const string& __x, const string& __y) const;
williamr@4
   172
#  ifndef _STLP_NO_WCHAR_T
williamr@4
   173
  bool operator()(const wstring& __x, const wstring& __y) const;
williamr@4
   174
#  endif
williamr@4
   175
#else
williamr@4
   176
  template <class _CharT, class _Traits, class _Alloc>
williamr@4
   177
  bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
williamr@4
   178
                  const basic_string<_CharT, _Traits, _Alloc>& __y) const {
williamr@4
   179
    return __locale_do_operator_call(this, __x, __y);
williamr@4
   180
  }
williamr@4
   181
#endif
williamr@4
   182
williamr@4
   183
  // global locale objects:
williamr@4
   184
  static locale _STLP_CALL global(const locale&);
williamr@4
   185
  static const locale& _STLP_CALL classic();
williamr@4
   186
williamr@4
   187
//protected:                         // Helper functions for locale globals.
williamr@4
   188
  facet* _M_get_facet(const id&) const;
williamr@4
   189
  // same, but throws
williamr@4
   190
  facet* _M_use_facet(const id&) const;
williamr@4
   191
  static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_runtime_error(const char* = 0);
williamr@4
   192
williamr@4
   193
protected:                        // More helper functions.
williamr@4
   194
  void _M_insert(facet* __f, id& __id);
williamr@4
   195
williamr@4
   196
  // friends:
williamr@4
   197
  friend class _Locale_impl;
williamr@4
   198
  friend class ios_base;
williamr@4
   199
williamr@4
   200
protected:                        // Data members
williamr@4
   201
  _Locale_impl* _M_impl;
williamr@4
   202
  _Locale_impl* _M_get_impl() const { return _M_impl; }
williamr@4
   203
};
williamr@4
   204
williamr@4
   205
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
williamr@4
   206
#  undef locale
williamr@4
   207
#  define _Locale _STLP_NO_MEM_T_NAME(loc)
williamr@4
   208
williamr@4
   209
class locale : public _Locale {
williamr@4
   210
public:
williamr@4
   211
williamr@4
   212
  // construct/copy/destroy:
williamr@4
   213
  locale() {}
williamr@4
   214
  locale(const locale& __loc) _STLP_NOTHROW : _Locale(__loc) {}
williamr@4
   215
  explicit locale(const char *__str) : _Locale(__str) {}
williamr@4
   216
  locale(const locale& __loc, const char* __str, category __cat)
williamr@4
   217
    : _Locale(__loc, __str, __cat) {}
williamr@4
   218
williamr@4
   219
  template <class _Facet>
williamr@4
   220
  locale(const locale& __loc, _Facet* __f) {
williamr@4
   221
    if ( __f != 0 ) {
williamr@4
   222
      this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) );
williamr@4
   223
      this->_M_insert(__f, _Facet::id);
williamr@4
   224
    } else {
williamr@4
   225
      this->_M_impl = _get_Locale_impl( __loc._M_impl );
williamr@4
   226
    }
williamr@4
   227
  }
williamr@4
   228
williamr@4
   229
private:
williamr@4
   230
  // those are for internal use
williamr@4
   231
  locale(_Locale_impl* __impl) : _Locale(__impl) {}
williamr@4
   232
  locale(const _Locale& __loc) : _Locale(__loc) {}
williamr@4
   233
williamr@4
   234
public:
williamr@4
   235
williamr@4
   236
  locale(const locale& __loc1, const locale& __loc2, category __cat)
williamr@4
   237
    : _Locale(__loc1, __loc2, __cat) {}
williamr@4
   238
williamr@4
   239
  const locale& operator=(const locale& __loc) _STLP_NOTHROW {
williamr@4
   240
    _Locale::operator=(__loc);
williamr@4
   241
    return *this;
williamr@4
   242
  }
williamr@4
   243
williamr@4
   244
  template <class _Facet>
williamr@4
   245
  locale combine(const locale& __loc) {
williamr@4
   246
    facet* __f = __loc._M_get_facet( _Facet::id );
williamr@4
   247
    if ( __f == 0 )
williamr@4
   248
      _M_throw_runtime_error();
williamr@4
   249
williamr@4
   250
    locale __result(__loc._M_impl);
williamr@4
   251
williamr@4
   252
    __result._M_insert(__f, _Facet::id);
williamr@4
   253
williamr@4
   254
    return __result;
williamr@4
   255
  }
williamr@4
   256
williamr@4
   257
  // locale operations:
williamr@4
   258
  bool operator==(const locale& __loc) const { return _Locale::operator==(__loc); }
williamr@4
   259
  bool operator!=(const locale& __loc) const { return _Locale::operator!=(__loc); }
williamr@4
   260
williamr@4
   261
  // global locale objects:
williamr@4
   262
  static locale _STLP_CALL global(const locale& __loc) {
williamr@4
   263
    return _Locale::global(__loc);
williamr@4
   264
  }
williamr@4
   265
  static const locale& _STLP_CALL classic() {
williamr@4
   266
    return __STATIC_CAST(const locale&, _Locale::classic());
williamr@4
   267
  }
williamr@4
   268
williamr@4
   269
  // friends:
williamr@4
   270
  friend class _Locale_impl;
williamr@4
   271
  friend class ios_base;
williamr@4
   272
};
williamr@4
   273
williamr@4
   274
#endif /* _STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND */
williamr@4
   275
williamr@4
   276
williamr@4
   277
//----------------------------------------------------------------------
williamr@4
   278
// locale globals
williamr@4
   279
williamr@4
   280
# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
williamr@4
   281
template <class _Facet>
williamr@4
   282
inline const _Facet&
williamr@4
   283
_Use_facet<_Facet>::operator *() const
williamr@4
   284
# else
williamr@4
   285
template <class _Facet> inline const _Facet& use_facet(const locale& __loc)
williamr@4
   286
# endif
williamr@4
   287
{
williamr@4
   288
  return *__STATIC_CAST(const _Facet*,__loc._M_use_facet(_Facet::id));
williamr@4
   289
}
williamr@4
   290
williamr@4
   291
williamr@4
   292
# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
williamr@4
   293
template <class _Facet>
williamr@4
   294
struct has_facet {
williamr@4
   295
  const locale& __loc;
williamr@4
   296
  has_facet(const locale& __p_loc) : __loc(__p_loc) {}
williamr@4
   297
  operator bool() const _STLP_NOTHROW
williamr@4
   298
# else
williamr@4
   299
template <class _Facet> inline bool has_facet(const locale& __loc) _STLP_NOTHROW
williamr@4
   300
# endif
williamr@4
   301
{
williamr@4
   302
  return (__loc._M_get_facet(_Facet::id) != 0);
williamr@4
   303
}
williamr@4
   304
williamr@4
   305
# ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
williamr@4
   306
  // close class definition
williamr@4
   307
};
williamr@4
   308
# endif
williamr@4
   309
williamr@4
   310
_STLP_END_NAMESPACE
williamr@4
   311
williamr@4
   312
#endif /* _STLP_INTERNAL_LOCALE_H */
williamr@4
   313
williamr@4
   314
// Local Variables:
williamr@4
   315
// mode:C++
williamr@4
   316
// End:
williamr@4
   317