Boost.Locale: boost::locale::collator< CharType > Class Template Reference

| Boost.Locale

Public Types | Public Member Functions | Protected Member Functions | List of all members
boost::locale::collator< CharType > Class Template Referenceabstract
Collation

Collation facet. More...

`#include <boost/locale/collator.hpp>`

Inheritance diagram for boost::locale::collator< CharType >:

## Public Types
typedef CharType | char_type
| Type of the underlying character.
typedef std::basic_string< CharType > | string_type
| Type of string used with this facet.

## Public Member Functions
int | compare (collate_level level, const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const
int | compare (const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const
string_type | transform (collate_level level, const char_type *b, const char_type *e) const
string_type | transform (const char_type *b, const char_type *e) const
long | hash (collate_level level, const char_type *b, const char_type *e) const
long | hash (const char_type *b, const char_type *e) const
int | compare (collate_level level, const string_type &l, const string_type &r) const
long | hash (collate_level level, const string_type &s) const
string_type | transform (collate_level level, const string_type &s) const

## Protected Member Functions
| collator (size_t refs=0)
| constructor of the collator object
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
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. Can be overridden.
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.

## Detailed Description

template<typename CharType>
class boost::locale::collator< CharType >

Collation facet.

It reimplements standard C++ std::collate with support for collation levels

## Member Function Documentation

## ◆ compare() [1/3]

template<typename CharType >

int boost::locale::collator< CharType >::compare | ( | collate_level | level,
|  | const char_type * | b1,
|  | const char_type * | e1,
|  | const char_type * | b2,
|  | const char_type * | e2
| ) |  | const
| inline

Compare two strings in range [b1,e1), [b2,e2) according to collation level level. Calls do_compare

Returns -1 if the first of the two strings sorts before the seconds, returns 1 if sorts after and 0 if they considered equal.

## ◆ compare() [2/3]

template<typename CharType >

int boost::locale::collator< CharType >::compare | ( | collate_level | level,
|  | const string_type & | l,
|  | const string_type & | r
| ) |  | const
| inline

Compare two strings l and r using collation level level

Returns -1 if the first of the two strings sorts before the seconds, returns 1 if sorts after and 0 if they considered equal.

## ◆ compare() [3/3]

template<typename CharType >

int boost::locale::collator< CharType >::compare | ( | const char_type * | b1,
|  | const char_type * | e1,
|  | const char_type * | b2,
|  | const char_type * | e2
| ) |  | const
| inline

Default compare function as-in std::collate that does not take collation level into account. Uses identical level

## ◆ do_compare()

template<typename CharType >

virtual int boost::locale::collator< CharType >::do_compare | ( | collate_level | level,
|  | const char_type * | b1,
|  | const char_type * | e1,
|  | const char_type * | b2,
|  | const char_type * | e2
| ) |  | const
| protectedpure virtual

Actual function that performs comparison between the strings. For details see compare member function. Can be overridden.

## ◆ hash() [1/3]

template<typename CharType >

long boost::locale::collator< CharType >::hash | ( | collate_level | level,
|  | const char_type * | b,
|  | const char_type * | e
| ) |  | const
| inline

Calculate a hash of a text in range [b,e). The value can be used for collation sensitive string comparison.

If compare(level,b1,e1,b2,e2) == 0 then hash(level,b1,e1) == hash(level,b2,e2)

Calls do_hash

## ◆ hash() [2/3]

template<typename CharType >

long boost::locale::collator< CharType >::hash | ( | collate_level | level,
|  | const string_type & | s
| ) |  | const
| inline

Calculate a hash that can be used for collation sensitive string comparison of a string s

If compare(level,s1,s2) == 0 then hash(level,s1) == hash(level,s2)

## ◆ hash() [3/3]

template<typename CharType >

long boost::locale::collator< CharType >::hash | ( | const char_type * | b,
|  | const char_type * | e
| ) |  | const
| inline

Default hash function as-in std::collate that does not take collation level into account. Uses identical level

## ◆ transform() [1/3]

template<typename CharType >

string_type boost::locale::collator< CharType >::transform | ( | collate_level | level,
|  | const char_type * | b,
|  | const char_type * | e
| ) |  | const
| inline

Create a binary string that can be compared to other in order to get collation order. The string is created for text in range [b,e). It is useful for collation of multiple strings for text.

The transformation follows these rules:

compare(level,b1,e1,b2,e2) == sign( transform(level,b1,e1).compare(transform(level,b2,e2)) );
boost::locale::collator::compare
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
boost::locale::collator::transform
string_type transform(collate_level level, const char_type *b, const char_type *e) const
Definition: collator.hpp:85

Calls do_transform

## ◆ transform() [2/3]

template<typename CharType >

string_type boost::locale::collator< CharType >::transform | ( | collate_level | level,
|  | const string_type & | s
| ) |  | const
| inline

Create a binary string from string s, that can be compared to other, useful for collation of multiple strings.

The transformation follows this rule:

compare(level,s1,s2) == sign( transform(level,s1).compare(transform(level,s2)) );

## ◆ transform() [3/3]

template<typename CharType >

string_type boost::locale::collator< CharType >::transform | ( | const char_type * | b,
|  | const char_type * | e
| ) |  | const
| inline

Default transform function as-in std::collate that does not take collation level into account. Uses identical level

The documentation for this class was generated from the following file:

- boost/locale/collator.hpp

- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.