7#ifndef BOOST_LOCALE_COLLATOR_HPP_INCLUDED
8#define BOOST_LOCALE_COLLATOR_HPP_INCLUDED
10#include <boost/locale/config.hpp>
11#include <boost/locale/detail/facet_id.hpp>
16# pragma warning(disable : 4275 4251 4231 4660)
19namespace boost {
namespace locale {
35 class BOOST_DEPRECATED(
"Use collate_level") collator_base {
48 template<
typename CharType>
49 class BOOST_SYMBOL_VISIBLE
collator :
public std::locale::facet,
public detail::facet_id<collator<CharType>> {
66 return do_compare(level, b1, e1, b2, e2);
73 return compare(collate_level::identical, b1, e1, b2, e2);
87 return do_transform(level, b, e);
94 return transform(collate_level::identical, b, e);
114 return do_compare(level, l.data(), l.data() + l.size(), r.data(), r.data() + r.size());
122 return do_hash(level, s.data(), s.data() + s.size());
134 return do_transform(level, s.data(), s.data() + s.size());
139 collator(
size_t refs = 0) : std::locale::facet(refs) {}
165 template<
typename CharType, collate_level default_level = collate_level::
identical>
172 locale_(l), collator_(std::use_facet<
collator<CharType>>(locale_)), level_(level)
176 bool operator()(
const std::basic_string<CharType>& left,
const std::basic_string<CharType>& right)
const
178 return collator_.compare(level_, left, right) < 0;
Collation facet.
Definition: collator.hpp:49
long hash(collate_level level, const string_type &s) const
Definition: collator.hpp:120
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
int compare(const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const
Definition: collator.hpp:71
collator(size_t refs=0)
constructor of the collator object
Definition: collator.hpp:139
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
string_type transform(const char_type *b, const char_type *e) const
Definition: collator.hpp:92
long hash(const char_type *b, const char_type *e) const
Definition: collator.hpp:106
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.
long hash(collate_level level, const char_type *b, const char_type *e) const
Definition: collator.hpp:102
int compare(collate_level level, const string_type &l, const string_type &r) const
Definition: collator.hpp:112
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:85
string_type transform(collate_level level, const string_type &s) const
Definition: collator.hpp:132
collate_level
Unicode collation level types.
Definition: collator.hpp:27
@ 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:166
comparator(const std::locale &l=std::locale(), collate_level level=default_level)
Definition: collator.hpp:171
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:176