1999-12-28 23:57:50 +00:00
|
|
|
/*
|
2003-05-10 00:06:12 +00:00
|
|
|
********************************************************************************
|
2011-06-09 22:49:40 +00:00
|
|
|
* Copyright (C) 1997-2011, 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
|
|
|
|
2005-06-22 22:39:36 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief C++ API: Break Iterator.
|
|
|
|
*/
|
2007-08-16 23:14:06 +00:00
|
|
|
|
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"
|
2005-06-14 01:47:59 +00:00
|
|
|
#include "unicode/utext.h"
|
2006-02-02 03:48:14 +00:00
|
|
|
#include "unicode/umisc.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
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2006-01-18 05:50:06 +00:00
|
|
|
* <p>
|
1999-12-28 23:57:50 +00:00
|
|
|
* Line boundary analysis determines where a text string can be broken
|
|
|
|
* when line-wrapping. The mechanism correctly handles punctuation and
|
|
|
|
* hyphenated words.
|
2006-01-18 05:50:06 +00:00
|
|
|
* <p>
|
1999-12-28 23:57:50 +00:00
|
|
|
* Sentence boundary analysis allows selection with correct
|
|
|
|
* interpretation of periods within numbers and abbreviations, and
|
|
|
|
* trailing punctuation marks such as quotation marks and parentheses.
|
2006-01-18 05:50:06 +00:00
|
|
|
* <p>
|
1999-12-28 23:57:50 +00:00
|
|
|
* 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.
|
2006-01-18 05:50:06 +00:00
|
|
|
* <p>
|
1999-12-28 23:57:50 +00:00
|
|
|
* 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.
|
2006-01-18 05:50:06 +00:00
|
|
|
* <p>
|
2005-08-17 05:11:41 +00:00
|
|
|
* The text boundary positions are found according to the rules
|
|
|
|
* described in Unicode Standard Annex #29, Text Boundaries, and
|
|
|
|
* Unicode Standard Annex #14, Line Breaking Properties. These
|
|
|
|
* are available at http://www.unicode.org/reports/tr14/ and
|
|
|
|
* http://www.unicode.org/reports/tr29/.
|
2006-01-18 05:50:06 +00:00
|
|
|
* <p>
|
2005-08-17 05:11:41 +00:00
|
|
|
* In addition to the C++ API defined in this header file, a
|
|
|
|
* plain C API with equivalent functionality is defined in the
|
|
|
|
* file ubrk.h
|
2006-01-18 05:50:06 +00:00
|
|
|
* <p>
|
2010-02-11 00:53:57 +00:00
|
|
|
* Code snippets illustrating the use of the Break Iterator APIs
|
2007-08-16 23:14:06 +00:00
|
|
|
* are available in the ICU User Guide,
|
2007-06-11 19:14:47 +00:00
|
|
|
* http://icu-project.org/userguide/boundaryAnalysis.html
|
2010-02-11 00:53:57 +00:00
|
|
|
* and in the sample program icu/source/samples/break/break.cpp
|
2002-08-08 00:39:13 +00:00
|
|
|
*
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
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-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-08 02:05:05 +00:00
|
|
|
*/
|
2006-04-26 04:01:00 +00:00
|
|
|
virtual CharacterIterator& getText(void) const = 0;
|
2000-01-08 02:05:05 +00:00
|
|
|
|
2005-06-23 05:51:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a UText for the text being analyzed.
|
|
|
|
* The returned UText is a shallow clone of the UText used internally
|
|
|
|
* by the break iterator implementation. It can safely be used to
|
|
|
|
* access the text without impacting any break iterator operations,
|
|
|
|
* but the underlying text itself must not be altered.
|
|
|
|
*
|
|
|
|
* @param fillIn A UText to be filled in. If NULL, a new UText will be
|
|
|
|
* allocated to hold the result.
|
2005-06-27 16:08:36 +00:00
|
|
|
* @param status receives any error codes.
|
2005-06-23 05:51:28 +00:00
|
|
|
* @return The current UText for this break iterator. If an input
|
|
|
|
* UText was provided, it will always be returned.
|
2007-08-19 08:59:28 +00:00
|
|
|
* @stable ICU 3.4
|
2005-06-23 05:51:28 +00:00
|
|
|
*/
|
|
|
|
virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
|
|
|
|
|
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;
|
|
|
|
|
2005-06-14 01:47:59 +00:00
|
|
|
/**
|
2007-08-16 23:14:06 +00:00
|
|
|
* Reset the break iterator to operate over the text represented by
|
2005-06-23 05:51:28 +00:00
|
|
|
* the UText. The iterator position is reset to the start.
|
|
|
|
*
|
|
|
|
* This function makes a shallow clone of the supplied UText. This means
|
|
|
|
* that the caller is free to immediately close or otherwise reuse the
|
|
|
|
* Utext that was passed as a parameter, but that the underlying text itself
|
|
|
|
* must not be altered while being referenced by the break iterator.
|
|
|
|
*
|
2005-06-14 01:47:59 +00:00
|
|
|
* @param text The UText used to change the text.
|
2005-06-27 16:08:36 +00:00
|
|
|
* @param status receives any error codes.
|
2007-08-19 08:59:28 +00:00
|
|
|
* @stable ICU 3.4
|
2005-06-14 01:47:59 +00:00
|
|
|
*/
|
2005-06-23 05:51:28 +00:00
|
|
|
virtual void setText(UText *text, UErrorCode &status) = 0;
|
2005-06-14 01:47:59 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Change the text over which this operates. The text boundary is
|
|
|
|
* reset to the start.
|
2006-04-22 05:29:27 +00:00
|
|
|
* Note that setText(UText *) provides similar functionality to this function,
|
|
|
|
* and is more efficient.
|
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;
|
|
|
|
|
2005-03-08 23:05:38 +00:00
|
|
|
enum {
|
|
|
|
/**
|
|
|
|
* DONE is returned by previous() and next() after all valid
|
|
|
|
* boundaries have been returned.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
DONE = (int32_t)-1
|
|
|
|
};
|
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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static BreakIterator* U_EXPORT2
|
|
|
|
createWordInstance(const Locale& where, 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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static BreakIterator* U_EXPORT2
|
|
|
|
createLineInstance(const Locale& where, 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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static BreakIterator* U_EXPORT2
|
|
|
|
createCharacterInstance(const Locale& where, 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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static BreakIterator* U_EXPORT2
|
|
|
|
createSentenceInstance(const Locale& where, 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.
|
2004-08-24 17:21:14 +00:00
|
|
|
* The iterator returned locates title boundaries as described for
|
2003-05-24 02:03:32 +00:00
|
|
|
* Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
|
2004-06-09 21:30:50 +00:00
|
|
|
* please use Word Boundary iterator.{@link #createWordInstance }
|
2003-05-24 02:03:32 +00:00
|
|
|
*
|
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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static BreakIterator* U_EXPORT2
|
|
|
|
createTitleInstance(const Locale& where, UErrorCode& status);
|
2002-02-28 01:28:04 +00:00
|
|
|
|
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
|
2004-07-18 01:18:23 +00:00
|
|
|
* call. To see the registered locales too, use the getAvailableLocales
|
|
|
|
* function that returns a StringEnumeration object </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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
|
1999-12-28 23:57:50 +00:00
|
|
|
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
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
|
1999-12-28 23:57:50 +00:00
|
|
|
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
|
|
|
|
2004-07-18 01:18:23 +00:00
|
|
|
#if !UCONFIG_NO_SERVICE
|
2002-11-08 00:22:18 +00:00
|
|
|
/**
|
|
|
|
* Register a new break iterator of the indicated kind, to use in the given locale.
|
2004-01-22 19:56:21 +00:00
|
|
|
* The break iterator will be adopted. Clones of the iterator will be returned
|
2002-11-08 00:22:18 +00:00
|
|
|
* 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
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-11-08 00:22:18 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static URegistryKey U_EXPORT2 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
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-11-08 00:22:18 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
|
2002-11-08 00:22:18 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Return a StringEnumeration over the locales available at the time of the call,
|
2002-11-15 23:52:14 +00:00
|
|
|
* including registered locales.
|
|
|
|
* @return a StringEnumeration over the locales available at the time of the call
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-11-08 00:22:18 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
|
2004-07-18 01:18:23 +00:00
|
|
|
#endif
|
2002-11-08 00:22:18 +00:00
|
|
|
|
2003-11-14 07:06:58 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Returns the locale for this break iterator. Two flavors are available: valid and
|
|
|
|
* actual locale.
|
2006-01-18 04:02:07 +00:00
|
|
|
* @stable ICU 2.8
|
2003-11-14 07:06:58 +00:00
|
|
|
*/
|
2004-01-20 23:06:38 +00:00
|
|
|
Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
|
2003-11-14 07:06:58 +00:00
|
|
|
|
2011-08-01 02:20:46 +00:00
|
|
|
#ifndef U_HIDE_INTERNAL_API
|
2003-11-20 00:03:20 +00:00
|
|
|
/** Get the locale for this break iterator object. You can choose between valid and actual locale.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param type type of the locale we're looking for (valid or actual)
|
2003-11-20 00:03:20 +00:00
|
|
|
* @param status error code for the operation
|
|
|
|
* @return the locale
|
|
|
|
* @internal
|
|
|
|
*/
|
2004-01-20 23:06:38 +00:00
|
|
|
const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
|
2011-08-01 02:20:46 +00:00
|
|
|
#endif /* U_HIDE_INTERNAL_API */
|
2004-01-20 23:06:38 +00:00
|
|
|
|
2011-06-09 22:49:40 +00:00
|
|
|
/**
|
|
|
|
* Set the subject text string upon which the break iterator is operating
|
|
|
|
* without changing any other aspect of the matching state.
|
|
|
|
* The new and previous text strings must have the same content.
|
|
|
|
*
|
|
|
|
* This function is intended for use in environments where ICU is operating on
|
|
|
|
* strings that may move around in memory. It provides a mechanism for notifying
|
|
|
|
* ICU that the string has been relocated, and providing a new UText to access the
|
|
|
|
* string in its new position.
|
|
|
|
*
|
|
|
|
* Note that the break iterator implementation never copies the underlying text
|
|
|
|
* of a string being processed, but always operates directly on the original text
|
|
|
|
* provided by the user. Refreshing simply drops the references to the old text
|
|
|
|
* and replaces them with references to the new.
|
|
|
|
*
|
|
|
|
* Caution: this function is normally used only by very specialized,
|
|
|
|
* system-level code. One example use case is with garbage collection that moves
|
|
|
|
* the text in memory.
|
|
|
|
*
|
|
|
|
* @param input The new (moved) text string.
|
|
|
|
* @param status Receives errors detected by this function.
|
|
|
|
* @return *this
|
|
|
|
*
|
2011-08-01 02:20:46 +00:00
|
|
|
* @draft ICU 49
|
2011-06-09 22:49:40 +00:00
|
|
|
*/
|
|
|
|
virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
|
|
|
|
|
2002-11-08 00:22:18 +00:00
|
|
|
private:
|
2006-03-23 00:54:12 +00:00
|
|
|
static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
|
|
|
|
static BreakIterator* createInstance(const Locale& loc, int32_t 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:
|
2011-08-01 02:20:46 +00:00
|
|
|
// Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
|
|
|
|
// or else the compiler will create a public ones.
|
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) {}
|
2003-11-20 00:03:20 +00:00
|
|
|
|
2004-01-20 23:06:38 +00:00
|
|
|
private:
|
|
|
|
|
2003-11-14 07:06:58 +00:00
|
|
|
/** @internal */
|
2004-01-12 22:39:41 +00:00
|
|
|
char actualLocale[ULOC_FULLNAME_CAPACITY];
|
|
|
|
char validLocale[ULOC_FULLNAME_CAPACITY];
|
2004-01-20 23:06:38 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
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
|
|
|
*/
|
2005-01-01 03:00:49 +00:00
|
|
|
BreakIterator& operator=(const BreakIterator&);
|
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
|
|
|
|