epoc32/include/stdapis/stlportv5/stl/_collate.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 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_INTERNAL_STRING_H
    36 # include <stl/_string.h>
    37 #endif
    38 
    39 _STLP_BEGIN_NAMESPACE
    40 
    41 template <class _CharT> class collate {};
    42 template <class _CharT> class collate_byname {};
    43 
    44 _STLP_TEMPLATE_NULL
    45 class _STLP_CLASS_DECLSPEC collate<char> : public locale::facet
    46 {
    47   friend class _Locale_impl;
    48 
    49 public:
    50   typedef char   char_type;
    51   typedef string string_type;
    52 
    53   explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
    54 
    55   int compare(const char* __low1, const char* __high1,
    56               const char* __low2, const char* __high2) const {
    57     return do_compare( __low1, __high1, __low2, __high2);
    58   }
    59 
    60   string_type transform(const char* __low, const char* __high) const {
    61     return do_transform(__low, __high);
    62   }
    63 
    64   long hash(const char* __low, const char* __high) const
    65     { return do_hash(__low, __high); }
    66 
    67 #if defined(__SYMBIAN32__WSD__) 
    68   static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
    69 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)    
    70   static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
    71   static locale::id id;       
    72 #else
    73   // NOTE: Symbian doesn't support exporting static data.  
    74   // Users of this class should use GetFacetLocaleId() to access the data member id  
    75   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
    76 #endif
    77 
    78 protected:
    79   _STLP_DECLSPEC ~collate();
    80 
    81   _STLP_DECLSPEC virtual int do_compare(const char*, const char*,
    82                          const char*, const char*) const;
    83   _STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
    84   _STLP_DECLSPEC virtual long do_hash(const char*, const char*) const;
    85 private:
    86   collate(const collate<char>&);
    87   collate<char>& operator =(const collate<char>&);
    88 };
    89 
    90 # ifndef _STLP_NO_WCHAR_T
    91 
    92 _STLP_TEMPLATE_NULL
    93 class _STLP_CLASS_DECLSPEC collate<wchar_t> : public locale::facet
    94 {
    95   friend class _Locale_impl;
    96 
    97 public:
    98   typedef wchar_t char_type;
    99   typedef wstring string_type;
   100 
   101   explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
   102 
   103   int compare(const wchar_t* __low1, const wchar_t* __high1,
   104               const wchar_t* __low2, const wchar_t* __high2) const {
   105     return do_compare( __low1, __high1, __low2, __high2);
   106   }
   107 
   108   string_type transform(const wchar_t* __low, const wchar_t* __high) const {
   109     return do_transform(__low, __high);
   110   }
   111 
   112   long hash(const wchar_t* __low, const wchar_t* __high) const
   113     { return do_hash(__low, __high); }
   114 
   115 #if defined(__SYMBIAN32__WSD__) 
   116   static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
   117 #elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)    
   118   static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
   119   static locale::id id;       
   120 #else
   121   // NOTE: Symbian doesn't support exporting static data.  
   122   // Users of this class should use GetFacetLocaleId() to access the data member id  
   123   static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   124 #endif
   125 
   126 protected:
   127   _STLP_DECLSPEC ~collate();
   128 
   129   _STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
   130                          const wchar_t*, const wchar_t*) const;
   131   _STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
   132   _STLP_DECLSPEC virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
   133 private:
   134   collate(const collate<wchar_t>&);
   135   collate<wchar_t>& operator = (const collate<wchar_t>&);
   136 };
   137 
   138 # endif /* NO_WCHAR_T */
   139 
   140 _STLP_TEMPLATE_NULL
   141 class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char>
   142 {
   143 public:
   144   _STLP_DECLSPEC explicit collate_byname(const char* __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
   145 
   146 protected:
   147   _STLP_DECLSPEC ~collate_byname();
   148 
   149   _STLP_DECLSPEC virtual int do_compare(const char*, const char*,
   150                          const char*, const char*) const;
   151   _STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
   152 
   153 private:
   154   _Locale_collate* _M_collate;
   155   collate_byname(const collate_byname<char>&);
   156   collate_byname<char>& operator =(const collate_byname<char>&);
   157   friend _Locale_name_hint* _Locale_extract_hint(collate_byname<char>*);
   158 };
   159 
   160 # ifndef _STLP_NO_WCHAR_T
   161 
   162 _STLP_TEMPLATE_NULL
   163 class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t>
   164 {
   165 public:
   166   _STLP_DECLSPEC explicit collate_byname(const char * __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
   167 
   168 protected:
   169   _STLP_DECLSPEC ~collate_byname();
   170 
   171   _STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
   172                          const wchar_t*, const wchar_t*) const;
   173   _STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
   174 
   175 private:
   176   _Locale_collate* _M_collate;
   177   collate_byname(const collate_byname<wchar_t>&);
   178   collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);
   179 };
   180 
   181 # endif /* NO_WCHAR_T */
   182 
   183 template <class _CharT, class _Traits, class _Alloc>
   184 bool
   185 __locale_do_operator_call (const locale& __loc,
   186                            const basic_string<_CharT, _Traits, _Alloc>& __x,
   187                            const basic_string<_CharT, _Traits, _Alloc>& __y) {
   188   collate<_CharT> const& __coll = use_facet<collate<_CharT> >(__loc);
   189   return __coll.compare(__x.data(), __x.data() + __x.size(),
   190                         __y.data(), __y.data() + __y.size()) < 0;
   191 }
   192 
   193 _STLP_END_NAMESPACE
   194 
   195 #endif /* _STLP_INTERNAL_COLLATE_H */
   196 
   197 // Local Variables:
   198 // mode:C++
   199 // End: