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

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
 
string_type transform (collate_level level, const char_type *b, const char_type *e) const
 
long hash (collate_level level, 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
 
int do_compare (const char_type *b1, const char_type *e1, const char_type *b2, const char_type *e2) const override
 
string_type do_transform (const char_type *b, const char_type *e) const override
 
long do_hash (const char_type *b, const char_type *e) const override
 
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, allowing usage of std::locale for direct string comparison

Member Function Documentation

◆ compare() [1/2]

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 rage [b1,e1), [b2,e2) according using a 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/2]

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.

◆ do_compare() [1/2]

template<typename CharType >
int boost::locale::collator< CharType >::do_compare ( const char_type b1,
const char_type e1,
const char_type b2,
const char_type e2 
) const
inlineoverrideprotected

This function is used to override default collation function that does not take in account collation level. Uses primary level

◆ do_compare() [2/2]

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.

◆ do_hash()

template<typename CharType >
long boost::locale::collator< CharType >::do_hash ( const char_type b,
const char_type e 
) const
inlineoverrideprotected

This function is used to override default collation function that does not take in account collation level. Uses primary level

◆ do_transform()

template<typename CharType >
string_type boost::locale::collator< CharType >::do_transform ( const char_type b,
const char_type e 
) const
inlineoverrideprotected

This function is used to override default collation function that does not take in account collation level. Uses primary level

◆ hash() [1/2]

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/2]

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)

◆ transform() [1/2]

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)) );

Calls do_transform

◆ transform() [2/2]

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 these rules:

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

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