1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************** 5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 1997-2016, International Business Machines 6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************** 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker * File brkiter.h 10*0e209d39SAndroid Build Coastguard Worker * 11*0e209d39SAndroid Build Coastguard Worker * Modification History: 12*0e209d39SAndroid Build Coastguard Worker * 13*0e209d39SAndroid Build Coastguard Worker * Date Name Description 14*0e209d39SAndroid Build Coastguard Worker * 02/18/97 aliu Added typedef for TextCount. Made DONE const. 15*0e209d39SAndroid Build Coastguard Worker * 05/07/97 aliu Fixed DLL declaration. 16*0e209d39SAndroid Build Coastguard Worker * 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK 17*0e209d39SAndroid Build Coastguard Worker * 08/11/98 helena Sync-up JDK1.2. 18*0e209d39SAndroid Build Coastguard Worker * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods. 19*0e209d39SAndroid Build Coastguard Worker ******************************************************************************** 20*0e209d39SAndroid Build Coastguard Worker */ 21*0e209d39SAndroid Build Coastguard Worker 22*0e209d39SAndroid Build Coastguard Worker #ifndef BRKITER_H 23*0e209d39SAndroid Build Coastguard Worker #define BRKITER_H 24*0e209d39SAndroid Build Coastguard Worker 25*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 26*0e209d39SAndroid Build Coastguard Worker 27*0e209d39SAndroid Build Coastguard Worker /** 28*0e209d39SAndroid Build Coastguard Worker * \file 29*0e209d39SAndroid Build Coastguard Worker * \brief C++ API: Break Iterator. 30*0e209d39SAndroid Build Coastguard Worker */ 31*0e209d39SAndroid Build Coastguard Worker 32*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 33*0e209d39SAndroid Build Coastguard Worker 34*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 35*0e209d39SAndroid Build Coastguard Worker 36*0e209d39SAndroid Build Coastguard Worker #if UCONFIG_NO_BREAK_ITERATION 37*0e209d39SAndroid Build Coastguard Worker 38*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 39*0e209d39SAndroid Build Coastguard Worker 40*0e209d39SAndroid Build Coastguard Worker /* 41*0e209d39SAndroid Build Coastguard Worker * Allow the declaration of APIs with pointers to BreakIterator 42*0e209d39SAndroid Build Coastguard Worker * even when break iteration is removed from the build. 43*0e209d39SAndroid Build Coastguard Worker */ 44*0e209d39SAndroid Build Coastguard Worker class BreakIterator; 45*0e209d39SAndroid Build Coastguard Worker 46*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 47*0e209d39SAndroid Build Coastguard Worker 48*0e209d39SAndroid Build Coastguard Worker #else 49*0e209d39SAndroid Build Coastguard Worker 50*0e209d39SAndroid Build Coastguard Worker #include "unicode/uobject.h" 51*0e209d39SAndroid Build Coastguard Worker #include "unicode/unistr.h" 52*0e209d39SAndroid Build Coastguard Worker #include "unicode/chariter.h" 53*0e209d39SAndroid Build Coastguard Worker #include "unicode/locid.h" 54*0e209d39SAndroid Build Coastguard Worker #include "unicode/ubrk.h" 55*0e209d39SAndroid Build Coastguard Worker #include "unicode/strenum.h" 56*0e209d39SAndroid Build Coastguard Worker #include "unicode/utext.h" 57*0e209d39SAndroid Build Coastguard Worker #include "unicode/umisc.h" 58*0e209d39SAndroid Build Coastguard Worker 59*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 60*0e209d39SAndroid Build Coastguard Worker 61*0e209d39SAndroid Build Coastguard Worker /** 62*0e209d39SAndroid Build Coastguard Worker * The BreakIterator class implements methods for finding the location 63*0e209d39SAndroid Build Coastguard Worker * of boundaries in text. BreakIterator is an abstract base class. 64*0e209d39SAndroid Build Coastguard Worker * Instances of BreakIterator maintain a current position and scan over 65*0e209d39SAndroid Build Coastguard Worker * text returning the index of characters where boundaries occur. 66*0e209d39SAndroid Build Coastguard Worker * <p> 67*0e209d39SAndroid Build Coastguard Worker * Line boundary analysis determines where a text string can be broken 68*0e209d39SAndroid Build Coastguard Worker * when line-wrapping. The mechanism correctly handles punctuation and 69*0e209d39SAndroid Build Coastguard Worker * hyphenated words. 70*0e209d39SAndroid Build Coastguard Worker * <p> 71*0e209d39SAndroid Build Coastguard Worker * Sentence boundary analysis allows selection with correct 72*0e209d39SAndroid Build Coastguard Worker * interpretation of periods within numbers and abbreviations, and 73*0e209d39SAndroid Build Coastguard Worker * trailing punctuation marks such as quotation marks and parentheses. 74*0e209d39SAndroid Build Coastguard Worker * <p> 75*0e209d39SAndroid Build Coastguard Worker * Word boundary analysis is used by search and replace functions, as 76*0e209d39SAndroid Build Coastguard Worker * well as within text editing applications that allow the user to 77*0e209d39SAndroid Build Coastguard Worker * select words with a double click. Word selection provides correct 78*0e209d39SAndroid Build Coastguard Worker * interpretation of punctuation marks within and following 79*0e209d39SAndroid Build Coastguard Worker * words. Characters that are not part of a word, such as symbols or 80*0e209d39SAndroid Build Coastguard Worker * punctuation marks, have word-breaks on both sides. 81*0e209d39SAndroid Build Coastguard Worker * <p> 82*0e209d39SAndroid Build Coastguard Worker * Character boundary analysis allows users to interact with 83*0e209d39SAndroid Build Coastguard Worker * characters as they expect to, for example, when moving the cursor 84*0e209d39SAndroid Build Coastguard Worker * through a text string. Character boundary analysis provides correct 85*0e209d39SAndroid Build Coastguard Worker * navigation of through character strings, regardless of how the 86*0e209d39SAndroid Build Coastguard Worker * character is stored. For example, an accented character might be 87*0e209d39SAndroid Build Coastguard Worker * stored as a base character and a diacritical mark. What users 88*0e209d39SAndroid Build Coastguard Worker * consider to be a character can differ between languages. 89*0e209d39SAndroid Build Coastguard Worker * <p> 90*0e209d39SAndroid Build Coastguard Worker * The text boundary positions are found according to the rules 91*0e209d39SAndroid Build Coastguard Worker * described in Unicode Standard Annex #29, Text Boundaries, and 92*0e209d39SAndroid Build Coastguard Worker * Unicode Standard Annex #14, Line Breaking Properties. These 93*0e209d39SAndroid Build Coastguard Worker * are available at http://www.unicode.org/reports/tr14/ and 94*0e209d39SAndroid Build Coastguard Worker * http://www.unicode.org/reports/tr29/. 95*0e209d39SAndroid Build Coastguard Worker * <p> 96*0e209d39SAndroid Build Coastguard Worker * In addition to the C++ API defined in this header file, a 97*0e209d39SAndroid Build Coastguard Worker * plain C API with equivalent functionality is defined in the 98*0e209d39SAndroid Build Coastguard Worker * file ubrk.h 99*0e209d39SAndroid Build Coastguard Worker * <p> 100*0e209d39SAndroid Build Coastguard Worker * Code snippets illustrating the use of the Break Iterator APIs 101*0e209d39SAndroid Build Coastguard Worker * are available in the ICU User Guide, 102*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/icu/userguide/boundaryanalysis/ 103*0e209d39SAndroid Build Coastguard Worker * and in the sample program icu/source/samples/break/break.cpp 104*0e209d39SAndroid Build Coastguard Worker * 105*0e209d39SAndroid Build Coastguard Worker */ 106*0e209d39SAndroid Build Coastguard Worker class U_COMMON_API BreakIterator : public UObject { 107*0e209d39SAndroid Build Coastguard Worker public: 108*0e209d39SAndroid Build Coastguard Worker /** 109*0e209d39SAndroid Build Coastguard Worker * destructor 110*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 111*0e209d39SAndroid Build Coastguard Worker */ 112*0e209d39SAndroid Build Coastguard Worker virtual ~BreakIterator(); 113*0e209d39SAndroid Build Coastguard Worker 114*0e209d39SAndroid Build Coastguard Worker /** 115*0e209d39SAndroid Build Coastguard Worker * Return true if another object is semantically equal to this 116*0e209d39SAndroid Build Coastguard Worker * one. The other object should be an instance of the same subclass of 117*0e209d39SAndroid Build Coastguard Worker * BreakIterator. Objects of different subclasses are considered 118*0e209d39SAndroid Build Coastguard Worker * unequal. 119*0e209d39SAndroid Build Coastguard Worker * <P> 120*0e209d39SAndroid Build Coastguard Worker * Return true if this BreakIterator is at the same position in the 121*0e209d39SAndroid Build Coastguard Worker * same text, and is the same class and type (word, line, etc.) of 122*0e209d39SAndroid Build Coastguard Worker * BreakIterator, as the argument. Text is considered the same if 123*0e209d39SAndroid Build Coastguard Worker * it contains the same characters, it need not be the same 124*0e209d39SAndroid Build Coastguard Worker * object, and styles are not considered. 125*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 126*0e209d39SAndroid Build Coastguard Worker */ 127*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const BreakIterator&) const = 0; 128*0e209d39SAndroid Build Coastguard Worker 129*0e209d39SAndroid Build Coastguard Worker /** 130*0e209d39SAndroid Build Coastguard Worker * Returns the complement of the result of operator== 131*0e209d39SAndroid Build Coastguard Worker * @param rhs The BreakIterator to be compared for inequality 132*0e209d39SAndroid Build Coastguard Worker * @return the complement of the result of operator== 133*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 134*0e209d39SAndroid Build Coastguard Worker */ 135*0e209d39SAndroid Build Coastguard Worker bool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); } 136*0e209d39SAndroid Build Coastguard Worker 137*0e209d39SAndroid Build Coastguard Worker /** 138*0e209d39SAndroid Build Coastguard Worker * Return a polymorphic copy of this object. This is an abstract 139*0e209d39SAndroid Build Coastguard Worker * method which subclasses implement. 140*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 141*0e209d39SAndroid Build Coastguard Worker */ 142*0e209d39SAndroid Build Coastguard Worker virtual BreakIterator* clone() const = 0; 143*0e209d39SAndroid Build Coastguard Worker 144*0e209d39SAndroid Build Coastguard Worker /** 145*0e209d39SAndroid Build Coastguard Worker * Return a polymorphic class ID for this object. Different subclasses 146*0e209d39SAndroid Build Coastguard Worker * will return distinct unequal values. 147*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 148*0e209d39SAndroid Build Coastguard Worker */ 149*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override = 0; 150*0e209d39SAndroid Build Coastguard Worker 151*0e209d39SAndroid Build Coastguard Worker /** 152*0e209d39SAndroid Build Coastguard Worker * Return a CharacterIterator over the text being analyzed. 153*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 154*0e209d39SAndroid Build Coastguard Worker */ 155*0e209d39SAndroid Build Coastguard Worker virtual CharacterIterator& getText() const = 0; 156*0e209d39SAndroid Build Coastguard Worker 157*0e209d39SAndroid Build Coastguard Worker /** 158*0e209d39SAndroid Build Coastguard Worker * Get a UText for the text being analyzed. 159*0e209d39SAndroid Build Coastguard Worker * The returned UText is a shallow clone of the UText used internally 160*0e209d39SAndroid Build Coastguard Worker * by the break iterator implementation. It can safely be used to 161*0e209d39SAndroid Build Coastguard Worker * access the text without impacting any break iterator operations, 162*0e209d39SAndroid Build Coastguard Worker * but the underlying text itself must not be altered. 163*0e209d39SAndroid Build Coastguard Worker * 164*0e209d39SAndroid Build Coastguard Worker * @param fillIn A UText to be filled in. If nullptr, a new UText will be 165*0e209d39SAndroid Build Coastguard Worker * allocated to hold the result. 166*0e209d39SAndroid Build Coastguard Worker * @param status receives any error codes. 167*0e209d39SAndroid Build Coastguard Worker * @return The current UText for this break iterator. If an input 168*0e209d39SAndroid Build Coastguard Worker * UText was provided, it will always be returned. 169*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 170*0e209d39SAndroid Build Coastguard Worker */ 171*0e209d39SAndroid Build Coastguard Worker virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0; 172*0e209d39SAndroid Build Coastguard Worker 173*0e209d39SAndroid Build Coastguard Worker /** 174*0e209d39SAndroid Build Coastguard Worker * Change the text over which this operates. The text boundary is 175*0e209d39SAndroid Build Coastguard Worker * reset to the start. 176*0e209d39SAndroid Build Coastguard Worker * 177*0e209d39SAndroid Build Coastguard Worker * The BreakIterator will retain a reference to the supplied string. 178*0e209d39SAndroid Build Coastguard Worker * The caller must not modify or delete the text while the BreakIterator 179*0e209d39SAndroid Build Coastguard Worker * retains the reference. 180*0e209d39SAndroid Build Coastguard Worker * 181*0e209d39SAndroid Build Coastguard Worker * @param text The UnicodeString used to change the text. 182*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 183*0e209d39SAndroid Build Coastguard Worker */ 184*0e209d39SAndroid Build Coastguard Worker virtual void setText(const UnicodeString &text) = 0; 185*0e209d39SAndroid Build Coastguard Worker 186*0e209d39SAndroid Build Coastguard Worker /** 187*0e209d39SAndroid Build Coastguard Worker * Reset the break iterator to operate over the text represented by 188*0e209d39SAndroid Build Coastguard Worker * the UText. The iterator position is reset to the start. 189*0e209d39SAndroid Build Coastguard Worker * 190*0e209d39SAndroid Build Coastguard Worker * This function makes a shallow clone of the supplied UText. This means 191*0e209d39SAndroid Build Coastguard Worker * that the caller is free to immediately close or otherwise reuse the 192*0e209d39SAndroid Build Coastguard Worker * Utext that was passed as a parameter, but that the underlying text itself 193*0e209d39SAndroid Build Coastguard Worker * must not be altered while being referenced by the break iterator. 194*0e209d39SAndroid Build Coastguard Worker * 195*0e209d39SAndroid Build Coastguard Worker * All index positions returned by break iterator functions are 196*0e209d39SAndroid Build Coastguard Worker * native indices from the UText. For example, when breaking UTF-8 197*0e209d39SAndroid Build Coastguard Worker * encoded text, the break positions returned by next(), previous(), etc. 198*0e209d39SAndroid Build Coastguard Worker * will be UTF-8 string indices, not UTF-16 positions. 199*0e209d39SAndroid Build Coastguard Worker * 200*0e209d39SAndroid Build Coastguard Worker * @param text The UText used to change the text. 201*0e209d39SAndroid Build Coastguard Worker * @param status receives any error codes. 202*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 203*0e209d39SAndroid Build Coastguard Worker */ 204*0e209d39SAndroid Build Coastguard Worker virtual void setText(UText *text, UErrorCode &status) = 0; 205*0e209d39SAndroid Build Coastguard Worker 206*0e209d39SAndroid Build Coastguard Worker /** 207*0e209d39SAndroid Build Coastguard Worker * Change the text over which this operates. The text boundary is 208*0e209d39SAndroid Build Coastguard Worker * reset to the start. 209*0e209d39SAndroid Build Coastguard Worker * Note that setText(UText *) provides similar functionality to this function, 210*0e209d39SAndroid Build Coastguard Worker * and is more efficient. 211*0e209d39SAndroid Build Coastguard Worker * @param it The CharacterIterator used to change the text. 212*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 213*0e209d39SAndroid Build Coastguard Worker */ 214*0e209d39SAndroid Build Coastguard Worker virtual void adoptText(CharacterIterator* it) = 0; 215*0e209d39SAndroid Build Coastguard Worker 216*0e209d39SAndroid Build Coastguard Worker enum { 217*0e209d39SAndroid Build Coastguard Worker /** 218*0e209d39SAndroid Build Coastguard Worker * DONE is returned by previous() and next() after all valid 219*0e209d39SAndroid Build Coastguard Worker * boundaries have been returned. 220*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 221*0e209d39SAndroid Build Coastguard Worker */ 222*0e209d39SAndroid Build Coastguard Worker DONE = (int32_t)-1 223*0e209d39SAndroid Build Coastguard Worker }; 224*0e209d39SAndroid Build Coastguard Worker 225*0e209d39SAndroid Build Coastguard Worker /** 226*0e209d39SAndroid Build Coastguard Worker * Sets the current iteration position to the beginning of the text, position zero. 227*0e209d39SAndroid Build Coastguard Worker * @return The offset of the beginning of the text, zero. 228*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 229*0e209d39SAndroid Build Coastguard Worker */ 230*0e209d39SAndroid Build Coastguard Worker virtual int32_t first() = 0; 231*0e209d39SAndroid Build Coastguard Worker 232*0e209d39SAndroid Build Coastguard Worker /** 233*0e209d39SAndroid Build Coastguard Worker * Set the iterator position to the index immediately BEYOND the last character in the text being scanned. 234*0e209d39SAndroid Build Coastguard Worker * @return The index immediately BEYOND the last character in the text being scanned. 235*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 236*0e209d39SAndroid Build Coastguard Worker */ 237*0e209d39SAndroid Build Coastguard Worker virtual int32_t last() = 0; 238*0e209d39SAndroid Build Coastguard Worker 239*0e209d39SAndroid Build Coastguard Worker /** 240*0e209d39SAndroid Build Coastguard Worker * Set the iterator position to the boundary preceding the current boundary. 241*0e209d39SAndroid Build Coastguard Worker * @return The character index of the previous text boundary or DONE if all 242*0e209d39SAndroid Build Coastguard Worker * boundaries have been returned. 243*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 244*0e209d39SAndroid Build Coastguard Worker */ 245*0e209d39SAndroid Build Coastguard Worker virtual int32_t previous() = 0; 246*0e209d39SAndroid Build Coastguard Worker 247*0e209d39SAndroid Build Coastguard Worker /** 248*0e209d39SAndroid Build Coastguard Worker * Advance the iterator to the boundary following the current boundary. 249*0e209d39SAndroid Build Coastguard Worker * @return The character index of the next text boundary or DONE if all 250*0e209d39SAndroid Build Coastguard Worker * boundaries have been returned. 251*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 252*0e209d39SAndroid Build Coastguard Worker */ 253*0e209d39SAndroid Build Coastguard Worker virtual int32_t next() = 0; 254*0e209d39SAndroid Build Coastguard Worker 255*0e209d39SAndroid Build Coastguard Worker /** 256*0e209d39SAndroid Build Coastguard Worker * Return character index of the current iterator position within the text. 257*0e209d39SAndroid Build Coastguard Worker * @return The boundary most recently returned. 258*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 259*0e209d39SAndroid Build Coastguard Worker */ 260*0e209d39SAndroid Build Coastguard Worker virtual int32_t current() const = 0; 261*0e209d39SAndroid Build Coastguard Worker 262*0e209d39SAndroid Build Coastguard Worker /** 263*0e209d39SAndroid Build Coastguard Worker * Advance the iterator to the first boundary following the specified offset. 264*0e209d39SAndroid Build Coastguard Worker * The value returned is always greater than the offset or 265*0e209d39SAndroid Build Coastguard Worker * the value BreakIterator.DONE 266*0e209d39SAndroid Build Coastguard Worker * @param offset the offset to begin scanning. 267*0e209d39SAndroid Build Coastguard Worker * @return The first boundary after the specified offset. 268*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 269*0e209d39SAndroid Build Coastguard Worker */ 270*0e209d39SAndroid Build Coastguard Worker virtual int32_t following(int32_t offset) = 0; 271*0e209d39SAndroid Build Coastguard Worker 272*0e209d39SAndroid Build Coastguard Worker /** 273*0e209d39SAndroid Build Coastguard Worker * Set the iterator position to the first boundary preceding the specified offset. 274*0e209d39SAndroid Build Coastguard Worker * The value returned is always smaller than the offset or 275*0e209d39SAndroid Build Coastguard Worker * the value BreakIterator.DONE 276*0e209d39SAndroid Build Coastguard Worker * @param offset the offset to begin scanning. 277*0e209d39SAndroid Build Coastguard Worker * @return The first boundary before the specified offset. 278*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 279*0e209d39SAndroid Build Coastguard Worker */ 280*0e209d39SAndroid Build Coastguard Worker virtual int32_t preceding(int32_t offset) = 0; 281*0e209d39SAndroid Build Coastguard Worker 282*0e209d39SAndroid Build Coastguard Worker /** 283*0e209d39SAndroid Build Coastguard Worker * Return true if the specified position is a boundary position. 284*0e209d39SAndroid Build Coastguard Worker * As a side effect, the current position of the iterator is set 285*0e209d39SAndroid Build Coastguard Worker * to the first boundary position at or following the specified offset. 286*0e209d39SAndroid Build Coastguard Worker * @param offset the offset to check. 287*0e209d39SAndroid Build Coastguard Worker * @return True if "offset" is a boundary position. 288*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 289*0e209d39SAndroid Build Coastguard Worker */ 290*0e209d39SAndroid Build Coastguard Worker virtual UBool isBoundary(int32_t offset) = 0; 291*0e209d39SAndroid Build Coastguard Worker 292*0e209d39SAndroid Build Coastguard Worker /** 293*0e209d39SAndroid Build Coastguard Worker * Set the iterator position to the nth boundary from the current boundary 294*0e209d39SAndroid Build Coastguard Worker * @param n the number of boundaries to move by. A value of 0 295*0e209d39SAndroid Build Coastguard Worker * does nothing. Negative values move to previous boundaries 296*0e209d39SAndroid Build Coastguard Worker * and positive values move to later boundaries. 297*0e209d39SAndroid Build Coastguard Worker * @return The new iterator position, or 298*0e209d39SAndroid Build Coastguard Worker * DONE if there are fewer than |n| boundaries in the specified direction. 299*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 300*0e209d39SAndroid Build Coastguard Worker */ 301*0e209d39SAndroid Build Coastguard Worker virtual int32_t next(int32_t n) = 0; 302*0e209d39SAndroid Build Coastguard Worker 303*0e209d39SAndroid Build Coastguard Worker /** 304*0e209d39SAndroid Build Coastguard Worker * For RuleBasedBreakIterators, return the status tag from the break rule 305*0e209d39SAndroid Build Coastguard Worker * that determined the boundary at the current iteration position. 306*0e209d39SAndroid Build Coastguard Worker * <p> 307*0e209d39SAndroid Build Coastguard Worker * For break iterator types that do not support a rule status, 308*0e209d39SAndroid Build Coastguard Worker * a default value of 0 is returned. 309*0e209d39SAndroid Build Coastguard Worker * <p> 310*0e209d39SAndroid Build Coastguard Worker * @return the status from the break rule that determined the boundary at 311*0e209d39SAndroid Build Coastguard Worker * the current iteration position. 312*0e209d39SAndroid Build Coastguard Worker * @see RuleBaseBreakIterator::getRuleStatus() 313*0e209d39SAndroid Build Coastguard Worker * @see UWordBreak 314*0e209d39SAndroid Build Coastguard Worker * @stable ICU 52 315*0e209d39SAndroid Build Coastguard Worker */ 316*0e209d39SAndroid Build Coastguard Worker virtual int32_t getRuleStatus() const; 317*0e209d39SAndroid Build Coastguard Worker 318*0e209d39SAndroid Build Coastguard Worker /** 319*0e209d39SAndroid Build Coastguard Worker * For RuleBasedBreakIterators, get the status (tag) values from the break rule(s) 320*0e209d39SAndroid Build Coastguard Worker * that determined the boundary at the current iteration position. 321*0e209d39SAndroid Build Coastguard Worker * <p> 322*0e209d39SAndroid Build Coastguard Worker * For break iterator types that do not support rule status, 323*0e209d39SAndroid Build Coastguard Worker * no values are returned. 324*0e209d39SAndroid Build Coastguard Worker * <p> 325*0e209d39SAndroid Build Coastguard Worker * The returned status value(s) are stored into an array provided by the caller. 326*0e209d39SAndroid Build Coastguard Worker * The values are stored in sorted (ascending) order. 327*0e209d39SAndroid Build Coastguard Worker * If the capacity of the output array is insufficient to hold the data, 328*0e209d39SAndroid Build Coastguard Worker * the output will be truncated to the available length, and a 329*0e209d39SAndroid Build Coastguard Worker * U_BUFFER_OVERFLOW_ERROR will be signaled. 330*0e209d39SAndroid Build Coastguard Worker * <p> 331*0e209d39SAndroid Build Coastguard Worker * @see RuleBaseBreakIterator::getRuleStatusVec 332*0e209d39SAndroid Build Coastguard Worker * 333*0e209d39SAndroid Build Coastguard Worker * @param fillInVec an array to be filled in with the status values. 334*0e209d39SAndroid Build Coastguard Worker * @param capacity the length of the supplied vector. A length of zero causes 335*0e209d39SAndroid Build Coastguard Worker * the function to return the number of status values, in the 336*0e209d39SAndroid Build Coastguard Worker * normal way, without attempting to store any values. 337*0e209d39SAndroid Build Coastguard Worker * @param status receives error codes. 338*0e209d39SAndroid Build Coastguard Worker * @return The number of rule status values from rules that determined 339*0e209d39SAndroid Build Coastguard Worker * the boundary at the current iteration position. 340*0e209d39SAndroid Build Coastguard Worker * In the event of a U_BUFFER_OVERFLOW_ERROR, the return value 341*0e209d39SAndroid Build Coastguard Worker * is the total number of status values that were available, 342*0e209d39SAndroid Build Coastguard Worker * not the reduced number that were actually returned. 343*0e209d39SAndroid Build Coastguard Worker * @see getRuleStatus 344*0e209d39SAndroid Build Coastguard Worker * @stable ICU 52 345*0e209d39SAndroid Build Coastguard Worker */ 346*0e209d39SAndroid Build Coastguard Worker virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status); 347*0e209d39SAndroid Build Coastguard Worker 348*0e209d39SAndroid Build Coastguard Worker /** 349*0e209d39SAndroid Build Coastguard Worker * Create BreakIterator for word-breaks using the given locale. 350*0e209d39SAndroid Build Coastguard Worker * Returns an instance of a BreakIterator implementing word breaks. 351*0e209d39SAndroid Build Coastguard Worker * WordBreak is useful for word selection (ex. double click) 352*0e209d39SAndroid Build Coastguard Worker * @param where the locale. 353*0e209d39SAndroid Build Coastguard Worker * @param status the error code 354*0e209d39SAndroid Build Coastguard Worker * @return A BreakIterator for word-breaks. The UErrorCode& status 355*0e209d39SAndroid Build Coastguard Worker * parameter is used to return status information to the user. 356*0e209d39SAndroid Build Coastguard Worker * To check whether the construction succeeded or not, you should check 357*0e209d39SAndroid Build Coastguard Worker * the value of U_SUCCESS(err). If you wish more detailed information, you 358*0e209d39SAndroid Build Coastguard Worker * can check for informational error results which still indicate success. 359*0e209d39SAndroid Build Coastguard Worker * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 360*0e209d39SAndroid Build Coastguard Worker * example, 'de_CH' was requested, but nothing was found there, so 'de' was 361*0e209d39SAndroid Build Coastguard Worker * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 362*0e209d39SAndroid Build Coastguard Worker * used; neither the requested locale nor any of its fall back locales 363*0e209d39SAndroid Build Coastguard Worker * could be found. 364*0e209d39SAndroid Build Coastguard Worker * The caller owns the returned object and is responsible for deleting it. 365*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 366*0e209d39SAndroid Build Coastguard Worker */ 367*0e209d39SAndroid Build Coastguard Worker static BreakIterator* U_EXPORT2 368*0e209d39SAndroid Build Coastguard Worker createWordInstance(const Locale& where, UErrorCode& status); 369*0e209d39SAndroid Build Coastguard Worker 370*0e209d39SAndroid Build Coastguard Worker /** 371*0e209d39SAndroid Build Coastguard Worker * Create BreakIterator for line-breaks using specified locale. 372*0e209d39SAndroid Build Coastguard Worker * Returns an instance of a BreakIterator implementing line breaks. Line 373*0e209d39SAndroid Build Coastguard Worker * breaks are logically possible line breaks, actual line breaks are 374*0e209d39SAndroid Build Coastguard Worker * usually determined based on display width. 375*0e209d39SAndroid Build Coastguard Worker * LineBreak is useful for word wrapping text. 376*0e209d39SAndroid Build Coastguard Worker * @param where the locale. 377*0e209d39SAndroid Build Coastguard Worker * @param status The error code. 378*0e209d39SAndroid Build Coastguard Worker * @return A BreakIterator for line-breaks. The UErrorCode& status 379*0e209d39SAndroid Build Coastguard Worker * parameter is used to return status information to the user. 380*0e209d39SAndroid Build Coastguard Worker * To check whether the construction succeeded or not, you should check 381*0e209d39SAndroid Build Coastguard Worker * the value of U_SUCCESS(err). If you wish more detailed information, you 382*0e209d39SAndroid Build Coastguard Worker * can check for informational error results which still indicate success. 383*0e209d39SAndroid Build Coastguard Worker * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 384*0e209d39SAndroid Build Coastguard Worker * example, 'de_CH' was requested, but nothing was found there, so 'de' was 385*0e209d39SAndroid Build Coastguard Worker * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 386*0e209d39SAndroid Build Coastguard Worker * used; neither the requested locale nor any of its fall back locales 387*0e209d39SAndroid Build Coastguard Worker * could be found. 388*0e209d39SAndroid Build Coastguard Worker * The caller owns the returned object and is responsible for deleting it. 389*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 390*0e209d39SAndroid Build Coastguard Worker */ 391*0e209d39SAndroid Build Coastguard Worker static BreakIterator* U_EXPORT2 392*0e209d39SAndroid Build Coastguard Worker createLineInstance(const Locale& where, UErrorCode& status); 393*0e209d39SAndroid Build Coastguard Worker 394*0e209d39SAndroid Build Coastguard Worker /** 395*0e209d39SAndroid Build Coastguard Worker * Create BreakIterator for character-breaks using specified locale 396*0e209d39SAndroid Build Coastguard Worker * Returns an instance of a BreakIterator implementing character breaks. 397*0e209d39SAndroid Build Coastguard Worker * Character breaks are boundaries of combining character sequences. 398*0e209d39SAndroid Build Coastguard Worker * @param where the locale. 399*0e209d39SAndroid Build Coastguard Worker * @param status The error code. 400*0e209d39SAndroid Build Coastguard Worker * @return A BreakIterator for character-breaks. The UErrorCode& status 401*0e209d39SAndroid Build Coastguard Worker * parameter is used to return status information to the user. 402*0e209d39SAndroid Build Coastguard Worker * To check whether the construction succeeded or not, you should check 403*0e209d39SAndroid Build Coastguard Worker * the value of U_SUCCESS(err). If you wish more detailed information, you 404*0e209d39SAndroid Build Coastguard Worker * can check for informational error results which still indicate success. 405*0e209d39SAndroid Build Coastguard Worker * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 406*0e209d39SAndroid Build Coastguard Worker * example, 'de_CH' was requested, but nothing was found there, so 'de' was 407*0e209d39SAndroid Build Coastguard Worker * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 408*0e209d39SAndroid Build Coastguard Worker * used; neither the requested locale nor any of its fall back locales 409*0e209d39SAndroid Build Coastguard Worker * could be found. 410*0e209d39SAndroid Build Coastguard Worker * The caller owns the returned object and is responsible for deleting it. 411*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 412*0e209d39SAndroid Build Coastguard Worker */ 413*0e209d39SAndroid Build Coastguard Worker static BreakIterator* U_EXPORT2 414*0e209d39SAndroid Build Coastguard Worker createCharacterInstance(const Locale& where, UErrorCode& status); 415*0e209d39SAndroid Build Coastguard Worker 416*0e209d39SAndroid Build Coastguard Worker /** 417*0e209d39SAndroid Build Coastguard Worker * Create BreakIterator for sentence-breaks using specified locale 418*0e209d39SAndroid Build Coastguard Worker * Returns an instance of a BreakIterator implementing sentence breaks. 419*0e209d39SAndroid Build Coastguard Worker * @param where the locale. 420*0e209d39SAndroid Build Coastguard Worker * @param status The error code. 421*0e209d39SAndroid Build Coastguard Worker * @return A BreakIterator for sentence-breaks. The UErrorCode& status 422*0e209d39SAndroid Build Coastguard Worker * parameter is used to return status information to the user. 423*0e209d39SAndroid Build Coastguard Worker * To check whether the construction succeeded or not, you should check 424*0e209d39SAndroid Build Coastguard Worker * the value of U_SUCCESS(err). If you wish more detailed information, you 425*0e209d39SAndroid Build Coastguard Worker * can check for informational error results which still indicate success. 426*0e209d39SAndroid Build Coastguard Worker * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 427*0e209d39SAndroid Build Coastguard Worker * example, 'de_CH' was requested, but nothing was found there, so 'de' was 428*0e209d39SAndroid Build Coastguard Worker * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 429*0e209d39SAndroid Build Coastguard Worker * used; neither the requested locale nor any of its fall back locales 430*0e209d39SAndroid Build Coastguard Worker * could be found. 431*0e209d39SAndroid Build Coastguard Worker * The caller owns the returned object and is responsible for deleting it. 432*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 433*0e209d39SAndroid Build Coastguard Worker */ 434*0e209d39SAndroid Build Coastguard Worker static BreakIterator* U_EXPORT2 435*0e209d39SAndroid Build Coastguard Worker createSentenceInstance(const Locale& where, UErrorCode& status); 436*0e209d39SAndroid Build Coastguard Worker 437*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 438*0e209d39SAndroid Build Coastguard Worker /** 439*0e209d39SAndroid Build Coastguard Worker * Create BreakIterator for title-casing breaks using the specified locale 440*0e209d39SAndroid Build Coastguard Worker * Returns an instance of a BreakIterator implementing title breaks. 441*0e209d39SAndroid Build Coastguard Worker * The iterator returned locates title boundaries as described for 442*0e209d39SAndroid Build Coastguard Worker * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, 443*0e209d39SAndroid Build Coastguard Worker * please use a word boundary iterator. See {@link #createWordInstance }. 444*0e209d39SAndroid Build Coastguard Worker * 445*0e209d39SAndroid Build Coastguard Worker * @param where the locale. 446*0e209d39SAndroid Build Coastguard Worker * @param status The error code. 447*0e209d39SAndroid Build Coastguard Worker * @return A BreakIterator for title-breaks. The UErrorCode& status 448*0e209d39SAndroid Build Coastguard Worker * parameter is used to return status information to the user. 449*0e209d39SAndroid Build Coastguard Worker * To check whether the construction succeeded or not, you should check 450*0e209d39SAndroid Build Coastguard Worker * the value of U_SUCCESS(err). If you wish more detailed information, you 451*0e209d39SAndroid Build Coastguard Worker * can check for informational error results which still indicate success. 452*0e209d39SAndroid Build Coastguard Worker * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 453*0e209d39SAndroid Build Coastguard Worker * example, 'de_CH' was requested, but nothing was found there, so 'de' was 454*0e209d39SAndroid Build Coastguard Worker * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 455*0e209d39SAndroid Build Coastguard Worker * used; neither the requested locale nor any of its fall back locales 456*0e209d39SAndroid Build Coastguard Worker * could be found. 457*0e209d39SAndroid Build Coastguard Worker * The caller owns the returned object and is responsible for deleting it. 458*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 64 Use createWordInstance instead. 459*0e209d39SAndroid Build Coastguard Worker */ 460*0e209d39SAndroid Build Coastguard Worker static BreakIterator* U_EXPORT2 461*0e209d39SAndroid Build Coastguard Worker createTitleInstance(const Locale& where, UErrorCode& status); 462*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 463*0e209d39SAndroid Build Coastguard Worker 464*0e209d39SAndroid Build Coastguard Worker /** 465*0e209d39SAndroid Build Coastguard Worker * Get the set of Locales for which TextBoundaries are installed. 466*0e209d39SAndroid Build Coastguard Worker * <p><b>Note:</b> this will not return locales added through the register 467*0e209d39SAndroid Build Coastguard Worker * call. To see the registered locales too, use the getAvailableLocales 468*0e209d39SAndroid Build Coastguard Worker * function that returns a StringEnumeration object </p> 469*0e209d39SAndroid Build Coastguard Worker * @param count the output parameter of number of elements in the locale list 470*0e209d39SAndroid Build Coastguard Worker * @return available locales 471*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 472*0e209d39SAndroid Build Coastguard Worker */ 473*0e209d39SAndroid Build Coastguard Worker static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); 474*0e209d39SAndroid Build Coastguard Worker 475*0e209d39SAndroid Build Coastguard Worker /** 476*0e209d39SAndroid Build Coastguard Worker * Get name of the object for the desired Locale, in the desired language. 477*0e209d39SAndroid Build Coastguard Worker * @param objectLocale must be from getAvailableLocales. 478*0e209d39SAndroid Build Coastguard Worker * @param displayLocale specifies the desired locale for output. 479*0e209d39SAndroid Build Coastguard Worker * @param name the fill-in parameter of the return value 480*0e209d39SAndroid Build Coastguard Worker * Uses best match. 481*0e209d39SAndroid Build Coastguard Worker * @return user-displayable name 482*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 483*0e209d39SAndroid Build Coastguard Worker */ 484*0e209d39SAndroid Build Coastguard Worker static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, 485*0e209d39SAndroid Build Coastguard Worker const Locale& displayLocale, 486*0e209d39SAndroid Build Coastguard Worker UnicodeString& name); 487*0e209d39SAndroid Build Coastguard Worker 488*0e209d39SAndroid Build Coastguard Worker /** 489*0e209d39SAndroid Build Coastguard Worker * Get name of the object for the desired Locale, in the language of the 490*0e209d39SAndroid Build Coastguard Worker * default locale. 491*0e209d39SAndroid Build Coastguard Worker * @param objectLocale must be from getMatchingLocales 492*0e209d39SAndroid Build Coastguard Worker * @param name the fill-in parameter of the return value 493*0e209d39SAndroid Build Coastguard Worker * @return user-displayable name 494*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 495*0e209d39SAndroid Build Coastguard Worker */ 496*0e209d39SAndroid Build Coastguard Worker static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, 497*0e209d39SAndroid Build Coastguard Worker UnicodeString& name); 498*0e209d39SAndroid Build Coastguard Worker 499*0e209d39SAndroid Build Coastguard Worker #ifndef U_FORCE_HIDE_DEPRECATED_API 500*0e209d39SAndroid Build Coastguard Worker /** 501*0e209d39SAndroid Build Coastguard Worker * Deprecated functionality. Use clone() instead. 502*0e209d39SAndroid Build Coastguard Worker * 503*0e209d39SAndroid Build Coastguard Worker * Thread safe client-buffer-based cloning operation 504*0e209d39SAndroid Build Coastguard Worker * Do NOT call delete on a safeclone, since 'new' is not used to create it. 505*0e209d39SAndroid Build Coastguard Worker * @param stackBuffer user allocated space for the new clone. If nullptr new memory will be allocated. 506*0e209d39SAndroid Build Coastguard Worker * If buffer is not large enough, new memory will be allocated. 507*0e209d39SAndroid Build Coastguard Worker * @param BufferSize reference to size of allocated space. 508*0e209d39SAndroid Build Coastguard Worker * If BufferSize == 0, a sufficient size for use in cloning will 509*0e209d39SAndroid Build Coastguard Worker * be returned ('pre-flighting') 510*0e209d39SAndroid Build Coastguard Worker * If BufferSize is not enough for a stack-based safe clone, 511*0e209d39SAndroid Build Coastguard Worker * new memory will be allocated. 512*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 513*0e209d39SAndroid Build Coastguard Worker * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were 514*0e209d39SAndroid Build Coastguard Worker * necessary. 515*0e209d39SAndroid Build Coastguard Worker * @return pointer to the new clone 516*0e209d39SAndroid Build Coastguard Worker * 517*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 52. Use clone() instead. 518*0e209d39SAndroid Build Coastguard Worker */ 519*0e209d39SAndroid Build Coastguard Worker virtual BreakIterator * createBufferClone(void *stackBuffer, 520*0e209d39SAndroid Build Coastguard Worker int32_t &BufferSize, 521*0e209d39SAndroid Build Coastguard Worker UErrorCode &status) = 0; 522*0e209d39SAndroid Build Coastguard Worker #endif // U_FORCE_HIDE_DEPRECATED_API 523*0e209d39SAndroid Build Coastguard Worker 524*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 525*0e209d39SAndroid Build Coastguard Worker 526*0e209d39SAndroid Build Coastguard Worker /** 527*0e209d39SAndroid Build Coastguard Worker * Determine whether the BreakIterator was created in user memory by 528*0e209d39SAndroid Build Coastguard Worker * createBufferClone(), and thus should not be deleted. Such objects 529*0e209d39SAndroid Build Coastguard Worker * must be closed by an explicit call to the destructor (not delete). 530*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 52. Always delete the BreakIterator. 531*0e209d39SAndroid Build Coastguard Worker */ 532*0e209d39SAndroid Build Coastguard Worker inline UBool isBufferClone(); 533*0e209d39SAndroid Build Coastguard Worker 534*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 535*0e209d39SAndroid Build Coastguard Worker 536*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_SERVICE 537*0e209d39SAndroid Build Coastguard Worker /** 538*0e209d39SAndroid Build Coastguard Worker * Register a new break iterator of the indicated kind, to use in the given locale. 539*0e209d39SAndroid Build Coastguard Worker * The break iterator will be adopted. Clones of the iterator will be returned 540*0e209d39SAndroid Build Coastguard Worker * if a request for a break iterator of the given kind matches or falls back to 541*0e209d39SAndroid Build Coastguard Worker * this locale. 542*0e209d39SAndroid Build Coastguard Worker * Because ICU may choose to cache BreakIterators internally, this must 543*0e209d39SAndroid Build Coastguard Worker * be called at application startup, prior to any calls to 544*0e209d39SAndroid Build Coastguard Worker * BreakIterator::createXXXInstance to avoid undefined behavior. 545*0e209d39SAndroid Build Coastguard Worker * @param toAdopt the BreakIterator instance to be adopted 546*0e209d39SAndroid Build Coastguard Worker * @param locale the Locale for which this instance is to be registered 547*0e209d39SAndroid Build Coastguard Worker * @param kind the type of iterator for which this instance is to be registered 548*0e209d39SAndroid Build Coastguard Worker * @param status the in/out status code, no special meanings are assigned 549*0e209d39SAndroid Build Coastguard Worker * @return a registry key that can be used to unregister this instance 550*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.4 551*0e209d39SAndroid Build Coastguard Worker */ 552*0e209d39SAndroid Build Coastguard Worker static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt, 553*0e209d39SAndroid Build Coastguard Worker const Locale& locale, 554*0e209d39SAndroid Build Coastguard Worker UBreakIteratorType kind, 555*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 556*0e209d39SAndroid Build Coastguard Worker 557*0e209d39SAndroid Build Coastguard Worker /** 558*0e209d39SAndroid Build Coastguard Worker * Unregister a previously-registered BreakIterator using the key returned from the 559*0e209d39SAndroid Build Coastguard Worker * register call. Key becomes invalid after a successful call and should not be used again. 560*0e209d39SAndroid Build Coastguard Worker * The BreakIterator corresponding to the key will be deleted. 561*0e209d39SAndroid Build Coastguard Worker * Because ICU may choose to cache BreakIterators internally, this should 562*0e209d39SAndroid Build Coastguard Worker * be called during application shutdown, after all calls to 563*0e209d39SAndroid Build Coastguard Worker * BreakIterator::createXXXInstance to avoid undefined behavior. 564*0e209d39SAndroid Build Coastguard Worker * @param key the registry key returned by a previous call to registerInstance 565*0e209d39SAndroid Build Coastguard Worker * @param status the in/out status code, no special meanings are assigned 566*0e209d39SAndroid Build Coastguard Worker * @return true if the iterator for the key was successfully unregistered 567*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.4 568*0e209d39SAndroid Build Coastguard Worker */ 569*0e209d39SAndroid Build Coastguard Worker static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); 570*0e209d39SAndroid Build Coastguard Worker 571*0e209d39SAndroid Build Coastguard Worker /** 572*0e209d39SAndroid Build Coastguard Worker * Return a StringEnumeration over the locales available at the time of the call, 573*0e209d39SAndroid Build Coastguard Worker * including registered locales. 574*0e209d39SAndroid Build Coastguard Worker * @return a StringEnumeration over the locales available at the time of the call 575*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.4 576*0e209d39SAndroid Build Coastguard Worker */ 577*0e209d39SAndroid Build Coastguard Worker static StringEnumeration* U_EXPORT2 getAvailableLocales(); 578*0e209d39SAndroid Build Coastguard Worker #endif 579*0e209d39SAndroid Build Coastguard Worker 580*0e209d39SAndroid Build Coastguard Worker /** 581*0e209d39SAndroid Build Coastguard Worker * Returns the locale for this break iterator. Two flavors are available: valid and 582*0e209d39SAndroid Build Coastguard Worker * actual locale. 583*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8 584*0e209d39SAndroid Build Coastguard Worker */ 585*0e209d39SAndroid Build Coastguard Worker Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; 586*0e209d39SAndroid Build Coastguard Worker 587*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 588*0e209d39SAndroid Build Coastguard Worker /** Get the locale for this break iterator object. You can choose between valid and actual locale. 589*0e209d39SAndroid Build Coastguard Worker * @param type type of the locale we're looking for (valid or actual) 590*0e209d39SAndroid Build Coastguard Worker * @param status error code for the operation 591*0e209d39SAndroid Build Coastguard Worker * @return the locale 592*0e209d39SAndroid Build Coastguard Worker * @internal 593*0e209d39SAndroid Build Coastguard Worker */ 594*0e209d39SAndroid Build Coastguard Worker const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const; 595*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 596*0e209d39SAndroid Build Coastguard Worker 597*0e209d39SAndroid Build Coastguard Worker /** 598*0e209d39SAndroid Build Coastguard Worker * Set the subject text string upon which the break iterator is operating 599*0e209d39SAndroid Build Coastguard Worker * without changing any other aspect of the matching state. 600*0e209d39SAndroid Build Coastguard Worker * The new and previous text strings must have the same content. 601*0e209d39SAndroid Build Coastguard Worker * 602*0e209d39SAndroid Build Coastguard Worker * This function is intended for use in environments where ICU is operating on 603*0e209d39SAndroid Build Coastguard Worker * strings that may move around in memory. It provides a mechanism for notifying 604*0e209d39SAndroid Build Coastguard Worker * ICU that the string has been relocated, and providing a new UText to access the 605*0e209d39SAndroid Build Coastguard Worker * string in its new position. 606*0e209d39SAndroid Build Coastguard Worker * 607*0e209d39SAndroid Build Coastguard Worker * Note that the break iterator implementation never copies the underlying text 608*0e209d39SAndroid Build Coastguard Worker * of a string being processed, but always operates directly on the original text 609*0e209d39SAndroid Build Coastguard Worker * provided by the user. Refreshing simply drops the references to the old text 610*0e209d39SAndroid Build Coastguard Worker * and replaces them with references to the new. 611*0e209d39SAndroid Build Coastguard Worker * 612*0e209d39SAndroid Build Coastguard Worker * Caution: this function is normally used only by very specialized, 613*0e209d39SAndroid Build Coastguard Worker * system-level code. One example use case is with garbage collection that moves 614*0e209d39SAndroid Build Coastguard Worker * the text in memory. 615*0e209d39SAndroid Build Coastguard Worker * 616*0e209d39SAndroid Build Coastguard Worker * @param input The new (moved) text string. 617*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 618*0e209d39SAndroid Build Coastguard Worker * @return *this 619*0e209d39SAndroid Build Coastguard Worker * 620*0e209d39SAndroid Build Coastguard Worker * @stable ICU 49 621*0e209d39SAndroid Build Coastguard Worker */ 622*0e209d39SAndroid Build Coastguard Worker virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0; 623*0e209d39SAndroid Build Coastguard Worker 624*0e209d39SAndroid Build Coastguard Worker private: 625*0e209d39SAndroid Build Coastguard Worker static BreakIterator* buildInstance(const Locale& loc, const char *type, UErrorCode& status); 626*0e209d39SAndroid Build Coastguard Worker static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status); 627*0e209d39SAndroid Build Coastguard Worker static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status); 628*0e209d39SAndroid Build Coastguard Worker 629*0e209d39SAndroid Build Coastguard Worker friend class ICUBreakIteratorFactory; 630*0e209d39SAndroid Build Coastguard Worker friend class ICUBreakIteratorService; 631*0e209d39SAndroid Build Coastguard Worker 632*0e209d39SAndroid Build Coastguard Worker protected: 633*0e209d39SAndroid Build Coastguard Worker // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API 634*0e209d39SAndroid Build Coastguard Worker // or else the compiler will create a public ones. 635*0e209d39SAndroid Build Coastguard Worker /** @internal */ 636*0e209d39SAndroid Build Coastguard Worker BreakIterator(); 637*0e209d39SAndroid Build Coastguard Worker /** @internal */ 638*0e209d39SAndroid Build Coastguard Worker BreakIterator (const BreakIterator &other); 639*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 640*0e209d39SAndroid Build Coastguard Worker /** @internal */ 641*0e209d39SAndroid Build Coastguard Worker BreakIterator (const Locale& valid, const Locale &actual); 642*0e209d39SAndroid Build Coastguard Worker /** @internal. Assignment Operator, used by RuleBasedBreakIterator. */ 643*0e209d39SAndroid Build Coastguard Worker BreakIterator &operator = (const BreakIterator &other); 644*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 645*0e209d39SAndroid Build Coastguard Worker 646*0e209d39SAndroid Build Coastguard Worker private: 647*0e209d39SAndroid Build Coastguard Worker 648*0e209d39SAndroid Build Coastguard Worker /** @internal (private) */ 649*0e209d39SAndroid Build Coastguard Worker char actualLocale[ULOC_FULLNAME_CAPACITY]; 650*0e209d39SAndroid Build Coastguard Worker char validLocale[ULOC_FULLNAME_CAPACITY]; 651*0e209d39SAndroid Build Coastguard Worker char requestLocale[ULOC_FULLNAME_CAPACITY]; 652*0e209d39SAndroid Build Coastguard Worker }; 653*0e209d39SAndroid Build Coastguard Worker 654*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 655*0e209d39SAndroid Build Coastguard Worker 656*0e209d39SAndroid Build Coastguard Worker inline UBool BreakIterator::isBufferClone() 657*0e209d39SAndroid Build Coastguard Worker { 658*0e209d39SAndroid Build Coastguard Worker return false; 659*0e209d39SAndroid Build Coastguard Worker } 660*0e209d39SAndroid Build Coastguard Worker 661*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 662*0e209d39SAndroid Build Coastguard Worker 663*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 664*0e209d39SAndroid Build Coastguard Worker 665*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 666*0e209d39SAndroid Build Coastguard Worker 667*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */ 668*0e209d39SAndroid Build Coastguard Worker 669*0e209d39SAndroid Build Coastguard Worker #endif // BRKITER_H 670*0e209d39SAndroid Build Coastguard Worker //eof 671