1999-12-28 23:57:50 +00:00
|
|
|
/*
|
2001-01-18 00:22:38 +00:00
|
|
|
******************************************************************************
|
2012-02-18 23:10:51 +00:00
|
|
|
* Copyright (C) 1996-2012, International Business Machines Corporation and
|
2001-01-18 00:22:38 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2008-05-28 21:20:51 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief C++ API: RuleBasedCollator class provides the simple implementation of Collator.
|
|
|
|
*/
|
|
|
|
|
2001-01-18 00:22:38 +00:00
|
|
|
/**
|
2001-01-30 18:52:58 +00:00
|
|
|
* File tblcoll.h
|
|
|
|
*
|
|
|
|
* Created by: Helena Shih
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 2/5/97 aliu Added streamIn and streamOut methods. Added
|
|
|
|
* constructor which reads RuleBasedCollator object from
|
|
|
|
* a binary file. Added writeToFile method which streams
|
|
|
|
* RuleBasedCollator out to a binary file. The streamIn
|
|
|
|
* and streamOut methods use istream and ostream objects
|
|
|
|
* in binary mode.
|
|
|
|
* 2/12/97 aliu Modified to use TableCollationData sub-object to
|
|
|
|
* hold invariant data.
|
|
|
|
* 2/13/97 aliu Moved several methods into this class from Collation.
|
|
|
|
* Added a private RuleBasedCollator(Locale&) constructor,
|
|
|
|
* to be used by Collator::createDefault(). General
|
|
|
|
* clean up.
|
|
|
|
* 2/20/97 helena Added clone, operator==, operator!=, operator=, and copy
|
|
|
|
* constructor and getDynamicClassID.
|
|
|
|
* 3/5/97 aliu Modified constructFromFile() to add parameter
|
|
|
|
* specifying whether or not binary loading is to be
|
|
|
|
* attempted. This is required for dynamic rule loading.
|
|
|
|
* 05/07/97 helena Added memory allocation error detection.
|
2001-03-22 00:09:10 +00:00
|
|
|
* 6/17/97 helena Added IDENTICAL strength for compare, changed getRules to
|
2001-01-30 18:52:58 +00:00
|
|
|
* use MergeCollation::getPattern.
|
|
|
|
* 6/20/97 helena Java class name change.
|
|
|
|
* 8/18/97 helena Added internal API documentation.
|
|
|
|
* 09/03/97 helena Added createCollationKeyValues().
|
|
|
|
* 02/10/98 damiba Added compare with "length" parameter
|
|
|
|
* 08/05/98 erm Synched with 1.2 version of RuleBasedCollator.java
|
|
|
|
* 04/23/99 stephen Removed EDecompositionMode, merged with
|
|
|
|
* Normalizer::EMode
|
|
|
|
* 06/14/99 stephen Removed kResourceBundleSuffix
|
2001-03-22 00:09:10 +00:00
|
|
|
* 11/02/99 helena Collator performance enhancements. Eliminates the
|
2001-01-30 18:52:58 +00:00
|
|
|
* UnicodeString construction and special case for NO_OP.
|
|
|
|
* 11/23/99 srl More performance enhancements. Updates to NormalizerIterator
|
|
|
|
* internal state management.
|
|
|
|
* 12/15/99 aliu Update to support Thai collation. Move NormalizerIterator
|
|
|
|
* to implementation file.
|
2001-03-22 00:09:10 +00:00
|
|
|
* 01/29/01 synwee Modified into a C++ wrapper which calls C API
|
2001-01-30 18:52:58 +00:00
|
|
|
* (ucol.h)
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TBLCOLL_H
|
|
|
|
#define TBLCOLL_H
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2005-06-22 22:39:36 +00:00
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#if !UCONFIG_NO_COLLATION
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/coll.h"
|
2003-05-08 17:31:45 +00:00
|
|
|
#include "unicode/ucol.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/sortkey.h"
|
|
|
|
#include "unicode/normlzr.h"
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2002-08-12 16:20:26 +00:00
|
|
|
/**
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
2002-08-12 16:20:26 +00:00
|
|
|
*/
|
2001-10-08 23:26:58 +00:00
|
|
|
class StringSearch;
|
2002-08-12 16:20:26 +00:00
|
|
|
/**
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
2002-08-12 16:20:26 +00:00
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
class CollationElementIterator;
|
|
|
|
|
|
|
|
/**
|
2001-03-22 00:09:10 +00:00
|
|
|
* The RuleBasedCollator class provides the simple implementation of
|
|
|
|
* Collator, using data-driven tables. The user can create a customized
|
2001-01-18 00:22:38 +00:00
|
|
|
* table-based collation.
|
1999-12-28 23:57:50 +00:00
|
|
|
* <P>
|
2001-11-15 22:49:24 +00:00
|
|
|
* <em>Important: </em>The ICU collation service has been reimplemented
|
|
|
|
* in order to achieve better performance and UCA compliance.
|
|
|
|
* For details, see the
|
2007-06-11 19:14:47 +00:00
|
|
|
* <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm">
|
2001-11-15 22:49:24 +00:00
|
|
|
* collation design document</a>.
|
1999-12-28 23:57:50 +00:00
|
|
|
* <p>
|
2001-11-15 22:49:24 +00:00
|
|
|
* RuleBasedCollator is a thin C++ wrapper over the C implementation.
|
1999-12-28 23:57:50 +00:00
|
|
|
* <p>
|
2001-11-15 22:49:24 +00:00
|
|
|
* For more information about the collation service see
|
2007-06-11 19:14:47 +00:00
|
|
|
* <a href="http://icu-project.org/userguide/Collate_Intro.html">the users guide</a>.
|
1999-12-28 23:57:50 +00:00
|
|
|
* <p>
|
2001-11-15 22:49:24 +00:00
|
|
|
* Collation service provides correct sorting orders for most locales supported in ICU.
|
|
|
|
* If specific data for a locale is not available, the orders eventually falls back
|
|
|
|
* to the <a href="http://www.unicode.org/unicode/reports/tr10/">UCA sort order</a>.
|
|
|
|
* <p>
|
|
|
|
* Sort ordering may be customized by providing your own set of rules. For more on
|
2007-06-11 19:14:47 +00:00
|
|
|
* this subject see the <a href="http://icu-project.org/userguide/Collate_Customization.html">
|
2001-11-15 22:49:24 +00:00
|
|
|
* Collation customization</a> section of the users guide.
|
1999-12-28 23:57:50 +00:00
|
|
|
* <p>
|
2002-09-11 00:27:41 +00:00
|
|
|
* Note, RuleBasedCollator is not to be subclassed.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see Collator
|
2001-11-15 22:49:24 +00:00
|
|
|
* @version 2.0 11/15/2001
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2001-03-22 00:09:10 +00:00
|
|
|
class U_I18N_API RuleBasedCollator : public Collator
|
1999-12-28 23:57:50 +00:00
|
|
|
{
|
2001-03-22 00:09:10 +00:00
|
|
|
public:
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2001-01-18 00:22:38 +00:00
|
|
|
// constructor -------------------------------------------------------------
|
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* RuleBasedCollator constructor. This takes the table rules and builds a
|
|
|
|
* collation table out of them. Please see RuleBasedCollator class
|
|
|
|
* description for more details on the collation rule syntax.
|
|
|
|
* @param rules the collation rules to build the collation table from.
|
|
|
|
* @param status reporting a success or an error.
|
|
|
|
* @see Locale
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2001-10-11 23:54:55 +00:00
|
|
|
RuleBasedCollator(const UnicodeString& rules, UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* RuleBasedCollator constructor. This takes the table rules and builds a
|
|
|
|
* collation table out of them. Please see RuleBasedCollator class
|
|
|
|
* description for more details on the collation rule syntax.
|
|
|
|
* @param rules the collation rules to build the collation table from.
|
|
|
|
* @param collationStrength default strength for comparison
|
|
|
|
* @param status reporting a success or an error.
|
|
|
|
* @see Locale
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
RuleBasedCollator(const UnicodeString& rules,
|
2001-03-22 00:09:10 +00:00
|
|
|
ECollationStrength collationStrength,
|
2001-01-18 00:22:38 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* RuleBasedCollator constructor. This takes the table rules and builds a
|
|
|
|
* collation table out of them. Please see RuleBasedCollator class
|
|
|
|
* description for more details on the collation rule syntax.
|
|
|
|
* @param rules the collation rules to build the collation table from.
|
|
|
|
* @param decompositionMode the normalisation mode
|
|
|
|
* @param status reporting a success or an error.
|
|
|
|
* @see Locale
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
RuleBasedCollator(const UnicodeString& rules,
|
2001-09-22 01:10:41 +00:00
|
|
|
UColAttributeValue decompositionMode,
|
2001-01-18 00:22:38 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* RuleBasedCollator constructor. This takes the table rules and builds a
|
|
|
|
* collation table out of them. Please see RuleBasedCollator class
|
|
|
|
* description for more details on the collation rule syntax.
|
|
|
|
* @param rules the collation rules to build the collation table from.
|
|
|
|
* @param collationStrength default strength for comparison
|
|
|
|
* @param decompositionMode the normalisation mode
|
|
|
|
* @param status reporting a success or an error.
|
|
|
|
* @see Locale
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
RuleBasedCollator(const UnicodeString& rules,
|
2001-01-18 00:22:38 +00:00
|
|
|
ECollationStrength collationStrength,
|
2001-09-22 01:10:41 +00:00
|
|
|
UColAttributeValue decompositionMode,
|
2001-01-18 00:22:38 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Copy constructor.
|
|
|
|
* @param other the RuleBasedCollator object to be copied
|
|
|
|
* @see Locale
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2001-10-11 23:54:55 +00:00
|
|
|
RuleBasedCollator(const RuleBasedCollator& other);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2005-06-16 20:08:56 +00:00
|
|
|
|
|
|
|
/** Opens a collator from a collator binary image created using
|
|
|
|
* cloneBinary. Binary image used in instantiation of the
|
|
|
|
* collator remains owned by the user and should stay around for
|
|
|
|
* the lifetime of the collator. The API also takes a base collator
|
|
|
|
* which usualy should be UCA.
|
|
|
|
* @param bin binary image owned by the user and required through the
|
|
|
|
* lifetime of the collator
|
|
|
|
* @param length size of the image. If negative, the API will try to
|
|
|
|
* figure out the length of the image
|
|
|
|
* @param base fallback collator, usually UCA. Base is required to be
|
|
|
|
* present through the lifetime of the collator. Currently
|
|
|
|
* it cannot be NULL.
|
|
|
|
* @param status for catching errors
|
|
|
|
* @return newly created collator
|
|
|
|
* @see cloneBinary
|
2007-08-19 08:59:28 +00:00
|
|
|
* @stable ICU 3.4
|
2005-06-16 20:08:56 +00:00
|
|
|
*/
|
|
|
|
RuleBasedCollator(const uint8_t *bin, int32_t length,
|
|
|
|
const RuleBasedCollator *base,
|
|
|
|
UErrorCode &status);
|
2003-08-29 18:29:26 +00:00
|
|
|
// destructor --------------------------------------------------------------
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Destructor.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2001-10-11 23:54:55 +00:00
|
|
|
virtual ~RuleBasedCollator();
|
2001-01-18 00:22:38 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
// public methods ----------------------------------------------------------
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Assignment operator.
|
|
|
|
* @param other other RuleBasedCollator object to compare with.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2001-10-11 23:54:55 +00:00
|
|
|
RuleBasedCollator& operator=(const RuleBasedCollator& other);
|
2001-03-22 00:09:10 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Returns true if argument is the same as this object.
|
|
|
|
* @param other Collator object to be compared.
|
|
|
|
* @return true if arguments is the same as this object.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual UBool operator==(const Collator& other) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes a deep copy of the object.
|
|
|
|
* The caller owns the returned object.
|
|
|
|
* @return the cloned object.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual Collator* clone(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a collation element iterator for the source string. The caller of
|
|
|
|
* this method is responsible for the memory management of the return
|
|
|
|
* pointer.
|
|
|
|
* @param source the string over which the CollationElementIterator will
|
|
|
|
* iterate.
|
|
|
|
* @return the collation element iterator of the source string using this as
|
|
|
|
* the based Collator.
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
2001-10-11 23:54:55 +00:00
|
|
|
virtual CollationElementIterator* createCollationElementIterator(
|
2001-01-18 00:22:38 +00:00
|
|
|
const UnicodeString& source) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Creates a collation element iterator for the source. The caller of this
|
|
|
|
* method is responsible for the memory management of the returned pointer.
|
|
|
|
* @param source the CharacterIterator which produces the characters over
|
|
|
|
* which the CollationElementItgerator will iterate.
|
|
|
|
* @return the collation element iterator of the source using this as the
|
|
|
|
* based Collator.
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
|
|
|
virtual CollationElementIterator* createCollationElementIterator(
|
|
|
|
const CharacterIterator& source) const;
|
|
|
|
|
2012-08-03 21:49:28 +00:00
|
|
|
// Make deprecated versions of Collator::compare() visible.
|
|
|
|
using Collator::compare;
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The comparison function compares the character data stored in two
|
|
|
|
* different strings. Returns information about whether a string is less
|
|
|
|
* than, greater than or equal to another string.
|
|
|
|
* @param source the source string to be compared with.
|
|
|
|
* @param target the string that is to be compared with the source string.
|
|
|
|
* @param status possible error code
|
|
|
|
* @return Returns an enum value. UCOL_GREATER if source is greater
|
|
|
|
* than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
|
|
|
|
* than target
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-08-29 18:29:26 +00:00
|
|
|
**/
|
|
|
|
virtual UCollationResult compare(const UnicodeString& source,
|
|
|
|
const UnicodeString& target,
|
|
|
|
UErrorCode &status) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does the same thing as compare but limits the comparison to a specified
|
|
|
|
* length
|
|
|
|
* @param source the source string to be compared with.
|
|
|
|
* @param target the string that is to be compared with the source string.
|
|
|
|
* @param length the length the comparison is limited to
|
|
|
|
* @param status possible error code
|
|
|
|
* @return Returns an enum value. UCOL_GREATER if source (up to the specified
|
|
|
|
* length) is greater than target; UCOL_EQUAL if source (up to specified
|
|
|
|
* length) is equal to target; UCOL_LESS if source (up to the specified
|
|
|
|
* length) is less than target.
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-08-29 18:29:26 +00:00
|
|
|
*/
|
|
|
|
virtual UCollationResult compare(const UnicodeString& source,
|
|
|
|
const UnicodeString& target,
|
|
|
|
int32_t length,
|
|
|
|
UErrorCode &status) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The comparison function compares the character data stored in two
|
|
|
|
* different string arrays. Returns information about whether a string array
|
|
|
|
* is less than, greater than or equal to another string array.
|
|
|
|
* @param source the source string array to be compared with.
|
|
|
|
* @param sourceLength the length of the source string array. If this value
|
|
|
|
* is equal to -1, the string array is null-terminated.
|
|
|
|
* @param target the string that is to be compared with the source string.
|
|
|
|
* @param targetLength the length of the target string array. If this value
|
|
|
|
* is equal to -1, the string array is null-terminated.
|
|
|
|
* @param status possible error code
|
|
|
|
* @return Returns an enum value. UCOL_GREATER if source is greater
|
|
|
|
* than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
|
|
|
|
* than target
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-08-29 18:29:26 +00:00
|
|
|
*/
|
|
|
|
virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
|
|
|
|
const UChar* target, int32_t targetLength,
|
|
|
|
UErrorCode &status) const;
|
|
|
|
|
2009-03-13 23:38:43 +00:00
|
|
|
/**
|
|
|
|
* Compares two strings using the Collator.
|
|
|
|
* Returns whether the first one compares less than/equal to/greater than
|
|
|
|
* the second one.
|
|
|
|
* This version takes UCharIterator input.
|
|
|
|
* @param sIter the first ("source") string iterator
|
|
|
|
* @param tIter the second ("target") string iterator
|
2009-03-17 01:47:25 +00:00
|
|
|
* @param status ICU status
|
2009-03-13 23:38:43 +00:00
|
|
|
* @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER
|
2010-01-28 21:09:53 +00:00
|
|
|
* @stable ICU 4.2
|
2009-03-13 23:38:43 +00:00
|
|
|
*/
|
|
|
|
virtual UCollationResult compare(UCharIterator &sIter,
|
|
|
|
UCharIterator &tIter,
|
|
|
|
UErrorCode &status) const;
|
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Transforms a specified region of the string into a series of characters
|
|
|
|
* that can be compared with CollationKey.compare. Use a CollationKey when
|
|
|
|
* you need to do repeated comparisions on the same string. For a single
|
|
|
|
* comparison the compare method will be faster.
|
|
|
|
* @param source the source string.
|
|
|
|
* @param key the transformed key of the source string.
|
|
|
|
* @param status the error code status.
|
|
|
|
* @return the transformed key.
|
|
|
|
* @see CollationKey
|
2003-09-17 20:10:10 +00:00
|
|
|
* @deprecated ICU 2.8 Use getSortKey(...) instead
|
2003-08-29 18:29:26 +00:00
|
|
|
*/
|
|
|
|
virtual CollationKey& getCollationKey(const UnicodeString& source,
|
|
|
|
CollationKey& key,
|
|
|
|
UErrorCode& status) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transforms a specified region of the string into a series of characters
|
|
|
|
* that can be compared with CollationKey.compare. Use a CollationKey when
|
|
|
|
* you need to do repeated comparisions on the same string. For a single
|
|
|
|
* comparison the compare method will be faster.
|
|
|
|
* @param source the source string.
|
|
|
|
* @param sourceLength the length of the source string.
|
|
|
|
* @param key the transformed key of the source string.
|
|
|
|
* @param status the error code status.
|
|
|
|
* @return the transformed key.
|
|
|
|
* @see CollationKey
|
2003-09-17 20:10:10 +00:00
|
|
|
* @deprecated ICU 2.8 Use getSortKey(...) instead
|
2003-08-29 18:29:26 +00:00
|
|
|
*/
|
|
|
|
virtual CollationKey& getCollationKey(const UChar *source,
|
|
|
|
int32_t sourceLength,
|
|
|
|
CollationKey& key,
|
|
|
|
UErrorCode& status) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the hash code for the rule-based collation object.
|
|
|
|
* @return the hash code.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual int32_t hashCode(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the locale of the Collator
|
|
|
|
* @param type can be either requested, valid or actual locale. For more
|
|
|
|
* information see the definition of ULocDataLocaleType in
|
|
|
|
* uloc.h
|
|
|
|
* @param status the error code status.
|
|
|
|
* @return locale where the collation data lives. If the collator
|
|
|
|
* was instantiated from rules, locale is empty.
|
2004-01-23 19:28:19 +00:00
|
|
|
* @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback
|
2003-08-29 18:29:26 +00:00
|
|
|
*/
|
2012-08-03 21:49:28 +00:00
|
|
|
virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the table-based rules for the collation object.
|
|
|
|
* @return returns the collation rules that the table collation object was
|
|
|
|
* created from.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
const UnicodeString& getRules(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the version information for a Collator.
|
|
|
|
* @param info the version # information, the result will be filled in
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual void getVersion(UVersionInfo info) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the maximum length of any expansion sequences that end with the
|
|
|
|
* specified comparison order.
|
|
|
|
* @param order a collation order returned by previous or next.
|
|
|
|
* @return maximum size of the expansion sequences ending with the collation
|
|
|
|
* element or 1 if collation element does not occur at the end of
|
|
|
|
* any expansion sequence
|
|
|
|
* @see CollationElementIterator#getMaxExpansion
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
int32_t getMaxExpansion(int32_t order) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
|
|
|
* method is to implement a simple version of RTTI, since not all C++
|
|
|
|
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
|
|
|
* methods call this method.
|
|
|
|
* @return The class ID for this object. All objects of a given class have
|
|
|
|
* the same class ID. Objects of other classes have different class
|
|
|
|
* IDs.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual UClassID getDynamicClassID(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the class ID for this class. This is useful only for comparing to
|
|
|
|
* a return value from getDynamicClassID(). For example:
|
|
|
|
* <pre>
|
|
|
|
* Base* polymorphic_pointer = createPolymorphicObject();
|
|
|
|
* if (polymorphic_pointer->getDynamicClassID() ==
|
|
|
|
* Derived::getStaticClassID()) ...
|
|
|
|
* </pre>
|
|
|
|
* @return The class ID for all objects of this class.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID(void);
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the binary format of the class's rules. The format is that of
|
|
|
|
* .col files.
|
|
|
|
* @param length Returns the length of the data, in bytes
|
|
|
|
* @param status the error code status.
|
|
|
|
* @return memory, owned by the caller, of size 'length' bytes.
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
|
|
|
uint8_t *cloneRuleData(int32_t &length, UErrorCode &status);
|
2005-06-16 20:08:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** Creates a binary image of a collator. This binary image can be stored and
|
|
|
|
* later used to instantiate a collator using ucol_openBinary.
|
|
|
|
* This API supports preflighting.
|
|
|
|
* @param buffer a fill-in buffer to receive the binary image
|
|
|
|
* @param capacity capacity of the destination buffer
|
|
|
|
* @param status for catching errors
|
|
|
|
* @return size of the image
|
|
|
|
* @see ucol_openBinary
|
2007-08-19 08:59:28 +00:00
|
|
|
* @stable ICU 3.4
|
2005-06-16 20:08:56 +00:00
|
|
|
*/
|
|
|
|
int32_t cloneBinary(uint8_t *buffer, int32_t capacity, UErrorCode &status);
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns current rules. Delta defines whether full rules are returned or
|
|
|
|
* just the tailoring.
|
|
|
|
* @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
|
|
|
|
* @param buffer UnicodeString to store the result rules
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
|
|
|
void getRules(UColRuleOption delta, UnicodeString &buffer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Universal attribute setter
|
|
|
|
* @param attr attribute type
|
|
|
|
* @param value attribute value
|
|
|
|
* @param status to indicate whether the operation went on smoothly or there were errors
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
|
|
|
virtual void setAttribute(UColAttribute attr, UColAttributeValue value,
|
|
|
|
UErrorCode &status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Universal attribute getter.
|
|
|
|
* @param attr attribute type
|
|
|
|
* @param status to indicate whether the operation went on smoothly or there were errors
|
|
|
|
* @return attribute value
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
|
|
|
virtual UColAttributeValue getAttribute(UColAttribute attr,
|
2012-08-03 21:49:28 +00:00
|
|
|
UErrorCode &status) const;
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the variable top to a collation element value of a string supplied.
|
|
|
|
* @param varTop one or more (if contraction) UChars to which the variable top should be set
|
|
|
|
* @param len length of variable top string. If -1 it is considered to be zero terminated.
|
|
|
|
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
|
|
|
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>
|
|
|
|
* U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
|
|
|
|
* @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the variable top to a collation element value of a string supplied.
|
|
|
|
* @param varTop an UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
|
|
|
|
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
|
|
|
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>
|
|
|
|
* U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
|
|
|
|
* @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2012-08-03 21:49:28 +00:00
|
|
|
virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status);
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the variable top to a collation element value supplied. Variable top is set to the upper 16 bits.
|
|
|
|
* Lower 16 bits are ignored.
|
|
|
|
* @param varTop CE value, as returned by setVariableTop or ucol)getVariableTop
|
|
|
|
* @param status error code (not changed by function)
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2012-08-03 21:49:28 +00:00
|
|
|
virtual void setVariableTop(uint32_t varTop, UErrorCode &status);
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the variable top value of a Collator.
|
|
|
|
* Lower 16 bits are undefined and should be ignored.
|
|
|
|
* @param status error code (not changed by function). If error code is set, the return value is undefined.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual uint32_t getVariableTop(UErrorCode &status) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get an UnicodeSet that contains all the characters and sequences tailored in
|
|
|
|
* this collator.
|
|
|
|
* @param status error code of the operation
|
|
|
|
* @return a pointer to a UnicodeSet object containing all the
|
|
|
|
* code points and sequences that may sort differently than
|
|
|
|
* in the UCA. The object must be disposed of by using delete
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2003-08-29 18:29:26 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thread safe cloning operation.
|
|
|
|
* @return pointer to the new clone, user should remove it.
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
2012-08-03 21:49:28 +00:00
|
|
|
virtual Collator* safeClone(void) const;
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the sort key as an array of bytes from an UnicodeString.
|
|
|
|
* @param source string to be processed.
|
|
|
|
* @param result buffer to store result in. If NULL, number of bytes needed
|
|
|
|
* will be returned.
|
|
|
|
* @param resultLength length of the result buffer. If if not enough the
|
|
|
|
* buffer will be filled to capacity.
|
|
|
|
* @return Number of bytes needed for storing the sort key
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
virtual int32_t getSortKey(const UnicodeString& source, uint8_t *result,
|
|
|
|
int32_t resultLength) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the sort key as an array of bytes from an UChar buffer.
|
|
|
|
* @param source string to be processed.
|
|
|
|
* @param sourceLength length of string to be processed. If -1, the string
|
|
|
|
* is 0 terminated and length will be decided by the function.
|
|
|
|
* @param result buffer to store result in. If NULL, number of bytes needed
|
|
|
|
* will be returned.
|
|
|
|
* @param resultLength length of the result buffer. If if not enough the
|
|
|
|
* buffer will be filled to capacity.
|
|
|
|
* @return Number of bytes needed for storing the sort key
|
|
|
|
* @stable ICU 2.2
|
|
|
|
*/
|
|
|
|
virtual int32_t getSortKey(const UChar *source, int32_t sourceLength,
|
|
|
|
uint8_t *result, int32_t resultLength) const;
|
|
|
|
|
2010-10-27 18:02:52 +00:00
|
|
|
/**
|
2011-03-18 22:52:30 +00:00
|
|
|
* Retrieves the reordering codes for this collator.
|
2010-10-27 18:02:52 +00:00
|
|
|
* @param dest The array to fill with the script ordering.
|
2011-03-18 22:52:30 +00:00
|
|
|
* @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function
|
|
|
|
* will only return the length of the result without writing any of the result string (pre-flighting).
|
|
|
|
* @param status A reference to an error code value, which must not indicate
|
|
|
|
* a failure before the function call.
|
2011-05-06 22:34:03 +00:00
|
|
|
* @return The length of the script ordering array.
|
2011-03-18 22:52:30 +00:00
|
|
|
* @see ucol_setReorderCodes
|
|
|
|
* @see Collator#getEquivalentReorderCodes
|
|
|
|
* @see Collator#setReorderCodes
|
2012-02-20 04:28:17 +00:00
|
|
|
* @stable ICU 4.8
|
2010-10-27 18:02:52 +00:00
|
|
|
*/
|
2012-08-03 21:49:28 +00:00
|
|
|
virtual int32_t getReorderCodes(int32_t *dest,
|
|
|
|
int32_t destCapacity,
|
|
|
|
UErrorCode& status) const;
|
2010-10-27 18:02:52 +00:00
|
|
|
|
|
|
|
/**
|
2011-03-18 22:52:30 +00:00
|
|
|
* Sets the ordering of scripts for this collator.
|
|
|
|
* @param reorderCodes An array of script codes in the new order. This can be NULL if the
|
|
|
|
* length is also set to 0. An empty array will clear any reordering codes on the collator.
|
2010-11-03 02:41:22 +00:00
|
|
|
* @param reorderCodesLength The length of reorderCodes.
|
2011-05-05 01:35:22 +00:00
|
|
|
* @param status error code
|
2011-03-18 22:52:30 +00:00
|
|
|
* @see Collator#getReorderCodes
|
|
|
|
* @see Collator#getEquivalentReorderCodes
|
2012-02-20 04:28:17 +00:00
|
|
|
* @stable ICU 4.8
|
2011-03-18 22:52:30 +00:00
|
|
|
*/
|
2012-08-03 21:49:28 +00:00
|
|
|
virtual void setReorderCodes(const int32_t* reorderCodes,
|
|
|
|
int32_t reorderCodesLength,
|
|
|
|
UErrorCode& status) ;
|
2011-03-18 22:52:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the reorder codes that are grouped with the given reorder code. Some reorder
|
|
|
|
* codes will be grouped and must reorder together.
|
|
|
|
* @param reorderCode The reorder code to determine equivalence for.
|
|
|
|
* @param dest The array to fill with the script equivalene reordering codes.
|
|
|
|
* @param destCapacity The length of dest. If it is 0, then dest may be NULL and the
|
|
|
|
* function will only return the length of the result without writing any of the result
|
|
|
|
* string (pre-flighting).
|
|
|
|
* @param status A reference to an error code value, which must not indicate
|
|
|
|
* a failure before the function call.
|
|
|
|
* @return The length of the of the reordering code equivalence array.
|
2010-11-03 02:41:22 +00:00
|
|
|
* @see ucol_setReorderCodes
|
2011-03-18 22:52:30 +00:00
|
|
|
* @see Collator#getReorderCodes
|
|
|
|
* @see Collator#setReorderCodes
|
2012-02-20 04:28:17 +00:00
|
|
|
* @stable ICU 4.8
|
2011-03-18 22:52:30 +00:00
|
|
|
*/
|
|
|
|
static int32_t U_EXPORT2 getEquivalentReorderCodes(int32_t reorderCode,
|
|
|
|
int32_t* dest,
|
|
|
|
int32_t destCapacity,
|
|
|
|
UErrorCode& status);
|
2010-10-27 18:02:52 +00:00
|
|
|
|
2001-01-18 00:22:38 +00:00
|
|
|
private:
|
2001-03-22 00:09:10 +00:00
|
|
|
|
2003-08-29 18:29:26 +00:00
|
|
|
// private static constants -----------------------------------------------
|
|
|
|
|
2007-06-11 02:32:47 +00:00
|
|
|
enum {
|
|
|
|
/* need look up in .commit() */
|
|
|
|
CHARINDEX = 0x70000000,
|
|
|
|
/* Expand index follows */
|
|
|
|
EXPANDCHARINDEX = 0x7E000000,
|
|
|
|
/* contract indexes follows */
|
|
|
|
CONTRACTCHARINDEX = 0x7F000000,
|
|
|
|
/* unmapped character values */
|
|
|
|
UNMAPPED = 0xFFFFFFFF,
|
|
|
|
/* primary strength increment */
|
|
|
|
PRIMARYORDERINCREMENT = 0x00010000,
|
|
|
|
/* secondary strength increment */
|
|
|
|
SECONDARYORDERINCREMENT = 0x00000100,
|
|
|
|
/* tertiary strength increment */
|
|
|
|
TERTIARYORDERINCREMENT = 0x00000001,
|
|
|
|
/* mask off anything but primary order */
|
|
|
|
PRIMARYORDERMASK = 0xffff0000,
|
|
|
|
/* mask off anything but secondary order */
|
|
|
|
SECONDARYORDERMASK = 0x0000ff00,
|
|
|
|
/* mask off anything but tertiary order */
|
|
|
|
TERTIARYORDERMASK = 0x000000ff,
|
|
|
|
/* mask off ignorable char order */
|
|
|
|
IGNORABLEMASK = 0x0000ffff,
|
|
|
|
/* use only the primary difference */
|
|
|
|
PRIMARYDIFFERENCEONLY = 0xffff0000,
|
|
|
|
/* use only the primary and secondary difference */
|
|
|
|
SECONDARYDIFFERENCEONLY = 0xffffff00,
|
|
|
|
/* primary order shift */
|
|
|
|
PRIMARYORDERSHIFT = 16,
|
|
|
|
/* secondary order shift */
|
|
|
|
SECONDARYORDERSHIFT = 8,
|
|
|
|
/* starting value for collation elements */
|
|
|
|
COLELEMENTSTART = 0x02020202,
|
|
|
|
/* testing mask for primary low element */
|
|
|
|
PRIMARYLOWZEROMASK = 0x00FF0000,
|
|
|
|
/* reseting value for secondaries and tertiaries */
|
|
|
|
RESETSECONDARYTERTIARY = 0x00000202,
|
|
|
|
/* reseting value for tertiaries */
|
|
|
|
RESETTERTIARY = 0x00000002,
|
|
|
|
|
|
|
|
PRIMIGNORABLE = 0x0202
|
|
|
|
};
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
// private data members ---------------------------------------------------
|
|
|
|
|
|
|
|
UBool dataIsOwned;
|
|
|
|
|
|
|
|
UBool isWriteThroughAlias;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* c struct for collation. All initialisation for it has to be done through
|
|
|
|
* setUCollator().
|
|
|
|
*/
|
|
|
|
UCollator *ucollator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rule UnicodeString
|
|
|
|
*/
|
2006-04-02 19:07:50 +00:00
|
|
|
UnicodeString urulestring;
|
2003-08-29 18:29:26 +00:00
|
|
|
|
|
|
|
// friend classes --------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to iterate over collation elements in a character source.
|
|
|
|
*/
|
|
|
|
friend class CollationElementIterator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collator ONLY needs access to RuleBasedCollator(const Locale&,
|
|
|
|
* UErrorCode&)
|
|
|
|
*/
|
|
|
|
friend class Collator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Searching over collation elements in a character source
|
|
|
|
*/
|
|
|
|
friend class StringSearch;
|
|
|
|
|
|
|
|
// private constructors --------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default constructor
|
|
|
|
*/
|
|
|
|
RuleBasedCollator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RuleBasedCollator constructor. This constructor takes a locale. The
|
|
|
|
* only caller of this class should be Collator::createInstance(). If
|
|
|
|
* createInstance() happens to know that the requested locale's collation is
|
|
|
|
* implemented as a RuleBasedCollator, it can then call this constructor.
|
|
|
|
* OTHERWISE IT SHOULDN'T, since this constructor ALWAYS RETURNS A VALID
|
|
|
|
* COLLATION TABLE. It does this by falling back to defaults.
|
|
|
|
* @param desiredLocale locale used
|
|
|
|
* @param status error code status
|
|
|
|
*/
|
|
|
|
RuleBasedCollator(const Locale& desiredLocale, UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* common constructor implementation
|
|
|
|
*
|
|
|
|
* @param rules the collation rules to build the collation table from.
|
|
|
|
* @param collationStrength default strength for comparison
|
|
|
|
* @param decompositionMode the normalisation mode
|
|
|
|
* @param status reporting a success or an error.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
construct(const UnicodeString& rules,
|
|
|
|
UColAttributeValue collationStrength,
|
|
|
|
UColAttributeValue decompositionMode,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
// private methods -------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the c struct for ucollator
|
|
|
|
* @param locale desired locale
|
|
|
|
* @param status error status
|
|
|
|
*/
|
|
|
|
void setUCollator(const Locale& locale, UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the c struct for ucollator
|
|
|
|
* @param locale desired locale name
|
|
|
|
* @param status error status
|
|
|
|
*/
|
|
|
|
void setUCollator(const char* locale, UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the c struct for ucollator. This used internally by StringSearch.
|
|
|
|
* Hence the responsibility of cleaning up the ucollator is not done by
|
|
|
|
* this RuleBasedCollator. The isDataOwned flag is set to FALSE.
|
|
|
|
* @param collator new ucollator data
|
|
|
|
*/
|
2006-04-02 19:07:50 +00:00
|
|
|
void setUCollator(UCollator *collator);
|
2001-08-25 02:03:53 +00:00
|
|
|
|
2003-02-20 01:11:39 +00:00
|
|
|
public:
|
2011-08-01 02:20:46 +00:00
|
|
|
#ifndef U_HIDE_INTERNAL_API
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Get UCollator data struct. Used only by StringSearch & intltest.
|
|
|
|
* @return UCollator data struct
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
const UCollator * getUCollator();
|
2011-08-01 02:20:46 +00:00
|
|
|
#endif /* U_HIDE_INTERNAL_API */
|
2001-08-25 02:03:53 +00:00
|
|
|
|
2003-05-02 22:17:14 +00:00
|
|
|
protected:
|
2003-08-29 18:29:26 +00:00
|
|
|
/**
|
|
|
|
* Used internally by registraton to define the requested and valid locales.
|
|
|
|
* @param requestedLocale the requsted locale
|
|
|
|
* @param validLocale the valid locale
|
2008-06-28 07:08:51 +00:00
|
|
|
* @param actualLocale the actual locale
|
2003-08-29 18:29:26 +00:00
|
|
|
* @internal
|
|
|
|
*/
|
2007-12-18 01:19:16 +00:00
|
|
|
virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale);
|
2003-04-28 21:13:14 +00:00
|
|
|
|
2003-02-20 01:11:39 +00:00
|
|
|
private:
|
2003-08-29 18:29:26 +00:00
|
|
|
// if not owned and not a write through alias, copy the ucollator
|
|
|
|
void checkOwned(void);
|
|
|
|
|
|
|
|
// utility to init rule string used by checkOwned and construct
|
2006-04-02 19:07:50 +00:00
|
|
|
void setRuleStringFromCollator();
|
2003-08-29 18:29:26 +00:00
|
|
|
|
2012-08-03 21:49:28 +00:00
|
|
|
public:
|
2012-02-18 23:10:51 +00:00
|
|
|
/** Get the short definition string for a collator. This internal API harvests the collator's
|
|
|
|
* locale and the attribute set and produces a string that can be used for opening
|
|
|
|
* a collator with the same properties using the ucol_openFromShortString API.
|
|
|
|
* This string will be normalized.
|
|
|
|
* The structure and the syntax of the string is defined in the "Naming collators"
|
|
|
|
* section of the users guide:
|
|
|
|
* http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators
|
|
|
|
* This function supports preflighting.
|
|
|
|
*
|
|
|
|
* This is internal, and intended to be used with delegate converters.
|
|
|
|
*
|
|
|
|
* @param locale a locale that will appear as a collators locale in the resulting
|
|
|
|
* short string definition. If NULL, the locale will be harvested
|
|
|
|
* from the collator.
|
|
|
|
* @param buffer space to hold the resulting string
|
|
|
|
* @param capacity capacity of the buffer
|
|
|
|
* @param status for returning errors. All the preflighting errors are featured
|
|
|
|
* @return length of the resulting string
|
|
|
|
* @see ucol_openFromShortString
|
|
|
|
* @see ucol_normalizeShortDefinitionString
|
|
|
|
* @see ucol_getShortDefinitionString
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
virtual int32_t internalGetShortDefinitionString(const char *locale,
|
|
|
|
char *buffer,
|
|
|
|
int32_t capacity,
|
2012-02-19 06:39:16 +00:00
|
|
|
UErrorCode &status) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
|
|
|
|
2001-01-18 00:22:38 +00:00
|
|
|
// inline method implementation ---------------------------------------------
|
2000-12-14 01:11:11 +00:00
|
|
|
|
2001-03-22 00:09:10 +00:00
|
|
|
inline void RuleBasedCollator::setUCollator(const Locale &locale,
|
2001-02-05 19:53:37 +00:00
|
|
|
UErrorCode &status)
|
|
|
|
{
|
2003-08-29 18:29:26 +00:00
|
|
|
setUCollator(locale.getName(), status);
|
2001-02-05 19:53:37 +00:00
|
|
|
}
|
|
|
|
|
2003-05-02 22:17:14 +00:00
|
|
|
|
2006-04-02 19:07:50 +00:00
|
|
|
inline void RuleBasedCollator::setUCollator(UCollator *collator)
|
2001-08-25 02:03:53 +00:00
|
|
|
{
|
2006-04-02 19:07:50 +00:00
|
|
|
|
2001-08-25 02:03:53 +00:00
|
|
|
if (ucollator && dataIsOwned) {
|
|
|
|
ucol_close(ucollator);
|
|
|
|
}
|
|
|
|
ucollator = collator;
|
|
|
|
dataIsOwned = FALSE;
|
2003-08-29 18:29:26 +00:00
|
|
|
isWriteThroughAlias = TRUE;
|
2007-08-19 08:59:28 +00:00
|
|
|
setRuleStringFromCollator();
|
2001-08-25 02:03:53 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 02:45:09 +00:00
|
|
|
#ifndef U_HIDE_INTERNAL_API
|
2001-08-25 02:03:53 +00:00
|
|
|
inline const UCollator * RuleBasedCollator::getUCollator()
|
|
|
|
{
|
|
|
|
return ucollator;
|
|
|
|
}
|
2011-08-13 02:45:09 +00:00
|
|
|
#endif
|
2001-08-25 02:03:53 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_COLLATION */
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#endif
|