ReactOS  0.4.14-dev-342-gdc047f9
_collate.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999
3  * Silicon Graphics Computer Systems, Inc.
4  *
5  * Copyright (c) 1999
6  * Boris Fomitchev
7  *
8  * This material is provided "as is", with absolutely no warranty expressed
9  * or implied. Any use is at your own risk.
10  *
11  * Permission to use or copy this software for any purpose is hereby granted
12  * without fee, provided the above notices are retained on all copies.
13  * Permission to modify the code and to distribute modified code is granted,
14  * provided the above notices are retained, and a notice that the code was
15  * modified is included with the above copyright notice.
16  *
17  */
18 // WARNING: This is an internal header file, included by other C++
19 // standard library headers. You should not attempt to use this header
20 // file directly.
21 
22 #ifndef _STLP_INTERNAL_COLLATE_H
23 #define _STLP_INTERNAL_COLLATE_H
24 
25 #ifndef _STLP_C_LOCALE_H
26 # include <stl/c_locale.h>
27 #endif
28 
29 #ifndef _STLP_INTERNAL_LOCALE_H
30 # include <stl/_locale.h>
31 #endif
32 
33 #ifndef _STLP_INTERNAL_STRING_H
34 # include <stl/_string.h>
35 #endif
36 
38 
39 template <class _CharT> class collate {};
40 template <class _CharT> class collate_byname {};
41 
44 public:
45  typedef char char_type;
46  typedef string string_type;
47 
48  explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
49 
50  int compare(const char* __low1, const char* __high1,
51  const char* __low2, const char* __high2) const {
52  return do_compare( __low1, __high1, __low2, __high2);
53  }
54 
55  string_type transform(const char* __low, const char* __high) const {
56  return do_transform(__low, __high);
57  }
58 
59  long hash(const char* __low, const char* __high) const
60  { return do_hash(__low, __high); }
61 
63 
64 protected:
65  ~collate();
66 
67  virtual int do_compare(const char*, const char*,
68  const char*, const char*) const;
69  virtual string_type do_transform(const char*, const char*) const;
70  virtual long do_hash(const char*, const char*) const;
71 private:
72  collate(const collate<char>&);
74 };
75 
76 # ifndef _STLP_NO_WCHAR_T
77 
80 public:
81  typedef wchar_t char_type;
82  typedef wstring string_type;
83 
84  explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
85 
86  int compare(const wchar_t* __low1, const wchar_t* __high1,
87  const wchar_t* __low2, const wchar_t* __high2) const {
88  return do_compare( __low1, __high1, __low2, __high2);
89  }
90 
91  string_type transform(const wchar_t* __low, const wchar_t* __high) const {
92  return do_transform(__low, __high);
93  }
94 
95  long hash(const wchar_t* __low, const wchar_t* __high) const
96  { return do_hash(__low, __high); }
97 
99 
100 protected:
101  ~collate();
102 
103  virtual int do_compare(const wchar_t*, const wchar_t*,
104  const wchar_t*, const wchar_t*) const;
105  virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
106  virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
107 private:
108  collate(const collate<wchar_t>&);
110 };
111 
112 # endif /* NO_WCHAR_T */
113 
116  friend class _Locale_impl;
117 public:
118  explicit collate_byname(const char* __name, size_t __refs = 0);
119 
120 protected:
121  ~collate_byname();
122 
123  virtual int do_compare(const char*, const char*,
124  const char*, const char*) const;
125  virtual string_type do_transform(const char*, const char*) const;
126 
127 private:
129  : _M_collate(__coll) {}
133 };
134 
135 # ifndef _STLP_NO_WCHAR_T
136 
139  friend class _Locale_impl;
140 public:
141  explicit collate_byname(const char * __name, size_t __refs = 0);
142 
143 protected:
144  ~collate_byname();
145 
146  virtual int do_compare(const wchar_t*, const wchar_t*,
147  const wchar_t*, const wchar_t*) const;
148  virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
149 
150 private:
152  : _M_collate(__coll) {}
156 };
157 
158 # endif /* NO_WCHAR_T */
159 
160 template <class _CharT, class _Traits, class _Alloc>
161 bool
165  collate<_CharT> const& __coll = use_facet<collate<_CharT> >(__loc);
166  return __coll.compare(__x.data(), __x.data() + __x.size(),
167  __y.data(), __y.data() + __y.size()) < 0;
168 }
169 
171 
172 #endif /* _STLP_INTERNAL_COLLATE_H */
173 
174 // Local Variables:
175 // mode:C++
176 // End:
int compare(const char *__low1, const char *__high1, const char *__low2, const char *__high2) const
Definition: _collate.h:50
_Locale_collate * _M_collate
Definition: _collate.h:153
static _STLP_STATIC_DECLSPEC locale::id id
Definition: _collate.h:62
long hash(const char *__low, const char *__high) const
Definition: _collate.h:59
collate(size_t __refs=0)
Definition: _collate.h:84
wstring string_type
Definition: _collate.h:82
const _CharT * data() const
Definition: _string.h:950
void operator=(const facet &)
string string_type
Definition: _collate.h:46
void operator=(const _Locale_impl &)
wchar_t char_type
Definition: _collate.h:81
Definition: _locale.h:75
size_type size() const
Definition: _string.h:400
unsigned char
Definition: typeof.h:29
unsigned short wchar_t
Definition: crtdefs.h:324
collate(size_t __refs=0)
Definition: _collate.h:48
collate_byname(_Locale_collate *__coll)
Definition: _collate.h:151
_Locale_collate * _M_collate
Definition: _collate.h:130
static __inline int do_hash(unsigned char *name, int len, int size)
Definition: hash.c:63
string_type transform(const char *__low, const char *__high) const
Definition: _collate.h:55
int compare(const wchar_t *__low1, const wchar_t *__high1, const wchar_t *__low2, const wchar_t *__high2) const
Definition: _collate.h:86
collate_byname(_Locale_collate *__coll)
Definition: _collate.h:128
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
char char_type
Definition: _collate.h:45
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
#define _STLP_END_NAMESPACE
Definition: features.h:503
string_type transform(const wchar_t *__low, const wchar_t *__high) const
Definition: _collate.h:91
long hash(const wchar_t *__low, const wchar_t *__high) const
Definition: _collate.h:95
static _STLP_STATIC_DECLSPEC locale::id id
Definition: _collate.h:98
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_STATIC_DECLSPEC
Definition: features.h:992
bool __locale_do_operator_call(const locale &__loc, const basic_string< _CharT, _Traits, _Alloc > &__x, const basic_string< _CharT, _Traits, _Alloc > &__y)
Definition: _collate.h:162