os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/utext.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 *******************************************************************************
     3 *
     4 *   Copyright (C) 2004-2005, International Business Machines
     5 *   Corporation and others.  All Rights Reserved.
     6 *
     7 *******************************************************************************
     8 *   file name:  utext.h
     9 *   encoding:   US-ASCII
    10 *   tab size:   8 (not used)
    11 *   indentation:4
    12 *
    13 *   created on: 2004oct06
    14 *   created by: Markus W. Scherer
    15 */
    16 
    17 #ifndef __UTEXT_H__
    18 #define __UTEXT_H__
    19 
    20 /**
    21  * \file
    22  * \brief C API: Abstract Unicode Text API
    23  *
    24  * The Text Access API provides a means to allow text that is stored in alternative
    25  * formats to work with ICU services.  ICU normally operates on text that is
    26  * stored UTF-16 format, in (UChar *) arrays for the C APIs or as type
    27  * UnicodeString for C++ APIs.
    28  *
    29  * ICU Text Access allows other formats, such as UTF-8 or non-contiguous
    30  * UTF-16 strings, to be placed in a UText wrapper and then passed to ICU services.
    31  *
    32  * There are three general classes of usage for UText:
    33  *
    34  *     Application Level Use.  This is the simplest usage - applications would
    35  *     use one of the utext_open() functions on their input text, and pass
    36  *     the resulting UText to the desired ICU service.
    37  *
    38  *     Second is usage in ICU Services, such as break iteration, that will need to
    39  *     operate on input presented to them as a UText.  These implementations
    40  *     will need to use the iteration and related UText functions to gain
    41  *     access to the actual text.
    42  *
    43  *     The third class of UText users are "text providers."  These are the
    44  *     UText implementations for the various text storage formats.  An application
    45  *     or system with a unique text storage format can implement a set of
    46  *     UText provider functions for that format, which will then allow
    47  *     ICU services to operate on that format.
    48  *
    49  *
    50  * <em>Iterating over text</em>
    51  *
    52  * Here is sample code for a forward iteration over the contents of a UText
    53  *
    54  * \code
    55  *    UChar32  c;
    56  *    UText    *ut = whatever();
    57  *
    58  *    for (c=utext_next32From(ut, 0); c>=0; c=utext_next32(ut)) {
    59  *       // do whatever with the codepoint c here.
    60  *    }
    61  * \endcode
    62  *
    63  * And here is similar code to iterate in the reverse direction, from the end
    64  * of the text towards the beginning.
    65  *
    66  * \code
    67  *    UChar32  c;
    68  *    UText    *ut = whatever();
    69  *    int      textLength = utext_nativeLength(ut);
    70  *    for (c=utext_previous32From(ut, textLength); c>=0; c=utext_previous32(ut)) {
    71  *       // do whatever with the codepoint c here.
    72  *    }
    73  * \endcode
    74  *
    75  * <em>Characters and Indexing</em>
    76  *
    77  * Indexing into text by UText functions is nearly always in terms of the native
    78  * indexing of the underlying text storage.  The storage format could be UTF-8
    79  * or UTF-32, for example.  When coding to the UText access API, no assumptions
    80  * can be made regarding the size of characters, or how far an index
    81  * may move when iterating between characters.
    82  *
    83  * All indices supplied to UText functions are pinned to the length of the
    84  * text.  An out-of-bounds index is not considered to be an error, but is
    85  * adjusted to be in the range  0 <= index <= length of input text.
    86  *
    87  *
    88  * When an index position is returned from a UText function, it will be
    89  * a native index to the underlying text.  In the case of multi-unit characters,
    90  * it will  always refer to the first position of the character,
    91  * never to the interior.  This is essentially the same thing as saying that
    92  * a returned index will always point to a boundary between characters.
    93  *
    94  * When a native index is supplied to a UText function, all indices that
    95  * refer to any part of a multi-unit character representation are considered
    96  * to be equivalent.  In the case of multi-unit characters, an incoming index
    97  * will be logically normalized to refer to the start of the character.
    98  * 
    99  * It is possible to test whether a native index is on a code point boundary
   100  * by doing a utext_setNativeIndex() followed by a utext_getNativeIndex().
   101  * If the index is returned unchanged, it was on a code point boundary.  If
   102  * an adjusted index is returned, the original index referred to the
   103  * interior of a character.
   104  *
   105  */
   106 
   107 
   108 
   109 #include "unicode/utypes.h"
   110 #ifdef XP_CPLUSPLUS
   111 #include "unicode/rep.h"
   112 #include "unicode/unistr.h"
   113 #endif
   114 
   115 #ifndef U_HIDE_DRAFT_API
   116 
   117 U_CDECL_BEGIN
   118 
   119 struct UText;
   120 typedef struct UText UText; /**< C typedef for struct UText. @draft ICU 3.4 */
   121 
   122 struct UTextChunk;
   123 typedef struct UTextChunk UTextChunk; /**< C typedef for struct UTextChunk. @draft ICU 3.4 */
   124 
   125 
   126 
   127 /***************************************************************************************
   128  *
   129  *   C Functions for creating UText wrappers around various kinds of text strings.
   130  *
   131  ****************************************************************************************/
   132 
   133 
   134 /**
   135   * utext_close    Close function for UText instances.
   136   *                Cleans up, releases any resources being held by an
   137   *                open UText.
   138   * <p/>
   139   *   If the UText was originally allocated by one of the utext_open functions,
   140   *   the storage associated with the utext will also be freed.
   141   *   If the UText storage originated with the application, as it would with
   142   *   a local or static instance, the storage will not be deleted.
   143   *
   144   *   An open UText can be reset to refer to new string by using one of the utext_open()
   145   *   functions without first closing the UText.  
   146   *
   147   * @param ut  The UText to be closed.
   148   * @return    NULL if the UText struct was deleted by the close.  If the UText struct
   149   *            was originally provided by the caller to the open function, it is
   150   *            returned by this function, and may be safely used again in
   151   *            a subsequent utext_open.
   152   *
   153   * @draft ICU 3.4
   154   */
   155 U_DRAFT UText * U_EXPORT2
   156 utext_close(UText *ut);
   157 
   158 
   159 /**
   160  * Open a read-only UText implementation for UTF-8 strings.
   161  * 
   162  * \htmlonly
   163  * Any invalid UTF-8 in the input will be handled in this way:
   164  * a sequence of bytes that has the form of a truncated, but otherwise valid,
   165  * UTF-8 sequence will be replaced by a single unicode replacement character, \uFFFD. 
   166  * Any other illegal bytes will each be replaced by a \uFFFD.
   167  * \endhtmlonly
   168  * 
   169  * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.
   170  *               If non-NULL, must refer to an initialized UText struct, which will then
   171  *               be reset to reference the specified UTF-8 string.
   172  * @param s      A UTF-8 string
   173  * @param length The length of the UTF-8 string in bytes, or -1 if the string is
   174  *               zero terminated.
   175  * @param status Errors are returned here.
   176  * @return       A pointer to the UText.  If a pre-allocated UText was provided, it
   177  *               will always be used and returned.
   178  * @draft ICU 3.4
   179  */
   180 U_DRAFT UText * U_EXPORT2
   181 utext_openUTF8(UText *ut, const char *s, int32_t length, UErrorCode *status);
   182 
   183 
   184 /**
   185  * Open a read-only UText for UChar * string.
   186  * 
   187  * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.
   188  *               If non-NULL, must refer to an initialized UText struct, which will then
   189  *               be reset to reference the specified UChar string.
   190  * @param s      A UChar (UTF-16) string
   191  * @param length The number of UChars in the input string, or -1 if the string is
   192  *               zero terminated.
   193  * @param status Errors are returned here.
   194  * @return       A pointer to the UText.  If a pre-allocated UText was provided, it
   195  *               will always be used and returned.
   196  * @draft ICU 3.4
   197  */
   198 U_DRAFT UText * U_EXPORT2
   199 utext_openUChars(UText *ut, const UChar *s, int32_t length, UErrorCode *status);
   200 
   201 
   202 #ifdef XP_CPLUSPLUS
   203 /**
   204  * Open a writable UText for a non-const UnicodeString. 
   205  * 
   206  * @param ut      Pointer to a UText struct.  If NULL, a new UText will be created.
   207  *                 If non-NULL, must refer to an initialized UText struct, which will then
   208  *                 be reset to reference the specified input string.
   209  * @param s       A UnicodeString.
   210  * @param status Errors are returned here.
   211  * @return        Pointer to the UText.  If a UText was supplied as input, this
   212  *                 will always be used and returned.
   213  * @draft ICU 3.4
   214  */
   215 U_DRAFT UText * U_EXPORT2
   216 utext_openUnicodeString(UText *ut, UnicodeString *s, UErrorCode *status);
   217 
   218 
   219 /**
   220  * Open a UText for a const UnicodeString.   The resulting UText will not be writable.
   221  * 
   222  * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
   223  *               If non-NULL, must refer to an initialized UText struct, which will then
   224  *               be reset to reference the specified input string.
   225  * @param s      A const UnicodeString to be wrapped.
   226  * @param status Errors are returned here.
   227  * @return       Pointer to the UText.  If a UText was supplied as input, this
   228  *               will always be used and returned.
   229  * @draft ICU 3.4
   230  */
   231 U_DRAFT UText * U_EXPORT2
   232 utext_openConstUnicodeString(UText *ut, const UnicodeString *s, UErrorCode *status);
   233 
   234 
   235 /**
   236  * Open a writable UText implementation for an ICU Replaceable object.
   237  * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
   238  *               If non-NULL, must refer to an already existing UText, which will then
   239  *               be reset to reference the specified replaceable text.
   240  * @param rep    A Replaceable text object.
   241  * @param status Errors are returned here.
   242  * @return       Pointer to the UText.  If a UText was supplied as input, this
   243  *               will always be used and returned.
   244  * @see Replaceable
   245  * @draft ICU 3.4
   246  */
   247 U_DRAFT UText * U_EXPORT2
   248 utext_openReplaceable(UText *ut, Replaceable *rep, UErrorCode *status);
   249 
   250 #endif
   251 
   252 
   253 /**
   254   *  clone a UText.  Much like opening a UText where the source text is itself
   255   *  another UText.
   256   *
   257   *  A deep clone will copy both the UText data structures and the underlying text.
   258   *  The original and cloned UText will operate completely independently; modifications
   259   *  made to the text in one will not effect the other.  Text providers are not
   260   *  required to support deep clones.  The user of clone() must check the status return
   261   *  and be prepared to handle failures.
   262   *
   263   *  A shallow clone replicates only the UText data structures; it does not make
   264   *  a copy of the underlying text.  Shallow clones can be used as an efficient way to 
   265   *  have multiple iterators active in a single text string that is not being
   266   *  modified.
   267   *
   268   *  A shallow clone operation will not fail, barring truly exceptional conditions such
   269   *  as memory allocation failures.
   270   *
   271   *  A UText and its clone may be safely concurrently accessed by separate threads.
   272   *  This is true for both shallow and deep clones.
   273   *  It is the responsibility of the Text Provider to ensure that this thread safety
   274   *  constraint is met.
   275   *
   276   *  @param dest   A UText struct to be filled in with the result of the clone operation,
   277   *                or NULL if the clone function should heap-allocate a new UText struct.
   278   *  @param src    The UText to be cloned.
   279   *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.
   280   *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR
   281   *                will be returned if the text provider is unable to clone the
   282   *                original text.
   283   *  @return       The newly created clone, or NULL if the clone operation failed.
   284   *  @draft ICU 3.4
   285   */
   286 U_DRAFT UText * U_EXPORT2
   287 utext_clone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
   288 
   289 
   290 /*****************************************************************************
   291  *
   292  *   C Functions to work with the text represeted by a UText wrapper
   293  *
   294  *****************************************************************************/
   295 
   296 /**
   297   * Get the length of the text.  Depending on the characteristics
   298   * of the underlying text representation, this may be expensive.  
   299   * @see  utext_isLengthExpensive()
   300   *
   301   *
   302   * @param ut  the text to be accessed.
   303   * @return the length of the text, expressed in native units.
   304   *
   305   * @draft ICU 3.4
   306   */
   307 U_DRAFT int32_t U_EXPORT2
   308 utext_nativeLength(UText *ut);
   309 
   310 /**
   311  *  Return TRUE if calculating the length of the text could be expensive.
   312  *  Finding the length of NUL terminated strings is considered to be expensive.
   313  *
   314  *  Note that the value of this function may change
   315  *  as the result of other operations on a UText.
   316  *  Once the length of a string has been discovered, it will no longer
   317  *  be expensive to report it.
   318  *
   319  * @param ut the text to be accessed.
   320  * @return TRUE if determining the length of the text could be time consuming.
   321  * @draft ICU 3.4
   322  */
   323 U_DRAFT UBool U_EXPORT2
   324 utext_isLengthExpensive(const UText *ut);
   325 
   326 /**
   327  * Returns the code point at the requested index,
   328  * or U_SENTINEL (-1) if it is out of bounds.
   329  *
   330  * If the specified index points to the interior of a multi-unit
   331  * character - one of the trail bytes of a UTF-8 sequence, for example -
   332  * the complete code point will be returned.
   333  *
   334  * The iteration position will be set to the start of the returned code point.
   335  *
   336  * This function is roughly equivalent to the the sequence
   337  *    utext_setNativeIndex(index);
   338  *    utext_current32();
   339  * (There is a difference if the index is out of bounds by being less than zero)
   340  * 
   341  * @param ut the text to be accessed
   342  * @param nativeIndex the native index of the character to be accessed.  If the index points
   343  *        to other than the first unit of a multi-unit character, it will be adjusted
   344  *        to the start of the character.
   345  * @return the code point at the specified index.
   346  * @draft ICU 3.4
   347  */
   348 U_DRAFT UChar32 U_EXPORT2
   349 utext_char32At(UText *ut, int32_t nativeIndex);
   350 
   351 
   352 /**
   353  *
   354  * Get the code point at the current iteration position,
   355  * or U_SENTINEL (-1) if the iteration has reached the end of
   356  * the input text.
   357  *
   358  * @param ut the text to be accessed.
   359  * @return the Unicode code point at the current iterator position.
   360  * @draft ICU 3.4
   361  */
   362 U_DRAFT UChar32 U_EXPORT2
   363 utext_current32(UText *ut);
   364 
   365 
   366 /**
   367  * Get the code point at the current iteration position of the UText, and
   368  * advance the position to the first index following the character.
   369  * Returns U_SENTINEL (-1) if the position is at the end of the
   370  * text.
   371  * This is a post-increment operation
   372  *
   373  * An inline macro version of this function, UTEXT_NEXT32(), 
   374  * is available for performance critical use.
   375  *
   376  * @param ut the text to be accessed.
   377  * @return the Unicode code point at the iteration position.
   378  * @see UTEXT_NEXT32
   379  * @draft ICU 3.4
   380  */
   381 U_DRAFT UChar32 U_EXPORT2
   382 utext_next32(UText *ut);
   383 
   384 
   385 /**
   386  *  Move the iterator position to the character (code point) whose
   387  *  index precedes the current position, and return that character.
   388  *  This is a pre-decrement operation.
   389  *  Returns U_SENTINEL (-1) if the position is at the start of the  text.
   390  *  This is a pre-decrement operation.
   391  *
   392  * An inline macro version of this function, UTEXT_PREVIOUS32(), 
   393  * is available for performance critical use.
   394  *
   395  *  @param ut the text to be accessed.
   396  *  @return the previous UChar32 code point, or U_SENTINEL (-1) 
   397  *          if the iteration has reached the start of the text.
   398  *  @see UTEXT_PREVIOUS32
   399  *  @draft ICU 3.4
   400  */
   401 U_DRAFT UChar32 U_EXPORT2
   402 utext_previous32(UText *ut);
   403 
   404 
   405 /**
   406   * Set the iteration index, access the text for forward iteration,
   407   * and return the code point starting at or before that index.
   408   * Leave the iteration index at the start of the following code point.
   409   *
   410   * This function is the most efficient and convenient way to
   411   * begin a forward iteration.
   412   *
   413   *  @param ut the text to be accessed.
   414   *  @param nativeIndex Iteration index, in the native units of the text provider.
   415   *  @return Code point which starts at or before index,
   416   *         or U_SENTINEL (-1) if it is out of bounds.
   417   * @draft ICU 3.4
   418   */
   419 U_DRAFT UChar32 U_EXPORT2
   420 utext_next32From(UText *ut, int32_t nativeIndex);
   421 
   422 
   423 
   424 /**
   425   * Set the iteration index, and return the code point preceding the
   426   * one specified by the initial index.  Leave the iteration position
   427   * at the start of the returned code point.
   428   *
   429   * This function is the most efficient and convenient way to
   430   * begin a backwards iteration.
   431   *
   432   * @param ut the text to be accessed.
   433   * @param nativeIndex Iteration index in the native units of the text provider.
   434   * @return Code point preceding the one at the initial index,
   435   *         or U_SENTINEL (-1) if it is out of bounds.
   436   *
   437   * @draft ICU 3.4
   438   */
   439 U_DRAFT UChar32 U_EXPORT2
   440 utext_previous32From(UText *ut, int32_t nativeIndex);
   441 
   442 /**
   443   * Get the current iterator position, which can range from 0 to 
   444   * the length of the text.
   445   * The position is a native index into the input text, in whatever format it
   446   * may have, and may not always correspond to a UChar (UTF-16) index
   447   * into the text.  The returned position will always be aligned to a
   448   * code point boundary 
   449   *
   450   * @param ut the text to be accessed.
   451   * @return the current index position, in the native units of the text provider.
   452   * @draft ICU 3.4
   453   */
   454 U_DRAFT int32_t U_EXPORT2
   455 utext_getNativeIndex(UText *ut);
   456 
   457 /**
   458   * Set the current iteration position to the nearest code point
   459   * boundary at or preceding the specified index.
   460   * The index is in the native units of the original input text.
   461   * If the index is out of range, it will be trimmed to be within
   462   * the range of the input text.
   463   * <p/>
   464   * It will usually be more efficient to begin an iteration
   465   * using the functions utext_next32From() or utext_previous32From()
   466   * rather than setIndex().
   467   * <p/>
   468   * Moving the index position to an adjacent character is best done
   469   * with utext_next32(), utext_previous32() or utext_moveIndex32().
   470   * Attempting to do direct arithmetic on the index position is
   471   * complicated by the fact that the size (in native units) of a
   472   * character depends on the underlying representation of the character
   473   * (UTF-8, UTF-16, UTF-32, arbitrary codepage), and is not
   474   * easily knowable.
   475   *
   476   * @param ut the text to be accessed.
   477   * @param nativeIndex the native unit index of the new iteration position.
   478   * @draft ICU 3.4
   479   */
   480 U_DRAFT void U_EXPORT2
   481 utext_setNativeIndex(UText *ut, int32_t nativeIndex);
   482 
   483 /**
   484   * Move the iterator postion by delta code points.  The number of code points
   485   * is a signed number; a negative delta will move the iterator backwards,
   486   * towards the start of the text.
   487   * <p/>
   488   * The index is moved by <code>delta</code> code points
   489   * forward or backward, but no further backward than to 0 and
   490   * no further forward than to utext_nativeLength().
   491   * The resulting index value will be in between 0 and length, inclusive.
   492   * <p/>
   493   * Because the index is kept in the native units of the text provider, the
   494   * actual numeric amount by which the index moves depends on the
   495   * underlying text storage representation of the text provider.
   496   *
   497   * @param ut the text to be accessed.
   498   * @param delta the signed number of code points to move the iteration position.
   499   * @return TRUE if the position could be moved the requested number of positions while
   500   *              staying within the range [0 - text length].
   501   * @draft ICU 3.4
   502   */
   503 U_DRAFT UBool U_EXPORT2
   504 utext_moveIndex32(UText *ut, int32_t delta);
   505 
   506 
   507 /**
   508  *
   509  * Extract text from a UText into a UChar buffer.  The range of text to be extracted
   510  * is specified in the native indices of the UText provider.  These may not necessarily
   511  * be UTF-16 indices.
   512  * <p/>
   513  * The size (number of 16 bit UChars) in the data to be extracted is returned.  The
   514  * full number of UChars is returned, even when the extracted text is truncated
   515  * because the specified buffer size is too small.
   516  *
   517  * The extracted string will (if you are a user) / must (if you are a text provider)
   518  * be NUL-terminated if there is sufficient space in the destination buffer.  This
   519  * terminating NUL is not included in the returned length.
   520  *
   521  * @param  ut    the UText from which to extract data.
   522  * @param  nativeStart the native index of the first character to extract.
   523  * @param  nativeLimit the native string index of the position following the last
   524  *               character to extract.  If the specified limit is greater than the length
   525  *               of the text, the limit will be trimmed back to the text length.
   526  * @param  dest  the UChar (UTF-16) buffer into which the extracted text is placed
   527  * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero
   528  *               for precomputing the required size.
   529  * @param  status receives any error status.
   530  *         U_BUFFER_OVERFLOW_ERROR: the extracted text was truncated because the 
   531  *         buffer was too small.  Returns number of UChars for preflighting.
   532  * @return Number of UChars in the data to be extracted.  Does not include a trailing NUL.
   533  *
   534  * @draft ICU 3.4
   535  */
   536 U_DRAFT int32_t U_EXPORT2
   537 utext_extract(UText *ut,
   538              int32_t nativeStart, int32_t nativeLimit,
   539              UChar *dest, int32_t destCapacity,
   540              UErrorCode *status);
   541 
   542 
   543 
   544 /************************************************************************************
   545  *
   546  *  #define inline versions of selected performance-critical text access functions
   547  *          Caution:  do not use auto increment++ or decrement-- expressions
   548  *                    as parameters to these macros.
   549  *
   550  *          For most use, where there is no extreme performance constraint, the
   551  *          normal, non-inline functions are a better choice.  The resulting code
   552  *          will be smaller, and, if the need ever arises, easier to debug.
   553  *
   554  *          These are implemented as #defines rather than real functions
   555  *          because there is no fully portable way to do inline functions in plain C.
   556  *
   557  ************************************************************************************/
   558 
   559 /**
   560  * inline version of utext_next32(), for performance-critical situations.
   561  *
   562  * Get the code point at the current iteration position of the UText, and
   563  * advance the position to the first index following the character.
   564  * This is a post-increment operation.
   565  * Returns U_SENTINEL (-1) if the position is at the end of the
   566  * text.
   567  *
   568  * @draft ICU 3.4
   569  */
   570 #define UTEXT_NEXT32(ut)  \
   571     ((ut)->chunk.offset < (ut)->chunk.length && ((ut)->chunk.contents)[(ut)->chunk.offset]<0xd800 ? \
   572     ((ut)->chunk.contents)[((ut)->chunk.offset)++] : utext_next32(ut))
   573 
   574 /**
   575  * inline version of utext_previous32(), for performance-critical situations.
   576  *
   577  *  Move the iterator position to the character (code point) whose
   578  *  index precedes the current position, and return that character.
   579  *  This is a pre-decrement operation.
   580  *  Returns U_SENTINEL (-1) if the position is at the start of the  text.
   581  *
   582  * @draft ICU 3.4
   583  */
   584 #define UTEXT_PREVIOUS32(ut)  \
   585     ((ut)->chunk.offset > 0 && \
   586      (ut)->chunk.contents[(ut)->chunk.offset-1] < 0xd800 ? \
   587           (ut)->chunk.contents[--((ut)->chunk.offset)]  :  utext_previous32(ut))
   588 
   589 
   590 
   591 
   592 /************************************************************************************
   593  *
   594  *   Functions related to writing or modifying the text.
   595  *   These will work only with modifiable UTexts.  Attempting to
   596  *   modify a read-only UText will return an error status.
   597  *
   598  ************************************************************************************/
   599 
   600 
   601 /**
   602  *  Return TRUE if the text can be written with utext_replace() or
   603  *  utext_copy().  For the text to be writable, the text provider must
   604  *  be of a type that supports writing.
   605  *
   606  * @param  ut   the UText to be tested.
   607  * @return TRUE if the text is modifiable.
   608  * @draft ICU 3.4
   609  *
   610  */
   611 U_DRAFT UBool U_EXPORT2
   612 utext_isWritable(const UText *ut);
   613 
   614 
   615 /**
   616   * Test whether there is meta data associated with the text.
   617   * @see Replaceable::hasMetaData()
   618   *
   619   * @param ut The UText to be tested
   620   * @return TRUE if the underlying text includes meta data.
   621   * @draft ICU 3.4
   622   */
   623 U_DRAFT UBool U_EXPORT2
   624 utext_hasMetaData(const UText *ut);
   625 
   626 
   627 /**
   628  * Replace a range of the original text with a replacement text.
   629  *
   630  * Leaves the current iteration position at the position following the
   631  *  newly inserted replacement text.
   632  *
   633  * This function is only available on UText types that support writing,
   634  * that is, ones where utext_isWritable() returns TRUE.
   635  *
   636  * When using this function, there should be only a single UText opened onto the
   637  * underlying native text string.  Behavior after a replace operation
   638  * on a UText is undefined for any other additional UTexts that refer to the
   639  * modified string.
   640  *
   641  * @param ut               the UText representing the text to be operated on.
   642  * @param nativeStart      the native index of the start of the region to be replaced
   643  * @param nativeLimit      the native index of the character following the region to be replaced.
   644  * @param replacementText  pointer to the replacement text
   645  * @param replacementLength length of the replacement text, or -1 if the text is NUL terminated.
   646  * @param status           receives any error status.  Possible errors include
   647  *                         U_NO_WRITE_PERMISSION
   648  *
   649  * @return The signed number of (native) storage units by which
   650  *         the length of the text expanded or contracted.
   651  *
   652  * @draft ICU 3.4
   653  */
   654 U_DRAFT int32_t U_EXPORT2
   655 utext_replace(UText *ut,
   656              int32_t nativeStart, int32_t nativeLimit,
   657              const UChar *replacementText, int32_t replacementLength,
   658              UErrorCode *status);
   659 
   660 
   661 
   662 /**
   663  *
   664  * Copy or move a substring from one position to another within the text,
   665  * while retaining any metadata associated with the text.
   666  * This function is used to duplicate or reorder substrings.
   667  * The destination index must not overlap the source range.
   668  *
   669  * The text to be copied or moved is inserted at destIndex;
   670  * it does not replace or overwrite any existing text.
   671  *
   672  * This function is only available on UText types that support writing,
   673  * that is, ones where utext_isWritable() returns TRUE.
   674  *
   675  * When using this function, there should be only a single UText opened onto the
   676  * underlying native text string.  Behavior after a copy operation
   677  * on a UText is undefined in any other additional UTexts that refer to the
   678  * modified string.
   679  *
   680  * @param ut           The UText representing the text to be operated on.
   681  * @param nativeStart  The native index of the start of the region to be copied or moved
   682  * @param nativeLimit  The native index of the character position following the region to be copied.
   683  * @param destIndex    The native destination index to which the source substring is copied or moved.
   684  * @param move         If TRUE, then the substring is moved, not copied/duplicated.
   685  * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION
   686  *                       
   687  * @draft ICU 3.4
   688  */
   689 U_DRAFT void U_EXPORT2
   690 utext_copy(UText *ut,
   691           int32_t nativeStart, int32_t nativeLimit,
   692           int32_t destIndex,
   693           UBool move,
   694           UErrorCode *status);
   695 
   696 
   697 
   698 
   699 
   700 /****************************************************************************************
   701  *
   702  *   The following items are required by text providers implementations -
   703  *    by packages that are writing UText wrappers for additional types of text strings.
   704  *    These declarations are not needed by applications that use already existing
   705  *    UText functions for wrapping strings or accessing text data that has been
   706  *    wrapped in a UText.
   707  *
   708  *****************************************************************************************/
   709 
   710 
   711 /**
   712   *  Descriptor of a chunk, or segment of text in UChar format.
   713   *
   714   *  UText provider implementations surface their text in the form of UTextChunks.
   715   *
   716   *  If the native form of the text if UTF-16, a chunk will typically refer back to the
   717   *   original native text storage.  If the native format is something else, chunks
   718   *   will typically refer to a buffer maintained by the provider that contains
   719   *   some amount input that has been converted to UTF-16 (UChar) form.
   720   *
   721   * @draft ICU 3.4
   722   */  
   723 struct UTextChunk {
   724     /** Pointer to contents of text chunk.  UChar format.   */
   725     const UChar *contents;
   726 
   727     /**  Index within the contents of the current iteration position. */
   728     int32_t     offset;  
   729 
   730     /** Number of UChars in the chunk. */
   731     int32_t     length;
   732 
   733     /** (Native) text index corresponding to the start of the chunk. */
   734     int32_t     nativeStart;
   735 
   736     /** (Native) text index corresponding to the end of the chunk (contents+length). */
   737     int32_t     nativeLimit;
   738 
   739     /** If TRUE, then non-UTF-16 indexes are used in this chunk. */
   740     UBool       nonUTF16Indexes;
   741 
   742     /** Unused. */
   743     UBool       padding1, padding2, padding3;
   744 
   745     /** Unused. */
   746     int32_t     padInt1, padInt2;
   747 
   748     /** Contains sizeof(UTextChunk) and allows the future addition of fields. */
   749     int32_t     sizeOfStruct;
   750 };
   751 
   752 
   753 /**
   754  * UText provider properties (bit field indexes).
   755  *
   756  * @see UText
   757  * @draft ICU 3.4
   758  */
   759 enum {
   760     /**
   761      * The provider works with non-UTF-16 ("native") text indexes.
   762      * For example, byte indexes into UTF-8 text or UTF-32 indexes into UTF-32 text.
   763      * @draft ICU 3.4
   764      */
   765     UTEXT_PROVIDER_NON_UTF16_INDEXES = 0,
   766     /**
   767      * It is potentially time consuming for the provider to determine the length of the text.
   768      * @draft ICU 3.4
   769      */
   770     UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,
   771     /**
   772      * Text chunks remain valid and usable until the text object is modified or
   773      * deleted, not just until the next time the access() function is called
   774      * (which is the default).
   775      * @draft ICU 3.4
   776      */
   777     UTEXT_PROVIDER_STABLE_CHUNKS = 2,
   778     /**
   779      * The provider supports modifying the text via the replace() and copy()
   780      * functions.
   781      * @see Replaceable
   782      * @draft ICU 3.4
   783      */
   784     UTEXT_PROVIDER_WRITABLE = 3,
   785     /**
   786      * There is meta data associated with the text.
   787      * @see Replaceable::hasMetaData()
   788      * @draft ICU 3.4
   789      */
   790     UTEXT_PROVIDER_HAS_META_DATA = 4
   791 };
   792 
   793 /**
   794   * Function type declaration for UText.clone().
   795   *
   796   *  clone a UText.  Much like opening a UText where the source text is itself
   797   *  another UText.
   798   *
   799   *  A deep clone will copy both the UText data structures and the underlying text.
   800   *  The original and cloned UText will operate completely independently; modifications
   801   *  made to the text in one will not effect the other.  Text providers are not
   802   *  required to support deep clones.  The user of clone() must check the status return
   803   *  and be prepared to handle failures.
   804   *
   805   *  A shallow clone replicates only the UText data structures; it does not make
   806   *  a copy of the underlying text.  Shallow clones can be used as an efficient way to 
   807   *  have multiple iterators active in a single text string that is not being
   808   *  modified.
   809   *
   810   *  A shallow clone operation must not fail except for truly exceptional conditions such
   811   *  as memory allocation failures.
   812   *
   813   *  A UText and its clone may be safely concurrently accessed by separate threads.
   814   *  This is true for both shallow and deep clones.
   815   *  It is the responsibility of the Text Provider to ensure that this thread safety
   816   *  constraint is met.
   817 
   818   *
   819   *  @param dest   A UText struct to be filled in with the result of the clone operation,
   820   *                or NULL if the clone function should heap-allocate a new UText struct.
   821   *  @param src    The UText to be cloned.
   822   *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.
   823   *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR
   824   *                should be returned if the text provider is unable to clone the
   825   *                original text.
   826   *  @return       The newly created clone, or NULL if the clone operation failed.
   827   *
   828   * @draft ICU 3.4
   829   */
   830 typedef UText * U_CALLCONV
   831 UTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
   832 
   833 
   834 /**
   835  * Function type declaration for UText.nativeLength().
   836  *
   837  * @param ut the UText to get the length of.
   838  * @return the length, in the native units of the original text string.
   839  * @see UText
   840  * @draft ICU 3.4
   841  */
   842 typedef int32_t U_CALLCONV
   843 UTextNativeLength(UText *ut);
   844 
   845 /**
   846  * Function type declaration for UText.access().  Get the description of the text chunk
   847  *  containing the text at a requested native index.  The UText's iteration
   848  *  position will be left at the requested index.  If the index is out
   849  *  of bounds, the iteration position will be left at the start or end
   850  *  of the string, as appropriate.
   851  *
   852  *  Chunks must begin and end on code point boundaries.  A single code point
   853  *  comprised of multiple storage units must never span a chunk boundary.
   854  *
   855  *
   856  * @param ut          the UText being accessed.
   857  * @param nativeIndex Requested index of the text to be accessed.
   858  * @param forward     If TRUE, then the returned chunk must contain text
   859  *                    starting from the index, so that start<=index<limit.
   860  *                    If FALSE, then the returned chunk must contain text
   861  *                    before the index, so that start<index<=limit.
   862  * @return            True if the requested index could be accessed.  The chunk
   863  *                    will contain the requested text.
   864  *                    False value if a chunk cannot be accessed
   865  *                    (the requested index is out of bounds).
   866  *
   867  * @see UText
   868  * @draft ICU 3.4
   869  */
   870 typedef UBool U_CALLCONV
   871 UTextAccess(UText *ut, int32_t nativeIndex, UBool forward, UTextChunk *chunk);
   872 
   873 /**
   874  * Function type declaration for UText.extract().
   875  *
   876  * Extract text from a UText into a UChar buffer.  The range of text to be extracted
   877  * is specified in the native indices of the UText provider.  These may not necessarily
   878  * be UTF-16 indices.
   879  * <p/>
   880  * The size (number of 16 bit UChars) in the data to be extracted is returned.  The
   881  * full amount is returned, even when the specified buffer size is smaller.
   882  *
   883  * The extracted string will (if you are a user) / must (if you are a text provider)
   884  * be NUL-terminated if there is sufficient space in the destination buffer.
   885  *
   886  * @param  ut            the UText from which to extract data.
   887  * @param  nativeStart   the native index of the first characer to extract.
   888  * @param  nativeLimit   the native string index of the position following the last
   889  *                       character to extract.
   890  * @param  dest          the UChar (UTF-16) buffer into which the extracted text is placed
   891  * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero
   892  *                       for precomputing the required size.
   893  * @param  status        receives any error status.
   894  *                       If U_BUFFER_OVERFLOW_ERROR: Returns number of UChars for
   895  *                       preflighting.
   896  * @return Number of UChars in the data.  Does not include a trailing NUL.
   897  *
   898  * @draft ICU 3.4
   899  */
   900 typedef int32_t U_CALLCONV
   901 UTextExtract(UText *ut,
   902              int32_t nativeStart, int32_t nativeLimit,
   903              UChar *dest, int32_t destCapacity,
   904              UErrorCode *status);
   905 
   906 /**
   907  * Function type declaration for UText.replace().
   908  *
   909  * Replace a range of the original text with a replacement text.
   910  *
   911  * Leaves the current iteration position at the position following the
   912  *  newly inserted replacement text.
   913  *
   914  * This function need only be implemented on UText types that support writing.
   915  *
   916  * When using this function, there should be only a single UText opened onto the
   917  * underlying native text string.  The function is responsible for updating the
   918  * text chunk within the UText to reflect the updated iteration position,
   919  * taking into account any changes to the underlying string's structure caused
   920  * by the replace operation.
   921  *
   922  * @param ut               the UText representing the text to be operated on.
   923  * @param nativeStart      the index of the start of the region to be replaced
   924  * @param nativeLimit      the index of the character following the region to be replaced.
   925  * @param replacementText  pointer to the replacement text
   926  * @param replacmentLength length of the replacement text in UChars, or -1 if the text is NUL terminated.
   927  * @param status           receives any error status.  Possible errors include
   928  *                         U_NO_WRITE_PERMISSION
   929  *
   930  * @return The signed number of (native) storage units by which
   931  *         the length of the text expanded or contracted.
   932  *
   933  * @draft ICU 3.4
   934  */
   935 typedef int32_t U_CALLCONV
   936 UTextReplace(UText *ut,
   937              int32_t nativeStart, int32_t nativeLimit,
   938              const UChar *replacementText, int32_t replacmentLength,
   939              UErrorCode *status);
   940 
   941 /**
   942  * Function type declaration for UText.copy().
   943  *
   944  * Copy or move a substring from one position to another within the text,
   945  * while retaining any metadata associated with the text.
   946  * This function is used to duplicate or reorder substrings.
   947  * The destination index must not overlap the source range.
   948  *
   949  * The text to be copied or moved is inserted at destIndex;
   950  * it does not replace or overwrite any existing text.
   951  *
   952  * This function need only be implemented for UText types that support writing.
   953  *
   954  * When using this function, there should be only a single UText opened onto the
   955  * underlying native text string.  The function is responsible for updating the
   956  * text chunk within the UText to reflect the updated iteration position,
   957  * taking into account any changes to the underlying string's structure caused
   958  * by the replace operation.
   959  *
   960  * @param ut           The UText representing the text to be operated on.
   961  * @param nativeStart  The index of the start of the region to be copied or moved
   962  * @param nativeLimit  The index of the character following the region to be replaced.
   963  * @param nativeDest   The destination index to which the source substring is copied or moved.
   964  * @param move         If TRUE, then the substring is moved, not copied/duplicated.
   965  * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION
   966  *
   967  * @draft ICU 3.4
   968  */
   969 typedef void U_CALLCONV
   970 UTextCopy(UText *ut,
   971           int32_t nativeStart, int32_t nativeLimit,
   972           int32_t nativeDest,
   973           UBool move,
   974           UErrorCode *status);
   975 
   976 /**
   977  * Function type declaration for UText.mapOffsetToNative().
   978  * Map from a UChar offset within the current text chunk within the UText to
   979  *  the corresponding native index in the original source text.
   980  *
   981  * This is required only for text providers that do not use native UTF-16 indexes.
   982  *
   983  * TODO:  specify behavior with out-of-bounds offset?  Shouldn't ever occur.
   984  *
   985  * @param ut     the UText.
   986  * @param offset UTF-16 offset within text chunk 
   987  *               0<=offset<=chunk->length.
   988  * @return Absolute (native) index corresponding to the specified chunk offset.
   989  *         The returned native index should always be to a code point boundary.
   990  *
   991  * @draft ICU 3.4
   992  */
   993 typedef int32_t U_CALLCONV
   994 UTextMapOffsetToNative(UText *ut, int32_t offset);
   995 
   996 /**
   997  * Function type declaration for UText.mapIndexToUTF16().
   998  * Map from a native index to a UChar offset within a text chunk
   999  *
  1000  * This function is required only for text providers that do not use native UTF-16 indexes.
  1001  *
  1002  * @param ut          The UText containing the text chunk.
  1003  * @param nativeIndex Absolute (native) text index, chunk->start<=index<=chunk->limit.
  1004  * @return            Chunk-relative UTF-16 offset corresponding to the specified native
  1005  *                    index.
  1006  *
  1007  * TODO:  specify behavior with out-of-bounds index?  Shouldn't ever occur.
  1008  * @draft ICU 3.4
  1009  */
  1010 typedef int32_t U_CALLCONV
  1011 UTextMapNativeIndexToUTF16(UText *ut, int32_t nativeIndex);
  1012 
  1013 
  1014 /**
  1015  * Function type declaration for UText.utextClose().
  1016  *
  1017  * A Text Provider close function is only required for provider types that make
  1018  *  allocations in their open function (or other functions) that must be 
  1019  *  cleaned when the UText is closed.
  1020  *
  1021  * The allocation of the UText struct itself and any "extra" storage
  1022  * associated with the UText is handled by the common UText implementation
  1023  * and does not require provider specific cleanup in a close function.
  1024  *
  1025  * Most UText provider implementations do not need to implement this function.
  1026  *
  1027  * @param ut A UText object to be closed.
  1028  *
  1029  * @draft ICU 3.4
  1030  */
  1031 typedef void U_CALLCONV
  1032 UTextClose(UText *ut);
  1033 
  1034 
  1035 /**
  1036   *   UText struct.  Provides the interface between the generic UText access code
  1037   *                  and the UText provider code that works on specific kinds of
  1038   *                  text  (UTF-8, noncontiguous UTF-16, whatever.)
  1039   *
  1040   *                  Applications that are using predefined types of text providers
  1041   *                  to pass text data to ICU services will have no need to view the
  1042   *                  internals of the UText structs that they open.
  1043   *
  1044   * @draft ICU 3.4
  1045   */
  1046 struct UText {
  1047     /**
  1048      * (protected) Pointer to string or wrapped object or similar.
  1049      * Not used by caller.
  1050      * @draft ICU 3.4
  1051      */
  1052     const void *context;
  1053 
  1054     /**
  1055      * (protected) Pointer fields available for use by the text provider.
  1056      * Not used by UText common code.
  1057      * @draft ICU 3.4
  1058      */
  1059     const void *p, *q, *r;
  1060 
  1061     /**
  1062      *  (protected)  Pointer to additional space requested by the
  1063      *               text provider during the utext_open operation.
  1064      * @draft ICU 3.4
  1065      */
  1066     void          *pExtra;
  1067 
  1068     /**
  1069      *   (protected)  Size in bytes of the extra space (pExtra).
  1070      *  @draft ICU 3.4
  1071      */
  1072     int32_t        extraSize;
  1073 
  1074     /**
  1075      *     (private)  Flags for managing the allocation and freeing of
  1076      *                memory associated with this UText.
  1077      * @internal
  1078      */
  1079     int32_t        flags;
  1080 
  1081     /**
  1082      *     (private)  Magic.  Try to detect when we are handed junk.
  1083      *                        utext_openXYZ() functions take an initialized,
  1084      *                        but not necessarily open, UText struct as an,
  1085      *                        optional fill-in parameter.  This magic field
  1086      *                        is used to check for that initialization.
  1087      *                        Text provider close functions must NOT clear
  1088      *                        the magic field because that would prevent
  1089      *                        reuse of the UText struct.
  1090      * @internal
  1091      */
  1092     uint32_t       magic;
  1093 
  1094 
  1095     /**
  1096      * (public) sizeOfStruct=sizeof(UText)
  1097      * Allows possible backward compatible extension.
  1098      *
  1099      * @draft ICU 3.4
  1100      */
  1101     int32_t         sizeOfStruct;
  1102 
  1103     /**
  1104       * (protected) Integer fields for use by text provider.
  1105       * Not used by caller.
  1106       * @draft ICU 3.4
  1107       */
  1108     int32_t         a, b, c;
  1109 
  1110 
  1111     /**
  1112       *  Text provider properties.  This set of flags is maintainted by the
  1113       *                             text provider implementation.
  1114       *  @draft ICU 3.4
  1115       */
  1116     int32_t providerProperties;     
  1117 
  1118 
  1119 
  1120     /**  descriptor for the text chunk that includes or is adjacent to
  1121       *  the current iteration position.
  1122       *   @draft ICU 3.4
  1123       */
  1124     UTextChunk      chunk;   
  1125 
  1126 
  1127     /**
  1128      * (public) Function pointer for UTextClone
  1129      *
  1130      * @see UTextClone
  1131      * @draft ICU 3.4
  1132      */
  1133     UTextClone *clone;
  1134 
  1135     /**
  1136      * (public) function pointer for UTextLength
  1137      * May be expensive to compute!
  1138      *
  1139      * @see UTextLength
  1140      * @draft ICU 3.4
  1141      */
  1142     UTextNativeLength *nativeLength;
  1143 
  1144     /**
  1145      * (public) Function pointer for UTextAccess.
  1146      *
  1147      * @see UTextAccess
  1148      * @draft ICU 3.4
  1149      */
  1150     UTextAccess *access;
  1151 
  1152     /**
  1153      * (public) Function pointer for UTextExtract.
  1154      *
  1155      * @see UTextExtract
  1156      * @draft ICU 3.4
  1157      */
  1158     UTextExtract *extract;
  1159 
  1160     /**
  1161      * (public) Function pointer for UTextReplace.
  1162      *
  1163      * @see UTextReplace
  1164      * @draft ICU 3.4
  1165      */
  1166     UTextReplace *replace;
  1167 
  1168     /**
  1169      * (public) Function pointer for UTextCopy.
  1170      *
  1171      * @see UTextCopy
  1172      * @draft ICU 3.4
  1173      */
  1174     UTextCopy *copy;
  1175 
  1176     /**
  1177      * (public) Function pointer for UTextMapOffsetToNative.
  1178      *
  1179      * @see UTextMapOffsetToNative
  1180      * @draft ICU 3.4
  1181      */
  1182     UTextMapOffsetToNative *mapOffsetToNative;
  1183 
  1184     /**
  1185      * (public) Function pointer for UTextMapNativeIndexToUTF16.
  1186      *
  1187      * @see UTextMapNativeIndexToUTF16
  1188      * @draft ICU 3.4
  1189      */
  1190     UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;
  1191 
  1192     /**
  1193      * (public) Function pointer for UTextClose.
  1194       *
  1195       * @see UTextClose
  1196       * @draft ICU 3.4
  1197       */
  1198     UTextClose  *close;
  1199 };
  1200 
  1201 
  1202 /**
  1203  *  Common function for use by Text Provider implementations to allocate and/or initialize
  1204  *  a new UText struct.  To be called in the implementation of utext_open() functions.
  1205  *  If the supplied UText parameter is null, a new UText struct will be allocated on the heap.
  1206  *  If the supplied UText is already open, the provider's close function will be called
  1207  *  so that the struct can be reused by the open that is in progress.
  1208  *
  1209  * @param ut   pointer to a UText struct to be re-used, or null if a new UText
  1210  *             should be allocated.
  1211  * @param extraSpace The amount of additional space to be allocated as part
  1212  *             of this UText, for use by types of providers that require
  1213  *             additional storage.
  1214  * @param status Errors are returned here.
  1215  * @return pointer to the UText, allocated if necessary, with extra space set up if requested.
  1216  * @draft ICU 3.4
  1217  */
  1218 U_DRAFT UText * U_EXPORT2
  1219 utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
  1220 
  1221 /**
  1222   * @internal
  1223   */
  1224 enum {
  1225     UTEXT_MAGIC = 0x345ad82c
  1226 };
  1227 
  1228 
  1229 /**
  1230  *  Initializer for a UTextChunk
  1231  *  @internal
  1232  */
  1233 #define UTEXT_CHUNK_INIT   {                               \
  1234                   NULL,                /* contents      */ \
  1235                   0,                   /* offset        */ \
  1236                   0,                   /* length        */ \
  1237                   0,                   /* start         */ \
  1238                   0,                   /* limit         */ \
  1239                   FALSE,               /* nonUTF16idx   */ \
  1240                   FALSE, FALSE, FALSE, /* padding1,2,3  */ \
  1241                   0, 0,                /* padInt1, 2    */ \
  1242                   sizeof(UTextChunk)                       \
  1243 }               
  1244 
  1245 
  1246 
  1247 /**
  1248  * Initializer for the first part of a UText struct, the part that is
  1249  *  in common for all types of text providers.
  1250  *
  1251  * @internal
  1252  */
  1253 #define UTEXT_INITIALIZER_HEAD  \
  1254                   NULL,                 /* context       */ \
  1255                   NULL, NULL, NULL,     /* p, q, r       */ \
  1256                   NULL,                 /* pExtra        */ \
  1257                   0,                    /* extraSize     */ \
  1258                   0,                    /* flags         */ \
  1259                   UTEXT_MAGIC,          /* magic         */ \
  1260                   sizeof(UText),        /* sizeOfStruct  */ \
  1261                   0, 0, 0,              /* a, b, c       */ \
  1262                   0,                    /* providerProps */ \
  1263                   UTEXT_CHUNK_INIT      /* UTextChunk    */
  1264 
  1265 
  1266 
  1267 /**
  1268  * initializer to be used with local (stack) instances of a UText
  1269  *  struct.  UText structs must be initialized before passing
  1270  *  them to one of the utext_open functions.
  1271  *
  1272  * @draft ICU 3.4
  1273  */
  1274 #define UTEXT_INITIALIZER {                                \
  1275                   UTEXT_INITIALIZER_HEAD,                  \
  1276                   NULL,                 /* clone ()     */ \
  1277                   NULL,                 /* length ()    */ \
  1278                   NULL,                 /* access ()    */ \
  1279                   NULL,                 /* extract ()   */ \
  1280                   NULL,                 /* replace ()   */ \
  1281                   NULL,                 /* copy ()      */ \
  1282                   NULL, NULL,           /* map * 2 ()   */ \
  1283                   NULL                  /* close ()     */ \
  1284 }
  1285 
  1286 
  1287 U_CDECL_END
  1288 
  1289 
  1290 
  1291 #endif /* U_HIDE_DRAFT_API */
  1292 
  1293 #endif