7 #ifndef BOOST_LOCALE_COLLATOR_HPP_INCLUDED 8 #define BOOST_LOCALE_COLLATOR_HPP_INCLUDED 10 #include <boost/locale/config.hpp> 14 # pragma warning(push) 15 # pragma warning(disable : 4275 4251 4231 4660) 18 namespace boost {
namespace locale {
50 template<
typename CharType>
51 class collator :
public std::collate<CharType> {
98 return do_compare(level, l.data(), l.data() + l.size(), r.data(), r.data() + r.size());
106 return do_hash(level, s.data(), s.data() + s.size());
118 return do_transform(level, s.data(), s.data() + s.size());
123 collator(
size_t refs = 0) : std::collate<CharType>(refs) {}
171 template<
typename CharType, collate_level default_level = collate_level::
identical>
178 locale_(l), level_(level)
182 bool operator()(
const std::basic_string<CharType>& left,
const std::basic_string<CharType>& right)
const 184 return std::use_facet<collator<CharType>>(locale_).compare(level_, left, right) < 0;
196 # pragma warning(pop) 1st collation level: base letters
long do_hash(const char_type *b, const char_type *e) const override
Definition: collator.hpp:142
string_type transform(collate_level level, const char_type *b, const char_type *e) const
Definition: collator.hpp:80
CharType char_type
Type of the underlying character.
Definition: collator.hpp:54
int do_compare(const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const override
Definition: collator.hpp:128
std::basic_string< CharType > string_type
Type of string used with this facet.
Definition: collator.hpp:56
collator(size_t refs=0)
constructor of the collator object
Definition: collator.hpp:123
3rd collation level: letters, accents and case
string_type do_transform(const char_type *b, const char_type *e) const override
Definition: collator.hpp:135
int compare(collate_level level, const string_type &l, const string_type &r) const
Definition: collator.hpp:96
long hash(collate_level level, const char_type *b, const char_type *e) const
Definition: collator.hpp:90
long hash(collate_level level, const string_type &s) const
Definition: collator.hpp:104
string_type transform(collate_level level, const string_type &s) const
Definition: collator.hpp:116
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:62
Collation facet.
Definition: collator.hpp:51
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:182
identical collation level: include code-point comparison
2nd collation level: letters and accents
collate_level
Unicode collation level types.
Definition: collator.hpp:28
4th collation level: letters, accents, case and punctuation
This class can be used in STL algorithms and containers for comparison of strings with a level other ...
Definition: collator.hpp:172
comparator(const std::locale &l=std::locale(), collate_level level=default_level)
Definition: collator.hpp:177