7#ifndef BOOST_LOCALE_COLLATOR_HPP_INCLUDED
8#define BOOST_LOCALE_COLLATOR_HPP_INCLUDED
10#include <boost/locale/config.hpp>
15# pragma warning(disable : 4275 4251 4231 4660)
18namespace boost {
namespace locale {
34 class BOOST_DEPRECATED(
"Use collate_level") collator_base {
48 template<
typename CharType>
49 class collator :
public std::collate<CharType> {
96 return do_compare(level, l.data(), l.data() + l.size(), r.data(), r.data() + r.size());
104 return do_hash(level, s.data(), s.data() + s.size());
116 return do_transform(level, s.data(), s.data() + s.size());
121 collator(
size_t refs = 0) : std::collate<CharType>(refs) {}
169 template<
typename CharType, collate_level default_level = collate_level::
identical>
176 locale_(l), level_(level)
180 bool operator()(
const std::basic_string<CharType>& left,
const std::basic_string<CharType>& right)
const
182 return std::use_facet<collator<CharType>>(locale_).compare(level_, left, right) < 0;
Collation facet.
Definition: collator.hpp:49
long hash(collate_level level, const string_type &s) const
Definition: collator.hpp:102
std::basic_string< CharType > string_type
Type of string used with this facet.
Definition: collator.hpp:54
int compare(collate_level level, const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const
Definition: collator.hpp:60
collator(size_t refs=0)
constructor of the collator object
Definition: collator.hpp:121
CharType char_type
Type of the underlying character.
Definition: collator.hpp:52
virtual int do_compare(collate_level level, const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const =0
int do_compare(const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const override
Definition: collator.hpp:126
virtual long do_hash(collate_level level, const char_type *b, const char_type *e) const =0
Actual function that calculates hash. For details see hash member function. Can be overridden.
string_type do_transform(const char_type *b, const char_type *e) const override
Definition: collator.hpp:133
long do_hash(const char_type *b, const char_type *e) const override
Definition: collator.hpp:140
long hash(collate_level level, const char_type *b, const char_type *e) const
Definition: collator.hpp:88
int compare(collate_level level, const string_type &l, const string_type &r) const
Definition: collator.hpp:94
virtual string_type do_transform(collate_level level, const char_type *b, const char_type *e) const =0
Actual function that performs transformation. For details see transform member function....
string_type transform(collate_level level, const char_type *b, const char_type *e) const
Definition: collator.hpp:78
string_type transform(collate_level level, const string_type &s) const
Definition: collator.hpp:114
collate_level
Unicode collation level types.
Definition: collator.hpp:26
@ secondary
2nd collation level: letters and accents
@ primary
1st collation level: base letters
@ quaternary
4th collation level: letters, accents, case and punctuation
@ tertiary
3rd collation level: letters, accents and case
@ identical
identical collation level: include code-point comparison
This class can be used in STL algorithms and containers for comparison of strings with a level other ...
Definition: collator.hpp:170
comparator(const std::locale &l=std::locale(), collate_level level=default_level)
Definition: collator.hpp:175
bool operator()(const std::basic_string< CharType > &left, const std::basic_string< CharType > &right) const
Compare two strings – equivalent to return left < right according to collation rules.
Definition: collator.hpp:180