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