Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internationalization Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWUCollator

Module:  Internationalization Module   Group:  Unicode String Processing


Does Not Inherit

Local Index

Members

Header File

#include <rw/i18n/RWUCollator.h> 

Description

RWUCollator performs locale-sensitive string comparison for use in searching and sorting natural language text.

Each language has its own rules for determining the proper collation order for strings. For example, in Lithuanian, the letter y appears between i and k in the alphabet. In order to take language-specific conventions into account, each RWUCollator is associated with an RWULocale at construction time. This locale specifies the default values for a variety of RWUCollator attributes. Many of these default values can be overridden using attribute mutator methods.

RWUCollator follows the Unicode Collation Algorithm, as described in Unicode Technical Standard #10:

http://www.unicode.org/unicode/reports/tr10/.

This collation algorithm can be customized using the attribute mutator methods of the RWUCollator class. With these methods, you can specify how collation elements are found, how collation weights are formed, and which collation levels should be considered significant. See the Internationalization Module User's Guide for more information on collation.

RWUCollator calculates collation weights incrementally. This ensures good performance, as most strings differ in their first few characters. However, if string comparisons are to be made repeatedly (for example, when sorting a set of strings), then best performance can be achieved by obtaining an RWUCollationKey for each string and comparing the keys. Generating a key via RWUCollator::getCollationKey() is a non-trivial operation, as it involves determining the collation elements and weights for an entire string. Comparing two RWUCollationKey objects, however, is fast.

Example

Related Classes

RWUCollationKey, RWUNormalizer

Public Typedefs

enum CaseOrder { Normal,
                 LowerFirst,
                 UpperFirst
};
enum CollationStrength { Primary,
                         Secondary,
                         Tertiary,
                         Quaternary, 
                         Identical
};

Public Constructors

RWUCollator(const RWULocale& locale = 
            RWULocale::getDefault());
RWUCollator(const RWUCollator &original);

Public Destructor

~RWUCollator(void);

Public Member Operators

RWUCollator&
operator=(const RWUCollator &rhs);

Public Member Functions

int
compareTo(const RWUString& lhs, const RWUString& rhs) const;
void
enableCaseLevel(bool caseLevel);
void
enableFrenchCollation(bool frenchCollation);
void
enableNormalizationChecking(bool check);
void
enablePunctuationShifting(bool shift);
bool
equals(const RWUString& lhs, const RWUString& rhs) const;
CaseOrder
getCaseOrder(void) const;
RWUCollationKey
getCollationKey(const RWUString& str) const;
RWULocale
getLocale(void) const;
CollationStrength
getStrength(void) const;
bool
isEnabledCaseLevel(void) const;
bool
isEnabledFrenchCollation(void) const;
bool
isEnabledNormalizationChecking(void) const;
bool
isEnabledPunctuationShifting(void) const;
void 
setCaseOrder(CaseOrder order);
void
setStrength(CollationStrength strength);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.