1.1 --- a/epoc32/include/stdapis/stlport/stl/_collate.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_collate.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,204 @@
1.4 -_collate.h
1.5 +/*
1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation. 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 + * Boris Fomitchev
1.13 + *
1.14 + * This material is provided "as is", with absolutely no warranty expressed
1.15 + * or implied. Any use is at your own risk.
1.16 + *
1.17 + * Permission to use or copy this software for any purpose is hereby granted
1.18 + * without fee, provided the above notices are retained on all copies.
1.19 + * Permission to modify the code and to distribute modified code is granted,
1.20 + * provided the above notices are retained, and a notice that the code was
1.21 + * modified is included with the above copyright notice.
1.22 + *
1.23 + */
1.24 +// WARNING: This is an internal header file, included by other C++
1.25 +// standard library headers. You should not attempt to use this header
1.26 +// file directly.
1.27 +
1.28 +#ifndef _STLP_INTERNAL_COLLATE_H
1.29 +#define _STLP_INTERNAL_COLLATE_H
1.30 +
1.31 +#ifndef _STLP_C_LOCALE_H
1.32 +# include <stl/c_locale.h>
1.33 +#endif
1.34 +
1.35 +#ifndef _STLP_INTERNAL_LOCALE_H
1.36 +# include <stl/_locale.h>
1.37 +#endif
1.38 +
1.39 +#ifndef _STLP_STRING_H
1.40 +# include <stl/_string.h>
1.41 +#endif
1.42 +
1.43 +_STLP_BEGIN_NAMESPACE
1.44 +
1.45 +
1.46 +template <class _CharT> class collate {};
1.47 +template <class _CharT> class collate_byname {};
1.48 +
1.49 +_STLP_TEMPLATE_NULL
1.50 +#ifdef __SYMBIAN32__
1.51 +class collate<char> : public locale::facet
1.52 +#else
1.53 +class _STLP_CLASS_DECLSPEC collate<char> : public locale::facet
1.54 +#endif
1.55 +{
1.56 + friend class _Locale;
1.57 +public:
1.58 + typedef char char_type;
1.59 + typedef string string_type;
1.60 +
1.61 + explicit collate(size_t __refs = 0) : _BaseFacet(__refs) {}
1.62 +
1.63 + int compare(const char* __low1, const char* __high1,
1.64 + const char* __low2, const char* __high2) const {
1.65 + return do_compare( __low1, __high1, __low2, __high2);
1.66 + }
1.67 +
1.68 + string_type transform(const char* __low, const char* __high) const {
1.69 + return do_transform(__low, __high);
1.70 + }
1.71 +
1.72 + long hash(const char* __low, const char* __high) const
1.73 + { return do_hash(__low, __high); }
1.74 +
1.75 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.76 + _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
1.77 +#else
1.78 + _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
1.79 +#endif
1.80 +
1.81 +protected:
1.82 +_STLP_DECLSPEC ~collate();
1.83 +
1.84 +_STLP_DECLSPEC virtual int do_compare(const char*, const char*,
1.85 + const char*, const char*) const;
1.86 +_STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
1.87 +_STLP_DECLSPEC virtual long do_hash(const char*, const char*) const;
1.88 +private:
1.89 + collate(const collate<char>&);
1.90 + collate<char>& operator =(const collate<char>&);
1.91 +};
1.92 +
1.93 +# ifndef _STLP_NO_WCHAR_T
1.94 +
1.95 +_STLP_TEMPLATE_NULL
1.96 +#ifdef __SYMBIAN32__
1.97 +class collate<wchar_t> : public locale::facet
1.98 +#else
1.99 +class _STLP_CLASS_DECLSPEC collate<wchar_t> : public locale::facet
1.100 +#endif
1.101 +{
1.102 + friend class _Locale;
1.103 +public:
1.104 + typedef wchar_t char_type;
1.105 + typedef wstring string_type;
1.106 +
1.107 + explicit collate(size_t __refs = 0) : _BaseFacet(__refs) {}
1.108 +
1.109 + int compare(const wchar_t* __low1, const wchar_t* __high1,
1.110 + const wchar_t* __low2, const wchar_t* __high2) const {
1.111 + return do_compare( __low1, __high1, __low2, __high2);
1.112 + }
1.113 +
1.114 + string_type transform(const wchar_t* __low, const wchar_t* __high) const {
1.115 + return do_transform(__low, __high);
1.116 + }
1.117 +
1.118 + long hash(const wchar_t* __low, const wchar_t* __high) const
1.119 + { return do_hash(__low, __high); }
1.120 +
1.121 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.122 + _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
1.123 +#else
1.124 + _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
1.125 +#endif
1.126 +
1.127 +protected:
1.128 +_STLP_DECLSPEC ~collate();
1.129 +
1.130 +_STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
1.131 + const wchar_t*, const wchar_t*) const;
1.132 +_STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
1.133 +_STLP_DECLSPEC virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
1.134 +private:
1.135 + collate(const collate<wchar_t>&);
1.136 + collate<wchar_t>& operator = (const collate<wchar_t>&);
1.137 +};
1.138 +
1.139 +# endif /* NO_WCHAR_T */
1.140 +
1.141 +_STLP_TEMPLATE_NULL
1.142 +class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char>
1.143 +{
1.144 +public:
1.145 + explicit _STLP_DECLSPEC collate_byname(const char* __name, size_t __refs = 0);
1.146 +
1.147 +protected:
1.148 +_STLP_DECLSPEC ~collate_byname();
1.149 +
1.150 +_STLP_DECLSPEC virtual int do_compare(const char*, const char*,
1.151 + const char*, const char*) const;
1.152 +_STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
1.153 +
1.154 +private:
1.155 + _Locale_collate* _M_collate;
1.156 + collate_byname(const collate_byname<char>&);
1.157 + collate_byname<char>& operator =(const collate_byname<char>&);
1.158 +};
1.159 +
1.160 +# ifndef _STLP_NO_WCHAR_T
1.161 +
1.162 +_STLP_TEMPLATE_NULL
1.163 +class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t>
1.164 +{
1.165 +public:
1.166 + explicit _STLP_DECLSPEC collate_byname(const char * __name, size_t __refs = 0);
1.167 +
1.168 +protected:
1.169 +_STLP_DECLSPEC ~collate_byname();
1.170 +
1.171 +_STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
1.172 + const wchar_t*, const wchar_t*) const;
1.173 +_STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
1.174 +
1.175 +private:
1.176 + _Locale_collate* _M_collate;
1.177 + collate_byname(const collate_byname<wchar_t>&);
1.178 + collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);
1.179 +};
1.180 +
1.181 +# endif /* NO_WCHAR_T */
1.182 +
1.183 +
1.184 +template <class _CharT, class _Traits, class _Alloc>
1.185 +bool
1.186 +__locale_do_operator_call (const locale* __that,
1.187 + const basic_string<_CharT, _Traits, _Alloc >& __x,
1.188 + const basic_string<_CharT, _Traits, _Alloc >& __y)
1.189 +{
1.190 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.191 + collate<_CharT>* __f = (collate<_CharT>*)__that->_M_get_facet(collate<_CharT>::GetFacetLocaleId());
1.192 +#else
1.193 + collate<_CharT>* __f = (collate<_CharT>*)__that->_M_get_facet(collate<_CharT>::id);
1.194 +#endif
1.195 + if (!__f)
1.196 + __that->_M_throw_runtime_error();
1.197 + return __f->compare(__x.data(), __x.data() + __x.size(),
1.198 + __y.data(), __y.data() + __y.size()) < 0;
1.199 +
1.200 +}
1.201 +
1.202 +_STLP_END_NAMESPACE
1.203 +
1.204 +#endif /* _STLP_INTERNAL_COLLATE_H */
1.205 +
1.206 +// Local Variables:
1.207 +// mode:C++
1.208 +// End: