1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/brkiter.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,668 @@
1.4 +/*
1.5 +********************************************************************************
1.6 +* Copyright (C) 1997-2005, International Business Machines
1.7 +* Corporation and others. All Rights Reserved.
1.8 +********************************************************************************
1.9 +*
1.10 +* File brkiter.h
1.11 +*
1.12 +* Modification History:
1.13 +*
1.14 +* Date Name Description
1.15 +* 02/18/97 aliu Added typedef for TextCount. Made DONE const.
1.16 +* 05/07/97 aliu Fixed DLL declaration.
1.17 +* 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK
1.18 +* 08/11/98 helena Sync-up JDK1.2.
1.19 +* 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods.
1.20 +********************************************************************************
1.21 +*/
1.22 +
1.23 +#ifndef BRKITER_H
1.24 +#define BRKITER_H
1.25 +
1.26 +#include "unicode/utypes.h"
1.27 +
1.28 +/**
1.29 + * \file
1.30 + * \brief C++ API: Break Iterator.
1.31 + */
1.32 +
1.33 +#if UCONFIG_NO_BREAK_ITERATION
1.34 +
1.35 +U_NAMESPACE_BEGIN
1.36 +
1.37 +/*
1.38 + * Allow the declaration of APIs with pointers to BreakIterator
1.39 + * even when break iteration is removed from the build.
1.40 + */
1.41 +class BreakIterator;
1.42 +
1.43 +U_NAMESPACE_END
1.44 +
1.45 +#else
1.46 +
1.47 +#include "unicode/uobject.h"
1.48 +#include "unicode/unistr.h"
1.49 +#include "unicode/chariter.h"
1.50 +#include "unicode/locid.h"
1.51 +#include "unicode/ubrk.h"
1.52 +#include "unicode/strenum.h"
1.53 +#include "unicode/utext.h"
1.54 +
1.55 +U_NAMESPACE_BEGIN
1.56 +
1.57 +#if !UCONFIG_NO_SERVICE
1.58 +/**
1.59 + * Opaque type returned by registerInstance.
1.60 + * @stable
1.61 + */
1.62 +typedef const void* URegistryKey;
1.63 +#endif
1.64 +
1.65 +/**
1.66 + * The BreakIterator class implements methods for finding the location
1.67 + * of boundaries in text. BreakIterator is an abstract base class.
1.68 + * Instances of BreakIterator maintain a current position and scan over
1.69 + * text returning the index of characters where boundaries occur.
1.70 + * <P>
1.71 + * Line boundary analysis determines where a text string can be broken
1.72 + * when line-wrapping. The mechanism correctly handles punctuation and
1.73 + * hyphenated words.
1.74 + * <P>
1.75 + * Sentence boundary analysis allows selection with correct
1.76 + * interpretation of periods within numbers and abbreviations, and
1.77 + * trailing punctuation marks such as quotation marks and parentheses.
1.78 + * <P>
1.79 + * Word boundary analysis is used by search and replace functions, as
1.80 + * well as within text editing applications that allow the user to
1.81 + * select words with a double click. Word selection provides correct
1.82 + * interpretation of punctuation marks within and following
1.83 + * words. Characters that are not part of a word, such as symbols or
1.84 + * punctuation marks, have word-breaks on both sides.
1.85 + * <P>
1.86 + * Character boundary analysis allows users to interact with
1.87 + * characters as they expect to, for example, when moving the cursor
1.88 + * through a text string. Character boundary analysis provides correct
1.89 + * navigation of through character strings, regardless of how the
1.90 + * character is stored. For example, an accented character might be
1.91 + * stored as a base character and a diacritical mark. What users
1.92 + * consider to be a character can differ between languages.
1.93 + * <P>
1.94 + * This is the interface for all text boundaries.
1.95 + * <P>
1.96 + * Examples:
1.97 + * <P>
1.98 + * Helper function to output text
1.99 + * <pre>
1.100 + * \code
1.101 + * void printTextRange( BreakIterator& iterator, int32_t start, int32_t end )
1.102 + * {
1.103 + * UnicodeString textBuffer, temp;
1.104 + * CharacterIterator *strIter = iterator.createText();
1.105 + * strIter->getText(temp);
1.106 + * cout << " " << start << " " << end << " |"
1.107 + * << temp.extractBetween(start, end, textBuffer)
1.108 + * << "|" << endl;
1.109 + * delete strIter;
1.110 + * }
1.111 + * \endcode
1.112 + * </pre>
1.113 + * Print each element in order:
1.114 + * <pre>
1.115 + * \code
1.116 + * void printEachForward( BreakIterator& boundary)
1.117 + * {
1.118 + * int32_t start = boundary.first();
1.119 + * for (int32_t end = boundary.next();
1.120 + * end != BreakIterator::DONE;
1.121 + * start = end, end = boundary.next())
1.122 + * {
1.123 + * printTextRange( boundary, start, end );
1.124 + * }
1.125 + * }
1.126 + * \endcode
1.127 + * </pre>
1.128 + * Print each element in reverse order:
1.129 + * <pre>
1.130 + * \code
1.131 + * void printEachBackward( BreakIterator& boundary)
1.132 + * {
1.133 + * int32_t end = boundary.last();
1.134 + * for (int32_t start = boundary.previous();
1.135 + * start != BreakIterator::DONE;
1.136 + * end = start, start = boundary.previous())
1.137 + * {
1.138 + * printTextRange( boundary, start, end );
1.139 + * }
1.140 + * }
1.141 + * \endcode
1.142 + * </pre>
1.143 + * Print first element
1.144 + * <pre>
1.145 + * \code
1.146 + * void printFirst(BreakIterator& boundary)
1.147 + * {
1.148 + * int32_t start = boundary.first();
1.149 + * int32_t end = boundary.next();
1.150 + * printTextRange( boundary, start, end );
1.151 + * }
1.152 + * \endcode
1.153 + * </pre>
1.154 + * Print last element
1.155 + * <pre>
1.156 + * \code
1.157 + * void printLast(BreakIterator& boundary)
1.158 + * {
1.159 + * int32_t end = boundary.last();
1.160 + * int32_t start = boundary.previous();
1.161 + * printTextRange( boundary, start, end );
1.162 + * }
1.163 + * \endcode
1.164 + * </pre>
1.165 + * Print the element at a specified position
1.166 + * <pre>
1.167 + * \code
1.168 + * void printAt(BreakIterator &boundary, int32_t pos )
1.169 + * {
1.170 + * int32_t end = boundary.following(pos);
1.171 + * int32_t start = boundary.previous();
1.172 + * printTextRange( boundary, start, end );
1.173 + * }
1.174 + * \endcode
1.175 + * </pre>
1.176 + * Creating and using text boundaries
1.177 + * <pre>
1.178 + * \code
1.179 + * void BreakIterator_Example( void )
1.180 + * {
1.181 + * BreakIterator* boundary;
1.182 + * UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff.");
1.183 + * cout << "Examining: " << stringToExamine << endl;
1.184 + *
1.185 + * //print each sentence in forward and reverse order
1.186 + * boundary = BreakIterator::createSentenceInstance( Locale::US );
1.187 + * boundary->setText(stringToExamine);
1.188 + * cout << "----- forward: -----------" << endl;
1.189 + * printEachForward(*boundary);
1.190 + * cout << "----- backward: ----------" << endl;
1.191 + * printEachBackward(*boundary);
1.192 + * delete boundary;
1.193 + *
1.194 + * //print each word in order
1.195 + * boundary = BreakIterator::createWordInstance();
1.196 + * boundary->setText(stringToExamine);
1.197 + * cout << "----- forward: -----------" << endl;
1.198 + * printEachForward(*boundary);
1.199 + * //print first element
1.200 + * cout << "----- first: -------------" << endl;
1.201 + * printFirst(*boundary);
1.202 + * //print last element
1.203 + * cout << "----- last: --------------" << endl;
1.204 + * printLast(*boundary);
1.205 + * //print word at charpos 10
1.206 + * cout << "----- at pos 10: ---------" << endl;
1.207 + * printAt(*boundary, 10 );
1.208 + *
1.209 + * delete boundary;
1.210 + * }
1.211 + * \endcode
1.212 + * </pre>
1.213 + */
1.214 +class U_COMMON_API BreakIterator : public UObject {
1.215 +public:
1.216 + /**
1.217 + * destructor
1.218 + * @stable ICU 2.0
1.219 + */
1.220 + virtual ~BreakIterator();
1.221 +
1.222 + /**
1.223 + * Return true if another object is semantically equal to this
1.224 + * one. The other object should be an instance of the same subclass of
1.225 + * BreakIterator. Objects of different subclasses are considered
1.226 + * unequal.
1.227 + * <P>
1.228 + * Return true if this BreakIterator is at the same position in the
1.229 + * same text, and is the same class and type (word, line, etc.) of
1.230 + * BreakIterator, as the argument. Text is considered the same if
1.231 + * it contains the same characters, it need not be the same
1.232 + * object, and styles are not considered.
1.233 + * @stable ICU 2.0
1.234 + */
1.235 + virtual UBool operator==(const BreakIterator&) const = 0;
1.236 +
1.237 + /**
1.238 + * Returns the complement of the result of operator==
1.239 + * @param rhs The BreakIterator to be compared for inequality
1.240 + * @return the complement of the result of operator==
1.241 + * @stable ICU 2.0
1.242 + */
1.243 + UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
1.244 +
1.245 + /**
1.246 + * Return a polymorphic copy of this object. This is an abstract
1.247 + * method which subclasses implement.
1.248 + * @stable ICU 2.0
1.249 + */
1.250 + virtual BreakIterator* clone(void) const = 0;
1.251 +
1.252 + /**
1.253 + * Return a polymorphic class ID for this object. Different subclasses
1.254 + * will return distinct unequal values.
1.255 + * @stable ICU 2.0
1.256 + */
1.257 + virtual UClassID getDynamicClassID(void) const = 0;
1.258 +
1.259 + /**
1.260 + * Return a CharacterIterator over the text being analyzed.
1.261 + * Changing the state of the returned iterator can have undefined consequences
1.262 + * on the operation of the break iterator. If you need to change it, clone it first.
1.263 + * @stable ICU 2.0
1.264 + */
1.265 + virtual const CharacterIterator& getText(void) const = 0;
1.266 +
1.267 +
1.268 + /**
1.269 + * Get a UText for the text being analyzed.
1.270 + * The returned UText is a shallow clone of the UText used internally
1.271 + * by the break iterator implementation. It can safely be used to
1.272 + * access the text without impacting any break iterator operations,
1.273 + * but the underlying text itself must not be altered.
1.274 + *
1.275 + * @param fillIn A UText to be filled in. If NULL, a new UText will be
1.276 + * allocated to hold the result.
1.277 + * @param status receives any error codes.
1.278 + * @return The current UText for this break iterator. If an input
1.279 + * UText was provided, it will always be returned.
1.280 + * @draft ICU 3.4
1.281 + */
1.282 + virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
1.283 +
1.284 + /**
1.285 + * Change the text over which this operates. The text boundary is
1.286 + * reset to the start.
1.287 + * @param text The UnicodeString used to change the text.
1.288 + * @stable ICU 2.0
1.289 + */
1.290 + virtual void setText(const UnicodeString &text) = 0;
1.291 +
1.292 + /**
1.293 + * Reset the break iterator to operate over the text represented by
1.294 + * the UText. The iterator position is reset to the start.
1.295 + *
1.296 + * This function makes a shallow clone of the supplied UText. This means
1.297 + * that the caller is free to immediately close or otherwise reuse the
1.298 + * Utext that was passed as a parameter, but that the underlying text itself
1.299 + * must not be altered while being referenced by the break iterator.
1.300 + *
1.301 + * @param text The UText used to change the text.
1.302 + * @param status receives any error codes.
1.303 + * @draft ICU 3.4
1.304 + */
1.305 + virtual void setText(UText *text, UErrorCode &status) = 0;
1.306 +
1.307 + /**
1.308 + * Change the text over which this operates. The text boundary is
1.309 + * reset to the start.
1.310 + * @param it The CharacterIterator used to change the text.
1.311 + * @stable ICU 2.0
1.312 + */
1.313 + virtual void adoptText(CharacterIterator* it) = 0;
1.314 +
1.315 + enum {
1.316 + /**
1.317 + * DONE is returned by previous() and next() after all valid
1.318 + * boundaries have been returned.
1.319 + * @stable ICU 2.0
1.320 + */
1.321 + DONE = (int32_t)-1
1.322 + };
1.323 +
1.324 + /**
1.325 + * Return the index of the first character in the text being scanned.
1.326 + * @stable ICU 2.0
1.327 + */
1.328 + virtual int32_t first(void) = 0;
1.329 +
1.330 + /**
1.331 + * Return the index immediately BEYOND the last character in the text being scanned.
1.332 + * @stable ICU 2.0
1.333 + */
1.334 + virtual int32_t last(void) = 0;
1.335 +
1.336 + /**
1.337 + * Return the boundary preceding the current boundary.
1.338 + * @return The character index of the previous text boundary or DONE if all
1.339 + * boundaries have been returned.
1.340 + * @stable ICU 2.0
1.341 + */
1.342 + virtual int32_t previous(void) = 0;
1.343 +
1.344 + /**
1.345 + * Return the boundary following the current boundary.
1.346 + * @return The character index of the next text boundary or DONE if all
1.347 + * boundaries have been returned.
1.348 + * @stable ICU 2.0
1.349 + */
1.350 + virtual int32_t next(void) = 0;
1.351 +
1.352 + /**
1.353 + * Return character index of the current interator position within the text.
1.354 + * @return The boundary most recently returned.
1.355 + * @stable ICU 2.0
1.356 + */
1.357 + virtual int32_t current(void) const = 0;
1.358 +
1.359 + /**
1.360 + * Return the first boundary following the specified offset.
1.361 + * The value returned is always greater than the offset or
1.362 + * the value BreakIterator.DONE
1.363 + * @param offset the offset to begin scanning.
1.364 + * @return The first boundary after the specified offset.
1.365 + * @stable ICU 2.0
1.366 + */
1.367 + virtual int32_t following(int32_t offset) = 0;
1.368 +
1.369 + /**
1.370 + * Return the first boundary preceding the specified offset.
1.371 + * The value returned is always smaller than the offset or
1.372 + * the value BreakIterator.DONE
1.373 + * @param offset the offset to begin scanning.
1.374 + * @return The first boundary before the specified offset.
1.375 + * @stable ICU 2.0
1.376 + */
1.377 + virtual int32_t preceding(int32_t offset) = 0;
1.378 +
1.379 + /**
1.380 + * Return true if the specfied position is a boundary position.
1.381 + * As a side effect, the current position of the iterator is set
1.382 + * to the first boundary position at or following the specified offset.
1.383 + * @param offset the offset to check.
1.384 + * @return True if "offset" is a boundary position.
1.385 + * @stable ICU 2.0
1.386 + */
1.387 + virtual UBool isBoundary(int32_t offset) = 0;
1.388 +
1.389 + /**
1.390 + * Return the nth boundary from the current boundary
1.391 + * @param n which boundary to return. A value of 0
1.392 + * does nothing. Negative values move to previous boundaries
1.393 + * and positive values move to later boundaries.
1.394 + * @return The index of the nth boundary from the current position, or
1.395 + * DONE if there are fewer than |n| boundaries in the specfied direction.
1.396 + * @stable ICU 2.0
1.397 + */
1.398 + virtual int32_t next(int32_t n) = 0;
1.399 +
1.400 + /**
1.401 + * Create BreakIterator for word-breaks using the given locale.
1.402 + * Returns an instance of a BreakIterator implementing word breaks.
1.403 + * WordBreak is useful for word selection (ex. double click)
1.404 + * @param where the locale.
1.405 + * @param status the error code
1.406 + * @return A BreakIterator for word-breaks. The UErrorCode& status
1.407 + * parameter is used to return status information to the user.
1.408 + * To check whether the construction succeeded or not, you should check
1.409 + * the value of U_SUCCESS(err). If you wish more detailed information, you
1.410 + * can check for informational error results which still indicate success.
1.411 + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
1.412 + * example, 'de_CH' was requested, but nothing was found there, so 'de' was
1.413 + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was
1.414 + * used; neither the requested locale nor any of its fall back locales
1.415 + * could be found.
1.416 + * The caller owns the returned object and is responsible for deleting it.
1.417 + * @stable ICU 2.0
1.418 + */
1.419 + static BreakIterator* U_EXPORT2
1.420 + createWordInstance(const Locale& where, UErrorCode& status);
1.421 +
1.422 + /**
1.423 + * Create BreakIterator for line-breaks using specified locale.
1.424 + * Returns an instance of a BreakIterator implementing line breaks. Line
1.425 + * breaks are logically possible line breaks, actual line breaks are
1.426 + * usually determined based on display width.
1.427 + * LineBreak is useful for word wrapping text.
1.428 + * @param where the locale.
1.429 + * @param status The error code.
1.430 + * @return A BreakIterator for line-breaks. The UErrorCode& status
1.431 + * parameter is used to return status information to the user.
1.432 + * To check whether the construction succeeded or not, you should check
1.433 + * the value of U_SUCCESS(err). If you wish more detailed information, you
1.434 + * can check for informational error results which still indicate success.
1.435 + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
1.436 + * example, 'de_CH' was requested, but nothing was found there, so 'de' was
1.437 + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was
1.438 + * used; neither the requested locale nor any of its fall back locales
1.439 + * could be found.
1.440 + * The caller owns the returned object and is responsible for deleting it.
1.441 + * @stable ICU 2.0
1.442 + */
1.443 + static BreakIterator* U_EXPORT2
1.444 + createLineInstance(const Locale& where, UErrorCode& status);
1.445 +
1.446 + /**
1.447 + * Create BreakIterator for character-breaks using specified locale
1.448 + * Returns an instance of a BreakIterator implementing character breaks.
1.449 + * Character breaks are boundaries of combining character sequences.
1.450 + * @param where the locale.
1.451 + * @param status The error code.
1.452 + * @return A BreakIterator for character-breaks. The UErrorCode& status
1.453 + * parameter is used to return status information to the user.
1.454 + * To check whether the construction succeeded or not, you should check
1.455 + * the value of U_SUCCESS(err). If you wish more detailed information, you
1.456 + * can check for informational error results which still indicate success.
1.457 + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
1.458 + * example, 'de_CH' was requested, but nothing was found there, so 'de' was
1.459 + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was
1.460 + * used; neither the requested locale nor any of its fall back locales
1.461 + * could be found.
1.462 + * The caller owns the returned object and is responsible for deleting it.
1.463 + * @stable ICU 2.0
1.464 + */
1.465 + static BreakIterator* U_EXPORT2
1.466 + createCharacterInstance(const Locale& where, UErrorCode& status);
1.467 +
1.468 + /**
1.469 + * Create BreakIterator for sentence-breaks using specified locale
1.470 + * Returns an instance of a BreakIterator implementing sentence breaks.
1.471 + * @param where the locale.
1.472 + * @param status The error code.
1.473 + * @return A BreakIterator for sentence-breaks. The UErrorCode& status
1.474 + * parameter is used to return status information to the user.
1.475 + * To check whether the construction succeeded or not, you should check
1.476 + * the value of U_SUCCESS(err). If you wish more detailed information, you
1.477 + * can check for informational error results which still indicate success.
1.478 + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
1.479 + * example, 'de_CH' was requested, but nothing was found there, so 'de' was
1.480 + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was
1.481 + * used; neither the requested locale nor any of its fall back locales
1.482 + * could be found.
1.483 + * The caller owns the returned object and is responsible for deleting it.
1.484 + * @stable ICU 2.0
1.485 + */
1.486 + static BreakIterator* U_EXPORT2
1.487 + createSentenceInstance(const Locale& where, UErrorCode& status);
1.488 +
1.489 + /**
1.490 + * Create BreakIterator for title-casing breaks using the specified locale
1.491 + * Returns an instance of a BreakIterator implementing title breaks.
1.492 + * The iterator returned locates title boundaries as described for
1.493 + * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
1.494 + * please use Word Boundary iterator.{@link #createWordInstance }
1.495 + *
1.496 + * @param where the locale.
1.497 + * @param status The error code.
1.498 + * @return A BreakIterator for title-breaks. The UErrorCode& status
1.499 + * parameter is used to return status information to the user.
1.500 + * To check whether the construction succeeded or not, you should check
1.501 + * the value of U_SUCCESS(err). If you wish more detailed information, you
1.502 + * can check for informational error results which still indicate success.
1.503 + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
1.504 + * example, 'de_CH' was requested, but nothing was found there, so 'de' was
1.505 + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was
1.506 + * used; neither the requested locale nor any of its fall back locales
1.507 + * could be found.
1.508 + * The caller owns the returned object and is responsible for deleting it.
1.509 + * @stable ICU 2.1
1.510 + */
1.511 + static BreakIterator* U_EXPORT2
1.512 + createTitleInstance(const Locale& where, UErrorCode& status);
1.513 +
1.514 + /**
1.515 + * Get the set of Locales for which TextBoundaries are installed.
1.516 + * <p><b>Note:</b> this will not return locales added through the register
1.517 + * call. To see the registered locales too, use the getAvailableLocales
1.518 + * function that returns a StringEnumeration object </p>
1.519 + * @param count the output parameter of number of elements in the locale list
1.520 + * @return available locales
1.521 + * @stable ICU 2.0
1.522 + */
1.523 + static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
1.524 +
1.525 + /**
1.526 + * Get name of the object for the desired Locale, in the desired langauge.
1.527 + * @param objectLocale must be from getAvailableLocales.
1.528 + * @param displayLocale specifies the desired locale for output.
1.529 + * @param name the fill-in parameter of the return value
1.530 + * Uses best match.
1.531 + * @return user-displayable name
1.532 + * @stable ICU 2.0
1.533 + */
1.534 + static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
1.535 + const Locale& displayLocale,
1.536 + UnicodeString& name);
1.537 +
1.538 + /**
1.539 + * Get name of the object for the desired Locale, in the langauge of the
1.540 + * default locale.
1.541 + * @param objectLocale must be from getMatchingLocales
1.542 + * @param name the fill-in parameter of the return value
1.543 + * @return user-displayable name
1.544 + * @stable ICU 2.0
1.545 + */
1.546 + static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
1.547 + UnicodeString& name);
1.548 +
1.549 + /**
1.550 + * Thread safe client-buffer-based cloning operation
1.551 + * Do NOT call delete on a safeclone, since 'new' is not used to create it.
1.552 + * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.
1.553 + * If buffer is not large enough, new memory will be allocated.
1.554 + * @param BufferSize reference to size of allocated space.
1.555 + * If BufferSize == 0, a sufficient size for use in cloning will
1.556 + * be returned ('pre-flighting')
1.557 + * If BufferSize is not enough for a stack-based safe clone,
1.558 + * new memory will be allocated.
1.559 + * @param status to indicate whether the operation went on smoothly or there were errors
1.560 + * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were
1.561 + * necessary.
1.562 + * @return pointer to the new clone
1.563 + *
1.564 + * @stable ICU 2.0
1.565 + */
1.566 + virtual BreakIterator * createBufferClone(void *stackBuffer,
1.567 + int32_t &BufferSize,
1.568 + UErrorCode &status) = 0;
1.569 +
1.570 + /**
1.571 + * Determine whether the BreakIterator was created in user memory by
1.572 + * createBufferClone(), and thus should not be deleted. Such objects
1.573 + * must be closed by an explicit call to the destructor (not delete).
1.574 + * @stable ICU 2.0
1.575 + */
1.576 + inline UBool isBufferClone(void);
1.577 +
1.578 +#if !UCONFIG_NO_SERVICE
1.579 + /**
1.580 + * Register a new break iterator of the indicated kind, to use in the given locale.
1.581 + * The break iterator will be adopted. Clones of the iterator will be returned
1.582 + * if a request for a break iterator of the given kind matches or falls back to
1.583 + * this locale.
1.584 + * @param toAdopt the BreakIterator instance to be adopted
1.585 + * @param locale the Locale for which this instance is to be registered
1.586 + * @param kind the type of iterator for which this instance is to be registered
1.587 + * @param status the in/out status code, no special meanings are assigned
1.588 + * @return a registry key that can be used to unregister this instance
1.589 + * @stable ICU 2.4
1.590 + */
1.591 + static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
1.592 + const Locale& locale,
1.593 + UBreakIteratorType kind,
1.594 + UErrorCode& status);
1.595 +
1.596 + /**
1.597 + * Unregister a previously-registered BreakIterator using the key returned from the
1.598 + * register call. Key becomes invalid after a successful call and should not be used again.
1.599 + * The BreakIterator corresponding to the key will be deleted.
1.600 + * @param key the registry key returned by a previous call to registerInstance
1.601 + * @param status the in/out status code, no special meanings are assigned
1.602 + * @return TRUE if the iterator for the key was successfully unregistered
1.603 + * @stable ICU 2.4
1.604 + */
1.605 + static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
1.606 +
1.607 + /**
1.608 + * Return a StringEnumeration over the locales available at the time of the call,
1.609 + * including registered locales.
1.610 + * @return a StringEnumeration over the locales available at the time of the call
1.611 + * @stable ICU 2.4
1.612 + */
1.613 + static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
1.614 +#endif
1.615 +
1.616 + /**
1.617 + * Returns the locale for this break iterator. Two flavors are available: valid and
1.618 + * actual locale.
1.619 + * @draft ICU 2.8 likely to change after ICU 3.0, based on feedback
1.620 + */
1.621 + Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
1.622 +
1.623 + /** Get the locale for this break iterator object. You can choose between valid and actual locale.
1.624 + * @param type type of the locale we're looking for (valid or actual)
1.625 + * @param status error code for the operation
1.626 + * @return the locale
1.627 + * @internal
1.628 + */
1.629 + const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
1.630 +
1.631 + private:
1.632 + static BreakIterator* buildInstance(const Locale& loc, const char *type, UBool dict, UErrorCode& status);
1.633 + static BreakIterator* createInstance(const Locale& loc, UBreakIteratorType kind, UErrorCode& status);
1.634 + static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
1.635 +
1.636 + friend class ICUBreakIteratorFactory;
1.637 + friend class ICUBreakIteratorService;
1.638 +
1.639 +protected:
1.640 + /** @internal */
1.641 + BreakIterator();
1.642 + /** @internal */
1.643 + UBool fBufferClone;
1.644 + /** @internal */
1.645 + BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
1.646 +
1.647 +private:
1.648 +
1.649 + /** @internal */
1.650 + char actualLocale[ULOC_FULLNAME_CAPACITY];
1.651 + char validLocale[ULOC_FULLNAME_CAPACITY];
1.652 +
1.653 + /**
1.654 + * The assignment operator has no real implementation.
1.655 + * It's provided to make the compiler happy. Do not call.
1.656 + */
1.657 + BreakIterator& operator=(const BreakIterator&);
1.658 +};
1.659 +
1.660 +inline UBool BreakIterator::isBufferClone()
1.661 +{
1.662 + return fBufferClone;
1.663 +}
1.664 +
1.665 +U_NAMESPACE_END
1.666 +
1.667 +#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
1.668 +
1.669 +#endif // _BRKITER
1.670 +//eof
1.671 +