1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_collate.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_collate.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,22 +1,22 @@
1.4 /*
1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.6 + * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.7 *
1.8 * Copyright (c) 1999
1.9 * Silicon Graphics Computer Systems, Inc.
1.10 *
1.11 - * Copyright (c) 1999
1.12 + * Copyright (c) 1999
1.13 * Boris Fomitchev
1.14 *
1.15 * This material is provided "as is", with absolutely no warranty expressed
1.16 * or implied. Any use is at your own risk.
1.17 *
1.18 - * Permission to use or copy this software for any purpose is hereby granted
1.19 + * Permission to use or copy this software for any purpose is hereby granted
1.20 * without fee, provided the above notices are retained on all copies.
1.21 * Permission to modify the code and to distribute modified code is granted,
1.22 * provided the above notices are retained, and a notice that the code was
1.23 * modified is included with the above copyright notice.
1.24 *
1.25 - */
1.26 + */
1.27 // WARNING: This is an internal header file, included by other C++
1.28 // standard library headers. You should not attempt to use this header
1.29 // file directly.
1.30 @@ -32,29 +32,25 @@
1.31 # include <stl/_locale.h>
1.32 #endif
1.33
1.34 -#ifndef _STLP_STRING_H
1.35 +#ifndef _STLP_INTERNAL_STRING_H
1.36 # include <stl/_string.h>
1.37 #endif
1.38
1.39 _STLP_BEGIN_NAMESPACE
1.40
1.41 -
1.42 template <class _CharT> class collate {};
1.43 template <class _CharT> class collate_byname {};
1.44
1.45 _STLP_TEMPLATE_NULL
1.46 -#ifdef __SYMBIAN32__
1.47 -class collate<char> : public locale::facet
1.48 -#else
1.49 class _STLP_CLASS_DECLSPEC collate<char> : public locale::facet
1.50 -#endif
1.51 {
1.52 - friend class _Locale;
1.53 + friend class _Locale_impl;
1.54 +
1.55 public:
1.56 typedef char char_type;
1.57 typedef string string_type;
1.58
1.59 - explicit collate(size_t __refs = 0) : _BaseFacet(__refs) {}
1.60 + explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
1.61
1.62 int compare(const char* __low1, const char* __high1,
1.63 const char* __low2, const char* __high2) const {
1.64 @@ -68,39 +64,41 @@
1.65 long hash(const char* __low, const char* __high) const
1.66 { return do_hash(__low, __high); }
1.67
1.68 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.69 - _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
1.70 +#if defined(__SYMBIAN32__WSD__)
1.71 + static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
1.72 +#elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
1.73 + static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
1.74 + static locale::id id;
1.75 #else
1.76 - _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
1.77 + // NOTE: Symbian doesn't support exporting static data.
1.78 + // Users of this class should use GetFacetLocaleId() to access the data member id
1.79 + static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
1.80 #endif
1.81
1.82 protected:
1.83 -_STLP_DECLSPEC ~collate();
1.84 + _STLP_DECLSPEC ~collate();
1.85
1.86 -_STLP_DECLSPEC virtual int do_compare(const char*, const char*,
1.87 + _STLP_DECLSPEC virtual int do_compare(const char*, const char*,
1.88 const char*, const char*) const;
1.89 -_STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
1.90 -_STLP_DECLSPEC virtual long do_hash(const char*, const char*) const;
1.91 + _STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
1.92 + _STLP_DECLSPEC virtual long do_hash(const char*, const char*) const;
1.93 private:
1.94 collate(const collate<char>&);
1.95 - collate<char>& operator =(const collate<char>&);
1.96 + collate<char>& operator =(const collate<char>&);
1.97 };
1.98
1.99 # ifndef _STLP_NO_WCHAR_T
1.100
1.101 _STLP_TEMPLATE_NULL
1.102 -#ifdef __SYMBIAN32__
1.103 -class collate<wchar_t> : public locale::facet
1.104 -#else
1.105 class _STLP_CLASS_DECLSPEC collate<wchar_t> : public locale::facet
1.106 -#endif
1.107 {
1.108 - friend class _Locale;
1.109 + friend class _Locale_impl;
1.110 +
1.111 public:
1.112 typedef wchar_t char_type;
1.113 typedef wstring string_type;
1.114
1.115 - explicit collate(size_t __refs = 0) : _BaseFacet(__refs) {}
1.116 + explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
1.117
1.118 int compare(const wchar_t* __low1, const wchar_t* __high1,
1.119 const wchar_t* __low2, const wchar_t* __high2) const {
1.120 @@ -114,85 +112,82 @@
1.121 long hash(const wchar_t* __low, const wchar_t* __high) const
1.122 { return do_hash(__low, __high); }
1.123
1.124 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.125 - _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
1.126 +#if defined(__SYMBIAN32__WSD__)
1.127 + static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
1.128 +#elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
1.129 + static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
1.130 + static locale::id id;
1.131 #else
1.132 - _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
1.133 + // NOTE: Symbian doesn't support exporting static data.
1.134 + // Users of this class should use GetFacetLocaleId() to access the data member id
1.135 + static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
1.136 #endif
1.137
1.138 protected:
1.139 -_STLP_DECLSPEC ~collate();
1.140 + _STLP_DECLSPEC ~collate();
1.141
1.142 -_STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
1.143 + _STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
1.144 const wchar_t*, const wchar_t*) const;
1.145 -_STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
1.146 -_STLP_DECLSPEC virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
1.147 + _STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
1.148 + _STLP_DECLSPEC virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
1.149 private:
1.150 collate(const collate<wchar_t>&);
1.151 - collate<wchar_t>& operator = (const collate<wchar_t>&);
1.152 + collate<wchar_t>& operator = (const collate<wchar_t>&);
1.153 };
1.154
1.155 # endif /* NO_WCHAR_T */
1.156
1.157 _STLP_TEMPLATE_NULL
1.158 -class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char>
1.159 +class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char>
1.160 {
1.161 public:
1.162 - explicit _STLP_DECLSPEC collate_byname(const char* __name, size_t __refs = 0);
1.163 + _STLP_DECLSPEC explicit collate_byname(const char* __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
1.164
1.165 protected:
1.166 -_STLP_DECLSPEC ~collate_byname();
1.167 + _STLP_DECLSPEC ~collate_byname();
1.168
1.169 -_STLP_DECLSPEC virtual int do_compare(const char*, const char*,
1.170 + _STLP_DECLSPEC virtual int do_compare(const char*, const char*,
1.171 const char*, const char*) const;
1.172 -_STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
1.173 + _STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
1.174
1.175 private:
1.176 _Locale_collate* _M_collate;
1.177 collate_byname(const collate_byname<char>&);
1.178 - collate_byname<char>& operator =(const collate_byname<char>&);
1.179 + collate_byname<char>& operator =(const collate_byname<char>&);
1.180 + friend _Locale_name_hint* _Locale_extract_hint(collate_byname<char>*);
1.181 };
1.182
1.183 # ifndef _STLP_NO_WCHAR_T
1.184
1.185 _STLP_TEMPLATE_NULL
1.186 -class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t>
1.187 +class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t>
1.188 {
1.189 public:
1.190 - explicit _STLP_DECLSPEC collate_byname(const char * __name, size_t __refs = 0);
1.191 + _STLP_DECLSPEC explicit collate_byname(const char * __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
1.192
1.193 protected:
1.194 -_STLP_DECLSPEC ~collate_byname();
1.195 + _STLP_DECLSPEC ~collate_byname();
1.196
1.197 -_STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
1.198 + _STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
1.199 const wchar_t*, const wchar_t*) const;
1.200 -_STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
1.201 + _STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
1.202
1.203 private:
1.204 _Locale_collate* _M_collate;
1.205 collate_byname(const collate_byname<wchar_t>&);
1.206 - collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);
1.207 + collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);
1.208 };
1.209
1.210 # endif /* NO_WCHAR_T */
1.211
1.212 -
1.213 template <class _CharT, class _Traits, class _Alloc>
1.214 -bool
1.215 -__locale_do_operator_call (const locale* __that,
1.216 - const basic_string<_CharT, _Traits, _Alloc >& __x,
1.217 - const basic_string<_CharT, _Traits, _Alloc >& __y)
1.218 -{
1.219 -#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.220 - collate<_CharT>* __f = (collate<_CharT>*)__that->_M_get_facet(collate<_CharT>::GetFacetLocaleId());
1.221 -#else
1.222 - collate<_CharT>* __f = (collate<_CharT>*)__that->_M_get_facet(collate<_CharT>::id);
1.223 -#endif
1.224 - if (!__f)
1.225 - __that->_M_throw_runtime_error();
1.226 - return __f->compare(__x.data(), __x.data() + __x.size(),
1.227 - __y.data(), __y.data() + __y.size()) < 0;
1.228 -
1.229 +bool
1.230 +__locale_do_operator_call (const locale& __loc,
1.231 + const basic_string<_CharT, _Traits, _Alloc>& __x,
1.232 + const basic_string<_CharT, _Traits, _Alloc>& __y) {
1.233 + collate<_CharT> const& __coll = use_facet<collate<_CharT> >(__loc);
1.234 + return __coll.compare(__x.data(), __x.data() + __x.size(),
1.235 + __y.data(), __y.data() + __y.size()) < 0;
1.236 }
1.237
1.238 _STLP_END_NAMESPACE