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