michael@0: /* michael@0: ******************************************************************************** michael@0: * Copyright (C) 1997-2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ******************************************************************************** michael@0: * michael@0: * File brkiter.h michael@0: * michael@0: * Modification History: michael@0: * michael@0: * Date Name Description michael@0: * 02/18/97 aliu Added typedef for TextCount. Made DONE const. michael@0: * 05/07/97 aliu Fixed DLL declaration. michael@0: * 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK michael@0: * 08/11/98 helena Sync-up JDK1.2. michael@0: * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods. michael@0: ******************************************************************************** michael@0: */ michael@0: michael@0: #ifndef BRKITER_H michael@0: #define BRKITER_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C++ API: Break Iterator. michael@0: */ michael@0: michael@0: #if UCONFIG_NO_BREAK_ITERATION michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /* michael@0: * Allow the declaration of APIs with pointers to BreakIterator michael@0: * even when break iteration is removed from the build. michael@0: */ michael@0: class BreakIterator; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #else michael@0: michael@0: #include "unicode/uobject.h" michael@0: #include "unicode/unistr.h" michael@0: #include "unicode/chariter.h" michael@0: #include "unicode/locid.h" michael@0: #include "unicode/ubrk.h" michael@0: #include "unicode/strenum.h" michael@0: #include "unicode/utext.h" michael@0: #include "unicode/umisc.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * The BreakIterator class implements methods for finding the location michael@0: * of boundaries in text. BreakIterator is an abstract base class. michael@0: * Instances of BreakIterator maintain a current position and scan over michael@0: * text returning the index of characters where boundaries occur. michael@0: *
michael@0: * Line boundary analysis determines where a text string can be broken michael@0: * when line-wrapping. The mechanism correctly handles punctuation and michael@0: * hyphenated words. michael@0: *
michael@0: * Sentence boundary analysis allows selection with correct michael@0: * interpretation of periods within numbers and abbreviations, and michael@0: * trailing punctuation marks such as quotation marks and parentheses. michael@0: *
michael@0: * Word boundary analysis is used by search and replace functions, as michael@0: * well as within text editing applications that allow the user to michael@0: * select words with a double click. Word selection provides correct michael@0: * interpretation of punctuation marks within and following michael@0: * words. Characters that are not part of a word, such as symbols or michael@0: * punctuation marks, have word-breaks on both sides. michael@0: *
michael@0: * Character boundary analysis allows users to interact with michael@0: * characters as they expect to, for example, when moving the cursor michael@0: * through a text string. Character boundary analysis provides correct michael@0: * navigation of through character strings, regardless of how the michael@0: * character is stored. For example, an accented character might be michael@0: * stored as a base character and a diacritical mark. What users michael@0: * consider to be a character can differ between languages. michael@0: *
michael@0: * The text boundary positions are found according to the rules michael@0: * described in Unicode Standard Annex #29, Text Boundaries, and michael@0: * Unicode Standard Annex #14, Line Breaking Properties. These michael@0: * are available at http://www.unicode.org/reports/tr14/ and michael@0: * http://www.unicode.org/reports/tr29/. michael@0: *
michael@0: * In addition to the C++ API defined in this header file, a michael@0: * plain C API with equivalent functionality is defined in the michael@0: * file ubrk.h michael@0: *
michael@0: * Code snippets illustrating the use of the Break Iterator APIs michael@0: * are available in the ICU User Guide, michael@0: * http://icu-project.org/userguide/boundaryAnalysis.html michael@0: * and in the sample program icu/source/samples/break/break.cpp michael@0: * michael@0: */ michael@0: class U_COMMON_API BreakIterator : public UObject { michael@0: public: michael@0: /** michael@0: * destructor michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual ~BreakIterator(); michael@0: michael@0: /** michael@0: * Return true if another object is semantically equal to this michael@0: * one. The other object should be an instance of the same subclass of michael@0: * BreakIterator. Objects of different subclasses are considered michael@0: * unequal. michael@0: *
michael@0: * Return true if this BreakIterator is at the same position in the michael@0: * same text, and is the same class and type (word, line, etc.) of michael@0: * BreakIterator, as the argument. Text is considered the same if michael@0: * it contains the same characters, it need not be the same michael@0: * object, and styles are not considered. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual UBool operator==(const BreakIterator&) const = 0; michael@0: michael@0: /** michael@0: * Returns the complement of the result of operator== michael@0: * @param rhs The BreakIterator to be compared for inequality michael@0: * @return the complement of the result of operator== michael@0: * @stable ICU 2.0 michael@0: */ michael@0: UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); } michael@0: michael@0: /** michael@0: * Return a polymorphic copy of this object. This is an abstract michael@0: * method which subclasses implement. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual BreakIterator* clone(void) const = 0; michael@0: michael@0: /** michael@0: * Return a polymorphic class ID for this object. Different subclasses michael@0: * will return distinct unequal values. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const = 0; michael@0: michael@0: /** michael@0: * Return a CharacterIterator over the text being analyzed. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual CharacterIterator& getText(void) const = 0; michael@0: michael@0: michael@0: /** michael@0: * Get a UText for the text being analyzed. michael@0: * The returned UText is a shallow clone of the UText used internally michael@0: * by the break iterator implementation. It can safely be used to michael@0: * access the text without impacting any break iterator operations, michael@0: * but the underlying text itself must not be altered. michael@0: * michael@0: * @param fillIn A UText to be filled in. If NULL, a new UText will be michael@0: * allocated to hold the result. michael@0: * @param status receives any error codes. michael@0: * @return The current UText for this break iterator. If an input michael@0: * UText was provided, it will always be returned. michael@0: * @stable ICU 3.4 michael@0: */ michael@0: virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0; michael@0: michael@0: /** michael@0: * Change the text over which this operates. The text boundary is michael@0: * reset to the start. michael@0: * @param text The UnicodeString used to change the text. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual void setText(const UnicodeString &text) = 0; michael@0: michael@0: /** michael@0: * Reset the break iterator to operate over the text represented by michael@0: * the UText. The iterator position is reset to the start. michael@0: * michael@0: * This function makes a shallow clone of the supplied UText. This means michael@0: * that the caller is free to immediately close or otherwise reuse the michael@0: * Utext that was passed as a parameter, but that the underlying text itself michael@0: * must not be altered while being referenced by the break iterator. michael@0: * michael@0: * All index positions returned by break iterator functions are michael@0: * native indices from the UText. For example, when breaking UTF-8 michael@0: * encoded text, the break positions returned by next(), previous(), etc. michael@0: * will be UTF-8 string indices, not UTF-16 positions. michael@0: * michael@0: * @param text The UText used to change the text. michael@0: * @param status receives any error codes. michael@0: * @stable ICU 3.4 michael@0: */ michael@0: virtual void setText(UText *text, UErrorCode &status) = 0; michael@0: michael@0: /** michael@0: * Change the text over which this operates. The text boundary is michael@0: * reset to the start. michael@0: * Note that setText(UText *) provides similar functionality to this function, michael@0: * and is more efficient. michael@0: * @param it The CharacterIterator used to change the text. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual void adoptText(CharacterIterator* it) = 0; michael@0: michael@0: enum { michael@0: /** michael@0: * DONE is returned by previous() and next() after all valid michael@0: * boundaries have been returned. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: DONE = (int32_t)-1 michael@0: }; michael@0: michael@0: /** michael@0: * Set the iterator position to the index of the first character in the text being scanned. michael@0: * @return The index of the first character in the text being scanned. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t first(void) = 0; michael@0: michael@0: /** michael@0: * Set the iterator position to the index immediately BEYOND the last character in the text being scanned. michael@0: * @return The index immediately BEYOND the last character in the text being scanned. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t last(void) = 0; michael@0: michael@0: /** michael@0: * Set the iterator position to the boundary preceding the current boundary. michael@0: * @return The character index of the previous text boundary or DONE if all michael@0: * boundaries have been returned. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t previous(void) = 0; michael@0: michael@0: /** michael@0: * Advance the iterator to the boundary following the current boundary. michael@0: * @return The character index of the next text boundary or DONE if all michael@0: * boundaries have been returned. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t next(void) = 0; michael@0: michael@0: /** michael@0: * Return character index of the current interator position within the text. michael@0: * @return The boundary most recently returned. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t current(void) const = 0; michael@0: michael@0: /** michael@0: * Advance the iterator to the first boundary following the specified offset. michael@0: * The value returned is always greater than the offset or michael@0: * the value BreakIterator.DONE michael@0: * @param offset the offset to begin scanning. michael@0: * @return The first boundary after the specified offset. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t following(int32_t offset) = 0; michael@0: michael@0: /** michael@0: * Set the iterator position to the first boundary preceding the specified offset. michael@0: * The value returned is always smaller than the offset or michael@0: * the value BreakIterator.DONE michael@0: * @param offset the offset to begin scanning. michael@0: * @return The first boundary before the specified offset. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t preceding(int32_t offset) = 0; michael@0: michael@0: /** michael@0: * Return true if the specfied position is a boundary position. michael@0: * As a side effect, the current position of the iterator is set michael@0: * to the first boundary position at or following the specified offset. michael@0: * @param offset the offset to check. michael@0: * @return True if "offset" is a boundary position. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual UBool isBoundary(int32_t offset) = 0; michael@0: michael@0: /** michael@0: * Set the iterator position to the nth boundary from the current boundary michael@0: * @param n the number of boundaries to move by. A value of 0 michael@0: * does nothing. Negative values move to previous boundaries michael@0: * and positive values move to later boundaries. michael@0: * @return The new iterator position, or michael@0: * DONE if there are fewer than |n| boundaries in the specfied direction. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual int32_t next(int32_t n) = 0; michael@0: michael@0: /** michael@0: * For RuleBasedBreakIterators, return the status tag from the michael@0: * break rule that determined the most recently michael@0: * returned break position. michael@0: *
michael@0: * For break iterator types that do not support a rule status, michael@0: * a default value of 0 is returned. michael@0: *
michael@0: * @return the status from the break rule that determined the most recently michael@0: * returned break position. michael@0: * @see RuleBaseBreakIterator::getRuleStatus() michael@0: * @see UWordBreak michael@0: * @draft ICU 52 michael@0: */ michael@0: virtual int32_t getRuleStatus() const; michael@0: michael@0: /** michael@0: * For RuleBasedBreakIterators, get the status (tag) values from the break rule(s) michael@0: * that determined the most recently returned break position. michael@0: *
michael@0: * For break iterator types that do not support rule status, michael@0: * no values are returned. michael@0: *
michael@0: * The returned status value(s) are stored into an array provided by the caller. michael@0: * The values are stored in sorted (ascending) order. michael@0: * If the capacity of the output array is insufficient to hold the data, michael@0: * the output will be truncated to the available length, and a michael@0: * U_BUFFER_OVERFLOW_ERROR will be signaled. michael@0: *
michael@0: * @see RuleBaseBreakIterator::getRuleStatusVec michael@0: * michael@0: * @param fillInVec an array to be filled in with the status values. michael@0: * @param capacity the length of the supplied vector. A length of zero causes michael@0: * the function to return the number of status values, in the michael@0: * normal way, without attemtping to store any values. michael@0: * @param status receives error codes. michael@0: * @return The number of rule status values from rules that determined michael@0: * the most recent boundary returned by the break iterator. michael@0: * In the event of a U_BUFFER_OVERFLOW_ERROR, the return value michael@0: * is the total number of status values that were available, michael@0: * not the reduced number that were actually returned. michael@0: * @see getRuleStatus michael@0: * @draft ICU 52 michael@0: */ michael@0: virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status); michael@0: michael@0: /** michael@0: * Create BreakIterator for word-breaks using the given locale. michael@0: * Returns an instance of a BreakIterator implementing word breaks. michael@0: * WordBreak is useful for word selection (ex. double click) michael@0: * @param where the locale. michael@0: * @param status the error code michael@0: * @return A BreakIterator for word-breaks. The UErrorCode& status michael@0: * parameter is used to return status information to the user. michael@0: * To check whether the construction succeeded or not, you should check michael@0: * the value of U_SUCCESS(err). If you wish more detailed information, you michael@0: * can check for informational error results which still indicate success. michael@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For michael@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was michael@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was michael@0: * used; neither the requested locale nor any of its fall back locales michael@0: * could be found. michael@0: * The caller owns the returned object and is responsible for deleting it. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static BreakIterator* U_EXPORT2 michael@0: createWordInstance(const Locale& where, UErrorCode& status); michael@0: michael@0: /** michael@0: * Create BreakIterator for line-breaks using specified locale. michael@0: * Returns an instance of a BreakIterator implementing line breaks. Line michael@0: * breaks are logically possible line breaks, actual line breaks are michael@0: * usually determined based on display width. michael@0: * LineBreak is useful for word wrapping text. michael@0: * @param where the locale. michael@0: * @param status The error code. michael@0: * @return A BreakIterator for line-breaks. The UErrorCode& status michael@0: * parameter is used to return status information to the user. michael@0: * To check whether the construction succeeded or not, you should check michael@0: * the value of U_SUCCESS(err). If you wish more detailed information, you michael@0: * can check for informational error results which still indicate success. michael@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For michael@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was michael@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was michael@0: * used; neither the requested locale nor any of its fall back locales michael@0: * could be found. michael@0: * The caller owns the returned object and is responsible for deleting it. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static BreakIterator* U_EXPORT2 michael@0: createLineInstance(const Locale& where, UErrorCode& status); michael@0: michael@0: /** michael@0: * Create BreakIterator for character-breaks using specified locale michael@0: * Returns an instance of a BreakIterator implementing character breaks. michael@0: * Character breaks are boundaries of combining character sequences. michael@0: * @param where the locale. michael@0: * @param status The error code. michael@0: * @return A BreakIterator for character-breaks. The UErrorCode& status michael@0: * parameter is used to return status information to the user. michael@0: * To check whether the construction succeeded or not, you should check michael@0: * the value of U_SUCCESS(err). If you wish more detailed information, you michael@0: * can check for informational error results which still indicate success. michael@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For michael@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was michael@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was michael@0: * used; neither the requested locale nor any of its fall back locales michael@0: * could be found. michael@0: * The caller owns the returned object and is responsible for deleting it. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static BreakIterator* U_EXPORT2 michael@0: createCharacterInstance(const Locale& where, UErrorCode& status); michael@0: michael@0: /** michael@0: * Create BreakIterator for sentence-breaks using specified locale michael@0: * Returns an instance of a BreakIterator implementing sentence breaks. michael@0: * @param where the locale. michael@0: * @param status The error code. michael@0: * @return A BreakIterator for sentence-breaks. The UErrorCode& status michael@0: * parameter is used to return status information to the user. michael@0: * To check whether the construction succeeded or not, you should check michael@0: * the value of U_SUCCESS(err). If you wish more detailed information, you michael@0: * can check for informational error results which still indicate success. michael@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For michael@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was michael@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was michael@0: * used; neither the requested locale nor any of its fall back locales michael@0: * could be found. michael@0: * The caller owns the returned object and is responsible for deleting it. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static BreakIterator* U_EXPORT2 michael@0: createSentenceInstance(const Locale& where, UErrorCode& status); michael@0: michael@0: /** michael@0: * Create BreakIterator for title-casing breaks using the specified locale michael@0: * Returns an instance of a BreakIterator implementing title breaks. michael@0: * The iterator returned locates title boundaries as described for michael@0: * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, michael@0: * please use Word Boundary iterator.{@link #createWordInstance } michael@0: * michael@0: * @param where the locale. michael@0: * @param status The error code. michael@0: * @return A BreakIterator for title-breaks. The UErrorCode& status michael@0: * parameter is used to return status information to the user. michael@0: * To check whether the construction succeeded or not, you should check michael@0: * the value of U_SUCCESS(err). If you wish more detailed information, you michael@0: * can check for informational error results which still indicate success. michael@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For michael@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was michael@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was michael@0: * used; neither the requested locale nor any of its fall back locales michael@0: * could be found. michael@0: * The caller owns the returned object and is responsible for deleting it. michael@0: * @stable ICU 2.1 michael@0: */ michael@0: static BreakIterator* U_EXPORT2 michael@0: createTitleInstance(const Locale& where, UErrorCode& status); michael@0: michael@0: /** michael@0: * Get the set of Locales for which TextBoundaries are installed. michael@0: *
Note: this will not return locales added through the register michael@0: * call. To see the registered locales too, use the getAvailableLocales michael@0: * function that returns a StringEnumeration object
michael@0: * @param count the output parameter of number of elements in the locale list michael@0: * @return available locales michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); michael@0: michael@0: /** michael@0: * Get name of the object for the desired Locale, in the desired langauge. michael@0: * @param objectLocale must be from getAvailableLocales. michael@0: * @param displayLocale specifies the desired locale for output. michael@0: * @param name the fill-in parameter of the return value michael@0: * Uses best match. michael@0: * @return user-displayable name michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, michael@0: const Locale& displayLocale, michael@0: UnicodeString& name); michael@0: michael@0: /** michael@0: * Get name of the object for the desired Locale, in the langauge of the michael@0: * default locale. michael@0: * @param objectLocale must be from getMatchingLocales michael@0: * @param name the fill-in parameter of the return value michael@0: * @return user-displayable name michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, michael@0: UnicodeString& name); michael@0: michael@0: /** michael@0: * Deprecated functionality. Use clone() instead. michael@0: * michael@0: * Thread safe client-buffer-based cloning operation michael@0: * Do NOT call delete on a safeclone, since 'new' is not used to create it. michael@0: * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. michael@0: * If buffer is not large enough, new memory will be allocated. michael@0: * @param BufferSize reference to size of allocated space. michael@0: * If BufferSize == 0, a sufficient size for use in cloning will michael@0: * be returned ('pre-flighting') michael@0: * If BufferSize is not enough for a stack-based safe clone, michael@0: * new memory will be allocated. michael@0: * @param status to indicate whether the operation went on smoothly or there were errors michael@0: * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were michael@0: * necessary. michael@0: * @return pointer to the new clone michael@0: * michael@0: * @deprecated ICU 52. Use clone() instead. michael@0: */ michael@0: virtual BreakIterator * createBufferClone(void *stackBuffer, michael@0: int32_t &BufferSize, michael@0: UErrorCode &status) = 0; michael@0: michael@0: #ifndef U_HIDE_DEPRECATED_API michael@0: michael@0: /** michael@0: * Determine whether the BreakIterator was created in user memory by michael@0: * createBufferClone(), and thus should not be deleted. Such objects michael@0: * must be closed by an explicit call to the destructor (not delete). michael@0: * @deprecated ICU 52. Always delete the BreakIterator. michael@0: */ michael@0: inline UBool isBufferClone(void); michael@0: michael@0: #endif /* U_HIDE_DEPRECATED_API */ michael@0: michael@0: #if !UCONFIG_NO_SERVICE michael@0: /** michael@0: * Register a new break iterator of the indicated kind, to use in the given locale. michael@0: * The break iterator will be adopted. Clones of the iterator will be returned michael@0: * if a request for a break iterator of the given kind matches or falls back to michael@0: * this locale. michael@0: * @param toAdopt the BreakIterator instance to be adopted michael@0: * @param locale the Locale for which this instance is to be registered michael@0: * @param kind the type of iterator for which this instance is to be registered michael@0: * @param status the in/out status code, no special meanings are assigned michael@0: * @return a registry key that can be used to unregister this instance michael@0: * @stable ICU 2.4 michael@0: */ michael@0: static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt, michael@0: const Locale& locale, michael@0: UBreakIteratorType kind, michael@0: UErrorCode& status); michael@0: michael@0: /** michael@0: * Unregister a previously-registered BreakIterator using the key returned from the michael@0: * register call. Key becomes invalid after a successful call and should not be used again. michael@0: * The BreakIterator corresponding to the key will be deleted. michael@0: * @param key the registry key returned by a previous call to registerInstance michael@0: * @param status the in/out status code, no special meanings are assigned michael@0: * @return TRUE if the iterator for the key was successfully unregistered michael@0: * @stable ICU 2.4 michael@0: */ michael@0: static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); michael@0: michael@0: /** michael@0: * Return a StringEnumeration over the locales available at the time of the call, michael@0: * including registered locales. michael@0: * @return a StringEnumeration over the locales available at the time of the call michael@0: * @stable ICU 2.4 michael@0: */ michael@0: static StringEnumeration* U_EXPORT2 getAvailableLocales(void); michael@0: #endif michael@0: michael@0: /** michael@0: * Returns the locale for this break iterator. Two flavors are available: valid and michael@0: * actual locale. michael@0: * @stable ICU 2.8 michael@0: */ michael@0: Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; michael@0: michael@0: #ifndef U_HIDE_INTERNAL_API michael@0: /** Get the locale for this break iterator object. You can choose between valid and actual locale. michael@0: * @param type type of the locale we're looking for (valid or actual) michael@0: * @param status error code for the operation michael@0: * @return the locale michael@0: * @internal michael@0: */ michael@0: const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const; michael@0: #endif /* U_HIDE_INTERNAL_API */ michael@0: michael@0: /** michael@0: * Set the subject text string upon which the break iterator is operating michael@0: * without changing any other aspect of the matching state. michael@0: * The new and previous text strings must have the same content. michael@0: * michael@0: * This function is intended for use in environments where ICU is operating on michael@0: * strings that may move around in memory. It provides a mechanism for notifying michael@0: * ICU that the string has been relocated, and providing a new UText to access the michael@0: * string in its new position. michael@0: * michael@0: * Note that the break iterator implementation never copies the underlying text michael@0: * of a string being processed, but always operates directly on the original text michael@0: * provided by the user. Refreshing simply drops the references to the old text michael@0: * and replaces them with references to the new. michael@0: * michael@0: * Caution: this function is normally used only by very specialized, michael@0: * system-level code. One example use case is with garbage collection that moves michael@0: * the text in memory. michael@0: * michael@0: * @param input The new (moved) text string. michael@0: * @param status Receives errors detected by this function. michael@0: * @return *this michael@0: * michael@0: * @stable ICU 49 michael@0: */ michael@0: virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0; michael@0: michael@0: private: michael@0: static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status); michael@0: static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status); michael@0: static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status); michael@0: michael@0: friend class ICUBreakIteratorFactory; michael@0: friend class ICUBreakIteratorService; michael@0: michael@0: protected: michael@0: // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API michael@0: // or else the compiler will create a public ones. michael@0: /** @internal */ michael@0: BreakIterator(); michael@0: /** @internal */ michael@0: BreakIterator (const BreakIterator &other) : UObject(other) {} michael@0: michael@0: private: michael@0: michael@0: /** @internal */ michael@0: char actualLocale[ULOC_FULLNAME_CAPACITY]; michael@0: char validLocale[ULOC_FULLNAME_CAPACITY]; michael@0: michael@0: /** michael@0: * The assignment operator has no real implementation. michael@0: * It's provided to make the compiler happy. Do not call. michael@0: */ michael@0: BreakIterator& operator=(const BreakIterator&); michael@0: }; michael@0: michael@0: #ifndef U_HIDE_DEPRECATED_API michael@0: michael@0: inline UBool BreakIterator::isBufferClone() michael@0: { michael@0: return FALSE; michael@0: } michael@0: michael@0: #endif /* U_HIDE_DEPRECATED_API */ michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ michael@0: michael@0: #endif // _BRKITER michael@0: //eof