1999-12-28 23:57:50 +00:00
|
|
|
/*
|
2003-05-10 00:06:12 +00:00
|
|
|
********************************************************************************
|
|
|
|
* Copyright (C) 1997-2003, International Business Machines
|
1999-12-28 23:57:50 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
2003-05-10 00:06:12 +00:00
|
|
|
********************************************************************************
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
2002-08-08 00:39:13 +00:00
|
|
|
* File brkiter.h
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 02/18/97 aliu Added typedef for TextCount. Made DONE const.
|
|
|
|
* 05/07/97 aliu Fixed DLL declaration.
|
|
|
|
* 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK
|
|
|
|
* 08/11/98 helena Sync-up JDK1.2.
|
2000-01-14 00:13:59 +00:00
|
|
|
* 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods.
|
2003-05-10 00:06:12 +00:00
|
|
|
********************************************************************************
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BRKITER_H
|
|
|
|
#define BRKITER_H
|
|
|
|
|
2002-06-27 01:19:20 +00:00
|
|
|
#include "unicode/utypes.h"
|
2002-09-20 01:54:48 +00:00
|
|
|
|
|
|
|
#if UCONFIG_NO_BREAK_ITERATION
|
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
/*
|
|
|
|
* Allow the declaration of APIs with pointers to BreakIterator
|
|
|
|
* even when break iteration is removed from the build.
|
|
|
|
*/
|
|
|
|
class BreakIterator;
|
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#else
|
|
|
|
|
2002-06-27 01:19:20 +00:00
|
|
|
#include "unicode/uobject.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/unistr.h"
|
|
|
|
#include "unicode/chariter.h"
|
|
|
|
#include "unicode/locid.h"
|
2002-07-30 19:09:14 +00:00
|
|
|
#include "unicode/ubrk.h"
|
2002-11-08 00:22:18 +00:00
|
|
|
#include "unicode/strenum.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2002-11-15 23:52:14 +00:00
|
|
|
typedef const void* URegistryKey;
|
2002-11-14 17:47:49 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* The BreakIterator class implements methods for finding the location
|
|
|
|
* of boundaries in text. BreakIterator is an abstract base class.
|
|
|
|
* Instances of BreakIterator maintain a current position and scan over
|
|
|
|
* text returning the index of characters where boundaries occur.
|
|
|
|
* <P>
|
|
|
|
* Line boundary analysis determines where a text string can be broken
|
|
|
|
* when line-wrapping. The mechanism correctly handles punctuation and
|
|
|
|
* hyphenated words.
|
|
|
|
* <P>
|
|
|
|
* Sentence boundary analysis allows selection with correct
|
|
|
|
* interpretation of periods within numbers and abbreviations, and
|
|
|
|
* trailing punctuation marks such as quotation marks and parentheses.
|
|
|
|
* <P>
|
|
|
|
* Word boundary analysis is used by search and replace functions, as
|
|
|
|
* well as within text editing applications that allow the user to
|
|
|
|
* select words with a double click. Word selection provides correct
|
|
|
|
* interpretation of punctuation marks within and following
|
|
|
|
* words. Characters that are not part of a word, such as symbols or
|
|
|
|
* punctuation marks, have word-breaks on both sides.
|
|
|
|
* <P>
|
|
|
|
* Character boundary analysis allows users to interact with
|
|
|
|
* characters as they expect to, for example, when moving the cursor
|
|
|
|
* through a text string. Character boundary analysis provides correct
|
|
|
|
* navigation of through character strings, regardless of how the
|
|
|
|
* character is stored. For example, an accented character might be
|
|
|
|
* stored as a base character and a diacritical mark. What users
|
|
|
|
* consider to be a character can differ between languages.
|
|
|
|
* <P>
|
|
|
|
* This is the interface for all text boundaries.
|
|
|
|
* <P>
|
|
|
|
* Examples:
|
|
|
|
* <P>
|
|
|
|
* Helper function to output text
|
|
|
|
* <pre>
|
2002-08-08 00:39:13 +00:00
|
|
|
* \code
|
2002-03-12 01:32:42 +00:00
|
|
|
* void printTextRange( BreakIterator& iterator, int32_t start, int32_t end )
|
2000-12-08 18:46:55 +00:00
|
|
|
* {
|
|
|
|
* UnicodeString textBuffer, temp;
|
|
|
|
* CharacterIterator *strIter = iterator.createText();
|
|
|
|
* strIter->getText(temp);
|
2002-08-08 00:39:13 +00:00
|
|
|
* cout << " " << start << " " << end << " |"
|
2001-03-19 22:30:38 +00:00
|
|
|
* << temp.extractBetween(start, end, textBuffer)
|
|
|
|
* << "|" << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* delete strIter;
|
|
|
|
* }
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* Print each element in order:
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* void printEachForward( BreakIterator& boundary)
|
|
|
|
* {
|
2002-03-12 01:32:42 +00:00
|
|
|
* int32_t start = boundary.first();
|
|
|
|
* for (int32_t end = boundary.next();
|
2000-12-08 18:46:55 +00:00
|
|
|
* end != BreakIterator::DONE;
|
|
|
|
* start = end, end = boundary.next())
|
|
|
|
* {
|
|
|
|
* printTextRange( boundary, start, end );
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* \code
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* Print each element in reverse order:
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* void printEachBackward( BreakIterator& boundary)
|
|
|
|
* {
|
2002-03-12 01:32:42 +00:00
|
|
|
* int32_t end = boundary.last();
|
|
|
|
* for (int32_t start = boundary.previous();
|
2000-12-08 18:46:55 +00:00
|
|
|
* start != BreakIterator::DONE;
|
|
|
|
* end = start, start = boundary.previous())
|
|
|
|
* {
|
|
|
|
* printTextRange( boundary, start, end );
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* Print first element
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* void printFirst(BreakIterator& boundary)
|
|
|
|
* {
|
2002-03-12 01:32:42 +00:00
|
|
|
* int32_t start = boundary.first();
|
|
|
|
* int32_t end = boundary.next();
|
2000-12-08 18:46:55 +00:00
|
|
|
* printTextRange( boundary, start, end );
|
|
|
|
* }
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* Print last element
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* void printLast(BreakIterator& boundary)
|
|
|
|
* {
|
2002-03-12 01:32:42 +00:00
|
|
|
* int32_t end = boundary.last();
|
|
|
|
* int32_t start = boundary.previous();
|
2000-12-08 18:46:55 +00:00
|
|
|
* printTextRange( boundary, start, end );
|
|
|
|
* }
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* Print the element at a specified position
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
2002-03-12 01:32:42 +00:00
|
|
|
* void printAt(BreakIterator &boundary, int32_t pos )
|
2000-12-08 18:46:55 +00:00
|
|
|
* {
|
2002-03-12 01:32:42 +00:00
|
|
|
* int32_t end = boundary.following(pos);
|
|
|
|
* int32_t start = boundary.previous();
|
2000-12-08 18:46:55 +00:00
|
|
|
* printTextRange( boundary, start, end );
|
|
|
|
* }
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* Creating and using text boundaries
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* void BreakIterator_Example( void )
|
|
|
|
* {
|
|
|
|
* BreakIterator* boundary;
|
|
|
|
* UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff.");
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << "Examining: " << stringToExamine << endl;
|
2002-08-08 00:39:13 +00:00
|
|
|
*
|
2000-12-08 18:46:55 +00:00
|
|
|
* //print each sentence in forward and reverse order
|
|
|
|
* boundary = BreakIterator::createSentenceInstance( Locale::US );
|
|
|
|
* boundary->setText(stringToExamine);
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << "----- forward: -----------" << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* printEachForward(*boundary);
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << "----- backward: ----------" << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* printEachBackward(*boundary);
|
|
|
|
* delete boundary;
|
2002-08-08 00:39:13 +00:00
|
|
|
*
|
2000-12-08 18:46:55 +00:00
|
|
|
* //print each word in order
|
|
|
|
* boundary = BreakIterator::createWordInstance();
|
|
|
|
* boundary->setText(stringToExamine);
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << "----- forward: -----------" << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* printEachForward(*boundary);
|
|
|
|
* //print first element
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << "----- first: -------------" << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* printFirst(*boundary);
|
|
|
|
* //print last element
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << "----- last: --------------" << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* printLast(*boundary);
|
|
|
|
* //print word at charpos 10
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << "----- at pos 10: ---------" << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* printAt(*boundary, 10 );
|
2002-08-08 00:39:13 +00:00
|
|
|
*
|
2000-12-08 18:46:55 +00:00
|
|
|
* delete boundary;
|
|
|
|
* }
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
*/
|
2002-06-27 01:19:20 +00:00
|
|
|
class U_COMMON_API BreakIterator : public UObject {
|
1999-12-28 23:57:50 +00:00
|
|
|
public:
|
2002-12-04 18:21:09 +00:00
|
|
|
/**
|
|
|
|
* destructor
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-12-04 18:21:09 +00:00
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
virtual ~BreakIterator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if another object is semantically equal to this
|
|
|
|
* one. The other object should be an instance of the same subclass of
|
|
|
|
* BreakIterator. Objects of different subclasses are considered
|
|
|
|
* unequal.
|
|
|
|
* <P>
|
|
|
|
* Return true if this BreakIterator is at the same position in the
|
|
|
|
* same text, and is the same class and type (word, line, etc.) of
|
|
|
|
* BreakIterator, as the argument. Text is considered the same if
|
|
|
|
* it contains the same characters, it need not be the same
|
|
|
|
* object, and styles are not considered.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual UBool operator==(const BreakIterator&) const = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2000-01-08 02:05:05 +00:00
|
|
|
/**
|
|
|
|
* Returns the complement of the result of operator==
|
2003-05-10 00:06:12 +00:00
|
|
|
* @param rhs The BreakIterator to be compared for inequality
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return the complement of the result of operator==
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-08 02:05:05 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a polymorphic copy of this object. This is an abstract
|
|
|
|
* method which subclasses implement.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual BreakIterator* clone(void) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a polymorphic class ID for this object. Different subclasses
|
|
|
|
* will return distinct unequal values.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual UClassID getDynamicClassID(void) const = 0;
|
|
|
|
|
2000-01-08 02:05:05 +00:00
|
|
|
/**
|
|
|
|
* Return a CharacterIterator over the text being analyzed.
|
2002-08-08 00:39:13 +00:00
|
|
|
* Changing the state of the returned iterator can have undefined consequences
|
|
|
|
* on the operation of the break iterator. If you need to change it, clone it first.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-08 02:05:05 +00:00
|
|
|
*/
|
2000-01-14 00:13:59 +00:00
|
|
|
virtual const CharacterIterator& getText(void) const = 0;
|
2000-01-08 02:05:05 +00:00
|
|
|
|
2000-06-29 20:21:45 +00:00
|
|
|
/**
|
|
|
|
* Change the text over which this operates. The text boundary is
|
|
|
|
* reset to the start.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param text The UnicodeString used to change the text.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-06-29 20:21:45 +00:00
|
|
|
*/
|
|
|
|
virtual void setText(const UnicodeString &text) = 0;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Change the text over which this operates. The text boundary is
|
|
|
|
* reset to the start.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param it The CharacterIterator used to change the text.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual void adoptText(CharacterIterator* it) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DONE is returned by previous() and next() after all valid
|
|
|
|
* boundaries have been returned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
static const int32_t DONE;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the index of the first character in the text being scanned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t first(void) = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the index immediately BEYOND the last character in the text being scanned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t last(void) = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the boundary preceding the current boundary.
|
|
|
|
* @return The character index of the previous text boundary or DONE if all
|
|
|
|
* boundaries have been returned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t previous(void) = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the boundary following the current boundary.
|
|
|
|
* @return The character index of the next text boundary or DONE if all
|
|
|
|
* boundaries have been returned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t next(void) = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
2002-08-08 00:39:13 +00:00
|
|
|
* Return character index of the current interator position within the text.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @return The boundary most recently returned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t current(void) const = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first boundary following the specified offset.
|
|
|
|
* The value returned is always greater than the offset or
|
|
|
|
* the value BreakIterator.DONE
|
|
|
|
* @param offset the offset to begin scanning.
|
|
|
|
* @return The first boundary after the specified offset.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t following(int32_t offset) = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first boundary preceding the specified offset.
|
|
|
|
* The value returned is always smaller than the offset or
|
|
|
|
* the value BreakIterator.DONE
|
|
|
|
* @param offset the offset to begin scanning.
|
|
|
|
* @return The first boundary before the specified offset.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t preceding(int32_t offset) = 0;
|
2002-08-08 00:39:13 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Return true if the specfied position is a boundary position.
|
2002-08-08 00:39:13 +00:00
|
|
|
* As a side effect, the current position of the iterator is set
|
|
|
|
* to the first boundary position at or following the specified offset.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @param offset the offset to check.
|
|
|
|
* @return True if "offset" is a boundary position.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual UBool isBoundary(int32_t offset) = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the nth boundary from the current boundary
|
|
|
|
* @param n which boundary to return. A value of 0
|
|
|
|
* does nothing. Negative values move to previous boundaries
|
|
|
|
* and positive values move to later boundaries.
|
|
|
|
* @return The index of the nth boundary from the current position, or
|
|
|
|
* DONE if there are fewer than |n| boundaries in the specfied direction.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual int32_t next(int32_t n) = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create BreakIterator for word-breaks using the given locale.
|
|
|
|
* Returns an instance of a BreakIterator implementing word breaks.
|
|
|
|
* WordBreak is useful for word selection (ex. double click)
|
2002-08-08 00:39:13 +00:00
|
|
|
* @param where the locale.
|
2000-01-14 00:13:59 +00:00
|
|
|
* @param status the error code
|
2002-08-08 00:39:13 +00:00
|
|
|
* @return A BreakIterator for word-breaks. The UErrorCode& status
|
2000-01-14 00:13:59 +00:00
|
|
|
* parameter is used to return status information to the user.
|
|
|
|
* To check whether the construction succeeded or not, you should check
|
|
|
|
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
|
|
|
* can check for informational error results which still indicate success.
|
2002-08-08 00:39:13 +00:00
|
|
|
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
2000-01-14 00:13:59 +00:00
|
|
|
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
2002-08-08 00:39:13 +00:00
|
|
|
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
2000-01-14 00:13:59 +00:00
|
|
|
* used; neither the requested locale nor any of its fall back locales
|
|
|
|
* could be found.
|
|
|
|
* The caller owns the returned object and is responsible for deleting it.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-08-08 00:39:13 +00:00
|
|
|
static BreakIterator* createWordInstance(const Locale& where,
|
2000-01-14 00:13:59 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create BreakIterator for line-breaks using specified locale.
|
|
|
|
* Returns an instance of a BreakIterator implementing line breaks. Line
|
|
|
|
* breaks are logically possible line breaks, actual line breaks are
|
|
|
|
* usually determined based on display width.
|
|
|
|
* LineBreak is useful for word wrapping text.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param where the locale.
|
|
|
|
* @param status The error code.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @return A BreakIterator for line-breaks. The UErrorCode& status
|
2000-01-14 00:13:59 +00:00
|
|
|
* parameter is used to return status information to the user.
|
|
|
|
* To check whether the construction succeeded or not, you should check
|
|
|
|
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
|
|
|
* can check for informational error results which still indicate success.
|
2002-08-08 00:39:13 +00:00
|
|
|
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
2000-01-14 00:13:59 +00:00
|
|
|
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
2002-08-08 00:39:13 +00:00
|
|
|
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
2000-01-14 00:13:59 +00:00
|
|
|
* used; neither the requested locale nor any of its fall back locales
|
|
|
|
* could be found.
|
|
|
|
* The caller owns the returned object and is responsible for deleting it.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-08-08 00:39:13 +00:00
|
|
|
static BreakIterator* createLineInstance(const Locale& where,
|
2000-01-14 00:13:59 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create BreakIterator for character-breaks using specified locale
|
|
|
|
* Returns an instance of a BreakIterator implementing character breaks.
|
|
|
|
* Character breaks are boundaries of combining character sequences.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @param where the locale.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param status The error code.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @return A BreakIterator for character-breaks. The UErrorCode& status
|
2000-01-14 00:13:59 +00:00
|
|
|
* parameter is used to return status information to the user.
|
|
|
|
* To check whether the construction succeeded or not, you should check
|
|
|
|
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
|
|
|
* can check for informational error results which still indicate success.
|
2002-08-08 00:39:13 +00:00
|
|
|
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
2000-01-14 00:13:59 +00:00
|
|
|
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
2002-08-08 00:39:13 +00:00
|
|
|
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
2000-01-14 00:13:59 +00:00
|
|
|
* used; neither the requested locale nor any of its fall back locales
|
|
|
|
* could be found.
|
|
|
|
* The caller owns the returned object and is responsible for deleting it.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-08-08 00:39:13 +00:00
|
|
|
static BreakIterator* createCharacterInstance(const Locale& where,
|
2000-01-14 00:13:59 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create BreakIterator for sentence-breaks using specified locale
|
|
|
|
* Returns an instance of a BreakIterator implementing sentence breaks.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @param where the locale.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param status The error code.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @return A BreakIterator for sentence-breaks. The UErrorCode& status
|
2000-01-14 00:13:59 +00:00
|
|
|
* parameter is used to return status information to the user.
|
|
|
|
* To check whether the construction succeeded or not, you should check
|
|
|
|
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
|
|
|
* can check for informational error results which still indicate success.
|
2002-08-08 00:39:13 +00:00
|
|
|
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
2000-01-14 00:13:59 +00:00
|
|
|
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
2002-08-08 00:39:13 +00:00
|
|
|
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
2000-01-14 00:13:59 +00:00
|
|
|
* used; neither the requested locale nor any of its fall back locales
|
|
|
|
* could be found.
|
|
|
|
* The caller owns the returned object and is responsible for deleting it.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-08-08 00:39:13 +00:00
|
|
|
static BreakIterator* createSentenceInstance(const Locale& where,
|
2000-01-14 00:13:59 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2002-02-28 01:28:04 +00:00
|
|
|
/**
|
|
|
|
* Create BreakIterator for title-casing breaks using the specified locale
|
|
|
|
* Returns an instance of a BreakIterator implementing title breaks.
|
2003-05-24 02:03:32 +00:00
|
|
|
* The iterator returned locates title boundaries as described for
|
|
|
|
* Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
|
|
|
|
* please use Word Boundary iterator.{@link createWordInstance}
|
|
|
|
*
|
2002-08-08 00:39:13 +00:00
|
|
|
* @param where the locale.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param status The error code.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @return A BreakIterator for title-breaks. The UErrorCode& status
|
2002-02-28 01:28:04 +00:00
|
|
|
* parameter is used to return status information to the user.
|
|
|
|
* To check whether the construction succeeded or not, you should check
|
|
|
|
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
|
|
|
* can check for informational error results which still indicate success.
|
2002-08-08 00:39:13 +00:00
|
|
|
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
2002-02-28 01:28:04 +00:00
|
|
|
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
2002-08-08 00:39:13 +00:00
|
|
|
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
2002-02-28 01:28:04 +00:00
|
|
|
* used; neither the requested locale nor any of its fall back locales
|
|
|
|
* could be found.
|
|
|
|
* The caller owns the returned object and is responsible for deleting it.
|
2003-06-04 00:04:35 +00:00
|
|
|
* @stable ICU 2.1
|
2002-02-28 01:28:04 +00:00
|
|
|
*/
|
2002-08-08 00:39:13 +00:00
|
|
|
static BreakIterator* createTitleInstance(const Locale& where,
|
2002-02-28 01:28:04 +00:00
|
|
|
UErrorCode& status);
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
2002-11-08 00:22:18 +00:00
|
|
|
* Get the set of Locales for which TextBoundaries are installed.
|
|
|
|
* <p><b>Note:</b> this will not return locales added through the register
|
|
|
|
* call.</p>
|
1999-12-28 23:57:50 +00:00
|
|
|
* @param count the output parameter of number of elements in the locale list
|
|
|
|
* @return available locales
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
static const Locale* getAvailableLocales(int32_t& count);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get name of the object for the desired Locale, in the desired langauge.
|
|
|
|
* @param objectLocale must be from getAvailableLocales.
|
|
|
|
* @param displayLocale specifies the desired locale for output.
|
|
|
|
* @param name the fill-in parameter of the return value
|
|
|
|
* Uses best match.
|
|
|
|
* @return user-displayable name
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
static UnicodeString& getDisplayName(const Locale& objectLocale,
|
|
|
|
const Locale& displayLocale,
|
|
|
|
UnicodeString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get name of the object for the desired Locale, in the langauge of the
|
|
|
|
* default locale.
|
|
|
|
* @param objectLocale must be from getMatchingLocales
|
|
|
|
* @param name the fill-in parameter of the return value
|
|
|
|
* @return user-displayable name
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
static UnicodeString& getDisplayName(const Locale& objectLocale,
|
|
|
|
UnicodeString& name);
|
|
|
|
|
2002-04-02 01:17:28 +00:00
|
|
|
/**
|
2001-02-21 23:40:41 +00:00
|
|
|
* Thread safe client-buffer-based cloning operation
|
|
|
|
* Do NOT call delete on a safeclone, since 'new' is not used to create it.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.
|
2002-04-02 01:17:28 +00:00
|
|
|
* If buffer is not large enough, new memory will be allocated.
|
2002-08-08 00:39:13 +00:00
|
|
|
* @param BufferSize reference to size of allocated space.
|
|
|
|
* If BufferSize == 0, a sufficient size for use in cloning will
|
2002-04-02 01:17:28 +00:00
|
|
|
* be returned ('pre-flighting')
|
2002-08-08 00:39:13 +00:00
|
|
|
* If BufferSize is not enough for a stack-based safe clone,
|
2002-04-02 01:17:28 +00:00
|
|
|
* new memory will be allocated.
|
2001-02-21 23:40:41 +00:00
|
|
|
* @param status to indicate whether the operation went on smoothly or there were errors
|
2002-08-08 00:39:13 +00:00
|
|
|
* An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were
|
2002-04-02 01:17:28 +00:00
|
|
|
* necessary.
|
2001-02-21 23:40:41 +00:00
|
|
|
* @return pointer to the new clone
|
2002-08-08 00:39:13 +00:00
|
|
|
*
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-21 23:40:41 +00:00
|
|
|
*/
|
|
|
|
virtual BreakIterator * createBufferClone(void *stackBuffer,
|
|
|
|
int32_t &BufferSize,
|
|
|
|
UErrorCode &status) = 0;
|
2002-04-02 01:17:28 +00:00
|
|
|
|
2002-08-08 00:39:13 +00:00
|
|
|
/**
|
|
|
|
* Determine whether the BreakIterator was created in user memory by
|
|
|
|
* createBufferClone(), and thus should not be deleted. Such objects
|
|
|
|
* must be closed by an explicit call to the destructor (not delete).
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-08-08 00:39:13 +00:00
|
|
|
*/
|
2001-02-21 23:40:41 +00:00
|
|
|
inline UBool isBufferClone(void);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2002-11-08 00:22:18 +00:00
|
|
|
/**
|
|
|
|
* Register a new break iterator of the indicated kind, to use in the given locale.
|
|
|
|
* The break iterator will be adoped. Clones of the iterator will be returned
|
|
|
|
* if a request for a break iterator of the given kind matches or falls back to
|
|
|
|
* this locale.
|
2002-11-15 23:52:14 +00:00
|
|
|
* @param toAdopt the BreakIterator instance to be adopted
|
|
|
|
* @param locale the Locale for which this instance is to be registered
|
|
|
|
* @param kind the type of iterator for which this instance is to be registered
|
|
|
|
* @param status the in/out status code, no special meanings are assigned
|
|
|
|
* @return a registry key that can be used to unregister this instance
|
|
|
|
* @draft ICU 2.4
|
2002-11-08 00:22:18 +00:00
|
|
|
*/
|
2002-11-15 23:52:14 +00:00
|
|
|
static URegistryKey registerInstance(BreakIterator* toAdopt, const Locale& locale, UBreakIteratorType kind, UErrorCode& status);
|
2002-11-08 00:22:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister a previously-registered BreakIterator using the key returned from the
|
2002-11-20 17:15:34 +00:00
|
|
|
* register call. Key becomes invalid after a successful call and should not be used again.
|
2002-11-15 23:52:14 +00:00
|
|
|
* The BreakIterator corresponding to the key will be deleted.
|
|
|
|
* @param key the registry key returned by a previous call to registerInstance
|
|
|
|
* @param status the in/out status code, no special meanings are assigned
|
|
|
|
* @return TRUE if the iterator for the key was successfully unregistered
|
|
|
|
* @draft ICU 2.4
|
2002-11-08 00:22:18 +00:00
|
|
|
*/
|
2002-11-15 23:52:14 +00:00
|
|
|
static UBool unregister(URegistryKey key, UErrorCode& status);
|
2002-11-08 00:22:18 +00:00
|
|
|
|
|
|
|
/**
|
2002-11-15 23:52:14 +00:00
|
|
|
* Return a StringEnumeration over the locales available at the time of the call,
|
|
|
|
* including registered locales.
|
|
|
|
* @return a StringEnumeration over the locales available at the time of the call
|
|
|
|
* @draft ICU 2.4
|
2002-11-08 00:22:18 +00:00
|
|
|
*/
|
|
|
|
static StringEnumeration* getAvailableLocales(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static BreakIterator* makeCharacterInstance(const Locale& loc, UErrorCode& status);
|
|
|
|
static BreakIterator* makeWordInstance(const Locale& loc, UErrorCode& status);
|
|
|
|
static BreakIterator* makeLineInstance(const Locale& loc, UErrorCode& status);
|
|
|
|
static BreakIterator* makeSentenceInstance(const Locale& loc, UErrorCode& status);
|
|
|
|
static BreakIterator* makeTitleInstance(const Locale& loc, UErrorCode& status);
|
|
|
|
|
2002-11-14 17:47:49 +00:00
|
|
|
static BreakIterator* createInstance(const Locale& loc, UBreakIteratorType kind, UErrorCode& status);
|
2002-11-08 00:22:18 +00:00
|
|
|
static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
|
|
|
|
|
|
|
|
friend class ICUBreakIteratorFactory;
|
2002-11-08 18:07:48 +00:00
|
|
|
friend class ICUBreakIteratorService;
|
2002-04-02 01:17:28 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
protected:
|
2002-12-04 18:21:09 +00:00
|
|
|
/** @internal */
|
1999-12-28 23:57:50 +00:00
|
|
|
BreakIterator();
|
2002-12-04 18:21:09 +00:00
|
|
|
/** @internal */
|
2001-02-21 23:40:41 +00:00
|
|
|
UBool fBufferClone;
|
2002-12-04 18:21:09 +00:00
|
|
|
/** @internal */
|
2002-07-24 19:07:37 +00:00
|
|
|
BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
|
1999-12-28 23:57:50 +00:00
|
|
|
private:
|
|
|
|
/**
|
2002-07-24 19:07:37 +00:00
|
|
|
* The assignment operator has no real implementation.
|
|
|
|
* It's provided to make the compiler happy. Do not call.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-08-23 16:46:39 +00:00
|
|
|
BreakIterator& operator=(const BreakIterator&) { return *this; }
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
|
|
|
|
2001-02-21 23:40:41 +00:00
|
|
|
inline UBool BreakIterator::isBufferClone()
|
|
|
|
{
|
|
|
|
return fBufferClone;
|
|
|
|
}
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#endif // _BRKITER
|
|
|
|
//eof
|
2001-02-22 01:03:05 +00:00
|
|
|
|