Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::locale::collator< CharType > Class Template Referenceabstract

Collation facet. More...

#include <collator.hpp>

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

Public Types

typedef CharType char_type
 Type of the underlying character. More...
 
typedef std::basic_string
< CharType > 
string_type
 Type of string used with this facet. More...
 
enum  level_type {
  primary = 0,
  secondary = 1,
  tertiary = 2,
  quaternary = 3,
  identical = 4
}
 Unicode collation level types. More...
 

Public Member Functions

int compare (level_type level, char_type const *b1, char_type const *e1, char_type const *b2, char_type const *e2) const
 Compare two strings in rage [b1,e1), [b2,e2) according using a collation level level. More...
 
string_type transform (level_type level, char_type const *b, char_type const *e) const
 Create a binary string that can be compared to other in order to get collation order. More...
 
long hash (level_type level, char_type const *b, char_type const *e) const
 Calculate a hash of a text in range [b,e). More...
 
int compare (level_type level, string_type const &l, string_type const &r) const
 Compare two strings l and r using collation level level. More...
 
long hash (level_type level, string_type const &s) const
 Calculate a hash that can be used for collation sensitive string comparison of a string s. More...
 
string_type transform (level_type level, string_type const &s) const
 Create a binary string from string s, that can be compared to other, useful for collation of multiple strings. More...
 

Protected Member Functions

 collator (size_t refs=0)
 constructor of the collator object More...
 
virtual ~collator ()
 
virtual int do_compare (char_type const *b1, char_type const *e1, char_type const *b2, char_type const *e2) const
 This function is used to override default collation function that does not take in account collation level. More...
 
virtual string_type do_transform (char_type const *b, char_type const *e) const
 This function is used to override default collation function that does not take in account collation level. More...
 
virtual long do_hash (char_type const *b, char_type const *e) const
 This function is used to override default collation function that does not take in account collation level. More...
 
virtual int do_compare (level_type level, char_type const *b1, char_type const *e1, char_type const *b2, char_type const *e2) const =0
 Actual function that performs comparison between the strings. More...
 
virtual string_type do_transform (level_type level, char_type const *b, char_type const *e) const =0
 Actual function that performs transformation. More...
 
virtual long do_hash (level_type level, char_type const *b, char_type const *e) const =0
 Actual function that calculates hash. More...
 

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 Typedef Documentation

template<typename CharType >
typedef CharType boost::locale::collator< CharType >::char_type

Type of the underlying character.

template<typename CharType >
typedef std::basic_string<CharType> boost::locale::collator< CharType >::string_type

Type of string used with this facet.

Constructor & Destructor Documentation

template<typename CharType >
boost::locale::collator< CharType >::collator ( size_t  refs = 0)
inlineprotected

constructor of the collator object

template<typename CharType >
virtual boost::locale::collator< CharType >::~collator ( )
inlineprotectedvirtual

Member Function Documentation

template<typename CharType >
int boost::locale::collator< CharType >::compare ( level_type  level,
char_type const *  b1,
char_type const *  e1,
char_type const *  b2,
char_type const *  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.

References boost::locale::collator< CharType >::do_compare().

template<typename CharType >
int boost::locale::collator< CharType >::compare ( level_type  level,
string_type const &  l,
string_type const &  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.

References boost::locale::collator< CharType >::do_compare().

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

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

Uses primary level

References boost::locale::collator_base::identical.

Referenced by boost::locale::collator< CharType >::compare().

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

Actual function that performs comparison between the strings.

For details see compare member function. Can be overridden.

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

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

Uses primary level

References boost::locale::collator_base::identical.

Referenced by boost::locale::collator< CharType >::hash().

template<typename CharType >
virtual long boost::locale::collator< CharType >::do_hash ( level_type  level,
char_type const *  b,
char_type const *  e 
) const
protectedpure virtual

Actual function that calculates hash.

For details see hash member function. Can be overridden.

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

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

Uses primary level

References boost::locale::collator_base::identical.

Referenced by boost::locale::collator< CharType >::transform().

template<typename CharType >
virtual string_type boost::locale::collator< CharType >::do_transform ( level_type  level,
char_type const *  b,
char_type const *  e 
) const
protectedpure virtual

Actual function that performs transformation.

For details see transform member function. Can be overridden.

template<typename CharType >
long boost::locale::collator< CharType >::hash ( level_type  level,
char_type const *  b,
char_type const *  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

References boost::locale::collator< CharType >::do_hash().

template<typename CharType >
long boost::locale::collator< CharType >::hash ( level_type  level,
string_type const &  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)

References boost::locale::collator< CharType >::do_hash().

template<typename CharType >
string_type boost::locale::collator< CharType >::transform ( level_type  level,
char_type const *  b,
char_type const *  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

References boost::locale::collator< CharType >::do_transform().

template<typename CharType >
string_type boost::locale::collator< CharType >::transform ( level_type  level,
string_type const &  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:

References boost::locale::collator< CharType >::do_transform().


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