mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-2203 fixes to breakiterator registration
X-SVN-Rev: 10256
This commit is contained in:
parent
f9076091f6
commit
5c886229bf
3 changed files with 21 additions and 30 deletions
|
@ -47,7 +47,7 @@ const int32_t BreakIterator::DONE = (int32_t)-1;
|
|||
BreakIterator*
|
||||
BreakIterator::createWordInstance(const Locale& key, UErrorCode& status)
|
||||
{
|
||||
return createInstance(key, BREAK_WORD, status);
|
||||
return createInstance(key, UBRK_WORD, status);
|
||||
}
|
||||
|
||||
BreakIterator*
|
||||
|
@ -98,7 +98,7 @@ BreakIterator::makeWordInstance(const Locale& key, UErrorCode& status)
|
|||
BreakIterator*
|
||||
BreakIterator::createLineInstance(const Locale& key, UErrorCode& status)
|
||||
{
|
||||
return createInstance(key, BREAK_LINE, status);
|
||||
return createInstance(key, UBRK_LINE, status);
|
||||
}
|
||||
|
||||
BreakIterator*
|
||||
|
@ -148,7 +148,7 @@ BreakIterator::makeLineInstance(const Locale& key, UErrorCode& status)
|
|||
BreakIterator*
|
||||
BreakIterator::createCharacterInstance(const Locale& key, UErrorCode& status)
|
||||
{
|
||||
return createInstance(key, BREAK_CHARACTER, status);
|
||||
return createInstance(key, UBRK_CHARACTER, status);
|
||||
}
|
||||
|
||||
BreakIterator*
|
||||
|
@ -186,7 +186,7 @@ BreakIterator::makeCharacterInstance(const Locale& /* key */, UErrorCode& status
|
|||
BreakIterator*
|
||||
BreakIterator::createSentenceInstance(const Locale& key, UErrorCode& status)
|
||||
{
|
||||
return createInstance(key, BREAK_SENTENCE, status);
|
||||
return createInstance(key, UBRK_SENTENCE, status);
|
||||
}
|
||||
|
||||
BreakIterator*
|
||||
|
@ -225,7 +225,7 @@ BreakIterator::makeSentenceInstance(const Locale& /*key */, UErrorCode& status)
|
|||
BreakIterator*
|
||||
BreakIterator::createTitleInstance(const Locale& key, UErrorCode& status)
|
||||
{
|
||||
return createInstance(key, BREAK_TITLE, status);
|
||||
return createInstance(key, UBRK_TITLE, status);
|
||||
}
|
||||
|
||||
BreakIterator*
|
||||
|
@ -365,7 +365,7 @@ getService(void)
|
|||
// -------------------------------------
|
||||
|
||||
BreakIterator*
|
||||
BreakIterator::createInstance(const Locale& loc, UBreakType kind, UErrorCode& status)
|
||||
BreakIterator::createInstance(const Locale& loc, UBreakIteratorType kind, UErrorCode& status)
|
||||
{
|
||||
if (gService != NULL) {
|
||||
return (BreakIterator*)gService->get(loc, kind, status);
|
||||
|
@ -376,16 +376,16 @@ BreakIterator::createInstance(const Locale& loc, UBreakType kind, UErrorCode& st
|
|||
|
||||
// -------------------------------------
|
||||
|
||||
const UObject*
|
||||
BreakIterator::registerBreak(BreakIterator* toAdopt, const Locale& locale, UBreakType kind, UErrorCode& status)
|
||||
UBreakRegistryKey
|
||||
BreakIterator::registerBreak(BreakIterator* toAdopt, const Locale& locale, UBreakIteratorType kind, UErrorCode& status)
|
||||
{
|
||||
return getService()->registerObject(toAdopt, locale, kind, status);
|
||||
return (UBreakRegistryKey)getService()->registerObject(toAdopt, locale, kind, status);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
UBool
|
||||
BreakIterator::unregisterBreak(const UObject* key, UErrorCode& status)
|
||||
BreakIterator::unregisterBreak(UBreakRegistryKey key, UErrorCode& status)
|
||||
{
|
||||
if (gService != NULL) {
|
||||
return gService->unregisterFactory((Factory*)key, status);
|
||||
|
@ -407,11 +407,11 @@ BreakIterator*
|
|||
BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
|
||||
{
|
||||
switch (kind) {
|
||||
case BREAK_CHARACTER: return BreakIterator::makeCharacterInstance(loc, status);
|
||||
case BREAK_WORD: return BreakIterator::makeWordInstance(loc, status);
|
||||
case BREAK_LINE: return BreakIterator::makeLineInstance(loc, status);
|
||||
case BREAK_SENTENCE: return BreakIterator::makeSentenceInstance(loc, status);
|
||||
case BREAK_TITLE: return BreakIterator::makeTitleInstance(loc, status);
|
||||
case UBRK_CHARACTER: return BreakIterator::makeCharacterInstance(loc, status);
|
||||
case UBRK_WORD: return BreakIterator::makeWordInstance(loc, status);
|
||||
case UBRK_LINE: return BreakIterator::makeLineInstance(loc, status);
|
||||
case UBRK_SENTENCE: return BreakIterator::makeSentenceInstance(loc, status);
|
||||
case UBRK_TITLE: return BreakIterator::makeTitleInstance(loc, status);
|
||||
default:
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
|
|
|
@ -45,17 +45,8 @@ U_NAMESPACE_END
|
|||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Used in registration of break iterators.
|
||||
*/
|
||||
typedef enum {
|
||||
BREAK_CHARACTER,
|
||||
BREAK_WORD,
|
||||
BREAK_LINE,
|
||||
BREAK_SENTENCE,
|
||||
BREAK_TITLE
|
||||
} UBreakType;
|
||||
|
||||
typedef const void* UBreakRegistryKey;
|
||||
|
||||
/**
|
||||
* The BreakIterator class implements methods for finding the location
|
||||
* of boundaries in text. BreakIterator is an abstract base class.
|
||||
|
@ -532,14 +523,14 @@ public:
|
|||
* if a request for a break iterator of the given kind matches or falls back to
|
||||
* this locale.
|
||||
*/
|
||||
static const UObject* registerBreak(BreakIterator* toAdopt, const Locale& locale, UBreakType kind, UErrorCode& status);
|
||||
static UBreakRegistryKey registerBreak(BreakIterator* toAdopt, const Locale& locale, UBreakIteratorType kind, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Unregister a previously-registered BreakIterator using the key returned from the
|
||||
* register call. Key becomes invalid after this call and should not be used again.
|
||||
* Returns TRUE if the iterator for the key was successfully unregistered.
|
||||
*/
|
||||
static UBool unregisterBreak(const UObject* key, UErrorCode& status);
|
||||
static UBool unregisterBreak(UBreakRegistryKey key, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Return a StringEnumeration over the available locales, including registered locales.
|
||||
|
@ -553,7 +544,7 @@ public:
|
|||
static BreakIterator* makeSentenceInstance(const Locale& loc, UErrorCode& status);
|
||||
static BreakIterator* makeTitleInstance(const Locale& loc, UErrorCode& status);
|
||||
|
||||
static BreakIterator* createInstance(const Locale& loc, UBreakType kind, UErrorCode& status);
|
||||
static BreakIterator* createInstance(const Locale& loc, UBreakIteratorType kind, UErrorCode& status);
|
||||
static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
|
||||
|
||||
friend class ICUBreakIteratorFactory;
|
||||
|
|
|
@ -738,7 +738,7 @@ void RBBIAPITest::TestRegistration() {
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
BreakIterator* thai_word = BreakIterator::createWordInstance("th_TH", status);
|
||||
BreakIterator* root_word = BreakIterator::createWordInstance("", status);
|
||||
const UObject* key = BreakIterator::registerBreak(thai_word, "xx", BREAK_WORD, status);
|
||||
UBreakRegistryKey key = BreakIterator::registerBreak(thai_word, "xx", UBRK_WORD, status);
|
||||
|
||||
{
|
||||
if (*thai_word == *root_word) {
|
||||
|
|
Loading…
Add table
Reference in a new issue