epoc32/include/stdapis/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
 * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
williamr@4
     3
 *
williamr@4
     4
 * Copyright (c) 1999
williamr@4
     5
 * Silicon Graphics Computer Systems, Inc.
williamr@4
     6
 *
williamr@4
     7
 * Copyright (c) 1999 
williamr@4
     8
 * Boris Fomitchev
williamr@4
     9
 *
williamr@4
    10
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
    11
 * or implied. Any use is at your own risk.
williamr@4
    12
 *
williamr@4
    13
 * Permission to use or copy this software for any purpose is hereby granted 
williamr@4
    14
 * without fee, provided the above notices are retained on all copies.
williamr@4
    15
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    16
 * provided the above notices are retained, and a notice that the code was
williamr@4
    17
 * modified is included with the above copyright notice.
williamr@4
    18
 *
williamr@4
    19
 */ 
williamr@4
    20
// WARNING: This is an internal header file, included by other C++
williamr@4
    21
// standard library headers.  You should not attempt to use this header
williamr@4
    22
// file directly.
williamr@4
    23
williamr@4
    24
#ifndef _STLP_INTERNAL_COLLATE_H
williamr@4
    25
#define _STLP_INTERNAL_COLLATE_H
williamr@4
    26
williamr@4
    27
#ifndef _STLP_C_LOCALE_H
williamr@4
    28
# include <stl/c_locale.h>
williamr@4
    29
#endif
williamr@4
    30
williamr@4
    31
#ifndef _STLP_INTERNAL_LOCALE_H
williamr@4
    32
# include <stl/_locale.h>
williamr@4
    33
#endif
williamr@4
    34
williamr@4
    35
#ifndef _STLP_STRING_H
williamr@4
    36
# include <stl/_string.h>
williamr@4
    37
#endif
williamr@4
    38
williamr@4
    39
_STLP_BEGIN_NAMESPACE
williamr@4
    40
williamr@4
    41
williamr@4
    42
template <class _CharT> class collate {};
williamr@4
    43
template <class _CharT> class collate_byname {};
williamr@4
    44
williamr@4
    45
_STLP_TEMPLATE_NULL
williamr@4
    46
#ifdef __SYMBIAN32__
williamr@4
    47
class  collate<char> : public locale::facet
williamr@4
    48
#else
williamr@4
    49
class _STLP_CLASS_DECLSPEC collate<char> : public locale::facet
williamr@4
    50
#endif
williamr@4
    51
{
williamr@4
    52
  friend class _Locale;
williamr@4
    53
public:
williamr@4
    54
  typedef char   char_type;
williamr@4
    55
  typedef string string_type;
williamr@4
    56
williamr@4
    57
  explicit collate(size_t __refs = 0) : _BaseFacet(__refs) {}
williamr@4
    58
williamr@4
    59
  int compare(const char* __low1, const char* __high1,
williamr@4
    60
              const char* __low2, const char* __high2) const {
williamr@4
    61
    return do_compare( __low1, __high1, __low2, __high2);
williamr@4
    62
  }
williamr@4
    63
williamr@4
    64
  string_type transform(const char* __low, const char* __high) const {
williamr@4
    65
    return do_transform(__low, __high);
williamr@4
    66
  }
williamr@4
    67
williamr@4
    68
  long hash(const char* __low, const char* __high) const
williamr@4
    69
    { return do_hash(__low, __high); }
williamr@4
    70
williamr@4
    71
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
williamr@4
    72
    _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
williamr@4
    73
#else
williamr@4
    74
	_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
williamr@4
    75
#endif
williamr@4
    76
williamr@4
    77
protected:
williamr@4
    78
_STLP_DECLSPEC  ~collate();
williamr@4
    79
williamr@4
    80
_STLP_DECLSPEC   virtual int do_compare(const char*, const char*,
williamr@4
    81
                         const char*, const char*) const;
williamr@4
    82
_STLP_DECLSPEC   virtual string_type do_transform(const char*, const char*) const;
williamr@4
    83
_STLP_DECLSPEC   virtual long do_hash(const char*, const char*) const;
williamr@4
    84
private:
williamr@4
    85
  collate(const collate<char>&);
williamr@4
    86
  collate<char>& operator =(const collate<char>&);  
williamr@4
    87
};
williamr@4
    88
williamr@4
    89
# ifndef _STLP_NO_WCHAR_T
williamr@4
    90
williamr@4
    91
_STLP_TEMPLATE_NULL
williamr@4
    92
#ifdef __SYMBIAN32__
williamr@4
    93
class  collate<wchar_t> : public locale::facet
williamr@4
    94
#else
williamr@4
    95
class _STLP_CLASS_DECLSPEC collate<wchar_t> : public locale::facet
williamr@4
    96
#endif
williamr@4
    97
{
williamr@4
    98
  friend class _Locale;
williamr@4
    99
public:
williamr@4
   100
  typedef wchar_t char_type;
williamr@4
   101
  typedef wstring string_type;
williamr@4
   102
williamr@4
   103
  explicit collate(size_t __refs = 0) : _BaseFacet(__refs) {}
williamr@4
   104
williamr@4
   105
  int compare(const wchar_t* __low1, const wchar_t* __high1,
williamr@4
   106
              const wchar_t* __low2, const wchar_t* __high2) const {
williamr@4
   107
    return do_compare( __low1, __high1, __low2, __high2);
williamr@4
   108
  }
williamr@4
   109
williamr@4
   110
  string_type transform(const wchar_t* __low, const wchar_t* __high) const {
williamr@4
   111
    return do_transform(__low, __high);
williamr@4
   112
  }
williamr@4
   113
williamr@4
   114
  long hash(const wchar_t* __low, const wchar_t* __high) const
williamr@4
   115
    { return do_hash(__low, __high); }
williamr@4
   116
williamr@4
   117
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
williamr@4
   118
    _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
williamr@4
   119
#else
williamr@4
   120
	_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
williamr@4
   121
#endif
williamr@4
   122
williamr@4
   123
protected:
williamr@4
   124
_STLP_DECLSPEC   ~collate();
williamr@4
   125
williamr@4
   126
_STLP_DECLSPEC   virtual int do_compare(const wchar_t*, const wchar_t*,
williamr@4
   127
                         const wchar_t*, const wchar_t*) const;
williamr@4
   128
_STLP_DECLSPEC   virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
williamr@4
   129
_STLP_DECLSPEC   virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
williamr@4
   130
private:
williamr@4
   131
  collate(const collate<wchar_t>&);
williamr@4
   132
  collate<wchar_t>& operator = (const collate<wchar_t>&);  
williamr@4
   133
};
williamr@4
   134
williamr@4
   135
# endif /* NO_WCHAR_T */
williamr@4
   136
williamr@4
   137
_STLP_TEMPLATE_NULL
williamr@4
   138
class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char> 
williamr@4
   139
{
williamr@4
   140
public:
williamr@4
   141
  explicit _STLP_DECLSPEC collate_byname(const char* __name, size_t __refs = 0);
williamr@4
   142
williamr@4
   143
protected:
williamr@4
   144
_STLP_DECLSPEC   ~collate_byname();
williamr@4
   145
williamr@4
   146
_STLP_DECLSPEC   virtual int do_compare(const char*, const char*,
williamr@4
   147
                         const char*, const char*) const;
williamr@4
   148
_STLP_DECLSPEC   virtual string_type do_transform(const char*, const char*) const;
williamr@4
   149
williamr@4
   150
private:
williamr@4
   151
  _Locale_collate* _M_collate;
williamr@4
   152
  collate_byname(const collate_byname<char>&);
williamr@4
   153
  collate_byname<char>& operator =(const collate_byname<char>&);  
williamr@4
   154
};
williamr@4
   155
williamr@4
   156
# ifndef _STLP_NO_WCHAR_T
williamr@4
   157
williamr@4
   158
_STLP_TEMPLATE_NULL
williamr@4
   159
class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t> 
williamr@4
   160
{
williamr@4
   161
public:
williamr@4
   162
  explicit _STLP_DECLSPEC  collate_byname(const char * __name, size_t __refs = 0);
williamr@4
   163
williamr@4
   164
protected:
williamr@4
   165
_STLP_DECLSPEC   ~collate_byname();
williamr@4
   166
williamr@4
   167
_STLP_DECLSPEC   virtual int do_compare(const wchar_t*, const wchar_t*,
williamr@4
   168
                         const wchar_t*, const wchar_t*) const;
williamr@4
   169
_STLP_DECLSPEC   virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
williamr@4
   170
williamr@4
   171
private:
williamr@4
   172
  _Locale_collate* _M_collate;
williamr@4
   173
  collate_byname(const collate_byname<wchar_t>&);
williamr@4
   174
  collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);  
williamr@4
   175
};
williamr@4
   176
williamr@4
   177
# endif /* NO_WCHAR_T */
williamr@4
   178
williamr@4
   179
williamr@4
   180
template <class _CharT, class _Traits, class _Alloc>
williamr@4
   181
bool 
williamr@4
   182
__locale_do_operator_call (const locale* __that, 
williamr@4
   183
                           const basic_string<_CharT, _Traits, _Alloc >& __x,
williamr@4
   184
                           const basic_string<_CharT, _Traits, _Alloc >& __y) 
williamr@4
   185
{
williamr@4
   186
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
williamr@4
   187
  collate<_CharT>* __f = (collate<_CharT>*)__that->_M_get_facet(collate<_CharT>::GetFacetLocaleId());
williamr@4
   188
#else
williamr@4
   189
  collate<_CharT>* __f = (collate<_CharT>*)__that->_M_get_facet(collate<_CharT>::id);
williamr@4
   190
#endif
williamr@4
   191
  if (!__f)
williamr@4
   192
    __that->_M_throw_runtime_error();
williamr@4
   193
  return __f->compare(__x.data(), __x.data() + __x.size(),
williamr@4
   194
                      __y.data(), __y.data() + __y.size()) < 0;
williamr@4
   195
  
williamr@4
   196
}
williamr@4
   197
williamr@4
   198
_STLP_END_NAMESPACE
williamr@4
   199
williamr@4
   200
#endif /* _STLP_INTERNAL_COLLATE_H */
williamr@4
   201
williamr@4
   202
// Local Variables:
williamr@4
   203
// mode:C++
williamr@4
   204
// End: