brkiter.h 27 KB

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