ICU 76.1: icu::CollatorFactory Class Reference

ICU 76.1 76.1

Public Member Functions
icu::CollatorFactory Class Referenceabstract

A factory, used with registerFactory, the creates multiple collators and provides display names for them. More...

`#include <coll.h>`

Inheritance diagram for icu::CollatorFactory:

## Public Member Functions
virtual | ~CollatorFactory ()
| Destructor.
virtual UBool | visible () const
| Return true if this factory is visible.
virtual Collator * | createCollator (const Locale &loc)=0
| Return a collator for the provided locale.
virtual UnicodeString & | getDisplayName (const Locale &objectLocale, const Locale &displayLocale, UnicodeString &result)
| Return the name of the collator for the objectLocale, localized for the displayLocale.
virtual const UnicodeString * | getSupportedIDs (int32_t &count, UErrorCode &status)=0
| Return an array of all the locale names directly supported by this factory.
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor.
virtual UClassID | getDynamicClassID () const
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.

## Detailed Description

A factory, used with registerFactory, the creates multiple collators and provides display names for them.

A factory supports some number of locales– these are the locales for which it can create collators. The factory can be visible, in which case the supported locales will be enumerated by getAvailableLocales, or invisible, in which they are not. Invisible locales are still supported, they are just not listed by getAvailableLocales.

If standard locale display names are sufficient, Collator instances can be registered using registerInstance instead.

Note: if the collators are to be used from C APIs, they must be instances of RuleBasedCollator.

Stable
  ICU 2.6

Definition at line 1325 of file coll.h.

## Constructor & Destructor Documentation

## ◆ ~CollatorFactory()

virtual icu::CollatorFactory::~CollatorFactory | ( |  | ) |
| virtual

Destructor.

Stable
  ICU 3.0

## Member Function Documentation

## ◆ createCollator()

virtual Collator * icu::CollatorFactory::createCollator | ( | const Locale & | loc | ) |
| pure virtual

Return a collator for the provided locale.

If the locale is not supported, return nullptr.

Parameters

  loc | the locale identifying the collator to be created.

Returns
  a new collator if the locale is supported, otherwise nullptr.

Stable
  ICU 2.6

## ◆ getDisplayName()

virtual UnicodeString & icu::CollatorFactory::getDisplayName | ( | const Locale & | objectLocale,
|  | const Locale & | displayLocale,
|  | UnicodeString & | result )
| virtual

Return the name of the collator for the objectLocale, localized for the displayLocale.

If objectLocale is not supported, or the factory is not visible, set the result string to bogus.

Parameters

  objectLocale | the locale identifying the collator
  displayLocale | the locale for which the display name of the collator should be localized
  result | an output parameter for the display name, set to bogus if not supported.

Returns
  the display name

Stable
  ICU 2.6

## ◆ getSupportedIDs()

virtual const UnicodeString * icu::CollatorFactory::getSupportedIDs | ( | int32_t & | count,
|  | UErrorCode & | status )
| pure virtual

Return an array of all the locale names directly supported by this factory.

The number of names is returned in count. This array is owned by the factory. Its contents must never change.

Parameters

  count | output parameter for the number of locales supported by the factory
  status | the in/out error code

Returns
  a pointer to an array of count UnicodeStrings.

Stable
  ICU 2.6

## ◆ visible()

virtual UBool icu::CollatorFactory::visible | ( |  | ) | const
| virtual

Return true if this factory is visible.

Default is true. If not visible, the locales supported by this factory will not be listed by getAvailableLocales.

Returns
  true if the factory is visible.

Stable
  ICU 2.6

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

- i18n/unicode/coll.h