1999-08-16 21:50:52 +00:00
|
|
|
/*
|
|
|
|
*****************************************************************************************
|
|
|
|
* *
|
|
|
|
* COPYRIGHT: *
|
|
|
|
* (C) Copyright Taligent, Inc., 1996 *
|
|
|
|
* (C) Copyright International Business Machines Corporation, 1998-1999 *
|
|
|
|
* Licensed Material - Program-Property of IBM - All Rights Reserved. *
|
|
|
|
* US Government Users Restricted Rights - Use, duplication, or disclosure *
|
|
|
|
* restricted by GSA ADP Schedule Contract with IBM Corp. *
|
|
|
|
* *
|
|
|
|
*****************************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ubrk.h"
|
|
|
|
|
|
|
|
#include "brkiter.h"
|
|
|
|
#include "uloc.h"
|
|
|
|
#include "ustring.h"
|
|
|
|
#include "uchriter.h"
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UBreakIterator*
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_open(UBreakIteratorType type,
|
|
|
|
const char *locale,
|
|
|
|
const UChar *text,
|
|
|
|
int32_t textLength,
|
|
|
|
UErrorCode *status)
|
|
|
|
{
|
1999-10-18 22:48:32 +00:00
|
|
|
if(U_FAILURE(*status)) return 0;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
BreakIterator *result = 0;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
|
|
|
|
case UBRK_CHARACTER:
|
|
|
|
result = BreakIterator::createCharacterInstance(Locale().init(locale));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UBRK_WORD:
|
|
|
|
result = BreakIterator::createWordInstance(Locale().init(locale));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UBRK_LINE:
|
|
|
|
result = BreakIterator::createLineInstance(Locale().init(locale));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UBRK_SENTENCE:
|
|
|
|
result = BreakIterator::createSentenceInstance(Locale().init(locale));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for allocation error
|
|
|
|
if(result == 0) {
|
1999-10-07 00:07:53 +00:00
|
|
|
*status = U_MEMORY_ALLOCATION_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t textLen = (textLength == -1 ? u_strlen(text) : textLength);
|
|
|
|
UCharCharacterIterator *iter = 0;
|
|
|
|
iter = new UCharCharacterIterator(text, textLen);
|
|
|
|
if(iter == 0) {
|
1999-10-07 00:07:53 +00:00
|
|
|
*status = U_MEMORY_ALLOCATION_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
delete result;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
result->adoptText(iter);
|
|
|
|
|
|
|
|
return (UBreakIterator*)result;
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UBreakIterator*
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_openRules(const UChar *rules,
|
|
|
|
int32_t rulesLength,
|
|
|
|
const UChar *text,
|
|
|
|
int32_t textLength,
|
|
|
|
UErrorCode *status)
|
|
|
|
{
|
1999-10-18 22:48:32 +00:00
|
|
|
if(U_FAILURE(*status)) return 0;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI void
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_close(UBreakIterator *bi)
|
|
|
|
{
|
|
|
|
delete (BreakIterator*) bi;
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UTextOffset
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_current(const UBreakIterator *bi)
|
|
|
|
{
|
|
|
|
return ((BreakIterator*)bi)->current();
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UTextOffset
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_next(UBreakIterator *bi)
|
|
|
|
{
|
|
|
|
return ((BreakIterator*)bi)->next();
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UTextOffset
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_previous(UBreakIterator *bi)
|
|
|
|
{
|
|
|
|
return ((BreakIterator*)bi)->previous();
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UTextOffset
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_first(UBreakIterator *bi)
|
|
|
|
{
|
|
|
|
return ((BreakIterator*)bi)->first();
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UTextOffset
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_last(UBreakIterator *bi)
|
|
|
|
{
|
|
|
|
return ((BreakIterator*)bi)->last();
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UTextOffset
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_preceding(UBreakIterator *bi,
|
|
|
|
UTextOffset offset)
|
|
|
|
{
|
|
|
|
return ((BreakIterator*)bi)->preceding(offset);
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI UTextOffset
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_following(UBreakIterator *bi,
|
|
|
|
UTextOffset offset)
|
|
|
|
{
|
|
|
|
return ((BreakIterator*)bi)->following(offset);
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI const char*
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_getAvailable(int32_t index)
|
|
|
|
{
|
|
|
|
return uloc_getAvailable(index);
|
|
|
|
}
|
|
|
|
|
1999-10-18 22:48:32 +00:00
|
|
|
U_CAPI int32_t
|
1999-08-16 21:50:52 +00:00
|
|
|
ubrk_countAvailable()
|
|
|
|
{
|
|
|
|
return uloc_countAvailable();
|
|
|
|
}
|