epoc32/include/tools/stlport/stl/_collate.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
#ifndef _STLP_INTERNAL_COLLATE_H
williamr@4
    23
#define _STLP_INTERNAL_COLLATE_H
williamr@4
    24
williamr@4
    25
#ifndef _STLP_C_LOCALE_H
williamr@4
    26
# include <stl/c_locale.h>
williamr@4
    27
#endif
williamr@4
    28
williamr@4
    29
#ifndef _STLP_INTERNAL_LOCALE_H
williamr@4
    30
# include <stl/_locale.h>
williamr@4
    31
#endif
williamr@4
    32
williamr@4
    33
#ifndef _STLP_INTERNAL_STRING_H
williamr@4
    34
# include <stl/_string.h>
williamr@4
    35
#endif
williamr@4
    36
williamr@4
    37
_STLP_BEGIN_NAMESPACE
williamr@4
    38
williamr@4
    39
template <class _CharT> class collate {};
williamr@4
    40
template <class _CharT> class collate_byname {};
williamr@4
    41
williamr@4
    42
_STLP_TEMPLATE_NULL
williamr@4
    43
class _STLP_CLASS_DECLSPEC collate<char> : public locale::facet
williamr@4
    44
{
williamr@4
    45
  friend class _Locale_impl;
williamr@4
    46
williamr@4
    47
public:
williamr@4
    48
  typedef char   char_type;
williamr@4
    49
  typedef string string_type;
williamr@4
    50
williamr@4
    51
  explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
williamr@4
    52
williamr@4
    53
  int compare(const char* __low1, const char* __high1,
williamr@4
    54
              const char* __low2, const char* __high2) const {
williamr@4
    55
    return do_compare( __low1, __high1, __low2, __high2);
williamr@4
    56
  }
williamr@4
    57
williamr@4
    58
  string_type transform(const char* __low, const char* __high) const {
williamr@4
    59
    return do_transform(__low, __high);
williamr@4
    60
  }
williamr@4
    61
williamr@4
    62
  long hash(const char* __low, const char* __high) const
williamr@4
    63
    { return do_hash(__low, __high); }
williamr@4
    64
williamr@4
    65
  static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
williamr@4
    66
williamr@4
    67
protected:
williamr@4
    68
  ~collate();
williamr@4
    69
williamr@4
    70
  virtual int do_compare(const char*, const char*,
williamr@4
    71
                         const char*, const char*) const;
williamr@4
    72
  virtual string_type do_transform(const char*, const char*) const;
williamr@4
    73
  virtual long do_hash(const char*, const char*) const;
williamr@4
    74
private:
williamr@4
    75
  collate(const collate<char>&);
williamr@4
    76
  collate<char>& operator =(const collate<char>&);
williamr@4
    77
};
williamr@4
    78
williamr@4
    79
# ifndef _STLP_NO_WCHAR_T
williamr@4
    80
williamr@4
    81
_STLP_TEMPLATE_NULL
williamr@4
    82
class _STLP_CLASS_DECLSPEC collate<wchar_t> : public locale::facet
williamr@4
    83
{
williamr@4
    84
  friend class _Locale_impl;
williamr@4
    85
williamr@4
    86
public:
williamr@4
    87
  typedef wchar_t char_type;
williamr@4
    88
  typedef wstring string_type;
williamr@4
    89
williamr@4
    90
  explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
williamr@4
    91
williamr@4
    92
  int compare(const wchar_t* __low1, const wchar_t* __high1,
williamr@4
    93
              const wchar_t* __low2, const wchar_t* __high2) const {
williamr@4
    94
    return do_compare( __low1, __high1, __low2, __high2);
williamr@4
    95
  }
williamr@4
    96
williamr@4
    97
  string_type transform(const wchar_t* __low, const wchar_t* __high) const {
williamr@4
    98
    return do_transform(__low, __high);
williamr@4
    99
  }
williamr@4
   100
williamr@4
   101
  long hash(const wchar_t* __low, const wchar_t* __high) const
williamr@4
   102
    { return do_hash(__low, __high); }
williamr@4
   103
williamr@4
   104
  static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
williamr@4
   105
williamr@4
   106
protected:
williamr@4
   107
  ~collate();
williamr@4
   108
williamr@4
   109
  virtual int do_compare(const wchar_t*, const wchar_t*,
williamr@4
   110
                         const wchar_t*, const wchar_t*) const;
williamr@4
   111
  virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
williamr@4
   112
  virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
williamr@4
   113
private:
williamr@4
   114
  collate(const collate<wchar_t>&);
williamr@4
   115
  collate<wchar_t>& operator = (const collate<wchar_t>&);
williamr@4
   116
};
williamr@4
   117
williamr@4
   118
# endif /* NO_WCHAR_T */
williamr@4
   119
williamr@4
   120
_STLP_TEMPLATE_NULL
williamr@4
   121
class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char>
williamr@4
   122
{
williamr@4
   123
public:
williamr@4
   124
  explicit collate_byname(const char* __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
williamr@4
   125
williamr@4
   126
protected:
williamr@4
   127
  ~collate_byname();
williamr@4
   128
williamr@4
   129
  virtual int do_compare(const char*, const char*,
williamr@4
   130
                         const char*, const char*) const;
williamr@4
   131
  virtual string_type do_transform(const char*, const char*) const;
williamr@4
   132
williamr@4
   133
private:
williamr@4
   134
  _Locale_collate* _M_collate;
williamr@4
   135
  collate_byname(const collate_byname<char>&);
williamr@4
   136
  collate_byname<char>& operator =(const collate_byname<char>&);
williamr@4
   137
  friend _Locale_name_hint* _Locale_extract_hint(collate_byname<char>*);
williamr@4
   138
};
williamr@4
   139
williamr@4
   140
# ifndef _STLP_NO_WCHAR_T
williamr@4
   141
williamr@4
   142
_STLP_TEMPLATE_NULL
williamr@4
   143
class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t>
williamr@4
   144
{
williamr@4
   145
public:
williamr@4
   146
  explicit collate_byname(const char * __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
williamr@4
   147
williamr@4
   148
protected:
williamr@4
   149
  ~collate_byname();
williamr@4
   150
williamr@4
   151
  virtual int do_compare(const wchar_t*, const wchar_t*,
williamr@4
   152
                         const wchar_t*, const wchar_t*) const;
williamr@4
   153
  virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
williamr@4
   154
williamr@4
   155
private:
williamr@4
   156
  _Locale_collate* _M_collate;
williamr@4
   157
  collate_byname(const collate_byname<wchar_t>&);
williamr@4
   158
  collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);
williamr@4
   159
};
williamr@4
   160
williamr@4
   161
# endif /* NO_WCHAR_T */
williamr@4
   162
williamr@4
   163
#if defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
williamr@4
   164
#  define locale _STLP_NO_MEM_T_NAME(loc)
williamr@4
   165
#endif
williamr@4
   166
williamr@4
   167
template <class _CharT, class _Traits, class _Alloc>
williamr@4
   168
bool
williamr@4
   169
__locale_do_operator_call (const locale* __that,
williamr@4
   170
                           const basic_string<_CharT, _Traits, _Alloc>& __x,
williamr@4
   171
                           const basic_string<_CharT, _Traits, _Alloc>& __y)
williamr@4
   172
{
williamr@4
   173
  collate<_CharT>* __f = (collate<_CharT>*)__that->_M_get_facet(collate<_CharT>::id);
williamr@4
   174
  if (!__f)
williamr@4
   175
    __that->_M_throw_runtime_error();
williamr@4
   176
  return __f->compare(__x.data(), __x.data() + __x.size(),
williamr@4
   177
                      __y.data(), __y.data() + __y.size()) < 0;
williamr@4
   178
}
williamr@4
   179
#if defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
williamr@4
   180
#  undef locale
williamr@4
   181
#endif
williamr@4
   182
williamr@4
   183
_STLP_END_NAMESPACE
williamr@4
   184
williamr@4
   185
#endif /* _STLP_INTERNAL_COLLATE_H */
williamr@4
   186
williamr@4
   187
// Local Variables:
williamr@4
   188
// mode:C++
williamr@4
   189
// End: