brkiter.h 28 KB

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