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