sl@0: /* sl@0: ******************************************************************************** sl@0: * Copyright (C) 1997-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: ******************************************************************************** sl@0: * sl@0: * File brkiter.h sl@0: * sl@0: * Modification History: sl@0: * sl@0: * Date Name Description sl@0: * 02/18/97 aliu Added typedef for TextCount. Made DONE const. sl@0: * 05/07/97 aliu Fixed DLL declaration. sl@0: * 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK sl@0: * 08/11/98 helena Sync-up JDK1.2. sl@0: * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods. sl@0: ******************************************************************************** sl@0: */ sl@0: sl@0: #ifndef BRKITER_H sl@0: #define BRKITER_H sl@0: sl@0: #include "unicode/utypes.h" sl@0: sl@0: /** sl@0: * \file sl@0: * \brief C++ API: Break Iterator. sl@0: */ sl@0: sl@0: #if UCONFIG_NO_BREAK_ITERATION sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: /* sl@0: * Allow the declaration of APIs with pointers to BreakIterator sl@0: * even when break iteration is removed from the build. sl@0: */ sl@0: class BreakIterator; sl@0: sl@0: U_NAMESPACE_END sl@0: sl@0: #else sl@0: sl@0: #include "unicode/uobject.h" sl@0: #include "unicode/unistr.h" sl@0: #include "unicode/chariter.h" sl@0: #include "unicode/locid.h" sl@0: #include "unicode/ubrk.h" sl@0: #include "unicode/strenum.h" sl@0: #include "unicode/utext.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: #if !UCONFIG_NO_SERVICE sl@0: /** sl@0: * Opaque type returned by registerInstance. sl@0: * @stable sl@0: */ sl@0: typedef const void* URegistryKey; sl@0: #endif sl@0: sl@0: /** sl@0: * The BreakIterator class implements methods for finding the location sl@0: * of boundaries in text. BreakIterator is an abstract base class. sl@0: * Instances of BreakIterator maintain a current position and scan over sl@0: * text returning the index of characters where boundaries occur. sl@0: *

sl@0: * Line boundary analysis determines where a text string can be broken sl@0: * when line-wrapping. The mechanism correctly handles punctuation and sl@0: * hyphenated words. sl@0: *

sl@0: * Sentence boundary analysis allows selection with correct sl@0: * interpretation of periods within numbers and abbreviations, and sl@0: * trailing punctuation marks such as quotation marks and parentheses. sl@0: *

sl@0: * Word boundary analysis is used by search and replace functions, as sl@0: * well as within text editing applications that allow the user to sl@0: * select words with a double click. Word selection provides correct sl@0: * interpretation of punctuation marks within and following sl@0: * words. Characters that are not part of a word, such as symbols or sl@0: * punctuation marks, have word-breaks on both sides. sl@0: *

sl@0: * Character boundary analysis allows users to interact with sl@0: * characters as they expect to, for example, when moving the cursor sl@0: * through a text string. Character boundary analysis provides correct sl@0: * navigation of through character strings, regardless of how the sl@0: * character is stored. For example, an accented character might be sl@0: * stored as a base character and a diacritical mark. What users sl@0: * consider to be a character can differ between languages. sl@0: *

sl@0: * This is the interface for all text boundaries. sl@0: *

sl@0: * Examples: sl@0: *

sl@0: * Helper function to output text sl@0: *

sl@0:  * \code
sl@0:  *    void printTextRange( BreakIterator& iterator, int32_t start, int32_t end )
sl@0:  *    {
sl@0:  *        UnicodeString textBuffer, temp;
sl@0:  *        CharacterIterator *strIter = iterator.createText();
sl@0:  *        strIter->getText(temp);
sl@0:  *        cout << " " << start << " " << end << " |"
sl@0:  *             << temp.extractBetween(start, end, textBuffer)
sl@0:  *             << "|" << endl;
sl@0:  *        delete strIter;
sl@0:  *    }
sl@0:  * \endcode
sl@0:  * 
sl@0: * Print each element in order: sl@0: *
sl@0:  * \code
sl@0:  *    void printEachForward( BreakIterator& boundary)
sl@0:  *    {
sl@0:  *       int32_t start = boundary.first();
sl@0:  *       for (int32_t end = boundary.next();
sl@0:  *         end != BreakIterator::DONE;
sl@0:  *         start = end, end = boundary.next())
sl@0:  *         {
sl@0:  *             printTextRange( boundary, start, end );
sl@0:  *         }
sl@0:  *    }
sl@0:  * \endcode
sl@0:  * 
sl@0: * Print each element in reverse order: sl@0: *
sl@0:  * \code
sl@0:  *    void printEachBackward( BreakIterator& boundary)
sl@0:  *    {
sl@0:  *       int32_t end = boundary.last();
sl@0:  *       for (int32_t start = boundary.previous();
sl@0:  *         start != BreakIterator::DONE;
sl@0:  *         end = start, start = boundary.previous())
sl@0:  *         {
sl@0:  *             printTextRange( boundary, start, end );
sl@0:  *         }
sl@0:  *    }
sl@0:  * \endcode
sl@0:  * 
sl@0: * Print first element sl@0: *
sl@0:  * \code
sl@0:  *    void printFirst(BreakIterator& boundary)
sl@0:  *    {
sl@0:  *        int32_t start = boundary.first();
sl@0:  *        int32_t end = boundary.next();
sl@0:  *        printTextRange( boundary, start, end );
sl@0:  *    }
sl@0:  * \endcode
sl@0:  * 
sl@0: * Print last element sl@0: *
sl@0:  *  \code
sl@0:  *    void printLast(BreakIterator& boundary)
sl@0:  *    {
sl@0:  *        int32_t end = boundary.last();
sl@0:  *        int32_t start = boundary.previous();
sl@0:  *        printTextRange( boundary, start, end );
sl@0:  *    }
sl@0:  * \endcode
sl@0:  * 
sl@0: * Print the element at a specified position sl@0: *
sl@0:  * \code
sl@0:  *    void printAt(BreakIterator &boundary, int32_t pos )
sl@0:  *    {
sl@0:  *        int32_t end = boundary.following(pos);
sl@0:  *        int32_t start = boundary.previous();
sl@0:  *        printTextRange( boundary, start, end );
sl@0:  *    }
sl@0:  * \endcode
sl@0:  * 
sl@0: * Creating and using text boundaries sl@0: *
sl@0:  * \code
sl@0:  *       void BreakIterator_Example( void )
sl@0:  *       {
sl@0:  *           BreakIterator* boundary;
sl@0:  *           UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff.");
sl@0:  *           cout << "Examining: " << stringToExamine << endl;
sl@0:  *
sl@0:  *           //print each sentence in forward and reverse order
sl@0:  *           boundary = BreakIterator::createSentenceInstance( Locale::US );
sl@0:  *           boundary->setText(stringToExamine);
sl@0:  *           cout << "----- forward: -----------" << endl;
sl@0:  *           printEachForward(*boundary);
sl@0:  *           cout << "----- backward: ----------" << endl;
sl@0:  *           printEachBackward(*boundary);
sl@0:  *           delete boundary;
sl@0:  *
sl@0:  *           //print each word in order
sl@0:  *           boundary = BreakIterator::createWordInstance();
sl@0:  *           boundary->setText(stringToExamine);
sl@0:  *           cout << "----- forward: -----------" << endl;
sl@0:  *           printEachForward(*boundary);
sl@0:  *           //print first element
sl@0:  *           cout << "----- first: -------------" << endl;
sl@0:  *           printFirst(*boundary);
sl@0:  *           //print last element
sl@0:  *           cout << "----- last: --------------" << endl;
sl@0:  *           printLast(*boundary);
sl@0:  *           //print word at charpos 10
sl@0:  *           cout << "----- at pos 10: ---------" << endl;
sl@0:  *           printAt(*boundary, 10 );
sl@0:  *
sl@0:  *           delete boundary;
sl@0:  *       }
sl@0:  * \endcode
sl@0:  * 
sl@0: */ sl@0: class U_COMMON_API BreakIterator : public UObject { sl@0: public: sl@0: /** sl@0: * destructor sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual ~BreakIterator(); sl@0: sl@0: /** sl@0: * Return true if another object is semantically equal to this sl@0: * one. The other object should be an instance of the same subclass of sl@0: * BreakIterator. Objects of different subclasses are considered sl@0: * unequal. sl@0: *

sl@0: * Return true if this BreakIterator is at the same position in the sl@0: * same text, and is the same class and type (word, line, etc.) of sl@0: * BreakIterator, as the argument. Text is considered the same if sl@0: * it contains the same characters, it need not be the same sl@0: * object, and styles are not considered. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual UBool operator==(const BreakIterator&) const = 0; sl@0: sl@0: /** sl@0: * Returns the complement of the result of operator== sl@0: * @param rhs The BreakIterator to be compared for inequality sl@0: * @return the complement of the result of operator== sl@0: * @stable ICU 2.0 sl@0: */ sl@0: UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); } sl@0: sl@0: /** sl@0: * Return a polymorphic copy of this object. This is an abstract sl@0: * method which subclasses implement. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual BreakIterator* clone(void) const = 0; sl@0: sl@0: /** sl@0: * Return a polymorphic class ID for this object. Different subclasses sl@0: * will return distinct unequal values. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual UClassID getDynamicClassID(void) const = 0; sl@0: sl@0: /** sl@0: * Return a CharacterIterator over the text being analyzed. sl@0: * Changing the state of the returned iterator can have undefined consequences sl@0: * on the operation of the break iterator. If you need to change it, clone it first. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual const CharacterIterator& getText(void) const = 0; sl@0: sl@0: sl@0: /** sl@0: * Get a UText for the text being analyzed. sl@0: * The returned UText is a shallow clone of the UText used internally sl@0: * by the break iterator implementation. It can safely be used to sl@0: * access the text without impacting any break iterator operations, sl@0: * but the underlying text itself must not be altered. sl@0: * sl@0: * @param fillIn A UText to be filled in. If NULL, a new UText will be sl@0: * allocated to hold the result. sl@0: * @param status receives any error codes. sl@0: * @return The current UText for this break iterator. If an input sl@0: * UText was provided, it will always be returned. sl@0: * @draft ICU 3.4 sl@0: */ sl@0: virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0; sl@0: sl@0: /** sl@0: * Change the text over which this operates. The text boundary is sl@0: * reset to the start. sl@0: * @param text The UnicodeString used to change the text. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual void setText(const UnicodeString &text) = 0; sl@0: sl@0: /** sl@0: * Reset the break iterator to operate over the text represented by sl@0: * the UText. The iterator position is reset to the start. sl@0: * sl@0: * This function makes a shallow clone of the supplied UText. This means sl@0: * that the caller is free to immediately close or otherwise reuse the sl@0: * Utext that was passed as a parameter, but that the underlying text itself sl@0: * must not be altered while being referenced by the break iterator. sl@0: * sl@0: * @param text The UText used to change the text. sl@0: * @param status receives any error codes. sl@0: * @draft ICU 3.4 sl@0: */ sl@0: virtual void setText(UText *text, UErrorCode &status) = 0; sl@0: sl@0: /** sl@0: * Change the text over which this operates. The text boundary is sl@0: * reset to the start. sl@0: * @param it The CharacterIterator used to change the text. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual void adoptText(CharacterIterator* it) = 0; sl@0: sl@0: enum { sl@0: /** sl@0: * DONE is returned by previous() and next() after all valid sl@0: * boundaries have been returned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: DONE = (int32_t)-1 sl@0: }; sl@0: sl@0: /** sl@0: * Return the index of the first character in the text being scanned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t first(void) = 0; sl@0: sl@0: /** sl@0: * Return the index immediately BEYOND the last character in the text being scanned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t last(void) = 0; sl@0: sl@0: /** sl@0: * Return the boundary preceding the current boundary. sl@0: * @return The character index of the previous text boundary or DONE if all sl@0: * boundaries have been returned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t previous(void) = 0; sl@0: sl@0: /** sl@0: * Return the boundary following the current boundary. sl@0: * @return The character index of the next text boundary or DONE if all sl@0: * boundaries have been returned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t next(void) = 0; sl@0: sl@0: /** sl@0: * Return character index of the current interator position within the text. sl@0: * @return The boundary most recently returned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t current(void) const = 0; sl@0: sl@0: /** sl@0: * Return the first boundary following the specified offset. sl@0: * The value returned is always greater than the offset or sl@0: * the value BreakIterator.DONE sl@0: * @param offset the offset to begin scanning. sl@0: * @return The first boundary after the specified offset. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t following(int32_t offset) = 0; sl@0: sl@0: /** sl@0: * Return the first boundary preceding the specified offset. sl@0: * The value returned is always smaller than the offset or sl@0: * the value BreakIterator.DONE sl@0: * @param offset the offset to begin scanning. sl@0: * @return The first boundary before the specified offset. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t preceding(int32_t offset) = 0; sl@0: sl@0: /** sl@0: * Return true if the specfied position is a boundary position. sl@0: * As a side effect, the current position of the iterator is set sl@0: * to the first boundary position at or following the specified offset. sl@0: * @param offset the offset to check. sl@0: * @return True if "offset" is a boundary position. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual UBool isBoundary(int32_t offset) = 0; sl@0: sl@0: /** sl@0: * Return the nth boundary from the current boundary sl@0: * @param n which boundary to return. A value of 0 sl@0: * does nothing. Negative values move to previous boundaries sl@0: * and positive values move to later boundaries. sl@0: * @return The index of the nth boundary from the current position, or sl@0: * DONE if there are fewer than |n| boundaries in the specfied direction. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual int32_t next(int32_t n) = 0; sl@0: sl@0: /** sl@0: * Create BreakIterator for word-breaks using the given locale. sl@0: * Returns an instance of a BreakIterator implementing word breaks. sl@0: * WordBreak is useful for word selection (ex. double click) sl@0: * @param where the locale. sl@0: * @param status the error code sl@0: * @return A BreakIterator for word-breaks. The UErrorCode& status sl@0: * parameter is used to return status information to the user. sl@0: * To check whether the construction succeeded or not, you should check sl@0: * the value of U_SUCCESS(err). If you wish more detailed information, you sl@0: * can check for informational error results which still indicate success. sl@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For sl@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was sl@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was sl@0: * used; neither the requested locale nor any of its fall back locales sl@0: * could be found. sl@0: * The caller owns the returned object and is responsible for deleting it. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: static BreakIterator* U_EXPORT2 sl@0: createWordInstance(const Locale& where, UErrorCode& status); sl@0: sl@0: /** sl@0: * Create BreakIterator for line-breaks using specified locale. sl@0: * Returns an instance of a BreakIterator implementing line breaks. Line sl@0: * breaks are logically possible line breaks, actual line breaks are sl@0: * usually determined based on display width. sl@0: * LineBreak is useful for word wrapping text. sl@0: * @param where the locale. sl@0: * @param status The error code. sl@0: * @return A BreakIterator for line-breaks. The UErrorCode& status sl@0: * parameter is used to return status information to the user. sl@0: * To check whether the construction succeeded or not, you should check sl@0: * the value of U_SUCCESS(err). If you wish more detailed information, you sl@0: * can check for informational error results which still indicate success. sl@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For sl@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was sl@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was sl@0: * used; neither the requested locale nor any of its fall back locales sl@0: * could be found. sl@0: * The caller owns the returned object and is responsible for deleting it. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: static BreakIterator* U_EXPORT2 sl@0: createLineInstance(const Locale& where, UErrorCode& status); sl@0: sl@0: /** sl@0: * Create BreakIterator for character-breaks using specified locale sl@0: * Returns an instance of a BreakIterator implementing character breaks. sl@0: * Character breaks are boundaries of combining character sequences. sl@0: * @param where the locale. sl@0: * @param status The error code. sl@0: * @return A BreakIterator for character-breaks. The UErrorCode& status sl@0: * parameter is used to return status information to the user. sl@0: * To check whether the construction succeeded or not, you should check sl@0: * the value of U_SUCCESS(err). If you wish more detailed information, you sl@0: * can check for informational error results which still indicate success. sl@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For sl@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was sl@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was sl@0: * used; neither the requested locale nor any of its fall back locales sl@0: * could be found. sl@0: * The caller owns the returned object and is responsible for deleting it. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: static BreakIterator* U_EXPORT2 sl@0: createCharacterInstance(const Locale& where, UErrorCode& status); sl@0: sl@0: /** sl@0: * Create BreakIterator for sentence-breaks using specified locale sl@0: * Returns an instance of a BreakIterator implementing sentence breaks. sl@0: * @param where the locale. sl@0: * @param status The error code. sl@0: * @return A BreakIterator for sentence-breaks. The UErrorCode& status sl@0: * parameter is used to return status information to the user. sl@0: * To check whether the construction succeeded or not, you should check sl@0: * the value of U_SUCCESS(err). If you wish more detailed information, you sl@0: * can check for informational error results which still indicate success. sl@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For sl@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was sl@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was sl@0: * used; neither the requested locale nor any of its fall back locales sl@0: * could be found. sl@0: * The caller owns the returned object and is responsible for deleting it. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: static BreakIterator* U_EXPORT2 sl@0: createSentenceInstance(const Locale& where, UErrorCode& status); sl@0: sl@0: /** sl@0: * Create BreakIterator for title-casing breaks using the specified locale sl@0: * Returns an instance of a BreakIterator implementing title breaks. sl@0: * The iterator returned locates title boundaries as described for sl@0: * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, sl@0: * please use Word Boundary iterator.{@link #createWordInstance } sl@0: * sl@0: * @param where the locale. sl@0: * @param status The error code. sl@0: * @return A BreakIterator for title-breaks. The UErrorCode& status sl@0: * parameter is used to return status information to the user. sl@0: * To check whether the construction succeeded or not, you should check sl@0: * the value of U_SUCCESS(err). If you wish more detailed information, you sl@0: * can check for informational error results which still indicate success. sl@0: * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For sl@0: * example, 'de_CH' was requested, but nothing was found there, so 'de' was sl@0: * used. U_USING_DEFAULT_WARNING indicates that the default locale data was sl@0: * used; neither the requested locale nor any of its fall back locales sl@0: * could be found. sl@0: * The caller owns the returned object and is responsible for deleting it. sl@0: * @stable ICU 2.1 sl@0: */ sl@0: static BreakIterator* U_EXPORT2 sl@0: createTitleInstance(const Locale& where, UErrorCode& status); sl@0: sl@0: /** sl@0: * Get the set of Locales for which TextBoundaries are installed. sl@0: *

Note: this will not return locales added through the register sl@0: * call. To see the registered locales too, use the getAvailableLocales sl@0: * function that returns a StringEnumeration object

sl@0: * @param count the output parameter of number of elements in the locale list sl@0: * @return available locales sl@0: * @stable ICU 2.0 sl@0: */ sl@0: static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); sl@0: sl@0: /** sl@0: * Get name of the object for the desired Locale, in the desired langauge. sl@0: * @param objectLocale must be from getAvailableLocales. sl@0: * @param displayLocale specifies the desired locale for output. sl@0: * @param name the fill-in parameter of the return value sl@0: * Uses best match. sl@0: * @return user-displayable name sl@0: * @stable ICU 2.0 sl@0: */ sl@0: static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, sl@0: const Locale& displayLocale, sl@0: UnicodeString& name); sl@0: sl@0: /** sl@0: * Get name of the object for the desired Locale, in the langauge of the sl@0: * default locale. sl@0: * @param objectLocale must be from getMatchingLocales sl@0: * @param name the fill-in parameter of the return value sl@0: * @return user-displayable name sl@0: * @stable ICU 2.0 sl@0: */ sl@0: static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, sl@0: UnicodeString& name); sl@0: sl@0: /** sl@0: * Thread safe client-buffer-based cloning operation sl@0: * Do NOT call delete on a safeclone, since 'new' is not used to create it. sl@0: * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. sl@0: * If buffer is not large enough, new memory will be allocated. sl@0: * @param BufferSize reference to size of allocated space. sl@0: * If BufferSize == 0, a sufficient size for use in cloning will sl@0: * be returned ('pre-flighting') sl@0: * If BufferSize is not enough for a stack-based safe clone, sl@0: * new memory will be allocated. sl@0: * @param status to indicate whether the operation went on smoothly or there were errors sl@0: * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were sl@0: * necessary. sl@0: * @return pointer to the new clone sl@0: * sl@0: * @stable ICU 2.0 sl@0: */ sl@0: virtual BreakIterator * createBufferClone(void *stackBuffer, sl@0: int32_t &BufferSize, sl@0: UErrorCode &status) = 0; sl@0: sl@0: /** sl@0: * Determine whether the BreakIterator was created in user memory by sl@0: * createBufferClone(), and thus should not be deleted. Such objects sl@0: * must be closed by an explicit call to the destructor (not delete). sl@0: * @stable ICU 2.0 sl@0: */ sl@0: inline UBool isBufferClone(void); sl@0: sl@0: #if !UCONFIG_NO_SERVICE sl@0: /** sl@0: * Register a new break iterator of the indicated kind, to use in the given locale. sl@0: * The break iterator will be adopted. Clones of the iterator will be returned sl@0: * if a request for a break iterator of the given kind matches or falls back to sl@0: * this locale. sl@0: * @param toAdopt the BreakIterator instance to be adopted sl@0: * @param locale the Locale for which this instance is to be registered sl@0: * @param kind the type of iterator for which this instance is to be registered sl@0: * @param status the in/out status code, no special meanings are assigned sl@0: * @return a registry key that can be used to unregister this instance sl@0: * @stable ICU 2.4 sl@0: */ sl@0: static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt, sl@0: const Locale& locale, sl@0: UBreakIteratorType kind, sl@0: UErrorCode& status); sl@0: sl@0: /** sl@0: * Unregister a previously-registered BreakIterator using the key returned from the sl@0: * register call. Key becomes invalid after a successful call and should not be used again. sl@0: * The BreakIterator corresponding to the key will be deleted. sl@0: * @param key the registry key returned by a previous call to registerInstance sl@0: * @param status the in/out status code, no special meanings are assigned sl@0: * @return TRUE if the iterator for the key was successfully unregistered sl@0: * @stable ICU 2.4 sl@0: */ sl@0: static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); sl@0: sl@0: /** sl@0: * Return a StringEnumeration over the locales available at the time of the call, sl@0: * including registered locales. sl@0: * @return a StringEnumeration over the locales available at the time of the call sl@0: * @stable ICU 2.4 sl@0: */ sl@0: static StringEnumeration* U_EXPORT2 getAvailableLocales(void); sl@0: #endif sl@0: sl@0: /** sl@0: * Returns the locale for this break iterator. Two flavors are available: valid and sl@0: * actual locale. sl@0: * @draft ICU 2.8 likely to change after ICU 3.0, based on feedback sl@0: */ sl@0: Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; sl@0: sl@0: /** Get the locale for this break iterator object. You can choose between valid and actual locale. sl@0: * @param type type of the locale we're looking for (valid or actual) sl@0: * @param status error code for the operation sl@0: * @return the locale sl@0: * @internal sl@0: */ sl@0: const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const; sl@0: sl@0: private: sl@0: static BreakIterator* buildInstance(const Locale& loc, const char *type, UBool dict, UErrorCode& status); sl@0: static BreakIterator* createInstance(const Locale& loc, UBreakIteratorType kind, UErrorCode& status); sl@0: static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status); sl@0: sl@0: friend class ICUBreakIteratorFactory; sl@0: friend class ICUBreakIteratorService; sl@0: sl@0: protected: sl@0: /** @internal */ sl@0: BreakIterator(); sl@0: /** @internal */ sl@0: UBool fBufferClone; sl@0: /** @internal */ sl@0: BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {} sl@0: sl@0: private: sl@0: sl@0: /** @internal */ sl@0: char actualLocale[ULOC_FULLNAME_CAPACITY]; sl@0: char validLocale[ULOC_FULLNAME_CAPACITY]; sl@0: sl@0: /** sl@0: * The assignment operator has no real implementation. sl@0: * It's provided to make the compiler happy. Do not call. sl@0: */ sl@0: BreakIterator& operator=(const BreakIterator&); sl@0: }; sl@0: sl@0: inline UBool BreakIterator::isBufferClone() sl@0: { sl@0: return fBufferClone; sl@0: } sl@0: sl@0: U_NAMESPACE_END sl@0: sl@0: #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ sl@0: sl@0: #endif // _BRKITER sl@0: //eof sl@0: