Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * Copyright (C) 1996-2013, International Business Machines Corporation and others. |
michael@0 | 4 | * All Rights Reserved. |
michael@0 | 5 | ****************************************************************************** |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef UBRK_H |
michael@0 | 9 | #define UBRK_H |
michael@0 | 10 | |
michael@0 | 11 | #include "unicode/utypes.h" |
michael@0 | 12 | #include "unicode/uloc.h" |
michael@0 | 13 | #include "unicode/utext.h" |
michael@0 | 14 | #include "unicode/localpointer.h" |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * A text-break iterator. |
michael@0 | 18 | * For usage in C programs. |
michael@0 | 19 | */ |
michael@0 | 20 | #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR |
michael@0 | 21 | # define UBRK_TYPEDEF_UBREAK_ITERATOR |
michael@0 | 22 | /** |
michael@0 | 23 | * Opaque type representing an ICU Break iterator object. |
michael@0 | 24 | * @stable ICU 2.0 |
michael@0 | 25 | */ |
michael@0 | 26 | typedef struct UBreakIterator UBreakIterator; |
michael@0 | 27 | #endif |
michael@0 | 28 | |
michael@0 | 29 | #if !UCONFIG_NO_BREAK_ITERATION |
michael@0 | 30 | |
michael@0 | 31 | #include "unicode/parseerr.h" |
michael@0 | 32 | |
michael@0 | 33 | /** |
michael@0 | 34 | * \file |
michael@0 | 35 | * \brief C API: BreakIterator |
michael@0 | 36 | * |
michael@0 | 37 | * <h2> BreakIterator C API </h2> |
michael@0 | 38 | * |
michael@0 | 39 | * The BreakIterator C API defines methods for finding the location |
michael@0 | 40 | * of boundaries in text. Pointer to a UBreakIterator maintain a |
michael@0 | 41 | * current position and scan over text returning the index of characters |
michael@0 | 42 | * where boundaries occur. |
michael@0 | 43 | * <p> |
michael@0 | 44 | * Line boundary analysis determines where a text string can be broken |
michael@0 | 45 | * when line-wrapping. The mechanism correctly handles punctuation and |
michael@0 | 46 | * hyphenated words. |
michael@0 | 47 | * <p> |
michael@0 | 48 | * Sentence boundary analysis allows selection with correct |
michael@0 | 49 | * interpretation of periods within numbers and abbreviations, and |
michael@0 | 50 | * trailing punctuation marks such as quotation marks and parentheses. |
michael@0 | 51 | * <p> |
michael@0 | 52 | * Word boundary analysis is used by search and replace functions, as |
michael@0 | 53 | * well as within text editing applications that allow the user to |
michael@0 | 54 | * select words with a double click. Word selection provides correct |
michael@0 | 55 | * interpretation of punctuation marks within and following |
michael@0 | 56 | * words. Characters that are not part of a word, such as symbols or |
michael@0 | 57 | * punctuation marks, have word-breaks on both sides. |
michael@0 | 58 | * <p> |
michael@0 | 59 | * Character boundary analysis identifies the boundaries of |
michael@0 | 60 | * "Extended Grapheme Clusters", which are groupings of codepoints |
michael@0 | 61 | * that should be treated as character-like units for many text operations. |
michael@0 | 62 | * Please see Unicode Standard Annex #29, Unicode Text Segmentation, |
michael@0 | 63 | * http://www.unicode.org/reports/tr29/ for additional information |
michael@0 | 64 | * on grapheme clusters and guidelines on their use. |
michael@0 | 65 | * <p> |
michael@0 | 66 | * Title boundary analysis locates all positions, |
michael@0 | 67 | * typically starts of words, that should be set to Title Case |
michael@0 | 68 | * when title casing the text. |
michael@0 | 69 | * <p> |
michael@0 | 70 | * The text boundary positions are found according to the rules |
michael@0 | 71 | * described in Unicode Standard Annex #29, Text Boundaries, and |
michael@0 | 72 | * Unicode Standard Annex #14, Line Breaking Properties. These |
michael@0 | 73 | * are available at http://www.unicode.org/reports/tr14/ and |
michael@0 | 74 | * http://www.unicode.org/reports/tr29/. |
michael@0 | 75 | * <p> |
michael@0 | 76 | * In addition to the plain C API defined in this header file, an |
michael@0 | 77 | * object oriented C++ API with equivalent functionality is defined in the |
michael@0 | 78 | * file brkiter.h. |
michael@0 | 79 | * <p> |
michael@0 | 80 | * Code snippets illustrating the use of the Break Iterator APIs |
michael@0 | 81 | * are available in the ICU User Guide, |
michael@0 | 82 | * http://icu-project.org/userguide/boundaryAnalysis.html |
michael@0 | 83 | * and in the sample program icu/source/samples/break/break.cpp |
michael@0 | 84 | */ |
michael@0 | 85 | |
michael@0 | 86 | /** The possible types of text boundaries. @stable ICU 2.0 */ |
michael@0 | 87 | typedef enum UBreakIteratorType { |
michael@0 | 88 | /** Character breaks @stable ICU 2.0 */ |
michael@0 | 89 | UBRK_CHARACTER = 0, |
michael@0 | 90 | /** Word breaks @stable ICU 2.0 */ |
michael@0 | 91 | UBRK_WORD = 1, |
michael@0 | 92 | /** Line breaks @stable ICU 2.0 */ |
michael@0 | 93 | UBRK_LINE = 2, |
michael@0 | 94 | /** Sentence breaks @stable ICU 2.0 */ |
michael@0 | 95 | UBRK_SENTENCE = 3, |
michael@0 | 96 | |
michael@0 | 97 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 98 | /** |
michael@0 | 99 | * Title Case breaks |
michael@0 | 100 | * The iterator created using this type locates title boundaries as described for |
michael@0 | 101 | * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, |
michael@0 | 102 | * please use Word Boundary iterator. |
michael@0 | 103 | * |
michael@0 | 104 | * @deprecated ICU 2.8 Use the word break iterator for titlecasing for Unicode 4 and later. |
michael@0 | 105 | */ |
michael@0 | 106 | UBRK_TITLE = 4, |
michael@0 | 107 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 108 | UBRK_COUNT = 5 |
michael@0 | 109 | } UBreakIteratorType; |
michael@0 | 110 | |
michael@0 | 111 | /** Value indicating all text boundaries have been returned. |
michael@0 | 112 | * @stable ICU 2.0 |
michael@0 | 113 | */ |
michael@0 | 114 | #define UBRK_DONE ((int32_t) -1) |
michael@0 | 115 | |
michael@0 | 116 | |
michael@0 | 117 | /** |
michael@0 | 118 | * Enum constants for the word break tags returned by |
michael@0 | 119 | * getRuleStatus(). A range of values is defined for each category of |
michael@0 | 120 | * word, to allow for further subdivisions of a category in future releases. |
michael@0 | 121 | * Applications should check for tag values falling within the range, rather |
michael@0 | 122 | * than for single individual values. |
michael@0 | 123 | * @stable ICU 2.2 |
michael@0 | 124 | */ |
michael@0 | 125 | typedef enum UWordBreak { |
michael@0 | 126 | /** Tag value for "words" that do not fit into any of other categories. |
michael@0 | 127 | * Includes spaces and most punctuation. */ |
michael@0 | 128 | UBRK_WORD_NONE = 0, |
michael@0 | 129 | /** Upper bound for tags for uncategorized words. */ |
michael@0 | 130 | UBRK_WORD_NONE_LIMIT = 100, |
michael@0 | 131 | /** Tag value for words that appear to be numbers, lower limit. */ |
michael@0 | 132 | UBRK_WORD_NUMBER = 100, |
michael@0 | 133 | /** Tag value for words that appear to be numbers, upper limit. */ |
michael@0 | 134 | UBRK_WORD_NUMBER_LIMIT = 200, |
michael@0 | 135 | /** Tag value for words that contain letters, excluding |
michael@0 | 136 | * hiragana, katakana or ideographic characters, lower limit. */ |
michael@0 | 137 | UBRK_WORD_LETTER = 200, |
michael@0 | 138 | /** Tag value for words containing letters, upper limit */ |
michael@0 | 139 | UBRK_WORD_LETTER_LIMIT = 300, |
michael@0 | 140 | /** Tag value for words containing kana characters, lower limit */ |
michael@0 | 141 | UBRK_WORD_KANA = 300, |
michael@0 | 142 | /** Tag value for words containing kana characters, upper limit */ |
michael@0 | 143 | UBRK_WORD_KANA_LIMIT = 400, |
michael@0 | 144 | /** Tag value for words containing ideographic characters, lower limit */ |
michael@0 | 145 | UBRK_WORD_IDEO = 400, |
michael@0 | 146 | /** Tag value for words containing ideographic characters, upper limit */ |
michael@0 | 147 | UBRK_WORD_IDEO_LIMIT = 500 |
michael@0 | 148 | } UWordBreak; |
michael@0 | 149 | |
michael@0 | 150 | /** |
michael@0 | 151 | * Enum constants for the line break tags returned by getRuleStatus(). |
michael@0 | 152 | * A range of values is defined for each category of |
michael@0 | 153 | * word, to allow for further subdivisions of a category in future releases. |
michael@0 | 154 | * Applications should check for tag values falling within the range, rather |
michael@0 | 155 | * than for single individual values. |
michael@0 | 156 | * @stable ICU 2.8 |
michael@0 | 157 | */ |
michael@0 | 158 | typedef enum ULineBreakTag { |
michael@0 | 159 | /** Tag value for soft line breaks, positions at which a line break |
michael@0 | 160 | * is acceptable but not required */ |
michael@0 | 161 | UBRK_LINE_SOFT = 0, |
michael@0 | 162 | /** Upper bound for soft line breaks. */ |
michael@0 | 163 | UBRK_LINE_SOFT_LIMIT = 100, |
michael@0 | 164 | /** Tag value for a hard, or mandatory line break */ |
michael@0 | 165 | UBRK_LINE_HARD = 100, |
michael@0 | 166 | /** Upper bound for hard line breaks. */ |
michael@0 | 167 | UBRK_LINE_HARD_LIMIT = 200 |
michael@0 | 168 | } ULineBreakTag; |
michael@0 | 169 | |
michael@0 | 170 | |
michael@0 | 171 | |
michael@0 | 172 | /** |
michael@0 | 173 | * Enum constants for the sentence break tags returned by getRuleStatus(). |
michael@0 | 174 | * A range of values is defined for each category of |
michael@0 | 175 | * sentence, to allow for further subdivisions of a category in future releases. |
michael@0 | 176 | * Applications should check for tag values falling within the range, rather |
michael@0 | 177 | * than for single individual values. |
michael@0 | 178 | * @stable ICU 2.8 |
michael@0 | 179 | */ |
michael@0 | 180 | typedef enum USentenceBreakTag { |
michael@0 | 181 | /** Tag value for for sentences ending with a sentence terminator |
michael@0 | 182 | * ('.', '?', '!', etc.) character, possibly followed by a |
michael@0 | 183 | * hard separator (CR, LF, PS, etc.) |
michael@0 | 184 | */ |
michael@0 | 185 | UBRK_SENTENCE_TERM = 0, |
michael@0 | 186 | /** Upper bound for tags for sentences ended by sentence terminators. */ |
michael@0 | 187 | UBRK_SENTENCE_TERM_LIMIT = 100, |
michael@0 | 188 | /** Tag value for for sentences that do not contain an ending |
michael@0 | 189 | * sentence terminator ('.', '?', '!', etc.) character, but |
michael@0 | 190 | * are ended only by a hard separator (CR, LF, PS, etc.) or end of input. |
michael@0 | 191 | */ |
michael@0 | 192 | UBRK_SENTENCE_SEP = 100, |
michael@0 | 193 | /** Upper bound for tags for sentences ended by a separator. */ |
michael@0 | 194 | UBRK_SENTENCE_SEP_LIMIT = 200 |
michael@0 | 195 | /** Tag value for a hard, or mandatory line break */ |
michael@0 | 196 | } USentenceBreakTag; |
michael@0 | 197 | |
michael@0 | 198 | |
michael@0 | 199 | /** |
michael@0 | 200 | * Open a new UBreakIterator for locating text boundaries for a specified locale. |
michael@0 | 201 | * A UBreakIterator may be used for detecting character, line, word, |
michael@0 | 202 | * and sentence breaks in text. |
michael@0 | 203 | * @param type The type of UBreakIterator to open: one of UBRK_CHARACTER, UBRK_WORD, |
michael@0 | 204 | * UBRK_LINE, UBRK_SENTENCE |
michael@0 | 205 | * @param locale The locale specifying the text-breaking conventions. |
michael@0 | 206 | * @param text The text to be iterated over. |
michael@0 | 207 | * @param textLength The number of characters in text, or -1 if null-terminated. |
michael@0 | 208 | * @param status A UErrorCode to receive any errors. |
michael@0 | 209 | * @return A UBreakIterator for the specified locale. |
michael@0 | 210 | * @see ubrk_openRules |
michael@0 | 211 | * @stable ICU 2.0 |
michael@0 | 212 | */ |
michael@0 | 213 | U_STABLE UBreakIterator* U_EXPORT2 |
michael@0 | 214 | ubrk_open(UBreakIteratorType type, |
michael@0 | 215 | const char *locale, |
michael@0 | 216 | const UChar *text, |
michael@0 | 217 | int32_t textLength, |
michael@0 | 218 | UErrorCode *status); |
michael@0 | 219 | |
michael@0 | 220 | /** |
michael@0 | 221 | * Open a new UBreakIterator for locating text boundaries using specified breaking rules. |
michael@0 | 222 | * The rule syntax is ... (TBD) |
michael@0 | 223 | * @param rules A set of rules specifying the text breaking conventions. |
michael@0 | 224 | * @param rulesLength The number of characters in rules, or -1 if null-terminated. |
michael@0 | 225 | * @param text The text to be iterated over. May be null, in which case ubrk_setText() is |
michael@0 | 226 | * used to specify the text to be iterated. |
michael@0 | 227 | * @param textLength The number of characters in text, or -1 if null-terminated. |
michael@0 | 228 | * @param parseErr Receives position and context information for any syntax errors |
michael@0 | 229 | * detected while parsing the rules. |
michael@0 | 230 | * @param status A UErrorCode to receive any errors. |
michael@0 | 231 | * @return A UBreakIterator for the specified rules. |
michael@0 | 232 | * @see ubrk_open |
michael@0 | 233 | * @stable ICU 2.2 |
michael@0 | 234 | */ |
michael@0 | 235 | U_STABLE UBreakIterator* U_EXPORT2 |
michael@0 | 236 | ubrk_openRules(const UChar *rules, |
michael@0 | 237 | int32_t rulesLength, |
michael@0 | 238 | const UChar *text, |
michael@0 | 239 | int32_t textLength, |
michael@0 | 240 | UParseError *parseErr, |
michael@0 | 241 | UErrorCode *status); |
michael@0 | 242 | |
michael@0 | 243 | /** |
michael@0 | 244 | * Thread safe cloning operation |
michael@0 | 245 | * @param bi iterator to be cloned |
michael@0 | 246 | * @param stackBuffer <em>Deprecated functionality as of ICU 52, use NULL.</em><br> |
michael@0 | 247 | * user allocated space for the new clone. If NULL new memory will be allocated. |
michael@0 | 248 | * If buffer is not large enough, new memory will be allocated. |
michael@0 | 249 | * Clients can use the U_BRK_SAFECLONE_BUFFERSIZE. |
michael@0 | 250 | * @param pBufferSize <em>Deprecated functionality as of ICU 52, use NULL or 1.</em><br> |
michael@0 | 251 | * pointer to size of allocated space. |
michael@0 | 252 | * If *pBufferSize == 0, a sufficient size for use in cloning will |
michael@0 | 253 | * be returned ('pre-flighting') |
michael@0 | 254 | * If *pBufferSize is not enough for a stack-based safe clone, |
michael@0 | 255 | * new memory will be allocated. |
michael@0 | 256 | * @param status to indicate whether the operation went on smoothly or there were errors |
michael@0 | 257 | * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary. |
michael@0 | 258 | * @return pointer to the new clone |
michael@0 | 259 | * @stable ICU 2.0 |
michael@0 | 260 | */ |
michael@0 | 261 | U_STABLE UBreakIterator * U_EXPORT2 |
michael@0 | 262 | ubrk_safeClone( |
michael@0 | 263 | const UBreakIterator *bi, |
michael@0 | 264 | void *stackBuffer, |
michael@0 | 265 | int32_t *pBufferSize, |
michael@0 | 266 | UErrorCode *status); |
michael@0 | 267 | |
michael@0 | 268 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 269 | |
michael@0 | 270 | /** |
michael@0 | 271 | * A recommended size (in bytes) for the memory buffer to be passed to ubrk_saveClone(). |
michael@0 | 272 | * @deprecated ICU 52. Do not rely on ubrk_safeClone() cloning into any provided buffer. |
michael@0 | 273 | */ |
michael@0 | 274 | #define U_BRK_SAFECLONE_BUFFERSIZE 1 |
michael@0 | 275 | |
michael@0 | 276 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 277 | |
michael@0 | 278 | /** |
michael@0 | 279 | * Close a UBreakIterator. |
michael@0 | 280 | * Once closed, a UBreakIterator may no longer be used. |
michael@0 | 281 | * @param bi The break iterator to close. |
michael@0 | 282 | * @stable ICU 2.0 |
michael@0 | 283 | */ |
michael@0 | 284 | U_STABLE void U_EXPORT2 |
michael@0 | 285 | ubrk_close(UBreakIterator *bi); |
michael@0 | 286 | |
michael@0 | 287 | #if U_SHOW_CPLUSPLUS_API |
michael@0 | 288 | |
michael@0 | 289 | U_NAMESPACE_BEGIN |
michael@0 | 290 | |
michael@0 | 291 | /** |
michael@0 | 292 | * \class LocalUBreakIteratorPointer |
michael@0 | 293 | * "Smart pointer" class, closes a UBreakIterator via ubrk_close(). |
michael@0 | 294 | * For most methods see the LocalPointerBase base class. |
michael@0 | 295 | * |
michael@0 | 296 | * @see LocalPointerBase |
michael@0 | 297 | * @see LocalPointer |
michael@0 | 298 | * @stable ICU 4.4 |
michael@0 | 299 | */ |
michael@0 | 300 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUBreakIteratorPointer, UBreakIterator, ubrk_close); |
michael@0 | 301 | |
michael@0 | 302 | U_NAMESPACE_END |
michael@0 | 303 | |
michael@0 | 304 | #endif |
michael@0 | 305 | |
michael@0 | 306 | /** |
michael@0 | 307 | * Sets an existing iterator to point to a new piece of text |
michael@0 | 308 | * @param bi The iterator to use |
michael@0 | 309 | * @param text The text to be set |
michael@0 | 310 | * @param textLength The length of the text |
michael@0 | 311 | * @param status The error code |
michael@0 | 312 | * @stable ICU 2.0 |
michael@0 | 313 | */ |
michael@0 | 314 | U_STABLE void U_EXPORT2 |
michael@0 | 315 | ubrk_setText(UBreakIterator* bi, |
michael@0 | 316 | const UChar* text, |
michael@0 | 317 | int32_t textLength, |
michael@0 | 318 | UErrorCode* status); |
michael@0 | 319 | |
michael@0 | 320 | |
michael@0 | 321 | /** |
michael@0 | 322 | * Sets an existing iterator to point to a new piece of text. |
michael@0 | 323 | * |
michael@0 | 324 | * All index positions returned by break iterator functions are |
michael@0 | 325 | * native indices from the UText. For example, when breaking UTF-8 |
michael@0 | 326 | * encoded text, the break positions returned by \ref ubrk_next, \ref ubrk_previous, etc. |
michael@0 | 327 | * will be UTF-8 string indices, not UTF-16 positions. |
michael@0 | 328 | * |
michael@0 | 329 | * @param bi The iterator to use |
michael@0 | 330 | * @param text The text to be set. |
michael@0 | 331 | * This function makes a shallow clone of the supplied UText. This means |
michael@0 | 332 | * that the caller is free to immediately close or otherwise reuse the |
michael@0 | 333 | * UText that was passed as a parameter, but that the underlying text itself |
michael@0 | 334 | * must not be altered while being referenced by the break iterator. |
michael@0 | 335 | * @param status The error code |
michael@0 | 336 | * @stable ICU 3.4 |
michael@0 | 337 | */ |
michael@0 | 338 | U_STABLE void U_EXPORT2 |
michael@0 | 339 | ubrk_setUText(UBreakIterator* bi, |
michael@0 | 340 | UText* text, |
michael@0 | 341 | UErrorCode* status); |
michael@0 | 342 | |
michael@0 | 343 | |
michael@0 | 344 | |
michael@0 | 345 | /** |
michael@0 | 346 | * Determine the most recently-returned text boundary. |
michael@0 | 347 | * |
michael@0 | 348 | * @param bi The break iterator to use. |
michael@0 | 349 | * @return The character index most recently returned by \ref ubrk_next, \ref ubrk_previous, |
michael@0 | 350 | * \ref ubrk_first, or \ref ubrk_last. |
michael@0 | 351 | * @stable ICU 2.0 |
michael@0 | 352 | */ |
michael@0 | 353 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 354 | ubrk_current(const UBreakIterator *bi); |
michael@0 | 355 | |
michael@0 | 356 | /** |
michael@0 | 357 | * Advance the iterator to the boundary following the current boundary. |
michael@0 | 358 | * |
michael@0 | 359 | * @param bi The break iterator to use. |
michael@0 | 360 | * @return The character index of the next text boundary, or UBRK_DONE |
michael@0 | 361 | * if all text boundaries have been returned. |
michael@0 | 362 | * @see ubrk_previous |
michael@0 | 363 | * @stable ICU 2.0 |
michael@0 | 364 | */ |
michael@0 | 365 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 366 | ubrk_next(UBreakIterator *bi); |
michael@0 | 367 | |
michael@0 | 368 | /** |
michael@0 | 369 | * Set the iterator position to the boundary preceding the current boundary. |
michael@0 | 370 | * |
michael@0 | 371 | * @param bi The break iterator to use. |
michael@0 | 372 | * @return The character index of the preceding text boundary, or UBRK_DONE |
michael@0 | 373 | * if all text boundaries have been returned. |
michael@0 | 374 | * @see ubrk_next |
michael@0 | 375 | * @stable ICU 2.0 |
michael@0 | 376 | */ |
michael@0 | 377 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 378 | ubrk_previous(UBreakIterator *bi); |
michael@0 | 379 | |
michael@0 | 380 | /** |
michael@0 | 381 | * Set the iterator position to the index of the first character in the text being scanned. |
michael@0 | 382 | * This is not always the same as index 0 of the text. |
michael@0 | 383 | * @param bi The break iterator to use. |
michael@0 | 384 | * @return The character index of the first character in the text being scanned. |
michael@0 | 385 | * @see ubrk_last |
michael@0 | 386 | * @stable ICU 2.0 |
michael@0 | 387 | */ |
michael@0 | 388 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 389 | ubrk_first(UBreakIterator *bi); |
michael@0 | 390 | |
michael@0 | 391 | /** |
michael@0 | 392 | * Set the iterator position to the index immediately <EM>beyond</EM> the last character in the text being scanned. |
michael@0 | 393 | * This is not the same as the last character. |
michael@0 | 394 | * @param bi The break iterator to use. |
michael@0 | 395 | * @return The character offset immediately <EM>beyond</EM> the last character in the |
michael@0 | 396 | * text being scanned. |
michael@0 | 397 | * @see ubrk_first |
michael@0 | 398 | * @stable ICU 2.0 |
michael@0 | 399 | */ |
michael@0 | 400 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 401 | ubrk_last(UBreakIterator *bi); |
michael@0 | 402 | |
michael@0 | 403 | /** |
michael@0 | 404 | * Set the iterator position to the first boundary preceding the specified offset. |
michael@0 | 405 | * The new position is always smaller than offset, or UBRK_DONE. |
michael@0 | 406 | * @param bi The break iterator to use. |
michael@0 | 407 | * @param offset The offset to begin scanning. |
michael@0 | 408 | * @return The text boundary preceding offset, or UBRK_DONE. |
michael@0 | 409 | * @see ubrk_following |
michael@0 | 410 | * @stable ICU 2.0 |
michael@0 | 411 | */ |
michael@0 | 412 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 413 | ubrk_preceding(UBreakIterator *bi, |
michael@0 | 414 | int32_t offset); |
michael@0 | 415 | |
michael@0 | 416 | /** |
michael@0 | 417 | * Advance the iterator to the first boundary following the specified offset. |
michael@0 | 418 | * The value returned is always greater than offset, or UBRK_DONE. |
michael@0 | 419 | * @param bi The break iterator to use. |
michael@0 | 420 | * @param offset The offset to begin scanning. |
michael@0 | 421 | * @return The text boundary following offset, or UBRK_DONE. |
michael@0 | 422 | * @see ubrk_preceding |
michael@0 | 423 | * @stable ICU 2.0 |
michael@0 | 424 | */ |
michael@0 | 425 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 426 | ubrk_following(UBreakIterator *bi, |
michael@0 | 427 | int32_t offset); |
michael@0 | 428 | |
michael@0 | 429 | /** |
michael@0 | 430 | * Get a locale for which text breaking information is available. |
michael@0 | 431 | * A UBreakIterator in a locale returned by this function will perform the correct |
michael@0 | 432 | * text breaking for the locale. |
michael@0 | 433 | * @param index The index of the desired locale. |
michael@0 | 434 | * @return A locale for which number text breaking information is available, or 0 if none. |
michael@0 | 435 | * @see ubrk_countAvailable |
michael@0 | 436 | * @stable ICU 2.0 |
michael@0 | 437 | */ |
michael@0 | 438 | U_STABLE const char* U_EXPORT2 |
michael@0 | 439 | ubrk_getAvailable(int32_t index); |
michael@0 | 440 | |
michael@0 | 441 | /** |
michael@0 | 442 | * Determine how many locales have text breaking information available. |
michael@0 | 443 | * This function is most useful as determining the loop ending condition for |
michael@0 | 444 | * calls to \ref ubrk_getAvailable. |
michael@0 | 445 | * @return The number of locales for which text breaking information is available. |
michael@0 | 446 | * @see ubrk_getAvailable |
michael@0 | 447 | * @stable ICU 2.0 |
michael@0 | 448 | */ |
michael@0 | 449 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 450 | ubrk_countAvailable(void); |
michael@0 | 451 | |
michael@0 | 452 | |
michael@0 | 453 | /** |
michael@0 | 454 | * Returns true if the specfied position is a boundary position. As a side |
michael@0 | 455 | * effect, leaves the iterator pointing to the first boundary position at |
michael@0 | 456 | * or after "offset". |
michael@0 | 457 | * @param bi The break iterator to use. |
michael@0 | 458 | * @param offset the offset to check. |
michael@0 | 459 | * @return True if "offset" is a boundary position. |
michael@0 | 460 | * @stable ICU 2.0 |
michael@0 | 461 | */ |
michael@0 | 462 | U_STABLE UBool U_EXPORT2 |
michael@0 | 463 | ubrk_isBoundary(UBreakIterator *bi, int32_t offset); |
michael@0 | 464 | |
michael@0 | 465 | /** |
michael@0 | 466 | * Return the status from the break rule that determined the most recently |
michael@0 | 467 | * returned break position. The values appear in the rule source |
michael@0 | 468 | * within brackets, {123}, for example. For rules that do not specify a |
michael@0 | 469 | * status, a default value of 0 is returned. |
michael@0 | 470 | * <p> |
michael@0 | 471 | * For word break iterators, the possible values are defined in enum UWordBreak. |
michael@0 | 472 | * @stable ICU 2.2 |
michael@0 | 473 | */ |
michael@0 | 474 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 475 | ubrk_getRuleStatus(UBreakIterator *bi); |
michael@0 | 476 | |
michael@0 | 477 | /** |
michael@0 | 478 | * Get the statuses from the break rules that determined the most recently |
michael@0 | 479 | * returned break position. The values appear in the rule source |
michael@0 | 480 | * within brackets, {123}, for example. The default status value for rules |
michael@0 | 481 | * that do not explicitly provide one is zero. |
michael@0 | 482 | * <p> |
michael@0 | 483 | * For word break iterators, the possible values are defined in enum UWordBreak. |
michael@0 | 484 | * @param bi The break iterator to use |
michael@0 | 485 | * @param fillInVec an array to be filled in with the status values. |
michael@0 | 486 | * @param capacity the length of the supplied vector. A length of zero causes |
michael@0 | 487 | * the function to return the number of status values, in the |
michael@0 | 488 | * normal way, without attemtping to store any values. |
michael@0 | 489 | * @param status receives error codes. |
michael@0 | 490 | * @return The number of rule status values from rules that determined |
michael@0 | 491 | * the most recent boundary returned by the break iterator. |
michael@0 | 492 | * @stable ICU 3.0 |
michael@0 | 493 | */ |
michael@0 | 494 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 495 | ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status); |
michael@0 | 496 | |
michael@0 | 497 | /** |
michael@0 | 498 | * Return the locale of the break iterator. You can choose between the valid and |
michael@0 | 499 | * the actual locale. |
michael@0 | 500 | * @param bi break iterator |
michael@0 | 501 | * @param type locale type (valid or actual) |
michael@0 | 502 | * @param status error code |
michael@0 | 503 | * @return locale string |
michael@0 | 504 | * @stable ICU 2.8 |
michael@0 | 505 | */ |
michael@0 | 506 | U_STABLE const char* U_EXPORT2 |
michael@0 | 507 | ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status); |
michael@0 | 508 | |
michael@0 | 509 | /** |
michael@0 | 510 | * Set the subject text string upon which the break iterator is operating |
michael@0 | 511 | * without changing any other aspect of the state. |
michael@0 | 512 | * The new and previous text strings must have the same content. |
michael@0 | 513 | * |
michael@0 | 514 | * This function is intended for use in environments where ICU is operating on |
michael@0 | 515 | * strings that may move around in memory. It provides a mechanism for notifying |
michael@0 | 516 | * ICU that the string has been relocated, and providing a new UText to access the |
michael@0 | 517 | * string in its new position. |
michael@0 | 518 | * |
michael@0 | 519 | * Note that the break iterator never copies the underlying text |
michael@0 | 520 | * of a string being processed, but always operates directly on the original text |
michael@0 | 521 | * provided by the user. Refreshing simply drops the references to the old text |
michael@0 | 522 | * and replaces them with references to the new. |
michael@0 | 523 | * |
michael@0 | 524 | * Caution: this function is normally used only by very specialized |
michael@0 | 525 | * system-level code. One example use case is with garbage collection |
michael@0 | 526 | * that moves the text in memory. |
michael@0 | 527 | * |
michael@0 | 528 | * @param bi The break iterator. |
michael@0 | 529 | * @param text The new (moved) text string. |
michael@0 | 530 | * @param status Receives errors detected by this function. |
michael@0 | 531 | * |
michael@0 | 532 | * @stable ICU 49 |
michael@0 | 533 | */ |
michael@0 | 534 | U_STABLE void U_EXPORT2 |
michael@0 | 535 | ubrk_refreshUText(UBreakIterator *bi, |
michael@0 | 536 | UText *text, |
michael@0 | 537 | UErrorCode *status); |
michael@0 | 538 | |
michael@0 | 539 | #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ |
michael@0 | 540 | |
michael@0 | 541 | #endif |