brkiter.h 28 KB

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