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