|
||||
Warning, file /include/unicode/brkiter.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ******************************************************************************** 0005 * Copyright (C) 1997-2016, International Business Machines 0006 * Corporation and others. All Rights Reserved. 0007 ******************************************************************************** 0008 * 0009 * File brkiter.h 0010 * 0011 * Modification History: 0012 * 0013 * Date Name Description 0014 * 02/18/97 aliu Added typedef for TextCount. Made DONE const. 0015 * 05/07/97 aliu Fixed DLL declaration. 0016 * 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK 0017 * 08/11/98 helena Sync-up JDK1.2. 0018 * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods. 0019 ******************************************************************************** 0020 */ 0021 0022 #ifndef BRKITER_H 0023 #define BRKITER_H 0024 0025 #include "unicode/utypes.h" 0026 0027 /** 0028 * \file 0029 * \brief C++ API: Break Iterator. 0030 */ 0031 0032 #include "unicode/utypes.h" 0033 0034 #if U_SHOW_CPLUSPLUS_API 0035 0036 #if UCONFIG_NO_BREAK_ITERATION 0037 0038 U_NAMESPACE_BEGIN 0039 0040 /* 0041 * Allow the declaration of APIs with pointers to BreakIterator 0042 * even when break iteration is removed from the build. 0043 */ 0044 class BreakIterator; 0045 0046 U_NAMESPACE_END 0047 0048 #else 0049 0050 #include "unicode/uobject.h" 0051 #include "unicode/unistr.h" 0052 #include "unicode/chariter.h" 0053 #include "unicode/locid.h" 0054 #include "unicode/ubrk.h" 0055 #include "unicode/strenum.h" 0056 #include "unicode/utext.h" 0057 #include "unicode/umisc.h" 0058 0059 U_NAMESPACE_BEGIN 0060 0061 /** 0062 * The BreakIterator class implements methods for finding the location 0063 * of boundaries in text. BreakIterator is an abstract base class. 0064 * Instances of BreakIterator maintain a current position and scan over 0065 * text returning the index of characters where boundaries occur. 0066 * <p> 0067 * Line boundary analysis determines where a text string can be broken 0068 * when line-wrapping. The mechanism correctly handles punctuation and 0069 * hyphenated words. 0070 * <p> 0071 * Sentence boundary analysis allows selection with correct 0072 * interpretation of periods within numbers and abbreviations, and 0073 * trailing punctuation marks such as quotation marks and parentheses. 0074 * <p> 0075 * Word boundary analysis is used by search and replace functions, as 0076 * well as within text editing applications that allow the user to 0077 * select words with a double click. Word selection provides correct 0078 * interpretation of punctuation marks within and following 0079 * words. Characters that are not part of a word, such as symbols or 0080 * punctuation marks, have word-breaks on both sides. 0081 * <p> 0082 * Character boundary analysis allows users to interact with 0083 * characters as they expect to, for example, when moving the cursor 0084 * through a text string. Character boundary analysis provides correct 0085 * navigation of through character strings, regardless of how the 0086 * character is stored. For example, an accented character might be 0087 * stored as a base character and a diacritical mark. What users 0088 * consider to be a character can differ between languages. 0089 * <p> 0090 * The text boundary positions are found according to the rules 0091 * described in Unicode Standard Annex #29, Text Boundaries, and 0092 * Unicode Standard Annex #14, Line Breaking Properties. These 0093 * are available at http://www.unicode.org/reports/tr14/ and 0094 * http://www.unicode.org/reports/tr29/. 0095 * <p> 0096 * In addition to the C++ API defined in this header file, a 0097 * plain C API with equivalent functionality is defined in the 0098 * file ubrk.h 0099 * <p> 0100 * Code snippets illustrating the use of the Break Iterator APIs 0101 * are available in the ICU User Guide, 0102 * https://unicode-org.github.io/icu/userguide/boundaryanalysis/ 0103 * and in the sample program icu/source/samples/break/break.cpp 0104 * 0105 */ 0106 class U_COMMON_API BreakIterator : public UObject { 0107 public: 0108 /** 0109 * destructor 0110 * @stable ICU 2.0 0111 */ 0112 virtual ~BreakIterator(); 0113 0114 /** 0115 * Return true if another object is semantically equal to this 0116 * one. The other object should be an instance of the same subclass of 0117 * BreakIterator. Objects of different subclasses are considered 0118 * unequal. 0119 * <P> 0120 * Return true if this BreakIterator is at the same position in the 0121 * same text, and is the same class and type (word, line, etc.) of 0122 * BreakIterator, as the argument. Text is considered the same if 0123 * it contains the same characters, it need not be the same 0124 * object, and styles are not considered. 0125 * @stable ICU 2.0 0126 */ 0127 virtual bool operator==(const BreakIterator&) const = 0; 0128 0129 /** 0130 * Returns the complement of the result of operator== 0131 * @param rhs The BreakIterator to be compared for inequality 0132 * @return the complement of the result of operator== 0133 * @stable ICU 2.0 0134 */ 0135 bool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); } 0136 0137 /** 0138 * Return a polymorphic copy of this object. This is an abstract 0139 * method which subclasses implement. 0140 * @stable ICU 2.0 0141 */ 0142 virtual BreakIterator* clone() const = 0; 0143 0144 /** 0145 * Return a polymorphic class ID for this object. Different subclasses 0146 * will return distinct unequal values. 0147 * @stable ICU 2.0 0148 */ 0149 virtual UClassID getDynamicClassID(void) const override = 0; 0150 0151 /** 0152 * Return a CharacterIterator over the text being analyzed. 0153 * @stable ICU 2.0 0154 */ 0155 virtual CharacterIterator& getText(void) const = 0; 0156 0157 0158 /** 0159 * Get a UText for the text being analyzed. 0160 * The returned UText is a shallow clone of the UText used internally 0161 * by the break iterator implementation. It can safely be used to 0162 * access the text without impacting any break iterator operations, 0163 * but the underlying text itself must not be altered. 0164 * 0165 * @param fillIn A UText to be filled in. If nullptr, a new UText will be 0166 * allocated to hold the result. 0167 * @param status receives any error codes. 0168 * @return The current UText for this break iterator. If an input 0169 * UText was provided, it will always be returned. 0170 * @stable ICU 3.4 0171 */ 0172 virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0; 0173 0174 /** 0175 * Change the text over which this operates. The text boundary is 0176 * reset to the start. 0177 * 0178 * The BreakIterator will retain a reference to the supplied string. 0179 * The caller must not modify or delete the text while the BreakIterator 0180 * retains the reference. 0181 * 0182 * @param text The UnicodeString used to change the text. 0183 * @stable ICU 2.0 0184 */ 0185 virtual void setText(const UnicodeString &text) = 0; 0186 0187 /** 0188 * Reset the break iterator to operate over the text represented by 0189 * the UText. The iterator position is reset to the start. 0190 * 0191 * This function makes a shallow clone of the supplied UText. This means 0192 * that the caller is free to immediately close or otherwise reuse the 0193 * Utext that was passed as a parameter, but that the underlying text itself 0194 * must not be altered while being referenced by the break iterator. 0195 * 0196 * All index positions returned by break iterator functions are 0197 * native indices from the UText. For example, when breaking UTF-8 0198 * encoded text, the break positions returned by next(), previous(), etc. 0199 * will be UTF-8 string indices, not UTF-16 positions. 0200 * 0201 * @param text The UText used to change the text. 0202 * @param status receives any error codes. 0203 * @stable ICU 3.4 0204 */ 0205 virtual void setText(UText *text, UErrorCode &status) = 0; 0206 0207 /** 0208 * Change the text over which this operates. The text boundary is 0209 * reset to the start. 0210 * Note that setText(UText *) provides similar functionality to this function, 0211 * and is more efficient. 0212 * @param it The CharacterIterator used to change the text. 0213 * @stable ICU 2.0 0214 */ 0215 virtual void adoptText(CharacterIterator* it) = 0; 0216 0217 enum { 0218 /** 0219 * DONE is returned by previous() and next() after all valid 0220 * boundaries have been returned. 0221 * @stable ICU 2.0 0222 */ 0223 DONE = (int32_t)-1 0224 }; 0225 0226 /** 0227 * Sets the current iteration position to the beginning of the text, position zero. 0228 * @return The offset of the beginning of the text, zero. 0229 * @stable ICU 2.0 0230 */ 0231 virtual int32_t first(void) = 0; 0232 0233 /** 0234 * Set the iterator position to the index immediately BEYOND the last character in the text being scanned. 0235 * @return The index immediately BEYOND the last character in the text being scanned. 0236 * @stable ICU 2.0 0237 */ 0238 virtual int32_t last(void) = 0; 0239 0240 /** 0241 * Set the iterator position to the boundary preceding the current boundary. 0242 * @return The character index of the previous text boundary or DONE if all 0243 * boundaries have been returned. 0244 * @stable ICU 2.0 0245 */ 0246 virtual int32_t previous(void) = 0; 0247 0248 /** 0249 * Advance the iterator to the boundary following the current boundary. 0250 * @return The character index of the next text boundary or DONE if all 0251 * boundaries have been returned. 0252 * @stable ICU 2.0 0253 */ 0254 virtual int32_t next(void) = 0; 0255 0256 /** 0257 * Return character index of the current iterator position within the text. 0258 * @return The boundary most recently returned. 0259 * @stable ICU 2.0 0260 */ 0261 virtual int32_t current(void) const = 0; 0262 0263 /** 0264 * Advance the iterator to the first boundary following the specified offset. 0265 * The value returned is always greater than the offset or 0266 * the value BreakIterator.DONE 0267 * @param offset the offset to begin scanning. 0268 * @return The first boundary after the specified offset. 0269 * @stable ICU 2.0 0270 */ 0271 virtual int32_t following(int32_t offset) = 0; 0272 0273 /** 0274 * Set the iterator position to the first boundary preceding the specified offset. 0275 * The value returned is always smaller than the offset or 0276 * the value BreakIterator.DONE 0277 * @param offset the offset to begin scanning. 0278 * @return The first boundary before the specified offset. 0279 * @stable ICU 2.0 0280 */ 0281 virtual int32_t preceding(int32_t offset) = 0; 0282 0283 /** 0284 * Return true if the specified position is a boundary position. 0285 * As a side effect, the current position of the iterator is set 0286 * to the first boundary position at or following the specified offset. 0287 * @param offset the offset to check. 0288 * @return True if "offset" is a boundary position. 0289 * @stable ICU 2.0 0290 */ 0291 virtual UBool isBoundary(int32_t offset) = 0; 0292 0293 /** 0294 * Set the iterator position to the nth boundary from the current boundary 0295 * @param n the number of boundaries to move by. A value of 0 0296 * does nothing. Negative values move to previous boundaries 0297 * and positive values move to later boundaries. 0298 * @return The new iterator position, or 0299 * DONE if there are fewer than |n| boundaries in the specified direction. 0300 * @stable ICU 2.0 0301 */ 0302 virtual int32_t next(int32_t n) = 0; 0303 0304 /** 0305 * For RuleBasedBreakIterators, return the status tag from the break rule 0306 * that determined the boundary at the current iteration position. 0307 * <p> 0308 * For break iterator types that do not support a rule status, 0309 * a default value of 0 is returned. 0310 * <p> 0311 * @return the status from the break rule that determined the boundary at 0312 * the current iteration position. 0313 * @see RuleBaseBreakIterator::getRuleStatus() 0314 * @see UWordBreak 0315 * @stable ICU 52 0316 */ 0317 virtual int32_t getRuleStatus() const; 0318 0319 /** 0320 * For RuleBasedBreakIterators, get the status (tag) values from the break rule(s) 0321 * that determined the boundary at the current iteration position. 0322 * <p> 0323 * For break iterator types that do not support rule status, 0324 * no values are returned. 0325 * <p> 0326 * The returned status value(s) are stored into an array provided by the caller. 0327 * The values are stored in sorted (ascending) order. 0328 * If the capacity of the output array is insufficient to hold the data, 0329 * the output will be truncated to the available length, and a 0330 * U_BUFFER_OVERFLOW_ERROR will be signaled. 0331 * <p> 0332 * @see RuleBaseBreakIterator::getRuleStatusVec 0333 * 0334 * @param fillInVec an array to be filled in with the status values. 0335 * @param capacity the length of the supplied vector. A length of zero causes 0336 * the function to return the number of status values, in the 0337 * normal way, without attempting to store any values. 0338 * @param status receives error codes. 0339 * @return The number of rule status values from rules that determined 0340 * the boundary at the current iteration position. 0341 * In the event of a U_BUFFER_OVERFLOW_ERROR, the return value 0342 * is the total number of status values that were available, 0343 * not the reduced number that were actually returned. 0344 * @see getRuleStatus 0345 * @stable ICU 52 0346 */ 0347 virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status); 0348 0349 /** 0350 * Create BreakIterator for word-breaks using the given locale. 0351 * Returns an instance of a BreakIterator implementing word breaks. 0352 * WordBreak is useful for word selection (ex. double click) 0353 * @param where the locale. 0354 * @param status the error code 0355 * @return A BreakIterator for word-breaks. The UErrorCode& status 0356 * parameter is used to return status information to the user. 0357 * To check whether the construction succeeded or not, you should check 0358 * the value of U_SUCCESS(err). If you wish more detailed information, you 0359 * can check for informational error results which still indicate success. 0360 * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 0361 * example, 'de_CH' was requested, but nothing was found there, so 'de' was 0362 * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 0363 * used; neither the requested locale nor any of its fall back locales 0364 * could be found. 0365 * The caller owns the returned object and is responsible for deleting it. 0366 * @stable ICU 2.0 0367 */ 0368 static BreakIterator* U_EXPORT2 0369 createWordInstance(const Locale& where, UErrorCode& status); 0370 0371 /** 0372 * Create BreakIterator for line-breaks using specified locale. 0373 * Returns an instance of a BreakIterator implementing line breaks. Line 0374 * breaks are logically possible line breaks, actual line breaks are 0375 * usually determined based on display width. 0376 * LineBreak is useful for word wrapping text. 0377 * @param where the locale. 0378 * @param status The error code. 0379 * @return A BreakIterator for line-breaks. The UErrorCode& status 0380 * parameter is used to return status information to the user. 0381 * To check whether the construction succeeded or not, you should check 0382 * the value of U_SUCCESS(err). If you wish more detailed information, you 0383 * can check for informational error results which still indicate success. 0384 * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 0385 * example, 'de_CH' was requested, but nothing was found there, so 'de' was 0386 * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 0387 * used; neither the requested locale nor any of its fall back locales 0388 * could be found. 0389 * The caller owns the returned object and is responsible for deleting it. 0390 * @stable ICU 2.0 0391 */ 0392 static BreakIterator* U_EXPORT2 0393 createLineInstance(const Locale& where, UErrorCode& status); 0394 0395 /** 0396 * Create BreakIterator for character-breaks using specified locale 0397 * Returns an instance of a BreakIterator implementing character breaks. 0398 * Character breaks are boundaries of combining character sequences. 0399 * @param where the locale. 0400 * @param status The error code. 0401 * @return A BreakIterator for character-breaks. The UErrorCode& status 0402 * parameter is used to return status information to the user. 0403 * To check whether the construction succeeded or not, you should check 0404 * the value of U_SUCCESS(err). If you wish more detailed information, you 0405 * can check for informational error results which still indicate success. 0406 * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 0407 * example, 'de_CH' was requested, but nothing was found there, so 'de' was 0408 * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 0409 * used; neither the requested locale nor any of its fall back locales 0410 * could be found. 0411 * The caller owns the returned object and is responsible for deleting it. 0412 * @stable ICU 2.0 0413 */ 0414 static BreakIterator* U_EXPORT2 0415 createCharacterInstance(const Locale& where, UErrorCode& status); 0416 0417 /** 0418 * Create BreakIterator for sentence-breaks using specified locale 0419 * Returns an instance of a BreakIterator implementing sentence breaks. 0420 * @param where the locale. 0421 * @param status The error code. 0422 * @return A BreakIterator for sentence-breaks. The UErrorCode& status 0423 * parameter is used to return status information to the user. 0424 * To check whether the construction succeeded or not, you should check 0425 * the value of U_SUCCESS(err). If you wish more detailed information, you 0426 * can check for informational error results which still indicate success. 0427 * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 0428 * example, 'de_CH' was requested, but nothing was found there, so 'de' was 0429 * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 0430 * used; neither the requested locale nor any of its fall back locales 0431 * could be found. 0432 * The caller owns the returned object and is responsible for deleting it. 0433 * @stable ICU 2.0 0434 */ 0435 static BreakIterator* U_EXPORT2 0436 createSentenceInstance(const Locale& where, UErrorCode& status); 0437 0438 #ifndef U_HIDE_DEPRECATED_API 0439 /** 0440 * Create BreakIterator for title-casing breaks using the specified locale 0441 * Returns an instance of a BreakIterator implementing title breaks. 0442 * The iterator returned locates title boundaries as described for 0443 * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, 0444 * please use a word boundary iterator. See {@link #createWordInstance }. 0445 * 0446 * @param where the locale. 0447 * @param status The error code. 0448 * @return A BreakIterator for title-breaks. The UErrorCode& status 0449 * parameter is used to return status information to the user. 0450 * To check whether the construction succeeded or not, you should check 0451 * the value of U_SUCCESS(err). If you wish more detailed information, you 0452 * can check for informational error results which still indicate success. 0453 * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For 0454 * example, 'de_CH' was requested, but nothing was found there, so 'de' was 0455 * used. U_USING_DEFAULT_WARNING indicates that the default locale data was 0456 * used; neither the requested locale nor any of its fall back locales 0457 * could be found. 0458 * The caller owns the returned object and is responsible for deleting it. 0459 * @deprecated ICU 64 Use createWordInstance instead. 0460 */ 0461 static BreakIterator* U_EXPORT2 0462 createTitleInstance(const Locale& where, UErrorCode& status); 0463 #endif /* U_HIDE_DEPRECATED_API */ 0464 0465 /** 0466 * Get the set of Locales for which TextBoundaries are installed. 0467 * <p><b>Note:</b> this will not return locales added through the register 0468 * call. To see the registered locales too, use the getAvailableLocales 0469 * function that returns a StringEnumeration object </p> 0470 * @param count the output parameter of number of elements in the locale list 0471 * @return available locales 0472 * @stable ICU 2.0 0473 */ 0474 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); 0475 0476 /** 0477 * Get name of the object for the desired Locale, in the desired language. 0478 * @param objectLocale must be from getAvailableLocales. 0479 * @param displayLocale specifies the desired locale for output. 0480 * @param name the fill-in parameter of the return value 0481 * Uses best match. 0482 * @return user-displayable name 0483 * @stable ICU 2.0 0484 */ 0485 static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, 0486 const Locale& displayLocale, 0487 UnicodeString& name); 0488 0489 /** 0490 * Get name of the object for the desired Locale, in the language of the 0491 * default locale. 0492 * @param objectLocale must be from getMatchingLocales 0493 * @param name the fill-in parameter of the return value 0494 * @return user-displayable name 0495 * @stable ICU 2.0 0496 */ 0497 static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, 0498 UnicodeString& name); 0499 0500 #ifndef U_FORCE_HIDE_DEPRECATED_API 0501 /** 0502 * Deprecated functionality. Use clone() instead. 0503 * 0504 * Thread safe client-buffer-based cloning operation 0505 * Do NOT call delete on a safeclone, since 'new' is not used to create it. 0506 * @param stackBuffer user allocated space for the new clone. If nullptr new memory will be allocated. 0507 * If buffer is not large enough, new memory will be allocated. 0508 * @param BufferSize reference to size of allocated space. 0509 * If BufferSize == 0, a sufficient size for use in cloning will 0510 * be returned ('pre-flighting') 0511 * If BufferSize is not enough for a stack-based safe clone, 0512 * new memory will be allocated. 0513 * @param status to indicate whether the operation went on smoothly or there were errors 0514 * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were 0515 * necessary. 0516 * @return pointer to the new clone 0517 * 0518 * @deprecated ICU 52. Use clone() instead. 0519 */ 0520 virtual BreakIterator * createBufferClone(void *stackBuffer, 0521 int32_t &BufferSize, 0522 UErrorCode &status) = 0; 0523 #endif // U_FORCE_HIDE_DEPRECATED_API 0524 0525 #ifndef U_HIDE_DEPRECATED_API 0526 0527 /** 0528 * Determine whether the BreakIterator was created in user memory by 0529 * createBufferClone(), and thus should not be deleted. Such objects 0530 * must be closed by an explicit call to the destructor (not delete). 0531 * @deprecated ICU 52. Always delete the BreakIterator. 0532 */ 0533 inline UBool isBufferClone(void); 0534 0535 #endif /* U_HIDE_DEPRECATED_API */ 0536 0537 #if !UCONFIG_NO_SERVICE 0538 /** 0539 * Register a new break iterator of the indicated kind, to use in the given locale. 0540 * The break iterator will be adopted. Clones of the iterator will be returned 0541 * if a request for a break iterator of the given kind matches or falls back to 0542 * this locale. 0543 * Because ICU may choose to cache BreakIterators internally, this must 0544 * be called at application startup, prior to any calls to 0545 * BreakIterator::createXXXInstance to avoid undefined behavior. 0546 * @param toAdopt the BreakIterator instance to be adopted 0547 * @param locale the Locale for which this instance is to be registered 0548 * @param kind the type of iterator for which this instance is to be registered 0549 * @param status the in/out status code, no special meanings are assigned 0550 * @return a registry key that can be used to unregister this instance 0551 * @stable ICU 2.4 0552 */ 0553 static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt, 0554 const Locale& locale, 0555 UBreakIteratorType kind, 0556 UErrorCode& status); 0557 0558 /** 0559 * Unregister a previously-registered BreakIterator using the key returned from the 0560 * register call. Key becomes invalid after a successful call and should not be used again. 0561 * The BreakIterator corresponding to the key will be deleted. 0562 * Because ICU may choose to cache BreakIterators internally, this should 0563 * be called during application shutdown, after all calls to 0564 * BreakIterator::createXXXInstance to avoid undefined behavior. 0565 * @param key the registry key returned by a previous call to registerInstance 0566 * @param status the in/out status code, no special meanings are assigned 0567 * @return true if the iterator for the key was successfully unregistered 0568 * @stable ICU 2.4 0569 */ 0570 static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); 0571 0572 /** 0573 * Return a StringEnumeration over the locales available at the time of the call, 0574 * including registered locales. 0575 * @return a StringEnumeration over the locales available at the time of the call 0576 * @stable ICU 2.4 0577 */ 0578 static StringEnumeration* U_EXPORT2 getAvailableLocales(void); 0579 #endif 0580 0581 /** 0582 * Returns the locale for this break iterator. Two flavors are available: valid and 0583 * actual locale. 0584 * @stable ICU 2.8 0585 */ 0586 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; 0587 0588 #ifndef U_HIDE_INTERNAL_API 0589 /** Get the locale for this break iterator object. You can choose between valid and actual locale. 0590 * @param type type of the locale we're looking for (valid or actual) 0591 * @param status error code for the operation 0592 * @return the locale 0593 * @internal 0594 */ 0595 const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const; 0596 #endif /* U_HIDE_INTERNAL_API */ 0597 0598 /** 0599 * Set the subject text string upon which the break iterator is operating 0600 * without changing any other aspect of the matching state. 0601 * The new and previous text strings must have the same content. 0602 * 0603 * This function is intended for use in environments where ICU is operating on 0604 * strings that may move around in memory. It provides a mechanism for notifying 0605 * ICU that the string has been relocated, and providing a new UText to access the 0606 * string in its new position. 0607 * 0608 * Note that the break iterator implementation never copies the underlying text 0609 * of a string being processed, but always operates directly on the original text 0610 * provided by the user. Refreshing simply drops the references to the old text 0611 * and replaces them with references to the new. 0612 * 0613 * Caution: this function is normally used only by very specialized, 0614 * system-level code. One example use case is with garbage collection that moves 0615 * the text in memory. 0616 * 0617 * @param input The new (moved) text string. 0618 * @param status Receives errors detected by this function. 0619 * @return *this 0620 * 0621 * @stable ICU 49 0622 */ 0623 virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0; 0624 0625 private: 0626 static BreakIterator* buildInstance(const Locale& loc, const char *type, UErrorCode& status); 0627 static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status); 0628 static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status); 0629 0630 friend class ICUBreakIteratorFactory; 0631 friend class ICUBreakIteratorService; 0632 0633 protected: 0634 // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API 0635 // or else the compiler will create a public ones. 0636 /** @internal */ 0637 BreakIterator(); 0638 /** @internal */ 0639 BreakIterator (const BreakIterator &other); 0640 #ifndef U_HIDE_INTERNAL_API 0641 /** @internal */ 0642 BreakIterator (const Locale& valid, const Locale &actual); 0643 /** @internal. Assignment Operator, used by RuleBasedBreakIterator. */ 0644 BreakIterator &operator = (const BreakIterator &other); 0645 #endif /* U_HIDE_INTERNAL_API */ 0646 0647 private: 0648 0649 /** @internal (private) */ 0650 char actualLocale[ULOC_FULLNAME_CAPACITY]; 0651 char validLocale[ULOC_FULLNAME_CAPACITY]; 0652 char requestLocale[ULOC_FULLNAME_CAPACITY]; 0653 }; 0654 0655 #ifndef U_HIDE_DEPRECATED_API 0656 0657 inline UBool BreakIterator::isBufferClone() 0658 { 0659 return false; 0660 } 0661 0662 #endif /* U_HIDE_DEPRECATED_API */ 0663 0664 U_NAMESPACE_END 0665 0666 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 0667 0668 #endif /* U_SHOW_CPLUSPLUS_API */ 0669 0670 #endif // BRKITER_H 0671 //eof
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |